Search in sources :

Example 1 with YAxis

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

the class PlotConfigDialog method addAxisContent.

private int addAxisContent(final GridPane layout, int row, final Axis<?> axis) {
    if (!axis.getName().trim().isEmpty())
        layout.add(new Label('"' + axis.getName() + '"'), 0, row);
    // is supposed to handle the 'scrolling'
    if (axis instanceof NumericAxis) {
        final NumericAxis num_axis = (NumericAxis) axis;
        Label label = new Label("Start");
        layout.add(label, 1, row);
        final TextField start = new TextField(axis.getValueRange().getLow().toString());
        layout.add(start, 2, row++);
        label = new Label("End");
        layout.add(label, 1, row);
        final TextField end = new TextField(axis.getValueRange().getHigh().toString());
        layout.add(end, 2, row++);
        @SuppressWarnings("unchecked") final EventHandler<ActionEvent> update_range = event -> {
            try {
                num_axis.setValueRange(Double.parseDouble(start.getText()), Double.parseDouble(end.getText()));
            } catch (NumberFormatException ex) {
                start.setText(axis.getValueRange().getLow().toString());
                end.setText(axis.getValueRange().getHigh().toString());
                return;
            }
            if (axis instanceof YAxisImpl)
                plot.internalGetPlot().fireYAxisChange((YAxisImpl<XTYPE>) axis);
            else if (axis instanceof HorizontalNumericAxis)
                plot.internalGetPlot().fireXAxisChange();
        };
        start.setOnAction(update_range);
        end.setOnAction(update_range);
        final CheckBox autoscale = new CheckBox("auto-scale");
        if (axis.isAutoscale()) {
            autoscale.setSelected(true);
            start.setDisable(true);
            end.setDisable(true);
        }
        autoscale.setOnAction(event -> {
            axis.setAutoscale(autoscale.isSelected());
            start.setDisable(autoscale.isSelected());
            end.setDisable(autoscale.isSelected());
            plot.internalGetPlot().fireAutoScaleChange(axis);
        });
        layout.add(autoscale, 2, row++);
        if (axis instanceof YAxis) {
            final CheckBox logscale = new CheckBox("log scale");
            logscale.setSelected(num_axis.isLogarithmic());
            logscale.setOnAction(event -> {
                num_axis.setLogarithmic(logscale.isSelected());
                plot.internalGetPlot().fireLogarithmicChange((YAxis<?>) num_axis);
            });
            layout.add(logscale, 2, row++);
        }
    }
    final CheckBox grid = new CheckBox("grid");
    grid.setSelected(axis.isGridVisible());
    grid.setOnAction(event -> {
        axis.setGridVisible(grid.isSelected());
        plot.internalGetPlot().fireGridChange(axis);
    });
    layout.add(grid, 2, row++);
    return row;
}
Also used : EventHandler(javafx.event.EventHandler) FontWeight(javafx.scene.text.FontWeight) Activator(org.csstudio.javafx.rtplot.Activator) TextField(javafx.scene.control.TextField) Modality(javafx.stage.Modality) Dialog(javafx.scene.control.Dialog) Label(javafx.scene.control.Label) ButtonType(javafx.scene.control.ButtonType) YAxis(org.csstudio.javafx.rtplot.YAxis) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) Font(javafx.scene.text.Font) ActionEvent(javafx.event.ActionEvent) ImageView(javafx.scene.image.ImageView) Axis(org.csstudio.javafx.rtplot.Axis) RTPlot(org.csstudio.javafx.rtplot.RTPlot) GridPane(javafx.scene.layout.GridPane) ActionEvent(javafx.event.ActionEvent) Label(javafx.scene.control.Label) CheckBox(javafx.scene.control.CheckBox) TextField(javafx.scene.control.TextField) YAxis(org.csstudio.javafx.rtplot.YAxis)

Aggregations

ActionEvent (javafx.event.ActionEvent)1 EventHandler (javafx.event.EventHandler)1 Node (javafx.scene.Node)1 ButtonType (javafx.scene.control.ButtonType)1 CheckBox (javafx.scene.control.CheckBox)1 Dialog (javafx.scene.control.Dialog)1 Label (javafx.scene.control.Label)1 TextField (javafx.scene.control.TextField)1 ImageView (javafx.scene.image.ImageView)1 GridPane (javafx.scene.layout.GridPane)1 Font (javafx.scene.text.Font)1 FontWeight (javafx.scene.text.FontWeight)1 Modality (javafx.stage.Modality)1 Activator (org.csstudio.javafx.rtplot.Activator)1 Axis (org.csstudio.javafx.rtplot.Axis)1 RTPlot (org.csstudio.javafx.rtplot.RTPlot)1 YAxis (org.csstudio.javafx.rtplot.YAxis)1