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;
}
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;
}
}
Aggregations