Search in sources :

Example 1 with ColorMap

use of org.csstudio.swt.widgets.datadefinition.ColorMap in project yamcs-studio by yamcs.

the class IntensityGraphEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    innerUpdateGraphAreaSizeProperty();
    registerAxisPropertyChangeHandler();
    registerROIPropertyChangeHandlers();
    registerROIAmountChangeHandler();
    IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            if (newValue == null)
                return false;
            VType value = (VType) newValue;
            if (value instanceof VNumberArray) {
                setValue(((VNumberArray) value).getData());
                return false;
            }
            ((IntensityGraphFigure) figure).setDataArray(VTypeHelper.getDoubleArray(value));
            return false;
        }
    };
    setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVVALUE, handler);
    getWidgetModel().getProperty(IntensityGraphModel.PROP_MIN).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            ((IntensityGraphFigure) figure).setMin((Double) evt.getNewValue());
            figure.repaint();
            innerUpdateGraphAreaSizeProperty();
        }
    });
    getWidgetModel().getProperty(IntensityGraphModel.PROP_MAX).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            ((IntensityGraphFigure) figure).setMax((Double) evt.getNewValue());
            figure.repaint();
            innerUpdateGraphAreaSizeProperty();
        }
    });
    getWidgetModel().getProperty(IntensityGraphModel.PROP_BORDER_STYLE).removeAllPropertyChangeListeners();
    getWidgetModel().getProperty(IntensityGraphModel.PROP_BORDER_STYLE).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            figure.setBorder(BorderFactory.createBorder(BorderStyle.values()[(Integer) evt.getNewValue()], getWidgetModel().getBorderWidth(), getWidgetModel().getBorderColor(), getWidgetModel().getName()));
            innerUpdateGraphAreaSizeProperty();
        }
    });
    getWidgetModel().getProperty(IntensityGraphModel.PROP_BORDER_WIDTH).removeAllPropertyChangeListeners();
    getWidgetModel().getProperty(IntensityGraphModel.PROP_BORDER_WIDTH).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            figure.setBorder(BorderFactory.createBorder(getWidgetModel().getBorderStyle(), (Integer) evt.getNewValue(), getWidgetModel().getBorderColor(), getWidgetModel().getName()));
            innerUpdateGraphAreaSizeProperty();
        }
    });
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((IntensityGraphFigure) figure).setDataWidth((Integer) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(IntensityGraphModel.PROP_DATA_WIDTH, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((IntensityGraphFigure) figure).setDataHeight((Integer) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(IntensityGraphModel.PROP_DATA_HEIGHT, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((IntensityGraphFigure) figure).setColorMap((ColorMap) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(IntensityGraphModel.PROP_COLOR_MAP, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((IntensityGraphFigure) figure).setCropLeft((Integer) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(IntensityGraphModel.PROP_CROP_LEFT, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((IntensityGraphFigure) figure).setCropRight((Integer) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(IntensityGraphModel.PROP_CROP_RIGHT, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((IntensityGraphFigure) figure).setCropTop((Integer) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(IntensityGraphModel.PROP_CROP_TOP, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((IntensityGraphFigure) figure).setCropBottom((Integer) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(IntensityGraphModel.PROP_CROP_BOTTOM, handler);
    getWidgetModel().getProperty(IntensityGraphModel.PROP_SHOW_RAMP).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            ((IntensityGraphFigure) getFigure()).setShowRamp((Boolean) evt.getNewValue());
            Dimension d = ((IntensityGraphFigure) getFigure()).getGraphAreaInsets();
            innerTrig = true;
            getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_GRAPH_AREA_WIDTH, getWidgetModel().getWidth() - d.width);
            innerTrig = false;
        }
    });
    getWidgetModel().getProperty(IntensityGraphModel.PROP_WIDTH).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (!innerTrig) {
                // if it is not triggered from inner
                innerTrig = true;
                Dimension d = ((IntensityGraphFigure) getFigure()).getGraphAreaInsets();
                getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_GRAPH_AREA_WIDTH, ((Integer) evt.getNewValue()) - d.width);
                // reset innerTrig to false after each inner triggering
                innerTrig = false;
            } else
                // if it is triggered from inner, do nothing
                innerTrig = false;
        }
    });
    getWidgetModel().getProperty(IntensityGraphModel.PROP_GRAPH_AREA_WIDTH).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (!innerTrig) {
                innerTrig = true;
                Dimension d = ((IntensityGraphFigure) getFigure()).getGraphAreaInsets();
                getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_WIDTH, ((Integer) evt.getNewValue()) + d.width);
                // reset innerTrig to false after each inner triggering
                innerTrig = false;
            } else
                innerTrig = false;
        }
    });
    getWidgetModel().getProperty(IntensityGraphModel.PROP_HEIGHT).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (!innerTrig) {
                innerTrig = true;
                Dimension d = ((IntensityGraphFigure) getFigure()).getGraphAreaInsets();
                getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_GRAPH_AREA_HEIGHT, ((Integer) evt.getNewValue()) - d.height);
                // reset innerTrig to false after each inner triggering
                innerTrig = false;
            } else
                innerTrig = false;
        }
    });
    getWidgetModel().getProperty(IntensityGraphModel.PROP_GRAPH_AREA_HEIGHT).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (!innerTrig) {
                innerTrig = true;
                Dimension d = ((IntensityGraphFigure) getFigure()).getGraphAreaInsets();
                getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_HEIGHT, ((Integer) evt.getNewValue()) + d.height);
                // reset innerTrig to false after each inner triggering
                innerTrig = false;
            } else
                innerTrig = false;
        }
    });
    getWidgetModel().getProperty(IntensityGraphModel.PROP_RGB_MODE).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            updatePropSheet();
            ((IntensityGraphFigure) getFigure()).setInRGBMode((Boolean) (evt.getNewValue()));
        }
    });
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((IntensityGraphFigure) getFigure()).setColorDepth(getWidgetModel().getColorDepth());
            return false;
        }
    };
    setPropertyChangeHandler(IntensityGraphModel.PROP_COLOR_DEPTH, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((IntensityGraphFigure) getFigure()).setSingleLineProfiling((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(IntensityGraphModel.PROP_SINGLE_LINE_PROFILING, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((IntensityGraphFigure) getFigure()).setROIColor(((OPIColor) newValue).getSWTColor());
            return false;
        }
    };
    setPropertyChangeHandler(IntensityGraphModel.PROP_ROI_COLOR, handler);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) ColorMap(org.csstudio.swt.widgets.datadefinition.ColorMap) PredefinedColorMap(org.csstudio.swt.widgets.datadefinition.ColorMap.PredefinedColorMap) Dimension(org.eclipse.draw2d.geometry.Dimension) ArrayDouble(org.diirt.util.array.ArrayDouble) VNumberArray(org.diirt.vtype.VNumberArray) IntensityGraphFigure(org.csstudio.swt.widgets.figures.IntensityGraphFigure) VType(org.diirt.vtype.VType) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) OPIColor(org.csstudio.opibuilder.util.OPIColor) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with ColorMap

