Search in sources :

Example 1 with NamedColorMapping

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

Example 2 with NamedColorMapping

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

the class JFXRepresentation method initialize.

@Override
protected void initialize() {
    final Map<String, WidgetRepresentationFactory<Parent, Node>> factories = new HashMap<>();
    registerKnownRepresentations(factories);
    final IExtensionRegistry registry = RegistryFactory.getRegistry();
    if (registry != null) {
        // which allows other plugins to contribute new widgets.
        for (IConfigurationElement config : registry.getConfigurationElementsFor(WidgetRepresentation.EXTENSION_POINT)) {
            final String type = config.getAttribute("type");
            final String clazz = config.getAttribute("class");
            logger.log(Level.CONFIG, "{0} contributes {1}", new Object[] { config.getContributor().getName(), clazz });
            factories.put(type, createFactory(config));
        }
    }
    for (Map.Entry<String, WidgetRepresentationFactory<Parent, Node>> entry : factories.entrySet()) register(entry.getKey(), entry.getValue());
    if (!initialized_colormaps) {
        for (PredefinedColorMaps.Predefined map : PredefinedColorMaps.PREDEFINED) NamedColorMappings.add(new NamedColorMapping(map.getName(), intensity -> ColorMappingFunction.getRGB(map.getColor(intensity))));
        initialized_colormaps = true;
    }
}
Also used : WidgetRepresentationFactory(org.csstudio.display.builder.representation.WidgetRepresentationFactory) HashMap(java.util.HashMap) PredefinedColorMaps(org.csstudio.display.builder.model.properties.PredefinedColorMaps) NamedColorMapping(org.csstudio.javafx.rtplot.NamedColorMapping) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) Map(java.util.Map) HashMap(java.util.HashMap) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Aggregations

NamedColorMapping (org.csstudio.javafx.rtplot.NamedColorMapping)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 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 ComboBox (javafx.scene.control.ComboBox)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 PredefinedColorMaps (org.csstudio.display.builder.model.properties.PredefinedColorMaps)1 WidgetRepresentationFactory (org.csstudio.display.builder.representation.WidgetRepresentationFactory)1 Activator (org.csstudio.javafx.rtplot.Activator)1