Search in sources :

Example 16 with LightweightSystem

use of org.eclipse.draw2d.LightweightSystem in project nebula by eclipse.

the class WidgetsExampleView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    GridLayout layout = new GridLayout();
    layout.numColumns = 4;
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    parent.setLayout(layout);
    // create canvases to hold the widgets.
    Canvas knobCanvas = new Canvas(parent, SWT.BORDER);
    knobCanvas.setLayoutData(gd);
    Canvas gaugeCanvas = new Canvas(parent, SWT.BORDER);
    gaugeCanvas.setLayoutData(gd);
    Canvas thermoCanvas = new Canvas(parent, SWT.BORDER);
    thermoCanvas.setLayoutData(gd);
    Canvas tankCanvas = new Canvas(parent, SWT.BORDER);
    tankCanvas.setLayoutData(gd);
    Canvas xyGraphCanvas = new Canvas(parent, SWT.BORDER);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 3);
    xyGraphCanvas.setLayoutData(gd);
    // use LightweightSystem to create the bridge between SWT and draw2D
    LightweightSystem lws = new LightweightSystem(knobCanvas);
    // Create widgets
    final KnobFigure knobFigure = new KnobFigure();
    lws.setContents(knobFigure);
    lws = new LightweightSystem(gaugeCanvas);
    final GaugeFigure gauge = new GaugeFigure();
    gauge.setBackgroundColor(XYGraphMediaFactory.getInstance().getColor(0, 0, 0));
    gauge.setForegroundColor(XYGraphMediaFactory.getInstance().getColor(255, 255, 255));
    lws.setContents(gauge);
    lws = new LightweightSystem(thermoCanvas);
    final ThermometerFigure thermo = new ThermometerFigure();
    lws.setContents(thermo);
    lws = new LightweightSystem(tankCanvas);
    final TankFigure tank = new TankFigure();
    lws.setContents(tank);
    // use LightweightSystem to create the bridge between SWT and draw2D
    lws = new LightweightSystem(xyGraphCanvas);
    // create a new XY Graph.
    IXYGraph xyGraph = new XYGraph();
    xyGraph.getPrimaryXAxis().setAutoScale(true);
    // set it as the content of LightwightSystem
    lws.setContents(xyGraph);
    // create a trace data provider, which will provide the data to the
    // trace.
    // Set chronological to true so it can sort the data chronologically.
    final CircularBufferDataProvider traceDataProvider = new CircularBufferDataProvider(true);
    traceDataProvider.setBufferSize(100);
    // Update the trace whenever any X or Y data changed. So only set Y data
    // can update the trace.
    traceDataProvider.setUpdateMode(UpdateMode.X_OR_Y);
    // create the trace
    Trace trace = new Trace("Trace1-XY Plot", xyGraph.getPrimaryXAxis(), xyGraph.getPrimaryYAxis(), traceDataProvider);
    // set trace property
    trace.setPointStyle(PointStyle.POINT);
    // add the trace to xyGraph
    xyGraph.addTrace(trace);
    // Add listener
    knobFigure.addManualValueChangeListener(new IManualValueChangeListener() {

        @Override
        public void manualValueChanged(double newValue) {
            gauge.setValue(newValue);
            thermo.setValue(newValue);
            tank.setValue(newValue);
            traceDataProvider.setCurrentYData(newValue);
        }
    });
}
Also used : TankFigure(org.eclipse.nebula.visualization.widgets.figures.TankFigure) IManualValueChangeListener(org.eclipse.nebula.visualization.widgets.datadefinition.IManualValueChangeListener) ThermometerFigure(org.eclipse.nebula.visualization.widgets.figures.ThermometerFigure) KnobFigure(org.eclipse.nebula.visualization.widgets.figures.KnobFigure) Canvas(org.eclipse.swt.widgets.Canvas) XYGraph(org.eclipse.nebula.visualization.xygraph.figures.XYGraph) IXYGraph(org.eclipse.nebula.visualization.xygraph.figures.IXYGraph) CircularBufferDataProvider(org.eclipse.nebula.visualization.xygraph.dataprovider.CircularBufferDataProvider) Trace(org.eclipse.nebula.visualization.xygraph.figures.Trace) GridLayout(org.eclipse.swt.layout.GridLayout) IXYGraph(org.eclipse.nebula.visualization.xygraph.figures.IXYGraph) GridData(org.eclipse.swt.layout.GridData) LightweightSystem(org.eclipse.draw2d.LightweightSystem) GaugeFigure(org.eclipse.nebula.visualization.widgets.figures.GaugeFigure)

Example 17 with LightweightSystem

use of org.eclipse.draw2d.LightweightSystem in project Sophena by GreenDelta.

the class ClimateDataChart method createChart.

private void createChart(Canvas canvas) {
    LightweightSystem lws = new LightweightSystem(canvas);
    XYGraph g = new XYGraph();
    lws.setContents(g);
    g.setShowTitle(false);
    g.setShowLegend(false);
    CircularBufferDataProvider data = new CircularBufferDataProvider(true);
    data.setBufferSize(Stats.HOURS);
    data.setCurrentYDataArray(station.data);
    data.setConcatenate_data(false);
    Trace trace = new Trace("Data", g.primaryXAxis, g.primaryYAxis, data);
    trace.setPointStyle(Trace.PointStyle.NONE);
    trace.setTraceColor(Colors.getLinkBlue());
    g.addTrace(trace);
    Axis x = g.primaryXAxis;
    x.setRange(0, Stats.HOURS);
    x.setTitle(M.DwdSourceInfo);
    x.setMinorTicksVisible(false);
    x.setMajorGridStep(10000);
    x.setTitleFont(x.getFont());
    formatY(g);
}
Also used : Trace(org.eclipse.nebula.visualization.xygraph.figures.Trace) LightweightSystem(org.eclipse.draw2d.LightweightSystem) XYGraph(org.eclipse.nebula.visualization.xygraph.figures.XYGraph) CircularBufferDataProvider(org.eclipse.nebula.visualization.xygraph.dataprovider.CircularBufferDataProvider) Axis(org.eclipse.nebula.visualization.xygraph.figures.Axis)

