Search in sources :

Example 1 with Axis

use of org.csstudio.javafx.rtplot.Axis 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)

Example 2 with Axis

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

the class ImageConfigDialog method addAxisContent.

private int addAxisContent(final GridPane layout, int row, final Axis<Double> 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++);
    final EventHandler<ActionEvent> update_range = event -> {
        try {
            axis.setValueRange(Double.parseDouble(start.getText()), Double.parseDouble(end.getText()));
            plot.internalGetImagePlot().fireChangedAxisRange(axis);
        } catch (NumberFormatException ex) {
            start.setText(axis.getValueRange().getLow().toString());
            end.setText(axis.getValueRange().getHigh().toString());
            return;
        }
    };
    start.setOnAction(update_range);
    end.setOnAction(update_range);
    return row;
}
Also used : NamedColorMapping(org.csstudio.javafx.rtplot.NamedColorMapping) EventHandler(javafx.event.EventHandler) FontWeight(javafx.scene.text.FontWeight) Activator(org.csstudio.javafx.rtplot.Activator) NamedColorMappings(org.csstudio.javafx.rtplot.NamedColorMappings) TextField(javafx.scene.control.TextField) Modality(javafx.stage.Modality) Dialog(javafx.scene.control.Dialog) Label(javafx.scene.control.Label) ButtonType(javafx.scene.control.ButtonType) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) Font(javafx.scene.text.Font) ValueRange(org.csstudio.javafx.rtplot.data.ValueRange) ActionEvent(javafx.event.ActionEvent) ComboBox(javafx.scene.control.ComboBox) RTImagePlot(org.csstudio.javafx.rtplot.RTImagePlot) ImageView(javafx.scene.image.ImageView) ColorMappingFunction(org.csstudio.javafx.rtplot.ColorMappingFunction) Axis(org.csstudio.javafx.rtplot.Axis) GridPane(javafx.scene.layout.GridPane) ActionEvent(javafx.event.ActionEvent) Label(javafx.scene.control.Label) TextField(javafx.scene.control.TextField)

Example 3 with Axis

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

the class ImageConfigDialog method createContent.

