org.eclipse.draw2d.LightweightSystem Java Examples
The following examples show how to use
org.eclipse.draw2d.LightweightSystem.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ComprehensiveExample.java From nebula with Eclipse Public License 2.0 | 6 votes |
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(); } } }
Example #2
Source File: TimelineComposite.java From nebula with Eclipse Public License 2.0 | 6 votes |
public TimelineComposite(Composite parent, int style) { super(parent, style); fResourceManager = new LocalResourceManager(JFaceResources.getResources(), this); final FillLayout layout = new FillLayout(); layout.marginHeight = 10; layout.marginWidth = 10; setLayout(layout); setBackground(ColorConstants.black); final Canvas canvas = new Canvas(this, SWT.DOUBLE_BUFFERED); canvas.setBackground(ColorConstants.black); final LightweightSystem lightWeightSystem = new LightweightSystem(canvas); fRootFigure = new RootFigure(fResourceManager); fRootFigure.setFont(parent.getFont()); lightWeightSystem.setContents(fRootFigure); // draw2d does not directly support mouseWheelEvents, so register on canvas canvas.addMouseWheelListener(new TimelineScaler(this)); }
Example #3
Source File: AbstractWidgetTest.java From nebula with Eclipse Public License 2.0 | 6 votes |
@Test public void testAll() throws Exception { shell = new Shell(); shell.open(); shell.setLayout(new GridLayout(1, false)); final Canvas canvas = new Canvas(shell, SWT.None); canvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); text = new Text(shell, SWT.READ_ONLY); text.setFont(XYGraphMediaFactory.getInstance().getFont("default", 18, SWT.BOLD)); text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); final LightweightSystem lws = new LightweightSystem(canvas); lws.setContents(getTestBench()); shell.setSize(800, 500); testGetBeanInfo(); testWidget(); }
Example #4
Source File: GraphDemo.java From nebula with Eclipse Public License 2.0 | 6 votes |
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 XYGraphTest2 testFigure = new XYGraphTest2(); lws.setContents(testFigure); shell.setText("XY Graph Test"); final Display display = Display.getDefault(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } //System.out.println(Calendar.getInstance().getTime()); }
Example #5
Source File: ProcessDiagramEditor.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * initialize the overview */ protected void initializeOverview() { LightweightSystem lws = new LightweightSystem(overview); RootEditPart rep = getGraphicalViewer().getRootEditPart(); DiagramRootEditPart root = (DiagramRootEditPart) rep; thumbnail = new ScrollableThumbnailEx((Viewport) root.getFigure()); // thumbnail.setSource(root.getLayer(org.eclipse.gef.LayerConstants.PRINTABLE_LAYERS)); thumbnail.setSource(root.getLayer(LayerConstants.SCALABLE_LAYERS)); lws.setContents(thumbnail); disposeListener = new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (thumbnail != null) { thumbnail.deactivate(); thumbnail = null; } } }; getEditor().addDisposeListener(disposeListener); this.overviewInitialized = true; }
Example #6
Source File: ERDiagramOutlinePage.java From ermasterr with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void createControl(final Composite parent) { sash = new SashForm(parent, SWT.VERTICAL); // コンストラクタで指定したビューワの作成 viewer.createControl(sash); // EditPartFactory の設定 final ERDiagramOutlineEditPartFactory editPartFactory = new ERDiagramOutlineEditPartFactory(); viewer.setEditPartFactory(editPartFactory); // グラフィカル・エディタのルート・モデルをツリー・ビューワにも設定 viewer.setContents(diagram); final Canvas canvas = new Canvas(sash, SWT.BORDER); // サムネイル・フィギュアを配置する為の LightweightSystem lws = new LightweightSystem(canvas); resetView(registry); final AbstractTransferDragSourceListener dragSourceListener = new ERDiagramTransferDragSourceListener(viewer, TemplateTransfer.getInstance()); viewer.addDragSourceListener(dragSourceListener); diagram.refreshOutline(); }
Example #7
Source File: ERDiagramOutlinePage.java From erflute with Apache License 2.0 | 6 votes |
@Override public void createControl(Composite parent) { this.sash = new SashForm(parent, SWT.VERTICAL); viewer.createControl(sash); editPartFactory = new ERDiagramOutlineEditPartFactory(); editPartFactory.setQuickMode(quickMode); viewer.setEditPartFactory(editPartFactory); viewer.setContents(diagram); if (!quickMode) { final Canvas canvas = new Canvas(sash, SWT.BORDER); lws = new LightweightSystem(canvas); } resetView(registry); final AbstractTransferDragSourceListener dragSourceListener = new ERDiagramTransferDragSourceListener(viewer, TemplateTransfer.getInstance()); viewer.addDragSourceListener(dragSourceListener); expandVirturalDiagramTree(); }
Example #8
Source File: ERDiagramOutlinePage.java From ermaster-b with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void createControl(Composite parent) { this.sash = new SashForm(parent, SWT.VERTICAL); // �R���X�g���N�^�Ŏw�肵���r���[���̍쐬 this.viewer.createControl(this.sash); editPartFactory = new ERDiagramOutlineEditPartFactory(); editPartFactory.setQuickMode(quickMode); this.viewer.setEditPartFactory(editPartFactory); // �O���t�B�J���E�G�f�B�^�̃��[�g�E���f�����c���[�E�r���[���ɂ��ݒ� this.viewer.setContents(this.diagram); if (!quickMode) { Canvas canvas = new Canvas(this.sash, SWT.BORDER); // �T���l�C���E�t�B�M���A��z�u����ׂ� LightweightSystem this.lws = new LightweightSystem(canvas); } this.resetView(this.registry); AbstractTransferDragSourceListener dragSourceListener = new ERDiagramTransferDragSourceListener( this.viewer, TemplateTransfer.getInstance()); this.viewer.addDragSourceListener(dragSourceListener); }
Example #9
Source File: ScaledSliderExample.java From nebula with Eclipse Public License 2.0 | 5 votes |
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 Scaled Slider final ScaledSliderFigure slider = new ScaledSliderFigure(); //Init Scaled Slider slider.setRange(-100, 100); slider.setLoLevel(-50); slider.setLoloLevel(-80); slider.setHiLevel(60); slider.setHihiLevel(80); slider.setMajorTickMarkStepHint(50); slider.setThumbColor(ColorConstants.gray); slider.addManualValueChangeListener(new IManualValueChangeListener() { @Override public void manualValueChanged(double newValue) { System.out.println("You set value to: " + newValue); } }); lws.setContents(slider); Display display = Display.getDefault(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
Example #10
Source File: KnobExample.java From nebula with Eclipse Public License 2.0 | 5 votes |
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 Knob final KnobFigure knobFigure = new KnobFigure(); //Init Knob knobFigure.setRange(-100, 100); knobFigure.setLoLevel(-50); knobFigure.setLoloLevel(-80); knobFigure.setHiLevel(60); knobFigure.setHihiLevel(80); knobFigure.setMajorTickMarkStepHint(50); knobFigure.setThumbColor(ColorConstants.gray); knobFigure.addManualValueChangeListener(new IManualValueChangeListener() { @Override public void manualValueChanged(double newValue) { System.out.println("You set value to: " + newValue); } }); lws.setContents(knobFigure); Display display = Display.getDefault(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
Example #11
Source File: GraphDemo.java From nebula with Eclipse Public License 2.0 | 5 votes |
public static void main(final String[] args) { // if testName is Default, the original Axis implementation will be // used. If Diamond, the new DAxis implementation will be used to // generate the tick marks. String testName = "Default"; String[] testNames = new String[] { "Default", "Diamond" }; final Shell shell = new Shell(); shell.setSize(800, 500); shell.open(); final LightweightSystem lws = new LightweightSystem(shell); XYGraphTest2 testFigure = null; if (testName.equals(testNames[0])) { testFigure = new XYGraphTest2( new XYGraph(new DefaultAxesFactory()), new Axis("X-2", false), new Axis("Log Scale", true)); } else { testFigure = new XYGraphTest2( new XYGraph(new DAxesFactory()), new DAxis("X-2", false), new DAxis("Log Scale", true)); } lws.setContents(testFigure); shell.setText("XY Graph Test"); final Display display = Display.getDefault(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } // System.out.println(Calendar.getInstance().getTime()); }
Example #12
Source File: XYGraphExampleView.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Override public void createPartControl(Composite parent) { // use LightweightSystem to create the bridge between SWT and draw2D final LightweightSystem lws = new LightweightSystem(new Canvas(parent, SWT.NONE)); // create a new XY Graph. IXYGraph xyGraph = new XYGraph(); ToolbarArmedXYGraph toolbarArmedXYGraph = new ToolbarArmedXYGraph(xyGraph); xyGraph.setTitle("Simple Example"); // set it as the content of LightwightSystem lws.setContents(toolbarArmedXYGraph); // 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.getPrimaryXAxis(), xyGraph.getPrimaryYAxis(), traceDataProvider); // set trace property trace.setPointStyle(PointStyle.XCROSS); // add the trace to xyGraph xyGraph.addTrace(trace); }
Example #13
Source File: XYGraphStyledDoubleExampleView.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Override public void createPartControl(Composite parent) { // use LightweightSystem to create the bridge between SWT and draw2D final LightweightSystem lws = new LightweightSystem(new Canvas(parent, SWT.NONE)); // create a new XY Graph. IXYGraph xyGraph = new XYGraph(); ToolbarArmedXYGraph toolbarArmedXYGraph = new ToolbarArmedXYGraph(xyGraph); xyGraph.setTitle("Simple Styled Example"); // set it as the content of LightwightSystem lws.setContents(toolbarArmedXYGraph); // 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, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6 }); traceDataProvider.setCurrentYDataArray(new double[] { 1, 1, 1, 1, 1, 1, 1 }); // create the trace Trace trace = new Trace("Trace-Styled XY Plot", xyGraph.getPrimaryXAxis(), xyGraph.getPrimaryYAxis(), traceDataProvider); // set trace property trace.setTraceColor(XYGraphMediaFactory.getInstance().getColor(XYGraphMediaFactory.COLOR_GRAY)); trace.setTraceType(TraceType.POINT); // set point properties trace.setPointStyle(PointStyle.FILLED_SQUARE); trace.setPointSize(40); trace.setPointStyleProvider(new Rainbowstyle()); // add the trace to xyGraph xyGraph.addTrace(trace); // perform AutoScale xyGraph.performAutoScale(); }
Example #14
Source File: ImageTest.java From ermasterr with Apache License 2.0 | 5 votes |
private static void main() throws FileNotFoundException { try { shell.setSize(100, 100); final LightweightSystem lws = new LightweightSystem(shell); final IFigure panel = new Figure(); panel.setLayoutManager(new ToolbarLayout()); initialize(panel); lws.setContents(panel); shell.open(); final Display display = Display.getDefault(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } finally { if (image != null) { image.dispose(); } } }
Example #15
Source File: GodClassDiagram.java From JDeodorant with MIT License | 5 votes |
public FigureCanvas createDiagram(){ canvas.setBackground(ColorConstants.white); LightweightSystem lws = new LightweightSystem(canvas); lws.setContents(this.root); return canvas; }
Example #16
Source File: ScaledSliderExample.java From nebula with Eclipse Public License 2.0 | 5 votes |
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 Scaled Slider final ScaledSliderFigure slider = new ScaledSliderFigure(); //Init Scaled Slider slider.setRange(-100, 100); slider.setLoLevel(-50); slider.setLoloLevel(-80); slider.setHiLevel(60); slider.setHihiLevel(80); slider.setMajorTickMarkStepHint(50); slider.setThumbColor(ColorConstants.gray); slider.addManualValueChangeListener(new IManualValueChangeListener() { public void manualValueChanged(double newValue) { System.out.println("You set value to: " + newValue); } }); lws.setContents(slider); Display display = Display.getDefault(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
Example #17
Source File: KnobExample.java From nebula with Eclipse Public License 2.0 | 5 votes |
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 Knob final KnobFigure knobFigure = new KnobFigure(); //Init Knob knobFigure.setRange(-100, 100); knobFigure.setLoLevel(-50); knobFigure.setLoloLevel(-80); knobFigure.setHiLevel(60); knobFigure.setHihiLevel(80); knobFigure.setMajorTickMarkStepHint(50); knobFigure.setThumbColor(ColorConstants.gray); knobFigure.addManualValueChangeListener(new IManualValueChangeListener() { public void manualValueChanged(double newValue) { System.out.println("You set value to: " + newValue); } }); lws.setContents(knobFigure); Display display = Display.getDefault(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
Example #18
Source File: SimpleExample.java From nebula with Eclipse Public License 2.0 | 5 votes |
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(); } }
Example #19
Source File: SankeyMiniViewAction.java From olca-app with Mozilla Public License 2.0 | 5 votes |
@Override protected Control createContents(Composite parent) { Composite composite = createForm(parent); createScale(composite); Canvas canvas = new Canvas(composite, SWT.BORDER); canvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); LightweightSystem lws = new LightweightSystem(canvas); ScrollableThumbnail thumbnail = createThumbnail(); lws.setContents(thumbnail); viewer.getControl().addDisposeListener((e) -> { if (!closed) close(); }); return super.createContents(parent); }
Example #20
Source File: ImageTest.java From ermaster-b with Apache License 2.0 | 5 votes |
private static void main() throws FileNotFoundException { // �f�t�H���gDisplay���g�p���ăV�F�����쐬 try { shell.setSize(100, 100); // �V�F���̃T�C�Y���w�� // �쐬�����V�F�����g�p����LightweightSystem�̍쐬 LightweightSystem lws = new LightweightSystem(shell); // ���[�g�E�t�B�M���A�̍쐬 IFigure panel = new Figure(); panel.setLayoutManager(new ToolbarLayout()); initialize(panel); // ���[�g�E�t�B�M���A�̓o�^ lws.setContents(panel); // �ȉ��́A���̑���SWT�A�v���P�[�V�����Ɠ��l shell.open(); Display display = Display.getDefault(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } finally { if (image != null) { image.dispose(); } } }
Example #21
Source File: CustomMainPaletteViewer.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
protected LightweightSystem createLightweightSystem() { return new AsyncLightweightSystem(); }
Example #22
Source File: ComponentRiskMonitor.java From arx with Apache License 2.0 | 4 votes |
/** * Creates a new instance * @param parent * @param controller * @param text * @param shortText */ public ComponentRiskMonitor(final Composite parent, final Controller controller, final String text, final String shortText) { // Images imageLow = controller.getResources().getManagedImage("bullet_green.png"); //$NON-NLS-1$ imageHigh = controller.getResources().getManagedImage("bullet_red.png"); //$NON-NLS-1$ // Layout GridLayout layout = SWTUtil.createGridLayout(1); layout.marginHeight = 0; layout.marginTop = 0; layout.marginBottom = 0; layout.verticalSpacing = 0; // Root this.root = new Composite(parent, SWT.NONE); this.root.setLayout(layout); this.root.setToolTipText(text); // Caption this.caption = new CLabel(root, SWT.CENTER); this.caption.setText(shortText); this.caption.setLayoutData(SWTUtil.createFillHorizontallyGridData()); this.caption.setToolTipText(text); this.caption.setImage(imageHigh); SWTUtil.changeFont(caption, SWT.BOLD); // Content Composite content = new Composite(root, SWT.NONE); content.setLayoutData(SWTUtil.createFillGridData()); content.setToolTipText(text); // Create meter Canvas canvas = new Canvas(content, SWT.DOUBLE_BUFFERED); canvas.setToolTipText(text); this.meter = new ComponentMeterFigure(); this.meter.setNeedleColor(XYGraphMediaFactory.getInstance().getColor(0, 0, 0)); this.meter.setValueLabelVisibility(true); this.meter.setRange(new Range(0, 100)); this.meter.setLoLevel(0); this.meter.setLoColor(XYGraphMediaFactory.getInstance().getColor(0, 150, 0)); this.meter.setLoloLevel(25); this.meter.setLoloColor(XYGraphMediaFactory.getInstance().getColor(255, 255, 0)); this.meter.setHiLevel(50); this.meter.setHiColor(XYGraphMediaFactory.getInstance().getColor(255, 200, 25)); this.meter.setHihiLevel(100); this.meter.setHihiColor(XYGraphMediaFactory.getInstance().getColor(255, 0, 0)); this.meter.setMajorTickMarkStepHint(50); LightweightSystem lws = new LightweightSystem(canvas); lws.setContents(this.meter); // Create label label = new CLabel(content, SWT.CENTER); label.setLayoutData(SWTUtil.createFillHorizontallyGridData()); label.setToolTipText(text); // Create responsive layout new ComponentResponsiveLayout(content, 100, 50, canvas, label); }
Example #23
Source File: BarChartExample.java From nebula with Eclipse Public License 2.0 | 4 votes |
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. IXYGraph xyGraph = new XYGraph(); xyGraph.setTitle("Bar and Area Chart"); // set it as the content of LightwightSystem lws.setContents(xyGraph); // Configure XYGraph xyGraph.getPrimaryXAxis().setShowMajorGrid(true); xyGraph.getPrimaryYAxis().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.getPrimaryXAxis(), xyGraph.getPrimaryYAxis(), 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.getPrimaryXAxis(), xyGraph.getPrimaryYAxis(), 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); Font LEGEND_FONT = XYGraphMediaFactory.getInstance().getFont(new FontData("Lucida Sans", 11, SWT.BOLD)); Legend legend = xyGraph.getLegend(trace); legend.setDrawBorder(true); legend.setPreferredHeight(100); legend.setTextFont(LEGEND_FONT); Display display = Display.getDefault(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
Example #24
Source File: OpenMiniatureViewAction.java From olca-app with Mozilla Public License 2.0 | 4 votes |
@Override protected Control createContents(final Composite parent) { FormToolkit toolkit = new FormToolkit(Display.getCurrent()); ScrolledForm scrolledForm = toolkit.createScrolledForm(parent); Composite body = scrolledForm.getBody(); body.setLayout(new FillLayout()); toolkit.paintBordersFor(body); SashForm sashForm = new SashForm(body, SWT.VERTICAL); toolkit.adapt(sashForm, true, true); Section categorySection = toolkit .createSection(sashForm, ExpandableComposite.NO_TITLE | ExpandableComposite.EXPANDED); categorySection.setText(""); Composite composite = toolkit.createComposite(categorySection, SWT.NONE); composite.setLayout(new GridLayout()); categorySection.setClient(composite); toolkit.paintBordersFor(composite); final Scale scale = new Scale(composite, SWT.NONE); scale.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); final double[] values = GraphConfig.ZOOM_LEVELS; final int increment = 100 / (values.length - 1); scale.setIncrement(increment); scale.setMinimum(0); scale.setMaximum(100); Controls.onSelect(scale, (e) -> { zoomManager.setZoom(values[scale.getSelection() / increment]); }); scale.setSelection(increment * (values.length - 1) / 2); Canvas canvas = new Canvas(composite, SWT.BORDER); canvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); lws = new LightweightSystem(canvas); thumbnail = new ScrollableThumbnail(port); thumbnail.setSource(figure); lws.setContents(thumbnail); disposeListener = new DisposeListener() { @Override public void widgetDisposed(final DisposeEvent e) { if (thumbnail != null) { thumbnail.deactivate(); thumbnail = null; } if (control != null && !control.isDisposed()) control.removeDisposeListener(disposeListener); close(); } }; control.addDisposeListener(disposeListener); return super.createContents(parent); }
Example #25
Source File: StaircaseExample.java From nebula with Eclipse Public License 2.0 | 4 votes |
public static void main(final String[] args) { // Main window (shell) final Shell shell = new Shell(); shell.setSize(800, 500); shell.open(); // XYGraph final LightweightSystem lws = new LightweightSystem(shell); final ToolbarArmedXYGraph plot = new ToolbarArmedXYGraph(new XYGraph(), XYGraphFlags.SEPARATE_ZOOM | XYGraphFlags.STAGGER); final XYGraph xygraph = (XYGraph) plot.getXYGraph(); xygraph.setTransparent(false); xygraph.setTitle("You should see a line. Zoom out to see more data"); lws.setContents(plot); // Add data & trace final CircularBufferDataProvider data = new CircularBufferDataProvider(true); data.addSample(new Sample(next_x++, 1, 1, 1, 0, 0)); data.addSample(new Sample(next_x++, 2, 1, 1, 0, 0)); data.addSample(new Sample(next_x++, 3, 1, 1, 0, 0)); data.addSample(new Sample(next_x++, 1, 1, 1, 0, 0)); data.addSample(new Sample(next_x++, 1, 1, 1, 0, 0)); data.addSample(new Sample(next_x++, 1, 1, 1, 0, 0)); // Add Double.NaN gap, single point data.addSample(new Sample(next_x++, Double.NaN, 0, 0, 0, 0, "Disconnected")); data.addSample(new Sample(next_x++, 1, 0, 0, 0, 0)); // Another gap, single point data.addSample(new Sample(next_x++, Double.NaN, 0, 0, 0, 0, "Disconnected")); data.addSample(new Sample(next_x++, 2, 0, 0, 0, 0)); // Last value is valid 'forever' data.addSample(new Sample(Double.MAX_VALUE, 2, 0, 0, 0, 0)); // Always looked OK with this range xygraph.getPrimaryXAxis().setRange(data.getXDataMinMax()); xygraph.getPrimaryYAxis().setRange(data.getYDataMinMax()); // With STEP_HORIZONTALLY this should have shown just a horizontal // line, but a bug resulted in nothing when both the 'start' and 'end' // point of the horizontal line were outside the plot range. // Similarly, using STEP_VERTICALLY failed to draw anything when // both end-points of the horizontal or vertical section of the step // were outside the plot. (fixed) // // There's still a question about handling 'YErrorInArea': // For now, the axis intersection removes x/y errors, // so when moving a sample with y error left or right outside // of the plot range, the error area suddenly shrinks when // the axis intersection is assumed to have +-0 y error. xygraph.getPrimaryXAxis().setRange(4.1, 4.9); // Gap, start of X range, sample @ x==8, gap @ 9, end of range. // Bug failed to show line from that sample up to gap @ 9. xygraph.getPrimaryXAxis().setRange(7.5, 9.5); final Trace trace = new Trace("Demo", xygraph.getPrimaryXAxis(), xygraph.getPrimaryYAxis(), data); trace.setTraceType(TraceType.STEP_HORIZONTALLY); // trace.setTraceType(TraceType.STEP_VERTICALLY); // // SOLID_LINE does not show individual points // trace.setTraceType(TraceType.SOLID_LINE); // trace.setPointStyle(PointStyle.CIRCLE); trace.setErrorBarEnabled(true); trace.setDrawYErrorInArea(true); xygraph.addTrace(trace); Font LEGEND_FONT = XYGraphMediaFactory.getInstance().getFont(new FontData("Lucida Sans", 11, SWT.BOLD)); Legend legend = xygraph.getLegend(trace); legend.setDrawBorder(true); legend.setPreferredHeight(100); legend.setTextFont(LEGEND_FONT); // SWT main loop final Display display = Display.getDefault(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
Example #26
Source File: ThermometerExample.java From nebula with Eclipse Public License 2.0 | 4 votes |
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 ThermometerFigure thermo = new ThermometerFigure(); //Init widget thermo.setBackgroundColor( XYGraphMediaFactory.getInstance().getColor(255, 255, 255)); thermo.setBorder(new SchemeBorder(SchemeBorder.SCHEMES.ETCHED)); thermo.setRange(-100, 100); thermo.setLoLevel(-50); thermo.setLoloLevel(-80); thermo.setHiLevel(60); thermo.setHihiLevel(80); thermo.setShowHi(false); thermo.setMajorTickMarkStepHint(50); lws.setContents(thermo); //Update the widget in another thread. ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); ScheduledFuture<?> future = scheduler.scheduleAtFixedRate(new Runnable() { @Override public void run() { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { thermo.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(); }
Example #27
Source File: SimpleExample.java From nebula with Eclipse Public License 2.0 | 4 votes |
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. IXYGraph 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.getPrimaryXAxis(), xyGraph.getPrimaryYAxis(), traceDataProvider); // set trace property trace.setPointStyle(PointStyle.XCROSS); // Create an annotation on Primary axis, pName is a String Annotation lAnnotation = new Annotation("Point1", xyGraph.getPrimaryXAxis(), xyGraph.getPrimaryYAxis()); // Set the value as an X lAnnotation.setValues(10, 11); lAnnotation.setEnabled(true); // the annotation can be moved on the graph lAnnotation.setShowPosition(true); lAnnotation.setShowName(true); lAnnotation.setShowSampleInfo(false); lAnnotation.setCursorLineStyle(CursorLineStyle.NONE); lAnnotation.setAnnotationColor(ColorConstants.darkGray); xyGraph.addAnnotation(lAnnotation); // add the trace to xyGraph xyGraph.addTrace(trace); Font LEGEND_FONT = XYGraphMediaFactory.getInstance().getFont(new FontData("Lucida Sans", 11, SWT.BOLD)); Legend legend = xyGraph.getLegend(trace); legend.setDrawBorder(true); legend.setPreferredHeight(100); legend.setTextFont(LEGEND_FONT); Display display = Display.getDefault(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
Example #28
Source File: SimpleToolbarArmedXYGraphExample.java From nebula with Eclipse Public License 2.0 | 4 votes |
public static void main(String[] args) { final Shell shell = new Shell(); shell.setSize(600, 400); shell.open(); // use LightweightSystem to create the bridge between SWT and draw2D final LightweightSystem lws = new LightweightSystem(shell); // create a new XY Graph. IXYGraph xyGraph = new XYGraph(); ToolbarArmedXYGraph toolbarArmedXYGraph = new ToolbarArmedXYGraph(xyGraph); xyGraph.setTitle("Simple Toolbar Armed XYGraph Example"); // set it as the content of LightwightSystem lws.setContents(toolbarArmedXYGraph); xyGraph.getPrimaryXAxis().setShowMajorGrid(true); xyGraph.getPrimaryYAxis().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[] { 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.getPrimaryXAxis(), xyGraph.getPrimaryYAxis(), 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(); } }
Example #29
Source File: PureJavaExample.java From nebula with Eclipse Public License 2.0 | 4 votes |
public static void main(String[] args) { final Shell shell = new Shell(); shell.setSize(600, 400); shell.open(); // use LightweightSystem to create the bridge between SWT and draw2D final LightweightSystem lws = new LightweightSystem(shell); // create a new XY Graph. IXYGraph xyGraph = new XYGraph(new DAxesFactory()); ToolbarArmedXYGraph toolbarArmedXYGraph = new ToolbarArmedXYGraph(xyGraph); xyGraph.setTitle("Simple Toolbar Armed XYGraph Example"); // set it as the content of LightwightSystem lws.setContents(toolbarArmedXYGraph); xyGraph.getPrimaryXAxis().setShowMajorGrid(true); xyGraph.getPrimaryYAxis().setShowMajorGrid(true); xyGraph.getPrimaryXAxis().setAutoScale(true); xyGraph.getPrimaryYAxis().setAutoScale(true); xyGraph.getPrimaryXAxis().setInverted(true); xyGraph.getPrimaryYAxis().setInverted(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.2, 23, 34, 45, 56, 78, 88, 100.1 }); traceDataProvider.setCurrentYDataArray(new double[] { -0.5, 44, 55, 45, 88, 100.1, 52, 23 }); // create the trace Trace trace = new Trace("Trace1-XY Plot", xyGraph.getPrimaryXAxis(), xyGraph.getPrimaryYAxis(), 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(); } }
Example #30
Source File: TankExample.java From nebula with Eclipse Public License 2.0 | 4 votes |
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(); }