Search in sources :

Example 91 with Canvas

use of org.eclipse.swt.widgets.Canvas in project BiglyBT by BiglySoftware.

the class TransferStatsView method createConnectionPanel.

private void createConnectionPanel() {
    connectionPanel = new Composite(mainPanel, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(connectionPanel, gridData);
    GridLayout panelLayout = new GridLayout();
    panelLayout.numColumns = 2;
    panelLayout.makeColumnsEqualWidth = true;
    connectionPanel.setLayout(panelLayout);
    Composite conn_area = new Composite(connectionPanel, SWT.NULL);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(conn_area, gridData);
    panelLayout = new GridLayout();
    panelLayout.numColumns = 2;
    conn_area.setLayout(panelLayout);
    Label label = new Label(conn_area, SWT.NULL);
    Messages.setLanguageText(label, "SpeedView.stats.con");
    connection_label = new BufferedLabel(conn_area, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(connection_label, gridData);
    Composite upload_area = new Composite(connectionPanel, SWT.NULL);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(upload_area, gridData);
    panelLayout = new GridLayout();
    panelLayout.numColumns = 2;
    upload_area.setLayout(panelLayout);
    label = new Label(upload_area, SWT.NULL);
    Messages.setLanguageText(label, "SpeedView.stats.upload");
    upload_label = new BufferedLabel(upload_area, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(upload_label, gridData);
    // connections
    con_folder = new TabFolder(connectionPanel, SWT.LEFT);
    gridData = new GridData(GridData.FILL_BOTH);
    gridData.horizontalSpan = 1;
    Utils.setLayoutData(con_folder, gridData);
    con_folder.setBackground(Colors.background);
    // connection counts
    TabItem conn_item = new TabItem(con_folder, SWT.NULL);
    conn_item.setText(MessageText.getString("label.connections"));
    Canvas connection_canvas = new Canvas(con_folder, SWT.NO_BACKGROUND);
    conn_item.setControl(connection_canvas);
    gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = 200;
    Utils.setLayoutData(connection_canvas, gridData);
    connection_graphic = SpeedGraphic.getInstance(new Scale(false), new ValueFormater() {

        @Override
        public String format(int value) {
            return (String.valueOf(value));
        }
    });
    connection_graphic.initialize(connection_canvas);
    Color[] colors = connection_graphic.colors;
    connection_graphic.setLineColors(colors);
    // route info
    TabItem route_info_tab = new TabItem(con_folder, SWT.NULL);
    route_info_tab.setText(MessageText.getString("label.routing"));
    Composite route_tab_comp = new Composite(con_folder, SWT.NULL);
    Utils.setLayoutData(route_tab_comp, new GridData(SWT.FILL, SWT.FILL, true, true));
    GridLayout routeTabLayout = new GridLayout();
    routeTabLayout.numColumns = 1;
    route_tab_comp.setLayout(routeTabLayout);
    route_info_tab.setControl(route_tab_comp);
    ScrolledComposite sc = new ScrolledComposite(route_tab_comp, SWT.V_SCROLL);
    Utils.setLayoutData(sc, new GridData(SWT.FILL, SWT.FILL, true, true));
    route_comp = new Composite(sc, SWT.NULL);
    Utils.setLayoutData(route_comp, new GridData(SWT.FILL, SWT.FILL, true, true));
    GridLayout routeLayout = new GridLayout();
    routeLayout.numColumns = 3;
    // routeLayout.makeColumnsEqualWidth = true;
    route_comp.setLayout(routeLayout);
    sc.setContent(route_comp);
    buildRouteComponent(5);
    // upload queued
    Canvas upload_canvas = new Canvas(connectionPanel, SWT.NO_BACKGROUND);
    gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = 200;
    Utils.setLayoutData(upload_canvas, gridData);
    upload_graphic = SpeedGraphic.getInstance(new ValueFormater() {

        @Override
        public String format(int value) {
            return DisplayFormatters.formatByteCountToKiBEtc(value);
        }
    });
    upload_graphic.initialize(upload_canvas);
}
Also used : BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Canvas(org.eclipse.swt.widgets.Canvas) Color(org.eclipse.swt.graphics.Color) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) Label(org.eclipse.swt.widgets.Label) TabFolder(org.eclipse.swt.widgets.TabFolder) ValueFormater(com.biglybt.ui.swt.components.graphics.ValueFormater) Scale(com.biglybt.ui.swt.components.graphics.Scale) TabItem(org.eclipse.swt.widgets.TabItem) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite)

Example 92 with Canvas

use of org.eclipse.swt.widgets.Canvas in project BiglyBT by BiglySoftware.

the class TransferStatsView method createAutoSpeedPanel.

private void createAutoSpeedPanel() {
    autoSpeedPanel = new Group(mainPanel, SWT.NONE);
    GridData generalPanelData = new GridData(GridData.FILL_BOTH);
    Utils.setLayoutData(autoSpeedPanel, generalPanelData);
    Messages.setLanguageText(autoSpeedPanel, "SpeedView.stats.autospeed", new String[] { String.valueOf(MAX_DISPLAYED_PING_MILLIS_DISP) });
    autoSpeedPanelLayout = new StackLayout();
    autoSpeedPanel.setLayout(autoSpeedPanelLayout);
    autoSpeedInfoPanel = new Composite(autoSpeedPanel, SWT.NULL);
    Utils.setLayoutData(autoSpeedInfoPanel, new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.numColumns = 8;
    layout.makeColumnsEqualWidth = true;
    autoSpeedInfoPanel.setLayout(layout);
    Canvas pingCanvas = new Canvas(autoSpeedInfoPanel, SWT.NO_BACKGROUND);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.horizontalSpan = 4;
    Utils.setLayoutData(pingCanvas, gridData);
    pingGraph.initialize(pingCanvas);
    TabFolder folder = new TabFolder(autoSpeedInfoPanel, SWT.LEFT);
    gridData = new GridData(GridData.FILL_BOTH);
    gridData.horizontalSpan = 4;
    Utils.setLayoutData(folder, gridData);
    folder.setBackground(Colors.background);
    ValueFormater speed_formatter = new ValueFormater() {

        @Override
        public String format(int value) {
            return (DisplayFormatters.formatByteCountToKiBEtc(value));
        }
    };
    ValueFormater time_formatter = new ValueFormater() {

        @Override
        public String format(int value) {
            return (value + " ms");
        }
    };
    ValueFormater[] formatters = new ValueFormater[] { speed_formatter, speed_formatter, time_formatter };
    String[] labels = new String[] { "up", "down", "ping" };
    SpeedManagerPingMapper[] mappers = speedManager.getMappers();
    plot_views = new plotView[mappers.length];
    zone_views = new zoneView[mappers.length];
    for (int i = 0; i < mappers.length; i++) {
        SpeedManagerPingMapper mapper = mappers[i];
        TabItem plot_item = new TabItem(folder, SWT.NULL);
        plot_item.setText("Plot " + mapper.getName());
        Canvas plotCanvas = new Canvas(folder, SWT.NO_BACKGROUND);
        gridData = new GridData(GridData.FILL_BOTH);
        Utils.setLayoutData(plotCanvas, gridData);
        plot_views[i] = new plotView(mapper, plotCanvas, labels, formatters);
        plot_item.setControl(plotCanvas);
        TabItem zones_item = new TabItem(folder, SWT.NULL);
        zones_item.setText("Zones " + mapper.getName());
        Canvas zoneCanvas = new Canvas(folder, SWT.NO_BACKGROUND);
        gridData = new GridData(GridData.FILL_BOTH);
        Utils.setLayoutData(zoneCanvas, gridData);
        zone_views[i] = new zoneView(mapper, zoneCanvas, labels, formatters);
        zones_item.setControl(zoneCanvas);
    }
    autoSpeedDisabledPanel = new Composite(autoSpeedPanel, SWT.NULL);
    autoSpeedDisabledPanel.setLayout(new GridLayout());
    Label disabled = new Label(autoSpeedDisabledPanel, SWT.NULL);
    disabled.setEnabled(false);
    Messages.setLanguageText(disabled, "SpeedView.stats.autospeed.disabled");
    Utils.setLayoutData(disabled, new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.FILL_HORIZONTAL));
    autoSpeedPanelLayout.topControl = speedManager.isAvailable() ? autoSpeedInfoPanel : autoSpeedDisabledPanel;
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 8;
    Legend.createLegendComposite(autoSpeedInfoPanel, PingGraphic.defaultColors, new String[] { "TransferStatsView.legend.pingaverage", "TransferStatsView.legend.ping1", "TransferStatsView.legend.ping2", "TransferStatsView.legend.ping3" }, gridData);
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Canvas(org.eclipse.swt.widgets.Canvas) TabFolder(org.eclipse.swt.widgets.TabFolder) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) Label(org.eclipse.swt.widgets.Label) ValueFormater(com.biglybt.ui.swt.components.graphics.ValueFormater) Point(org.eclipse.swt.graphics.Point) TransportStartpoint(com.biglybt.core.networkmanager.TransportStartpoint) TabItem(org.eclipse.swt.widgets.TabItem) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) StackLayout(org.eclipse.swt.custom.StackLayout) SpeedManagerPingMapper(com.biglybt.core.speedmanager.SpeedManagerPingMapper)

