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);
}
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);
}
}
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();
}
}
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();
}
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();
}
}
Aggregations