Search in sources :

Example 1 with ColorMap

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);
}
Also used : Arrays(java.util.Arrays) DisplayModel(org.csstudio.display.builder.model.DisplayModel) PredefinedColorMaps(org.csstudio.display.builder.model.properties.PredefinedColorMaps) Interpolation(org.csstudio.javafx.rtplot.Interpolation) VImageType(org.diirt.vtype.VImageType) Level(java.util.logging.Level) RTImagePlotListener(org.csstudio.javafx.rtplot.RTImagePlotListener) ValueFactory(org.diirt.vtype.ValueFactory) ImageWidget(org.csstudio.display.builder.model.widgets.plots.ImageWidget) RTImagePlot(org.csstudio.javafx.rtplot.RTImagePlot) ArrayInt(org.diirt.util.array.ArrayInt) DirtyFlag(org.csstudio.display.builder.model.DirtyFlag) WidgetProperty(org.csstudio.display.builder.model.WidgetProperty) ModelThreadPool(org.csstudio.display.builder.model.util.ModelThreadPool) AxisWidgetProperty(org.csstudio.display.builder.model.widgets.plots.ImageWidget.AxisWidgetProperty) VNumberArray(org.diirt.vtype.VNumberArray) Pane(javafx.scene.layout.Pane) NamedColorMappings(org.csstudio.javafx.rtplot.NamedColorMappings) ModelResourceUtil(org.csstudio.display.builder.model.util.ModelResourceUtil) Rectangle2D(javafx.geometry.Rectangle2D) ROIWidgetProperty(org.csstudio.display.builder.model.widgets.plots.ImageWidget.ROIWidgetProperty) RegionBaseRepresentation(org.csstudio.display.builder.representation.javafx.widgets.RegionBaseRepresentation) RepresentationUpdateThrottle(org.csstudio.display.builder.representation.RepresentationUpdateThrottle) RegionOfInterest(org.csstudio.javafx.rtplot.RegionOfInterest) VType(org.diirt.vtype.VType) ColorMap(org.csstudio.display.builder.model.properties.ColorMap) ToolkitRepresentation.logger(org.csstudio.display.builder.representation.ToolkitRepresentation.logger) TimeUnit(java.util.concurrent.TimeUnit) Platform(javafx.application.Platform) List(java.util.List) MacroHandler(org.csstudio.display.builder.model.macros.MacroHandler) WidgetPropertyListener(org.csstudio.display.builder.model.WidgetPropertyListener) ArrayDouble(org.diirt.util.array.ArrayDouble) ColorMappingFunction(org.csstudio.javafx.rtplot.ColorMappingFunction) JFXUtil(org.csstudio.display.builder.representation.javafx.JFXUtil) Axis(org.csstudio.javafx.rtplot.Axis) VImage(org.diirt.vtype.VImage) Image(javafx.scene.image.Image) ColorMap(org.csstudio.display.builder.model.properties.ColorMap) PredefinedColorMaps(org.csstudio.display.builder.model.properties.PredefinedColorMaps) ColorMappingFunction(org.csstudio.javafx.rtplot.ColorMappingFunction)

Example 2 with ColorMap

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();
}
Also used : ColorMap(org.csstudio.display.builder.model.properties.ColorMap)

Aggregations

ColorMap (org.csstudio.display.builder.model.properties.ColorMap)2 Arrays (java.util.Arrays)1 List (java.util.List)1 TimeUnit (java.util.concurrent.TimeUnit)1 Level (java.util.logging.Level)1 Platform (javafx.application.Platform)1 Rectangle2D (javafx.geometry.Rectangle2D)1 Image (javafx.scene.image.Image)1 Pane (javafx.scene.layout.Pane)1 DirtyFlag (org.csstudio.display.builder.model.DirtyFlag)1 DisplayModel (org.csstudio.display.builder.model.DisplayModel)1 WidgetProperty (org.csstudio.display.builder.model.WidgetProperty)1 WidgetPropertyListener (org.csstudio.display.builder.model.WidgetPropertyListener)1 MacroHandler (org.csstudio.display.builder.model.macros.MacroHandler)1 PredefinedColorMaps (org.csstudio.display.builder.model.properties.PredefinedColorMaps)1 ModelResourceUtil (org.csstudio.display.builder.model.util.ModelResourceUtil)1 ModelThreadPool (org.csstudio.display.builder.model.util.ModelThreadPool)1 ImageWidget (org.csstudio.display.builder.model.widgets.plots.ImageWidget)1 AxisWidgetProperty (org.csstudio.display.builder.model.widgets.plots.ImageWidget.AxisWidgetProperty)1 ROIWidgetProperty (org.csstudio.display.builder.model.widgets.plots.ImageWidget.ROIWidgetProperty)1