Example 93 with Canvas

use of org.eclipse.swt.widgets.Canvas in project webtools.sourceediting by eclipse.

the class ADTFloatingToolbar method createControl.

public Control createControl(Composite composite) {
    Canvas canvas = new Canvas(composite, SWT.NONE);
    canvas.setBackground(ColorConstants.white);
    setControl(canvas);
    return getControl();
}
Also used : Canvas(org.eclipse.swt.widgets.Canvas)

Example 94 with Canvas

use of org.eclipse.swt.widgets.Canvas in project org.csstudio.display.builder by kasemir.

the class LEDRepresentation method createSWTControl.

@Override
protected Canvas createSWTControl(final Composite parent) throws Exception {
    createColors();
    // Unfortunately, the canvas is not transparent..
    final Canvas canvas = new Canvas(parent, SWT.NO_FOCUS | SWT.NO_BACKGROUND | SWT.TRANSPARENT);
    canvas.addPaintListener(this::doPaint);
    canvas.addDisposeListener((e) -> {
        for (final Color color : colors) color.dispose();
    });
    return canvas;
}
Also used : Canvas(org.eclipse.swt.widgets.Canvas) Color(org.eclipse.swt.graphics.Color)

Example 95 with Canvas

use of org.eclipse.swt.widgets.Canvas in project netxms by netxms.

