Search in sources :

Example 1 with RTValuePlot

use of org.csstudio.javafx.rtplot.RTValuePlot in project org.csstudio.display.builder by kasemir.

the class WaveformView method doCreatePartControl.

/**
 * {@inheritDoc}
 */
@Override
protected void doCreatePartControl(final Composite parent) {
    // Arrange disposal
    parent.addDisposeListener((DisposeEvent e) -> {
        // Ignore current model after this view is disposed.
        if (model != null) {
            model.removeListener(model_listener);
            removeAnnotation();
        }
    });
    final GridLayout layout = new GridLayout(4, false);
    parent.setLayout(layout);
    // PV: .pvs..... [Refresh]
    // =====================
    // ======= Plot ========
    // =====================
    // <<<<<< Slider >>>>>>
    // Timestamp: __________ Sevr./Status: __________
    // PV: .pvs..... [Refresh]
    Label l = new Label(parent, 0);
    l.setText(Messages.SampleView_Item);
    l.setLayoutData(new GridData());
    pv_name = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
    pv_name.setLayoutData(new GridData(SWT.FILL, 0, true, false, layout.numColumns - 2, 1));
    pv_name.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        @Override
        public void widgetDefaultSelected(final SelectionEvent e) {
            // First item is "--select PV name--"
            if (pv_name.getSelectionIndex() == 0)
                selectPV(null);
            else
                selectPV(model.getItem(pv_name.getText()));
        }
    });
    final Button refresh = new Button(parent, SWT.PUSH);
    refresh.setText(Messages.SampleView_Refresh);
    refresh.setToolTipText(Messages.SampleView_RefreshTT);
    refresh.setLayoutData(new GridData());
    refresh.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            // First item is "--select PV name--"
            if (pv_name.getSelectionIndex() == 0)
                selectPV(null);
            else
                selectPV(model.getItem(pv_name.getText()));
        }
    });
    // =====================
    // ======= Plot ========
    // =====================
    final JFX_SWT_Wrapper wrapper = new JFX_SWT_Wrapper(parent, () -> {
        plot = new RTValuePlot(true);
        plot.getXAxis().setName(Messages.WaveformIndex);
        plot.getYAxes().get(0).setName(Messages.WaveformAmplitude);
        plot.getYAxes().get(0).setAutoscale(true);
        return new Scene(plot);
    });
    final Control plot_canvas = wrapper.getFXCanvas();
    plot_canvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, layout.numColumns, 1));
    // <<<<<< Slider >>>>>>
    sample_index = new Slider(parent, SWT.HORIZONTAL);
    sample_index.setToolTipText(Messages.WaveformTimeSelector);
    sample_index.setLayoutData(new GridData(SWT.FILL, 0, true, false, layout.numColumns, 1));
    sample_index.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            showSelectedSample();
        }
    });
    // Timestamp: __________ Sevr./Status: __________
    l = new Label(parent, 0);
    l.setText(Messages.WaveformTimestamp);
    l.setLayoutData(new GridData());
    timestamp = new Text(parent, SWT.BORDER | SWT.READ_ONLY);
    timestamp.setLayoutData(new GridData(SWT.FILL, 0, true, false));
    l = new Label(parent, 0);
    l.setText(Messages.WaveformStatus);
    l.setLayoutData(new GridData());
    status = new Text(parent, SWT.BORDER | SWT.READ_ONLY);
    status.setLayoutData(new GridData(SWT.FILL, 0, true, false));
    // Context Menu
    final MenuManager mm = new MenuManager();
    mm.setRemoveAllWhenShown(true);
    final Menu menu = mm.createContextMenu(plot_canvas);
    plot_canvas.setMenu(menu);
    getSite().registerContextMenu(mm, null);
    mm.addMenuListener(manager -> {
        mm.add(new ToggleToolbarAction(plot, true));
        mm.add(new ToggleLegendAction(plot, true));
        mm.add(new Separator());
        mm.add(new ToggleYAxisAction());
    });
}
Also used : Slider(org.eclipse.swt.widgets.Slider) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Scene(javafx.scene.Scene) ToggleToolbarAction(org.csstudio.trends.databrowser3.editor.ToggleToolbarAction) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) RTValuePlot(org.csstudio.javafx.rtplot.RTValuePlot) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuManager(org.eclipse.jface.action.MenuManager) JFX_SWT_Wrapper(org.csstudio.javafx.swt.JFX_SWT_Wrapper) Menu(org.eclipse.swt.widgets.Menu) Separator(org.eclipse.jface.action.Separator) SelectionListener(org.eclipse.swt.events.SelectionListener) ToggleLegendAction(org.csstudio.trends.databrowser3.editor.ToggleLegendAction)

Example 2 with RTValuePlot

use of org.csstudio.javafx.rtplot.RTValuePlot in project org.csstudio.display.builder by kasemir.

the class XYPlotRepresentation method createJFXNode.

@Override
public Pane createJFXNode() throws Exception {
    // Plot is only active in runtime mode, not edit mode
    plot = new RTValuePlot(!toolkit.isEditMode());
    plot.setUpdateThrottle(RepresentationUpdateThrottle.plot_update_delay, TimeUnit.MILLISECONDS);
    plot.showToolbar(false);
    plot.showCrosshair(false);
    // Create PlotMarkers once. Not allowing adding/removing them at runtime
    if (!toolkit.isEditMode())
        for (MarkerProperty marker : model_widget.propMarkers().getValue()) createMarker(marker);
    return plot;
}
Also used : RTValuePlot(org.csstudio.javafx.rtplot.RTValuePlot) MarkerProperty(org.csstudio.display.builder.model.widgets.plots.XYPlotWidget.MarkerProperty)

Aggregations

RTValuePlot (org.csstudio.javafx.rtplot.RTValuePlot)2 Scene (javafx.scene.Scene)1 MarkerProperty (org.csstudio.display.builder.model.widgets.plots.XYPlotWidget.MarkerProperty)1 JFX_SWT_Wrapper (org.csstudio.javafx.swt.JFX_SWT_Wrapper)1 ToggleLegendAction (org.csstudio.trends.databrowser3.editor.ToggleLegendAction)1 ToggleToolbarAction (org.csstudio.trends.databrowser3.editor.ToggleToolbarAction)1 MenuManager (org.eclipse.jface.action.MenuManager)1 Separator (org.eclipse.jface.action.Separator)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Combo (org.eclipse.swt.widgets.Combo)1 Control (org.eclipse.swt.widgets.Control)1 Label (org.eclipse.swt.widgets.Label)1 Menu (org.eclipse.swt.widgets.Menu)1 Slider (org.eclipse.swt.widgets.Slider)1