use of org.csstudio.display.builder.model.properties.ColorMap in project org.csstudio.display.builder by kasemir.
the class ImageRepresentation method coloringChanged.
/**
* Changes that affect the coloring of the image but not the zoom, size
*/
private void coloringChanged(final WidgetProperty<?> property, final Object old_value, final Object new_value) {
image_plot.setInterpolation(Interpolation.values()[model_widget.propDataInterpolation().getValue().ordinal()]);
final ColorMap colormap = model_widget.propDataColormap().getValue();
final ColorMappingFunction map_function;
if (colormap instanceof PredefinedColorMaps.Predefined)
map_function = NamedColorMappings.getMapping(((PredefinedColorMaps.Predefined) colormap).getName());
else
map_function = value -> ColorMappingFunction.getRGB(colormap.getColor(value));
image_plot.setColorMapping(map_function);
}
use of org.csstudio.display.builder.model.properties.ColorMap in project org.csstudio.display.builder by kasemir.
the class ColorMapDialog method updateMapFromSections.
/**
* Update 'map' from 'color_sections'
*/
private void updateMapFromSections() {
final int num = color_sections.size();
// Assert sections start .. end with 0 .. 255
if (color_sections.get(0).value != 0)
color_sections.set(0, new ColorSection(0, color_sections.get(0).color));
if (color_sections.get(num - 1).value != 255)
color_sections.set(num - 1, new ColorSection(255, color_sections.get(num - 1).color));
// Create ColorMap from sections
final int[][] sections = new int[num][4];
for (int i = 0; i < num; ++i) {
sections[i][0] = color_sections.get(i).value;
sections[i][1] = (int) Math.round(color_sections.get(i).color.getRed() * 255);
sections[i][2] = (int) Math.round(color_sections.get(i).color.getGreen() * 255);
sections[i][3] = (int) Math.round(color_sections.get(i).color.getBlue() * 255);
}
map = new ColorMap(sections);
// Custom color map, not based on any predefined map
predefined_table.getSelectionModel().clearSelection();
updateColorBar();
}
Aggregations