Search in sources :

Example 1 with ROIProperty

use of org.csstudio.opibuilder.widgets.model.IntensityGraphModel.ROIProperty in project yamcs-studio by yamcs.

the class IntensityGraphEditPart method registerROIPropertyChangeHandlers.

private void registerROIPropertyChangeHandlers() {
    for (int i = 0; i < IntensityGraphModel.MAX_ROIS_AMOUNT; i++) {
        final String roiName = getROIName(i);
        for (final ROIProperty roiProperty : ROIProperty.values()) {
            String propID = IntensityGraphModel.makeROIPropID(roiProperty.propIDPre, i);
            if (i >= (Integer) getPropertyValue(IntensityGraphModel.PROP_ROI_COUNT)) {
                getWidgetModel().setPropertyVisible(propID, false);
            }
            setPropertyChangeHandler(propID, new IWidgetPropertyChangeHandler() {

                @Override
                public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
                    setROIProperty(roiName, roiProperty, newValue);
                    return false;
                }
            });
        }
    }
}
Also used : ROIProperty(org.csstudio.opibuilder.widgets.model.IntensityGraphModel.ROIProperty) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with ROIProperty

use of org.csstudio.opibuilder.widgets.model.IntensityGraphModel.ROIProperty in project yamcs-studio by yamcs.

the class IntensityGraphEditPart method registerROIAmountChangeHandler.

private void registerROIAmountChangeHandler() {
    PropertyChangeListener listener = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            int currentCount = (Integer) evt.getOldValue();
            int newCount = (Integer) evt.getNewValue();
            if (newCount > currentCount) {
                for (int i = currentCount; i < newCount; i++) {
                    for (ROIProperty roiProperty : ROIProperty.values()) {
                        if (roiProperty != ROIProperty.XPV_VALUE && roiProperty != ROIProperty.YPV_VALUE && roiProperty != ROIProperty.WPV_VALUE && roiProperty != ROIProperty.HPV_VALUE) {
                            String propID = IntensityGraphModel.makeROIPropID(roiProperty.propIDPre, i);
                            getWidgetModel().setPropertyVisible(propID, true);
                        }
                    }
                    final int roiIndex = i;
                    graph.addROI(getROIName(roiIndex), new IntensityGraphFigure.IROIListener() {

                        @Override
                        public void roiUpdated(int xIndex, int yIndex, int width, int height) {
                            String propID = IntensityGraphModel.makeROIPropID(ROIProperty.XPV.propIDPre, roiIndex);
                            setPVValue(propID, xIndex);
                            propID = IntensityGraphModel.makeROIPropID(ROIProperty.YPV.propIDPre, roiIndex);
                            setPVValue(propID, yIndex);
                            propID = IntensityGraphModel.makeROIPropID(ROIProperty.WPV.propIDPre, roiIndex);
                            setPVValue(propID, width);
                            propID = IntensityGraphModel.makeROIPropID(ROIProperty.HPV.propIDPre, roiIndex);
                            setPVValue(propID, height);
                        }
                    }, new IntensityGraphFigure.IROIInfoProvider() {

                        @Override
                        public String getROIInfo(int xIndex, int yIndex, int width, int height) {
                            String propID = IntensityGraphModel.makeROIPropID(ROIProperty.TITLE.propIDPre, roiIndex);
                            return (String) getPropertyValue(propID);
                        }
                    });
                }
            } else if (newCount < currentCount) {
                for (int i = currentCount - 1; i >= newCount; i--) {
                    graph.removeROI(getROIName(i));
                    for (ROIProperty roiProperty : ROIProperty.values()) {
                        String propID = IntensityGraphModel.makeROIPropID(roiProperty.propIDPre, i);
                        getWidgetModel().setPropertyVisible(propID, false);
                    }
                }
            }
        }
    };
    AbstractWidgetProperty countProperty = getWidgetModel().getProperty(IntensityGraphModel.PROP_ROI_COUNT);
    countProperty.addPropertyChangeListener(listener);
    // init
    int currentCount = (Integer) getPropertyValue(IntensityGraphModel.PROP_ROI_COUNT);
    listener.propertyChange(new PropertyChangeEvent(countProperty, IntensityGraphModel.PROP_ROI_COUNT, 0, currentCount));
    for (int i = 0; i < currentCount; i++) {
        for (final ROIProperty roiProperty : ROIProperty.values()) {
            String propID = IntensityGraphModel.makeROIPropID(roiProperty.propIDPre, i);
            Object propertyValue = getPropertyValue(propID);
            if (propertyValue != null)
                setROIProperty(getROIName(i), roiProperty, propertyValue);
        }
    }
}
Also used : IntensityGraphFigure(org.csstudio.swt.widgets.figures.IntensityGraphFigure) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) ROIProperty(org.csstudio.opibuilder.widgets.model.IntensityGraphModel.ROIProperty) AbstractWidgetProperty(org.csstudio.opibuilder.properties.AbstractWidgetProperty)

Aggregations

ROIProperty (org.csstudio.opibuilder.widgets.model.IntensityGraphModel.ROIProperty)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 AbstractWidgetProperty (org.csstudio.opibuilder.properties.AbstractWidgetProperty)1 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)1 IntensityGraphFigure (org.csstudio.swt.widgets.figures.IntensityGraphFigure)1 IFigure (org.eclipse.draw2d.IFigure)1