/** * {@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(); }
/** * This operation sets up the Composite that contains the VisIt canvas and * create the VisIt widget. * * @param parent * The parent Composite to create the Control in. */ @Override public void createPartControl(Composite parent) { // Create a top level composite to hold the canvas or text vizComposite = new Composite(parent, SWT.NONE); vizComposite.setLayout(new GridLayout(1, true)); // Set up the canvas where the graph is displayed plotCanvas = new Canvas(vizComposite, SWT.BORDER); plotCanvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // MAGIC lws = new LightweightSystem(plotCanvas); return; }
/** * Initialize overview. */ protected void initializeOverview() { LightweightSystem lws = new J2DLightweightSystem(overview); RootEditPart rep = editor.getGraphicalViewer().getRootEditPart(); if (rep instanceof MainDesignerRootEditPart) { ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart) rep; thumbnail = new JSSScrollableThumbnail((Viewport) root.getFigure(), (MRoot)getViewer().getContents().getModel()); thumbnail.setSource(root.getLayer(LayerConstants.PRINTABLE_LAYERS)); lws.setContents(thumbnail); disposeListener = new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (thumbnail != null) { thumbnail.deactivate(); thumbnail = null; } } }; editor.getEditor().addDisposeListener(disposeListener); } lws.setControl(overview); }
@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(); }
private void createGraph(final Shell shell, final Map<Integer, Short> map, final BikeType bikeType) { final Canvas canvas = new Canvas(shell, SWT.NONE); final LightweightSystem lws = new LightweightSystem(canvas); torqueGraph = new ComplexTorqueGraph(map, bikeType); lws.setContents(torqueGraph.getToolbarArmedXYGraph()); GridDataFactory.fillDefaults().grab(true, true).applyTo(canvas); final IXYGraph xyGraph = torqueGraph.getXyGraph(); canvas.addKeyListener(new ZoomInListener(xyGraph)); canvas.addKeyListener(new ZoomOutListener(xyGraph)); canvas.addKeyListener(new UndoListener(xyGraph.getOperationsManager())); canvas.addKeyListener(new RedoListener(xyGraph.getOperationsManager())); canvas.addKeyListener(new SaveSnapshotListener(shell, xyGraph)); canvas.addMouseWheelListener(new ZoomMouseWheelListener(xyGraph)); new ComplexTorqueGraphContextMenu(canvas, torqueGraph); }
public CustomFigureCanvas(int style, Composite parent, LightweightSystem lws, CustomPaletteViewer toolViewer, PaletteRoot paletteRoot,ELTGraphicalEditor editor) { super(style | APPLY_STYLES, parent, lws); containerForSearchTextBox = toolViewer.creatSearchTextBox(this, paletteRoot,editor); if (containerForSearchTextBox != null && toolViewer != null) { org.eclipse.swt.graphics.Point bounds = containerForSearchTextBox.computeSize(SWT.DEFAULT, SWT.DEFAULT); if (containerHeight < bounds.y) { containerHeight = bounds.y; } } customLayoutViewPort(); }
public void createEyeViewControl(Composite parent) { Canvas canvas = new Canvas(parent, SWT.NONE); canvas.setLayoutData(new GridData(GridData.FILL_BOTH)); LightweightSystem liSystem = new LightweightSystem(canvas); ScalableFreeformRootEditPart rootEditPart = ((ScalableFreeformRootEditPart) dbToolGefEditor.getGraphicalViewer().getRootEditPart()); ScrollableThumbnail thumbnail = new ScrollableThumbnail((Viewport) rootEditPart.getFigure()); thumbnail.setSource(rootEditPart.getLayer(LayerConstants.SCALABLE_LAYERS)); liSystem.setContents(thumbnail); }
public static void main(String[] args) { Shell shell = new Shell(new Display()); shell.setSize(1200, 500); shell.setLayout(new GridLayout()); shell.setLocation(100, 150); Figure root = new Figure(); root.setFont(shell.getFont()); // XYLayout layout = new XYLayout(); // root.setLayoutManager(layout); org.eclipse.draw2d.GridLayout layout = new org.eclipse.draw2d.GridLayout(2,false); layout.horizontalSpacing = 100; root.setLayoutManager(layout); Canvas canvas = new Canvas(shell, SWT.DOUBLE_BUFFERED); canvas.setBackground(ColorConstants.white); canvas.setLayoutData(new GridData(GridData.FILL_BOTH)); createDiagram(root); LightweightSystem lws = new LightweightSystem(canvas); lws.setContents(root); Display display = shell.getDisplay(); shell.open(); while (!shell.isDisposed()) { while (!display.readAndDispatch()) { display.sleep(); } } }
public static void main(String[] args) { Shell shell = new Shell(new Display()); shell.setSize(1200, 500); shell.setLayout(new GridLayout()); shell.setLocation(100, 150); Figure root = new Figure(); root.setFont(shell.getFont()); // XYLayout layout = new XYLayout(); // root.setLayoutManager(layout); org.eclipse.draw2d.GridLayout layout = new org.eclipse.draw2d.GridLayout(2,false); layout.horizontalSpacing = 100; root.setLayoutManager(layout); Canvas canvas = new Canvas(shell, SWT.DOUBLE_BUFFERED); canvas.setBackground(ColorConstants.white); canvas.setLayoutData(new GridData(GridData.FILL_BOTH)); MatrixWidget widget = new MatrixWidget(); MockArray array = new MockArray("int[]", new int[]{1,2,3}, new int[]{4,5,6}, new int[]{7,8,9}, new int[]{10,11,12}); root.add(widget.createFigure(array)); LightweightSystem lws = new LightweightSystem(canvas); lws.setContents(root); Display display = shell.getDisplay(); shell.open(); while (!shell.isDisposed()) { while (!display.readAndDispatch()) { display.sleep(); } } }
public static void main(String[] args) { Shell shell = new Shell(new Display()); shell.setSize(365, 280); shell.setLayout(new GridLayout()); Figure root = new Figure(); root.setFont(shell.getFont()); XYLayout layout = new XYLayout(); root.setLayoutManager(layout); Canvas canvas = new Canvas(shell, SWT.DOUBLE_BUFFERED); canvas.setBackground(ColorConstants.white); canvas.setLayoutData(new GridData(GridData.FILL_BOTH)); VarParser parser = new VarParser("src/pt/iscte/pandionj/tests/Test.java"); parser.run(); System.out.println(parser.toText()); createDiagram(root, parser); LightweightSystem lws = new LightweightSystem(canvas); lws.setContents(root); Display display = shell.getDisplay(); shell.open(); while (!shell.isDisposed()) { while (!display.readAndDispatch()) { display.sleep(); } } }
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); }
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(); } } }
/** * {@inheritDoc} */ @Override public void createControl(Composite parent) { this.sash = new SashForm(parent, SWT.VERTICAL); // コンストラクタで指定したビューワの作成 this.viewer.createControl(this.sash); // EditPartFactory の設定 ERDiagramOutlineEditPartFactory editPartFactory = new ERDiagramOutlineEditPartFactory(); this.viewer.setEditPartFactory(editPartFactory); // グラフィカル・エディタのルート・モデルをツリー・ビューワにも設定 this.viewer.setContents(this.diagram); Canvas canvas = new Canvas(this.sash, SWT.BORDER); // サムネイル・フィギュアを配置する為の LightweightSystem this.lws = new LightweightSystem(canvas); this.resetView(this.registry); AbstractTransferDragSourceListener dragSourceListener = new ERDiagramTransferDragSourceListener( this.viewer, TemplateTransfer.getInstance()); this.viewer.addDragSourceListener(dragSourceListener); this.diagram.refreshOutline(); }
private static void main() throws FileNotFoundException { try { shell.setSize(100, 100); LightweightSystem lws = new LightweightSystem(shell); IFigure panel = new Figure(); panel.setLayoutManager(new ToolbarLayout()); initialize(panel); lws.setContents(panel); shell.open(); Display display = Display.getDefault(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } finally { if (image != null) { image.dispose(); } } }
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); }
protected void initializeOverview() { LightweightSystem lws = new LightweightSystem(overview); 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); } }
public void createControl(Composite parent) { control = new SashForm(parent, SWT.NONE); getViewer().createControl(parent); getViewer().setEditDomain(getEditDomain()); getSelectionSynchronizer().addViewer(getViewer()); Canvas canvas = new Canvas(control, SWT.BORDER); LightweightSystem lws = new LightweightSystem(canvas); thumbnail = new ScrollableThumbnail((Viewport) ((ScalableFreeformRootEditPart) getGraphicalViewer().getRootEditPart()).getFigure()); thumbnail.setSource(((ScalableFreeformRootEditPart) getGraphicalViewer().getRootEditPart()).getLayer(LayerConstants.PRINTABLE_LAYERS)); lws.setContents(thumbnail); disposeListener = new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (thumbnail != null) { thumbnail.deactivate(); thumbnail = null; } } }; getGraphicalViewer().getControl().addDisposeListener(disposeListener); }
/** * Creates the graphical Thumbnail viewer. */ protected void createThumbnailViewer() { LightweightSystem lws = new LightweightSystem(_overview); ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) _graphicalViewer.getRootEditPart(); _thumbnail = new FixedScrollableThumbnail((Viewport) rootEditPart.getFigure()); _thumbnail.setBorder(new MarginBorder(3)); _thumbnail.setSource(rootEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS)); lws.setContents(_thumbnail); }
/** * This is a callback that will allow us to create the viewer and initialize it. */ @Override public void createPartControl(final Composite parent) { // Create the composite to hold the controls final Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(1, false)); // Create the combo to hold the team names titleLbl = new Text(composite, SWT.NONE); titleLbl.setText(" "); // insert the holder for the heatmap parentCanvas = new Canvas(composite, SWT.NULL); parentCanvas.setLayoutData(new GridData(GridData.FILL_BOTH)); // Create Intensity Graph intensityGraph = new IntensityGraphFigure(); // use LightweightSystem to create the bridge between SWT and draw2D final LightweightSystem lws = new LightweightSystem(parentCanvas); lws.setContents(intensityGraph); // ok, layout the panel parentCanvas.pack(); makeActions(); contributeToActionBars(); getViewSite().getActionBars().getToolBarManager().add(showCount); getViewSite().getActionBars().getMenuManager().add(showCount); // register as selection listener setupListener(); }
public TorqueGraphCanvas(final Composite parent, final Bike bike) { super(parent, SWT.NONE); final LightweightSystem lws = new LightweightSystem(this); torqueGraph = new SimpleTorqueGraph(bike); lws.setContents(torqueGraph.getXyGraph()); setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); contextMenu = new SimpleTorqueGraphContextMenu(this, torqueGraph); }
private void init() { setCursor(SharedCursors.ARROW); lws = new LightweightSystem(); lws.setControl(this); final ArrowButton b = new ArrowButton(getArrowDirection()); b.setRolloverEnabled(true); b.setBorder(new ButtonBorder(ButtonBorder.SCHEMES.TOOLBAR)); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { transferFocus = true; if (isInState(STATE_COLLAPSED)) setState(STATE_PINNED_OPEN); else setState(STATE_COLLAPSED); } }); listeners.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals(PROPERTY_STATE)) { b.setDirection(getArrowDirection()); setToolTipText(getButtonTooltipText()); } else if (evt.getPropertyName().equals( PROPERTY_DOCK_LOCATION)) b.setDirection(getArrowDirection()); } }); lws.setContents(b); }
public Draw2DViewer(){ display = new Display(); shell = new Shell(display); shell.setLayout(new FillLayout()); canvas = new FigureCanvas(shell, SWT.V_SCROLL|SWT.H_SCROLL); LightweightSystem ls = new LightweightSystem(canvas); ls.setContents(canvas.getViewport()); }
@PostConstruct public void postConstruct(Composite parent, IEclipseContext ctx) { // Create the canvas and the related LightweightSystem for Draw2D canvas = new Canvas(parent, SWT.NONE); final LightweightSystem lws = new LightweightSystem(canvas); // Create a main figure to contain the 2 counters and the 2 labels IFigure root = new Figure(); root.setLayoutManager(new GridLayout(2, false)); rpmCounter = createRpmCounter(); root.add(rpmCounter); speedCounter = createSpeedCounter(); root.add(speedCounter); // Add two titles under the counters. Label rpmTitle = new Label(); rpmTitle.setText(" Rpm"); rpmTitle.setLabelAlignment(PositionConstants.CENTER); root.add(rpmTitle); Label speedTitle = new Label(); speedTitle.setText(" Speed"); speedTitle.setLabelAlignment(PositionConstants.CENTER); root.add(speedTitle); // Set the root figure. lws.setContents(root); }
@PostConstruct public void postConstruct(Composite parent, IEclipseContext ctx) { // Create the canvas and the related LightweightSystem for Draw2D canvas = new Canvas(parent, SWT.NONE); final LightweightSystem lws = new LightweightSystem(canvas); // Create a main figure to contain the 2 counters and the 2 labels IFigure root = new Figure(); root.setLayoutManager(new XYLayout()); root.setBackgroundColor(ColorConstants.lightBlue); rpmCounter = createRpmCounter(); rpmCounter.setBounds(new Rectangle(COUNTER_MARGIN,COUNTER_MARGIN,COUNTER_SIZE, COUNTER_SIZE)); root.add(rpmCounter); speedCounter = createSpeedCounter(); speedCounter.setBounds(new Rectangle(COUNTER_MARGIN*2 + COUNTER_SIZE, COUNTER_MARGIN,COUNTER_SIZE, COUNTER_SIZE)); root.add(speedCounter); // Add two titles under the counters. Label rpmTitle = new Label(); rpmTitle.setText("Rpm"); rpmTitle.setLabelAlignment(PositionConstants.CENTER); rpmTitle.setBounds(new Rectangle(COUNTER_MARGIN, COUNTER_SIZE + COUNTER_MARGIN,COUNTER_SIZE, 20)); root.add(rpmTitle); Label speedTitle = new Label(); speedTitle.setText("Speed"); speedTitle.setLabelAlignment(PositionConstants.CENTER); speedTitle.setBounds(new Rectangle(COUNTER_SIZE + 2*COUNTER_MARGIN, COUNTER_SIZE + COUNTER_MARGIN,COUNTER_SIZE, 20)); root.add(speedTitle); // Set the root figure. lws.setContents(root); }
@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); }
public CustomFigureCanvas(Composite parent, LightweightSystem lws, CustomPaletteViewer toolViewer, PaletteRoot paletteRoot,ELTGraphicalEditor editor) { this(SWT.DOUBLE_BUFFERED, parent, lws, toolViewer, paletteRoot,editor); }
public LightweightSystem getLightweightSys() { return getLightweightSystem(); }
RuntimeViewer(Composite parent) { super(parent, SWT.BORDER); instance = this; setLayout(new FillLayout()); setBackground(PandionJConstants.Colors.VIEW_BACKGROUND); scroll = new ScrolledComposite(this, SWT.H_SCROLL | SWT.V_SCROLL); scroll.setBackground(PandionJConstants.Colors.VIEW_BACKGROUND); canvas = new Canvas(scroll, SWT.DOUBLE_BUFFERED); canvas.setBackground(ColorConstants.white); canvas.setLayoutData(new GridData(GridData.FILL_BOTH)); scroll.setContent(canvas); addMenu(); // rootFig = new ScalableLayeredPane(); // ((ScalableLayeredPane) rootFig).setScale(2); rootFig = new Figure(); rootFig.setOpaque(true); rootGrid = new GridLayout(2, false); rootGrid.horizontalSpacing = PandionJConstants.STACK_TO_OBJECTS_GAP; rootGrid.marginWidth = PandionJConstants.MARGIN; rootGrid.marginHeight = PandionJConstants.MARGIN; rootFig.setLayoutManager(rootGrid); stackFig = new StackContainer(); rootFig.add(stackFig); org.eclipse.draw2d.GridData d = new org.eclipse.draw2d.GridData(SWT.BEGINNING, SWT.BEGINNING, true, true); d.widthHint = Math.max(PandionJConstants.STACKCOLUMN_MIN_WIDTH, stackFig.getPreferredSize().width); rootGrid.setConstraint(stackFig, d); objectContainers = new ArrayList<>(); objectContainer = ObjectContainer.create(true); rootFig.add(objectContainer); rootGrid.setConstraint(objectContainer, new org.eclipse.draw2d.GridData(SWT.FILL, SWT.FILL, true, true)); lws = new LightweightSystem(canvas); lws.setContents(rootFig); pointersMap = new HashMap<>(); pointersMapOwners = ArrayListMultimap.create(); }
/** * Creates a new instance * @param parent * @param controller * @param text * @param shortText */ public ComponentRiskMonitor(final Composite parent, final String text, final String shortText) { Display.getCurrent().getActiveShell(); // Images imageLow = Resources.getImage("bullet_green.png"); //$NON-NLS-1$ imageHigh = Resources.getImage("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); try { SWTUtil.changeFont(caption, SWT.BOLD); } catch (DeviceResourceException e) { // TODO Auto-generated catch block e.printStackTrace(); } // 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); }
private static void createGraphContent( Composite parent ) { Canvas graphPanel = new Canvas(parent, SWT.NONE); // use LightweightSystem to create the bridge between SWT and draw2D final LightweightSystem lws = new LightweightSystem(graphPanel); // create a new XY Graph. xyGraph = new XYGraph(); xyGraph.getPrimaryXAxis().setShowMajorGrid(true); xyGraph.getPrimaryXAxis().setAutoScale(true); xyGraph.getPrimaryYAxis().setShowMajorGrid(true); xyGraph.getPrimaryYAxis().setAutoScale(true); ToolbarArmedXYGraph toolbarArmedXYGraph = new ToolbarArmedXYGraph(xyGraph); //xyGraph.setTitle("Simple Toolbar Armed XYGraph Example"); // set it as the content of LightwightSystem lws.setContents(toolbarArmedXYGraph); // xyGraph.primaryXAxis.setShowMajorGrid(true); // xyGraph.primaryYAxis.setShowMajorGrid(true); // xyGraph.primaryXAxis.setAutoScale(true); // xyGraph.primaryYAxis.setAutoScale(true); // xyGraph.primaryXAxis.setAutoScaleThreshold(0.0); // xyGraph.primaryYAxis.setAutoScaleThreshold(0.0); // create a trace data provider, which will provide the data to the // trace. // if(ExperimentResultsView.measures != null){ //// xyGraph.primaryXAxis.setRange(0, experimentJob.getDeadline()); //// xyGraph.primaryYAxis.setRange(0,100); // LinkedList<SimulationTimeSeries> data = experimentJob.getCollection().getSimulationTimeSeries(); // for (SimulationTimeSeries serie : data) { // SimulationTrace traceDataProvider = new SimulationTrace(serie,experimentJob.getIterations()); // // // create the trace // Trace trace = new Trace(serie.getName(), xyGraph.primaryXAxis, xyGraph.primaryYAxis, traceDataProvider); // // // set trace property // trace.setPointStyle(PointStyle.XCROSS); // trace.setErrorBarEnabled(true); // trace.setYErrorBarType(ErrorBarType.BOTH); // trace.setXErrorBarType(ErrorBarType.NONE); // // // add the trace to xyGraph // xyGraph.addTrace(trace); // } // } }
@PostConstruct public void postConstruct(Composite parent, final ImageRegistry reg) { parent.setLayout(new GridLayout(1, true)); Canvas canvas = new Canvas(parent, SWT.BORDER); canvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); final LightweightSystem lws = new LightweightSystem(canvas); // Create Scaled Slider final ScaledSliderFigure slider = new ScaledSliderFigure(); slider.setHorizontal(true); // Init Scaled Slider slider.setRange(-10, 10); // can brake or accelerate from -10 to 10 m/s2 slider.setValue(0); slider.setLoLevel(-5); slider.setLoloLevel(-8); slider.setHiLevel(6); slider.setHihiLevel(8); slider.setThumbColor(ColorConstants.gray); slider.setEffect3D(true); slider.setShowMinorTicks(false); slider.addManualValueChangeListener(new IManualValueChangeListener() { public void manualValueChanged(double newValue) { if (engineSimu != null) engineSimu.accelerate((int) newValue); } }); lws.setContents(slider); // Initialize needed images Bundle b = FrameworkUtil.getBundle(getClass()); reg.put(IMG_START, ImageDescriptor.createFromURL(b.getEntry(IMG_START))); reg.put(IMG_STOP, ImageDescriptor.createFromURL(b.getEntry(IMG_STOP))); // reg.put(IMG_FUNCTION, // ImageDescriptor.createFromURL(b.getEntry(IMG_FUNCTION))); // Create only 1 button for start and stop. Composite buttonComposite = new Composite(parent, SWT.NONE); buttonComposite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true)); buttonComposite.setLayout(new GridLayout(1, true)); final Label startButton = new Label(buttonComposite, SWT.NONE); startButton.setImage(reg.get(IMG_START)); startButton.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { if (engineSimu != null) { if (engineSimu.isStarted()) { engineSimu.stop(); startButton.setImage(reg.get(IMG_START)); } else { engineSimu.start(); startButton.setImage(reg.get(IMG_STOP)); } } } }); }
/** * 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); }
/** * Allow external entities, to get access to the Lightweight system * @return */ public LightweightSystem getLWS() { return lws; }
@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); }