the class LineChart method setZoomEnabled.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.charts.api.HistoricalDataChart#setZoomEnabled(boolean)
	 */
@Override
public void setZoomEnabled(boolean enableZoom) {
    this.zoomEnabled = enableZoom;
    final Canvas plotArea = getPlotArea();
    if (enableZoom) {
        plotArea.addMouseListener(zoomMouseListener);
        plotArea.addPaintListener(zoomPaintListener);
    } else {
        plotArea.removeMouseListener(zoomMouseListener);
        plotArea.removePaintListener(zoomPaintListener);
    }
}
Also used : Canvas(org.eclipse.swt.widgets.Canvas)

Aggregations

Canvas (org.eclipse.swt.widgets.Canvas)111 GridData (org.eclipse.swt.layout.GridData)47 GridLayout (org.eclipse.swt.layout.GridLayout)38 Composite (org.eclipse.swt.widgets.Composite)38 PaintEvent (org.eclipse.swt.events.PaintEvent)36 PaintListener (org.eclipse.swt.events.PaintListener)35 Point (org.eclipse.swt.graphics.Point)32 Rectangle (org.eclipse.swt.graphics.Rectangle)32 Label (org.eclipse.swt.widgets.Label)31 Text (org.eclipse.swt.widgets.Text)24 Button (org.eclipse.swt.widgets.Button)22 Color (org.eclipse.swt.graphics.Color)20 Shell (org.eclipse.swt.widgets.Shell)20 MouseEvent (org.eclipse.swt.events.MouseEvent)18 GC (org.eclipse.swt.graphics.GC)17 FillLayout (org.eclipse.swt.layout.FillLayout)17 Event (org.eclipse.swt.widgets.Event)17 SelectionEvent (org.eclipse.swt.events.SelectionEvent)16 Listener (org.eclipse.swt.widgets.Listener)16 Display (org.eclipse.swt.widgets.Display)15