use of org.csstudio.swt.widgets.datadefinition.ColorMap in project yamcs-studio by yamcs.

the class ColorMapEditDialog method getOutput.

public ColorMap getOutput() {
    ColorMap result = new ColorMap();
    if (predefinedColorMap == PredefinedColorMap.None) {
        LinkedHashMap<Double, RGB> map = new LinkedHashMap<Double, RGB>();
        for (ColorTuple tuple : colorList) map.put(tuple.value, tuple.rgb);
        result.setColorMap(map);
    }
    result.setAutoScale(autoScale);
    result.setInterpolate(interpolate);
    result.setPredefinedColorMap(predefinedColorMap);
    return result;
}
Also used : ColorTuple(org.csstudio.swt.widgets.datadefinition.ColorTuple) ColorMap(org.csstudio.swt.widgets.datadefinition.ColorMap) PredefinedColorMap(org.csstudio.swt.widgets.datadefinition.ColorMap.PredefinedColorMap) RGB(org.eclipse.swt.graphics.RGB) LinkedHashMap(java.util.LinkedHashMap)

Example 3 with ColorMap

use of org.csstudio.swt.widgets.datadefinition.ColorMap in project yamcs-studio by yamcs.

the class ColorMapProperty method writeToXML.

@Override
public void writeToXML(Element propElement) {
    ColorMap colorMap = (ColorMap) getPropertyValue();
    Element interpolateElement = new Element(XML_ELEMENT_INTERPOLATE);
    interpolateElement.setText(Boolean.toString(colorMap.isInterpolate()));
    Element autoScaleElement = new Element(XML_ELEMENT_AUTOSCALE);
    autoScaleElement.setText(Boolean.toString(colorMap.isAutoScale()));
    Element preDefinedElement = new Element(XML_ELEMENT_MAP);
    if (colorMap.getPredefinedColorMap() == PredefinedColorMap.None) {
        for (Double k : colorMap.getMap().keySet()) {
            Element colorElement = new Element(XML_ELEMENT_E);
            colorElement.setText(k.toString());
            RGB color = colorMap.getMap().get(k);
            // $NON-NLS-1$
            colorElement.setAttribute(XML_ATTRIBUTE_RED, "" + color.red);
            // $NON-NLS-1$
            colorElement.setAttribute(XML_ATTRIBUTE_GREEN, "" + color.green);
            // $NON-NLS-1$
            colorElement.setAttribute(XML_ATTRIBUTE_BLUE, "" + color.blue);
            preDefinedElement.addContent(colorElement);
        }
    } else {
        preDefinedElement.setText(Integer.toString(// $NON-NLS-1$
        PredefinedColorMap.toIndex(colorMap.getPredefinedColorMap())));
    }
    propElement.addContent(interpolateElement);
    propElement.addContent(autoScaleElement);
    propElement.addContent(preDefinedElement);
}
Also used : ColorMap(org.csstudio.swt.widgets.datadefinition.ColorMap) PredefinedColorMap(org.csstudio.swt.widgets.datadefinition.ColorMap.PredefinedColorMap) Element(org.jdom.Element) RGB(org.eclipse.swt.graphics.RGB)

