Search in sources :

Example 1 with FXCanvas

use of javafx.embed.swt.FXCanvas in project org.csstudio.display.builder by kasemir.

the class ControllerDemo method createGUI.

private void createGUI(final Composite parent) {
    final GridLayout layout = new GridLayout(2, false);
    parent.setLayout(layout);
    // Plot
    try {
        plot = new ModelBasedPlot(true);
    } catch (Exception e1) {
        e1.printStackTrace();
    }
    final FXCanvas canvas = new FXCanvas(parent, SWT.NONE);
    canvas.setScene(new Scene(plot.getPlot()));
    canvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, layout.numColumns, 1));
    // [Debug] button
    final Button debug = new Button(parent, SWT.PUSH);
    debug.setText("Debug");
    debug.setLayoutData(new GridData(SWT.RIGHT, 0, true, false));
    debug.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            debug();
        }
    });
    // [Done] button to end demo
    final Button ok = new Button(parent, SWT.PUSH);
    ok.setText("Done");
    ok.setLayoutData(new GridData(SWT.RIGHT, 0, false, false));
    ok.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            run = false;
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FXCanvas(javafx.embed.swt.FXCanvas) Scene(javafx.scene.Scene)

Example 2 with FXCanvas

use of javafx.embed.swt.FXCanvas in project org.csstudio.display.builder by kasemir.

the class PlotDemo method createGUI.

// final private PlotListener listener = new PlotListener()
// {
// @Override
// public void scrollRequested(final boolean enable_scrolling)
// {
// System.out.println("Scroll enabled: " + enable_scrolling);
// scroll = enable_scrolling;
// }
// 
// @Override
// public void timeConfigRequested()
// {
// System.out.println("Time Config requested");
// }
// 
// @Override
// public void timeAxisChanged(final long start_ms, final long end_ms)
// {
// start_time = TimestampHelper.fromMillisecs(start_ms);
// end_time = TimestampHelper.fromMillisecs(end_ms);
// System.out.println("Time axis: " + start_time + " ... " + end_time);
// }
// 
// @Override
// public void valueAxisChanged(final int index, final double lower, final double upper)
// {
// System.out.println("Value axis " + index + ": " + lower + " ... " + upper);
// }
// 
// @Override
// public void droppedName(final String name)
// {
// System.out.println("Name dropped: " + name);
// }
// 
// @Override
// public void droppedPVName(final ProcessVariable name, final ArchiveDataSource archive)
// {
// System.out.println("PV Name dropped: " + name);
// }
// 
// @Override
// public void droppedFilename(final String file_name)
// {
// System.out.println("File Name dropped: " + file_name);
// }
// 
// @Override
// public void xyGraphConfigChanged(XYGraph newValue) {
// // TODO Auto-generated method stub
// 
// }
// 
// @Override
// public void removeAnnotationChanged(Annotation oldValue) {
// // TODO Auto-generated method stub
// 
// }
// 
// @Override
// public void addAnnotationChanged(Annotation newValue) {
// // TODO Auto-generated method stub
// 
// }
// 
// @Override
// public void backgroundColorChanged(Color newValue) {
// // TODO Auto-generated method stub
// 
// }
// 
// @Override
// public void timeAxisForegroundColorChanged(Color oldColor,
// Color newColor) {
// // TODO Auto-generated method stub
// 
// }
// 
// @Override
// public void valueAxisForegroundColorChanged(int index, Color oldColor,
// Color newColor) {
// // TODO Auto-generated method stub
// 
// }
// 
// @Override
// public void valueAxisTitleChanged(int index, String oldTitle,
// String newTitle) {
// // TODO Auto-generated method stub
// 
// }
// 
// @Override
// public void valueAxisAutoScaleChanged(int index, boolean oldAutoScale,
// boolean newAutoScale) {
// // TODO Auto-generated method stub
// 
// }
// 
// @Override
// public void traceNameChanged(int index, String oldName, String newName) {
// // TODO Auto-generated method stub
// 
// }
// 
// @Override
// public void traceYAxisChanged(int index, AxisConfig oldConfig,
// AxisConfig config) {
// // TODO Auto-generated method stub
// 
// }
// 
// @Override
// public void traceTypeChanged(int index, TraceType old,
// TraceType newTraceType) {
// // TODO Auto-generated method stub
// 
// }
// 
// @Override
// public void traceColorChanged(int index, Color old, Color newColor) {
// // TODO Auto-generated method stub
// 
// }
// 
// @Override
// public void valueAxisLogScaleChanged(int index, boolean old,
// boolean logScale) {
// // TODO Auto-generated method stub
// 
// }
// };
private void createGUI(final Composite parent) {
    final GridLayout layout = new GridLayout(1, false);
    parent.setLayout(layout);
    ModelBasedPlot plot;
    try {
        plot = new ModelBasedPlot(true);
    } catch (Exception e1) {
        e1.printStackTrace();
        return;
    }
    final FXCanvas canvas = new FXCanvas(parent, SWT.NONE);
    canvas.setScene(new Scene(plot.getPlot()));
    canvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, layout.numColumns, 1));
    // [Done] button to end demo
    final Button ok = new Button(parent, SWT.PUSH);
    ok.setText("Done");
    ok.setLayoutData(new GridData(SWT.RIGHT, 0, true, false));
    ok.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            run = false;
        }
    });
    // plot.addListener(listener);
    // Create demo samples
    final List<PlotSample> values = new ArrayList<PlotSample>();
    for (int i = 1; i < 10; ++i) values.add(new PlotSample("Test", TestHelper.makeValue(i)));
    values.add(new PlotSample("Test", TestHelper.makeError(15, "Disconnected")));
    // Single value. Line should continue until the following 'disconnect'.
    values.add(new PlotSample("Test", TestHelper.makeValue(17)));
    values.add(new PlotSample("Test", TestHelper.makeError(18, "Disconnected")));
    for (int i = 20; i < 30; ++i) values.add(new PlotSample("Test", TestHelper.makeValue(i)));
    final PlotSampleArray samples = new PlotSampleArray();
    samples.set(values);
    // Add item with demo samples
    final ModelItem item = new ModelItem("Demo") {

        @Override
        public PlotSamples getSamples() {
            return samples;
        }

        @Override
        public void write(final PrintWriter writer) {
        // NOP
        }
    };
    // TODO: Fix or remove
    // item.setColor(new RGB(0, 0, 255));
    plot.addTrace(item);
