Search in sources :

Example 31 with LightweightSystem

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

the class OverviewOutlinePage method createControl.

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 32 with LightweightSystem

use of org.eclipse.draw2d.LightweightSystem in project jbosstools-hibernate 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;
        if (this.thumbnail != null) {
            this.thumbnail.deactivate();
        }
        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 33 with LightweightSystem

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

the class BarChartExample 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("Bar and Area Chart");
    // set it as the content of LightwightSystem
    lws.setContents(xyGraph);
    // Configure XYGraph
    xyGraph.primaryXAxis.setShowMajorGrid(true);
    xyGraph.primaryYAxis.setShowMajorGrid(true);
    // 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[] { 0, 20, 30, 40, 50, 60, 70, 80, 100 });
    traceDataProvider.setCurrentYDataArray(new double[] { 11, 44, 55, 45, 88, 98, 52, 23, 78 });
    // create the trace
    Trace trace = new Trace("Trace1-XY Plot", xyGraph.primaryXAxis, xyGraph.primaryYAxis, traceDataProvider);
    // set trace property
    trace.setTraceType(TraceType.BAR);
    trace.setLineWidth(15);
    trace.setAreaAlpha(200);
    trace.setTraceColor(XYGraphMediaFactory.getInstance().getColor(XYGraphMediaFactory.COLOR_BLUE));
    // add the trace to xyGraph
    xyGraph.addTrace(trace);
    // create a trace data provider, which will provide the data to the trace.
    CircularBufferDataProvider traceDataProvider2 = new CircularBufferDataProvider(false);
    traceDataProvider2.setBufferSize(100);
    traceDataProvider2.setCurrentXDataArray(new double[] { 0, 20, 30, 40, 50, 60, 70, 80, 100 });
    traceDataProvider2.setCurrentYDataArray(new double[] { 15, 60, 40, 60, 70, 80, 65, 70, 23 });
    // create the trace
    Trace trace2 = new Trace("Trace1-XY Plot", xyGraph.primaryXAxis, xyGraph.primaryYAxis, traceDataProvider2);
    // set trace property
    trace2.setPointSize(6);
    trace2.setAreaAlpha(150);
    trace2.setTraceType(TraceType.AREA);
    trace2.setTraceColor(XYGraphMediaFactory.getInstance().getColor(XYGraphMediaFactory.COLOR_RED));
    // trace2.setLineWidth(5);
    // add the trace to xyGraph
    xyGraph.addTrace(trace2);
    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 34 with LightweightSystem

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

the class XYGraphTest method main.

public static void main(final String[] args) {
    final Shell shell = new Shell();
    shell.setSize(800, 500);
    shell.open();
    final LightweightSystem lws = new LightweightSystem(shell);
    final XYGraphTest testFigure = new XYGraphTest();
    lws.setContents(testFigure);
    shell.setText("Comprehensive Example");
    final Display display = Display.getDefault();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) LightweightSystem(org.eclipse.draw2d.LightweightSystem) Display(org.eclipse.swt.widgets.Display)

Example 35 with LightweightSystem

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

the class GaugeExample method main.

public static void main(String[] args) {
    final Shell shell = new Shell();
    shell.setSize(300, 250);
    shell.setBackground(XYGraphMediaFactory.getInstance().getColor(255, 255, 255));
    shell.open();
    // use LightweightSystem to create the bridge between SWT and draw2D
    final LightweightSystem lws = new LightweightSystem(shell);
    // Create Gauge
    final GaugeFigure gaugeFigure = new GaugeFigure();
    // Init gauge
    gaugeFigure.setBackgroundColor(XYGraphMediaFactory.getInstance().getColor(0, 0, 0));
    gaugeFigure.setForegroundColor(XYGraphMediaFactory.getInstance().getColor(255, 255, 255));
    gaugeFigure.setRange(-90, 90);
    gaugeFigure.setLoLevel(-50);
    gaugeFigure.setLoloLevel(-80);
    gaugeFigure.setHiLevel(60);
    gaugeFigure.setHihiLevel(80);
    gaugeFigure.setMajorTickMarkStepHint(50);
    gaugeFigure.setTitle("Rotation");
    gaugeFigure.setUnit("Degrees");
    lws.setContents(gaugeFigure);
    // Update the gauge 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() {
                    gaugeFigure.setValue(Math.sin(counter++ / 10.0) * 90);
                }
            });
        }
    }, 100, 100, TimeUnit.MILLISECONDS);
    Display display = Display.getDefault();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    future.cancel(true);
    scheduler.shutdown();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) 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