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