// start_time = VTypeHelper.getTimestamp(samples.getSample(0).getValue());
// end_time = VTypeHelper.getTimestamp(samples.getSample(samples.getSize()-1).getValue());
// plot.setTimeRange(start_time, end_time);
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ArrayList(java.util.ArrayList) ModelItem(org.csstudio.trends.databrowser3.model.ModelItem) Scene(javafx.scene.Scene) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) PlotSample(org.csstudio.trends.databrowser3.model.PlotSample) PlotSampleArray(org.csstudio.trends.databrowser3.model.PlotSampleArray) FXCanvas(javafx.embed.swt.FXCanvas) PrintWriter(java.io.PrintWriter)

Example 3 with FXCanvas

use of javafx.embed.swt.FXCanvas in project azure-tools-for-java by Microsoft.

the class JobViewFxUtil method startFx.

public static Object startFx(Object composite, final String webUrl, Object jobUtils) {
    try {
        Class compositeClass = Class.forName("org.eclipse.swt.widgets.Composite");
        Class[] paramTypes = { compositeClass, int.class };
        Constructor con = FXCanvas.class.getConstructor(paramTypes);
        Object[] parames = { composite, 1 << 16 };
        final FXCanvas canvas = (FXCanvas) con.newInstance(parames);
        Platform.setImplicitExit(false);
        Platform.runLater(new Runnable() {

            @Override
            public void run() {
                final WebView webView = new WebView();
                Scene scene = new Scene(webView);
                canvas.setScene(scene);
                WebEngine webEngine = webView.getEngine();
                webEngine.load(webUrl);
                webEngine.getLoadWorker().stateProperty().addListener(new ChangeListener<Worker.State>() {

                    @Override
                    public void changed(ObservableValue<? extends Worker.State> ov, Worker.State oldState, Worker.State newState) {
                        if (newState == Worker.State.SUCCEEDED) {
                            JSObject win = (JSObject) webEngine.executeScript("window");
                            win.setMember("JobUtils", new JobUtilsForEclipse());
                        }
                    }
                });
            }
        });
        return canvas;
    } catch (Exception e) {
        return e;
    }
}
Also used : Constructor(java.lang.reflect.Constructor) ObservableValue(javafx.beans.value.ObservableValue) JSObject(netscape.javascript.JSObject) Scene(javafx.scene.Scene) WebEngine(javafx.scene.web.WebEngine) Worker(javafx.concurrent.Worker) JSObject(netscape.javascript.JSObject) ChangeListener(javafx.beans.value.ChangeListener) FXCanvas(javafx.embed.swt.FXCanvas) WebView(javafx.scene.web.WebView)

Example 4 with FXCanvas

use of javafx.embed.swt.FXCanvas in project drbookings by DrBookings.

the class SamplePart method init.

protected void init(final Composite parent) {
    // this will initialize the FX Toolkit
    fxCanvas = new FXCanvas(parent, SWT.NONE);
    Platform.setImplicitExit(false);
    Platform.runLater(() -> createScene(parent));
}
Also used : FXCanvas(javafx.embed.swt.FXCanvas)

Aggregations

FXCanvas (javafx.embed.swt.FXCanvas)4 Scene (javafx.scene.Scene)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Button (org.eclipse.swt.widgets.Button)2 PrintWriter (java.io.PrintWriter)1 Constructor (java.lang.reflect.Constructor)1 ArrayList (java.util.ArrayList)1 ChangeListener (javafx.beans.value.ChangeListener)1 ObservableValue (javafx.beans.value.ObservableValue)1 Worker (javafx.concurrent.Worker)1 WebEngine (javafx.scene.web.WebEngine)1 WebView (javafx.scene.web.WebView)1 JSObject (netscape.javascript.JSObject)1 ModelItem (org.csstudio.trends.databrowser3.model.ModelItem)1 PlotSample (org.csstudio.trends.databrowser3.model.PlotSample)1 PlotSampleArray (org.csstudio.trends.databrowser3.model.PlotSampleArray)1