Example 4 with ColorMap

use of org.csstudio.swt.widgets.datadefinition.ColorMap in project yamcs-studio by yamcs.

the class IntensityGraphModel method configureProperties.

@Override
protected void configureProperties() {
    addPVProperty(new PVNameProperty(PROP_HORIZON_PROFILE_X_PV_NAME, "Horizon Profile X PV", WidgetPropertyCategory.Basic, ""), new PVValueProperty(PROP_HORIZON_PROFILE_X_PV_VALUE, null));
    addPVProperty(new PVNameProperty(PROP_VERTICAL_PROFILE_X_PV_NAME, "Vertical Profile X PV", WidgetPropertyCategory.Basic, ""), new PVValueProperty(PROP_VERTICAL_PROFILE_X_PV_VALUE, null));
    addPVProperty(new PVNameProperty(PROP_HORIZON_PROFILE_Y_PV_NAME, "Horizon Profile Y PV", WidgetPropertyCategory.Basic, ""), new PVValueProperty(PROP_HORIZON_PROFILE_Y_PV_VALUE, null));
    addPVProperty(new PVNameProperty(PROP_VERTICAL_PROFILE_Y_PV_NAME, "Vertical Profile Y PV", WidgetPropertyCategory.Basic, ""), new PVValueProperty(PROP_VERTICAL_PROFILE_Y_PV_VALUE, null));
    addPVProperty(new PVNameProperty(PROP_PIXEL_INFO_PV_NAME, "Pixel Info PV", WidgetPropertyCategory.Basic, ""), new PVValueProperty(PROP_PIXEL_INFO_PV_VALUE, null));
    addProperty(new DoubleProperty(PROP_MIN, "Minimum", WidgetPropertyCategory.Behavior, DEFAULT_MIN), true);
    addProperty(new DoubleProperty(PROP_MAX, "Maximum", WidgetPropertyCategory.Behavior, DEFAULT_MAX), true);
    addProperty(new IntegerProperty(PROP_DATA_WIDTH, "Data Width", WidgetPropertyCategory.Behavior, 0), true);
    addProperty(new IntegerProperty(PROP_DATA_HEIGHT, "Data Height", WidgetPropertyCategory.Behavior, 0), true);
    addProperty(new ColorMapProperty(PROP_COLOR_MAP, "Color Map", WidgetPropertyCategory.Display, new ColorMap(PredefinedColorMap.JET, true, true)), true);
    addProperty(new BooleanProperty(PROP_SHOW_RAMP, "Show Ramp", WidgetPropertyCategory.Display, true), true);
    addProperty(new IntegerProperty(PROP_GRAPH_AREA_WIDTH, "Graph Area Width", WidgetPropertyCategory.Position, 0), true);
    addProperty(new IntegerProperty(PROP_GRAPH_AREA_HEIGHT, "Graph Area Height", WidgetPropertyCategory.Position, 0), true);
    addProperty(new IntegerProperty(PROP_CROP_LEFT, "Crop Left", WidgetPropertyCategory.Behavior, 0));
    addProperty(new IntegerProperty(PROP_CROP_RIGHT, "Crop Right", WidgetPropertyCategory.Behavior, 0));
    addProperty(new IntegerProperty(PROP_CROP_TOP, "Crop Top", WidgetPropertyCategory.Behavior, 0));
    addProperty(new IntegerProperty(PROP_CROP_BOTTOM, "Crop Bottom", WidgetPropertyCategory.Behavior, 0));
    addProperty(new BooleanProperty(PROP_RGB_MODE, "RGB Mode", WidgetPropertyCategory.Behavior, false), false);
    addProperty(new ComboProperty(PROP_COLOR_DEPTH, "Color Depth", WidgetPropertyCategory.Behavior, ColorDepth.stringValues(), 0), true);
    addProperty(new BooleanProperty(PROP_SINGLE_LINE_PROFILING, "Profile on Single Line", WidgetPropertyCategory.Behavior, false), true);
    addProperty(new ColorProperty(PROP_ROI_COLOR, "ROI Color", WidgetPropertyCategory.Display, CustomMediaFactory.COLOR_CYAN), true);
    addProperty(new IntegerProperty(PROP_ROI_COUNT, "ROI Count", WidgetPropertyCategory.Behavior, 0, 0, MAX_ROIS_AMOUNT));
    addAxisProperties();
    addROIProperties();
}
Also used : ComboProperty(org.csstudio.opibuilder.properties.ComboProperty) IntegerProperty(org.csstudio.opibuilder.properties.IntegerProperty) ColorMap(org.csstudio.swt.widgets.datadefinition.ColorMap) PredefinedColorMap(org.csstudio.swt.widgets.datadefinition.ColorMap.PredefinedColorMap) BooleanProperty(org.csstudio.opibuilder.properties.BooleanProperty) PVValueProperty(org.csstudio.opibuilder.properties.PVValueProperty) DoubleProperty(org.csstudio.opibuilder.properties.DoubleProperty) ColorMapProperty(org.csstudio.opibuilder.widgets.properties.ColorMapProperty) PVNameProperty(org.csstudio.opibuilder.properties.PVNameProperty) ColorProperty(org.csstudio.opibuilder.properties.ColorProperty)