private Node createContent() {
    final GridPane layout = new GridPane();
    layout.setHgap(5);
    layout.setVgap(5);
    // Debug layout
    // layout.setGridLinesVisible(true);
    // Row to use for the next elements
    int row = 0;
    Label label = new Label("Value Range");
    final Font font = label.getFont();
    final Font section_font = Font.font(font.getFamily(), FontWeight.BOLD, font.getSize());
    label.setFont(section_font);
    layout.add(label, 0, ++row);
    // Only show the color mapping selector when it's currently a named mapping.
    // Suppress when widget has a custom color map.
    final ColorMappingFunction selected_mapping = plot.internalGetImagePlot().getColorMapping();
    if (selected_mapping instanceof NamedColorMapping) {
        label = new Label("Mapping");
        layout.add(label, 1, row);
        final ComboBox<String> mappings = new ComboBox<>();
        mappings.setEditable(false);
        mappings.setMaxWidth(Double.MAX_VALUE);
        for (NamedColorMapping mapping : NamedColorMappings.getMappings()) mappings.getItems().add(mapping.getName());
        mappings.setValue(((NamedColorMapping) selected_mapping).getName());
        mappings.setOnAction(event -> {
            final NamedColorMapping mapping = NamedColorMappings.getMapping(mappings.getValue());
            plot.setColorMapping(mapping);
        });
        layout.add(mappings, 2, row++);
    }
    label = new Label("Minimum");
    layout.add(label, 1, row);
    final TextField min = new TextField(Double.toString(plot.getValueRange().getLow()));
    layout.add(min, 2, row);
    label = new Label("Maximum");
    layout.add(label, 1, ++row);
    final TextField max = new TextField(Double.toString(plot.getValueRange().getHigh()));
    layout.add(max, 2, row);
    final EventHandler<ActionEvent> update_range = event -> {
        try {
            plot.setValueRange(Double.parseDouble(min.getText().trim()), Double.parseDouble(max.getText().trim()));
            plot.internalGetImagePlot().fireChangedValueRange();
        } catch (NumberFormatException ex) {
            final ValueRange range = plot.getValueRange();
            min.setText(Double.toString(range.getLow()));
            max.setText(Double.toString(range.getHigh()));
        }
    };
    min.setOnAction(update_range);
    max.setOnAction(update_range);
    final CheckBox autoscale = new CheckBox("auto-scale");
    autoscale.setSelected(plot.isAutoscale());
    min.setDisable(autoscale.isSelected());
    max.setDisable(autoscale.isSelected());
    autoscale.setOnAction(event -> {
        plot.setAutoscale(autoscale.isSelected());
        min.setDisable(autoscale.isSelected());
        max.setDisable(autoscale.isSelected());
        plot.internalGetImagePlot().fireChangedAutoScale();
    });
    layout.add(autoscale, 2, ++row);
    final CheckBox show_color_bar = new CheckBox("show color bar");
    show_color_bar.setSelected(plot.isShowingColorMap());
    show_color_bar.setOnAction(event -> plot.showColorMap(show_color_bar.isSelected()));
    layout.add(show_color_bar, 2, ++row);
    final CheckBox logscale = new CheckBox("log scale");
    logscale.setSelected(plot.isLogscale());
    logscale.setOnAction(event -> {
        plot.setLogscale(logscale.isSelected());
        plot.internalGetImagePlot().fireChangedLogarithmic();
    });
    layout.add(logscale, 2, ++row);
    label = new Label("Horizontal Axis");
    label.setFont(section_font);
    layout.add(label, 0, ++row);
    row = addAxisContent(layout, row, plot.getXAxis());
    label = new Label("Vertical Axis");
    label.setFont(section_font);
    layout.add(label, 0, ++row);
    row = addAxisContent(layout, row, plot.getYAxis());
    return layout;
}
Also used : NamedColorMapping(org.csstudio.javafx.rtplot.NamedColorMapping) EventHandler(javafx.event.EventHandler) FontWeight(javafx.scene.text.FontWeight) Activator(org.csstudio.javafx.rtplot.Activator) NamedColorMappings(org.csstudio.javafx.rtplot.NamedColorMappings) TextField(javafx.scene.control.TextField) Modality(javafx.stage.Modality) Dialog(javafx.scene.control.Dialog) Label(javafx.scene.control.Label) ButtonType(javafx.scene.control.ButtonType) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) Font(javafx.scene.text.Font) ValueRange(org.csstudio.javafx.rtplot.data.ValueRange) ActionEvent(javafx.event.ActionEvent) ComboBox(javafx.scene.control.ComboBox) RTImagePlot(org.csstudio.javafx.rtplot.RTImagePlot) ImageView(javafx.scene.image.ImageView) ColorMappingFunction(org.csstudio.javafx.rtplot.ColorMappingFunction) Axis(org.csstudio.javafx.rtplot.Axis) GridPane(javafx.scene.layout.GridPane) GridPane(javafx.scene.layout.GridPane) ComboBox(javafx.scene.control.ComboBox) ActionEvent(javafx.event.ActionEvent) ColorMappingFunction(org.csstudio.javafx.rtplot.ColorMappingFunction) Label(javafx.scene.control.Label) Font(javafx.scene.text.Font) ValueRange(org.csstudio.javafx.rtplot.data.ValueRange) CheckBox(javafx.scene.control.CheckBox) NamedColorMapping(org.csstudio.javafx.rtplot.NamedColorMapping) TextField(javafx.scene.control.TextField)

Aggregations

ActionEvent (javafx.event.ActionEvent)3 EventHandler (javafx.event.EventHandler)3 Node (javafx.scene.Node)3 ButtonType (javafx.scene.control.ButtonType)3 CheckBox (javafx.scene.control.CheckBox)3 Dialog (javafx.scene.control.Dialog)3 Label (javafx.scene.control.Label)3 TextField (javafx.scene.control.TextField)3 ImageView (javafx.scene.image.ImageView)3 GridPane (javafx.scene.layout.GridPane)3 Font (javafx.scene.text.Font)3 FontWeight (javafx.scene.text.FontWeight)3 Modality (javafx.stage.Modality)3 Activator (org.csstudio.javafx.rtplot.Activator)3 Axis (org.csstudio.javafx.rtplot.Axis)3 ComboBox (javafx.scene.control.ComboBox)2 ColorMappingFunction (org.csstudio.javafx.rtplot.ColorMappingFunction)2 NamedColorMapping (org.csstudio.javafx.rtplot.NamedColorMapping)2 NamedColorMappings (org.csstudio.javafx.rtplot.NamedColorMappings)2 RTImagePlot (org.csstudio.javafx.rtplot.RTImagePlot)2