Search in sources :

Example 6 with LightweightSystem

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

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)

Example 7 with LightweightSystem

use of org.eclipse.draw2d.LightweightSystem in project jbosstools-base by jbosstools.

the class DiagramContentOutlinePage method initializeOverview.

protected void initializeOverview() {
    LightweightSystem lws = new LightweightSystem(overview);
    RootEditPart rep = getGraphicalViewer().getRootEditPart();
    if (rep instanceof ScalableFreeformRootEditPart) {
        ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart) rep;
        thumbnail = new ScrollableThumbnail((Viewport) root.getFigure());
        thumbnail.setBorder(new MarginBorder(3));
        thumbnail.setSource(root.getLayer(LayerConstants.PRINTABLE_LAYERS));
        lws.setContents(thumbnail);
    }
}
Also used : ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) MarginBorder(org.eclipse.draw2d.MarginBorder) Viewport(org.eclipse.draw2d.Viewport) LightweightSystem(org.eclipse.draw2d.LightweightSystem) RootEditPart(org.eclipse.gef.RootEditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) ScrollableThumbnail(org.eclipse.draw2d.parts.ScrollableThumbnail)

Example 8 with LightweightSystem

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

the class SimpleExample method main.

public static void main(String[] args) {
    final Shell shell = new Shell();
    shell.setSize(300, 250);
    shell.open();
    // use LightweightSystem to create the bridge between SWT and draw2D
    final LightweightSystem lws = new LightweightSystem(shell);
    // create a new XY Graph.
    XYGraph xyGraph = new XYGraph();
    xyGraph.setTitle("Simple Example");
    // set it as the content of LightwightSystem
    lws.setContents(xyGraph);
    // create a trace data provider, which will provide the data to the trace.
    CircularBufferDataProvider traceDataProvider = new CircularBufferDataProvider(false);
    traceDataProvider.setBufferSize(100);
    traceDataProvider.setCurrentXDataArray(new double[] { 10, 23, 34, 45, 56, 78, 88, 99 });
    traceDataProvider.setCurrentYDataArray(new double[] { 11, 44, 55, 45, 88, 98, 52, 23 });
    // create the trace
    Trace trace = new Trace("Trace1-XY Plot", xyGraph.primaryXAxis, xyGraph.primaryYAxis, traceDataProvider);
    // set trace property
    trace.setPointStyle(PointStyle.XCROSS);
    // add the trace to xyGraph
    xyGraph.addTrace(trace);
    Display display = Display.getDefault();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
}
Also used : Trace(org.eclipse.nebula.visualization.xygraph.figures.Trace) Shell(org.eclipse.swt.widgets.Shell) LightweightSystem(org.eclipse.draw2d.LightweightSystem) XYGraph(org.eclipse.nebula.visualization.xygraph.figures.XYGraph) CircularBufferDataProvider(org.eclipse.nebula.visualization.xygraph.dataprovider.CircularBufferDataProvider) Display(org.eclipse.swt.widgets.Display)

Example 9 with LightweightSystem

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

the class TankExample method main.

public static void main(String[] args) {
    final Shell shell = new Shell();
    shell.setSize(300, 250);
    shell.open();
    // use LightweightSystem to create the bridge between SWT and draw2D
    final LightweightSystem lws = new LightweightSystem(shell);
    // Create widget
    final TankFigure tank = new TankFigure();
    // Init widget
    tank.setBackgroundColor(XYGraphMediaFactory.getInstance().getColor(255, 255, 255));
    tank.setBorder(new SchemeBorder(SchemeBorder.SCHEMES.ETCHED));
    tank.setRange(-100, 100);
    tank.setLoLevel(-50);
    tank.setLoloLevel(-80);
    tank.setHiLevel(60);
    tank.setHihiLevel(80);
    tank.setMajorTickMarkStepHint(50);
    lws.setContents(tank);
    // Update the widget in another thread.
    ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
    ScheduledFuture<?> future = scheduler.scheduleAtFixedRate(new Runnable() {

        public void run() {
            Display.getDefault().asyncExec(new Runnable() {

                public void run() {
                    tank.setValue(Math.sin(counter++ / 10.0) * 100);
                }
            });
        }
    }, 100, 100, TimeUnit.MILLISECONDS);
    Display display = Display.getDefault();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    future.cancel(true);
    scheduler.shutdown();
}
Also used : TankFigure(org.eclipse.nebula.visualization.widgets.figures.TankFigure) Shell(org.eclipse.swt.widgets.Shell) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) SchemeBorder(org.eclipse.draw2d.SchemeBorder) LightweightSystem(org.eclipse.draw2d.LightweightSystem) Display(org.eclipse.swt.widgets.Display)

Example 10 with LightweightSystem

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

the class MultipleWidgetsExample method main.

public static void main(String[] args) {
    final Shell shell = new Shell();
    shell.setText("Multiple Widgets Example");
    shell.setSize(400, 400);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    shell.setLayout(layout);
    // create canvases to hold the widgets.
    Canvas knobCanvas = new Canvas(shell, SWT.NONE);
    knobCanvas.setLayoutData(gd);
    Canvas gaugeCanvas = new Canvas(shell, SWT.NONE);
    gaugeCanvas.setLayoutData(gd);
    Canvas thermoCanvas = new Canvas(shell, SWT.NONE);
    thermoCanvas.setLayoutData(gd);
    Canvas tankCanvas = new Canvas(shell, SWT.NONE);
    tankCanvas.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);
    // Add listener
    knobFigure.addManualValueChangeListener(new IManualValueChangeListener() {

        public void manualValueChanged(double newValue) {
            gauge.setValue(newValue);
            thermo.setValue(newValue);
            tank.setValue(newValue);
        }
    });
    shell.open();
    Display display = Display.getDefault();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
}
Also used : TankFigure(org.eclipse.nebula.visualization.widgets.figures.TankFigure) IManualValueChangeListener(org.eclipse.nebula.visualization.widgets.datadefinition.IManualValueChangeListener) Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) ThermometerFigure(org.eclipse.nebula.visualization.widgets.figures.ThermometerFigure) KnobFigure(org.eclipse.nebula.visualization.widgets.figures.KnobFigure) Canvas(org.eclipse.swt.widgets.Canvas) GridData(org.eclipse.swt.layout.GridData) LightweightSystem(org.eclipse.draw2d.LightweightSystem) GaugeFigure(org.eclipse.nebula.visualization.widgets.figures.GaugeFigure) Display(org.eclipse.swt.widgets.Display)

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