Example 18 with LightweightSystem

use of org.eclipse.draw2d.LightweightSystem in project Sophena by GreenDelta.

the class BoilerChart method render.

void render(Composite body, FormToolkit tk) {
    String title = sorted ? "Geordnete Jahresdauerlinie" : "Ungeordnete Jahresdauerlinie";
    Section section = UI.section(body, tk, title);
    Actions.bind(section, new LoadTraceSwitch(), ImageExport.forXYGraph("Jahresdauerlinie.jpg", () -> chart));
    UI.gridData(section, true, false);
    Composite composite = UI.sectionClient(section, tk);
    UI.gridLayout(composite, 1);
    Canvas canvas = new Canvas(composite, SWT.DOUBLE_BUFFERED);
    UI.gridData(canvas, true, true).minimumHeight = 250;
    LightweightSystem lws = new LightweightSystem(canvas);
    chart = createGraph(lws);
    addZoom(canvas);
    fillData();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Canvas(org.eclipse.swt.widgets.Canvas) LightweightSystem(org.eclipse.draw2d.LightweightSystem) Section(org.eclipse.ui.forms.widgets.Section)

Example 19 with LightweightSystem

use of org.eclipse.draw2d.LightweightSystem in project Sophena by GreenDelta.

the class ElectricityChart method render.

void render(Composite body, FormToolkit tk) {
    Section section = UI.section(body, tk, "Stromerzeugung");
    Actions.bind(section, ImageExport.forXYGraph("Stromerzeugung.jpg", () -> chart));
    UI.gridData(section, true, false);
    Composite composite = UI.sectionClient(section, tk);
    UI.gridLayout(composite, 1);
    Canvas canvas = new Canvas(composite, SWT.DOUBLE_BUFFERED);
    UI.gridData(canvas, true, true).minimumHeight = 250;
    LightweightSystem lws = new LightweightSystem(canvas);
    chart = createGraph(lws);
    renderChart();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Canvas(org.eclipse.swt.widgets.Canvas) LightweightSystem(org.eclipse.draw2d.LightweightSystem) Section(org.eclipse.ui.forms.widgets.Section)

Example 20 with LightweightSystem

use of org.eclipse.draw2d.LightweightSystem in project dbeaver by serge-rider.

the class ERDOutlinePage method createControl.

/* (non-Javadoc)
     * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite)
     */
@Override
public void createControl(Composite parent) {
    // create canvas and lws
    overview = new Canvas(parent, SWT.NONE);
    LightweightSystem lws = new LightweightSystem(overview);
    // create thumbnail
    thumbnail = new ScrollableThumbnail((Viewport) rootEditPart.getFigure());
    thumbnail.setBorder(new MarginBorder(3));
    thumbnail.setSource(rootEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS));
    lws.setContents(thumbnail);
}
Also used : Canvas(org.eclipse.swt.widgets.Canvas) MarginBorder(org.eclipse.draw2d.MarginBorder) Viewport(org.eclipse.draw2d.Viewport) LightweightSystem(org.eclipse.draw2d.LightweightSystem) ScrollableThumbnail(org.eclipse.draw2d.parts.ScrollableThumbnail)

Aggregations

LightweightSystem (org.eclipse.draw2d.LightweightSystem)55 Shell (org.eclipse.swt.widgets.Shell)33 Display (org.eclipse.swt.widgets.Display)32 Canvas (org.eclipse.swt.widgets.Canvas)23 XYGraph (org.eclipse.nebula.visualization.xygraph.figures.XYGraph)16 CircularBufferDataProvider (org.eclipse.nebula.visualization.xygraph.dataprovider.CircularBufferDataProvider)15 Trace (org.eclipse.nebula.visualization.xygraph.figures.Trace)15 ScrollableThumbnail (org.eclipse.draw2d.parts.ScrollableThumbnail)14 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)12 Viewport (org.eclipse.draw2d.Viewport)12 MarginBorder (org.eclipse.draw2d.MarginBorder)11 IXYGraph (org.eclipse.nebula.visualization.xygraph.figures.IXYGraph)11 ToolbarArmedXYGraph (org.eclipse.nebula.visualization.xygraph.figures.ToolbarArmedXYGraph)11 IManualValueChangeListener (org.eclipse.nebula.visualization.widgets.datadefinition.IManualValueChangeListener)7 SchemeBorder (org.eclipse.draw2d.SchemeBorder)6 GridData (org.eclipse.swt.layout.GridData)6 GridLayout (org.eclipse.swt.layout.GridLayout)6 GaugeFigure (org.eclipse.nebula.visualization.widgets.figures.GaugeFigure)5 KnobFigure (org.eclipse.nebula.visualization.widgets.figures.KnobFigure)5 TankFigure (org.eclipse.nebula.visualization.widgets.figures.TankFigure)5