Example 5 with ColorMap

use of org.csstudio.swt.widgets.datadefinition.ColorMap in project yamcs-studio by yamcs.

the class ColorMapProperty method readValueFromXML.

@Override
public ColorMap readValueFromXML(Element propElement) {
    var result = new ColorMap();
    result.setInterpolate(Boolean.parseBoolean(propElement.getChild(XML_ELEMENT_INTERPOLATE).getValue()));
    result.setAutoScale(Boolean.parseBoolean(propElement.getChild(XML_ELEMENT_AUTOSCALE).getValue()));
    if (propElement.getChild(XML_ELEMENT_MAP).getChildren().size() == 0) {
        var p = PredefinedColorMap.fromIndex(Integer.parseInt(propElement.getChild(XML_ELEMENT_MAP).getValue()));
        result.setPredefinedColorMap(p);
    } else {
        var map = new LinkedHashMap<Double, RGB>();
        for (var o : propElement.getChild(XML_ELEMENT_MAP).getChildren()) {
            var e = (Element) o;
            map.put(Double.parseDouble(e.getValue()), new RGB(Integer.parseInt(e.getAttributeValue(XML_ATTRIBUTE_RED)), Integer.parseInt(e.getAttributeValue(XML_ATTRIBUTE_GREEN)), Integer.parseInt(e.getAttributeValue(XML_ATTRIBUTE_BLUE))));
        }
        result.setColorMap(map);
    }
    return result;
}
Also used : ColorMap(org.csstudio.swt.widgets.datadefinition.ColorMap) PredefinedColorMap(org.csstudio.swt.widgets.datadefinition.ColorMap.PredefinedColorMap) Element(org.jdom.Element) RGB(org.eclipse.swt.graphics.RGB) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ColorMap (org.csstudio.swt.widgets.datadefinition.ColorMap)5 PredefinedColorMap (org.csstudio.swt.widgets.datadefinition.ColorMap.PredefinedColorMap)5 RGB (org.eclipse.swt.graphics.RGB)3 LinkedHashMap (java.util.LinkedHashMap)2 Element (org.jdom.Element)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 BooleanProperty (org.csstudio.opibuilder.properties.BooleanProperty)1 ColorProperty (org.csstudio.opibuilder.properties.ColorProperty)1 ComboProperty (org.csstudio.opibuilder.properties.ComboProperty)1 DoubleProperty (org.csstudio.opibuilder.properties.DoubleProperty)1 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)1 IntegerProperty (org.csstudio.opibuilder.properties.IntegerProperty)1 PVNameProperty (org.csstudio.opibuilder.properties.PVNameProperty)1 PVValueProperty (org.csstudio.opibuilder.properties.PVValueProperty)1 OPIColor (org.csstudio.opibuilder.util.OPIColor)1 ColorMapProperty (org.csstudio.opibuilder.widgets.properties.ColorMapProperty)1 ColorTuple (org.csstudio.swt.widgets.datadefinition.ColorTuple)1 IntensityGraphFigure (org.csstudio.swt.widgets.figures.IntensityGraphFigure)1 ArrayDouble (org.diirt.util.array.ArrayDouble)1