use of org.csstudio.swt.widgets.figures.IntensityGraphFigure in project yamcs-studio by yamcs.
the class IntensityGraphEditPart method doCreateFigure.
@Override
protected IFigure doCreateFigure() {
IntensityGraphModel model = getWidgetModel();
graph = new IntensityGraphFigure(getExecutionMode() == ExecutionMode.RUN_MODE);
graph.setMin(model.getMinimum());
graph.setMax(model.getMaximum());
graph.setDataWidth(model.getDataWidth());
graph.setDataHeight(model.getDataHeight());
graph.setColorMap(model.getColorMap());
graph.setShowRamp(model.isShowRamp());
graph.setCropLeft(model.getCropLeft());
graph.setCropRight(model.getCropRight());
graph.setCropTop(model.getCropTOP());
graph.setCropBottom(model.getCropBottom());
graph.setInRGBMode(model.isRGBMode());
graph.setColorDepth(model.getColorDepth());
graph.setSingleLineProfiling(model.isSingleLineProfiling());
graph.setROIColor(model.getROIColor().getSWTColor());
// init X-Axis
for (AxisProperty axisProperty : AxisProperty.values()) {
String propID = IntensityGraphModel.makeAxisPropID(IntensityGraphModel.X_AXIS_ID, axisProperty.propIDPre);
setAxisProperty(graph.getXAxis(), axisProperty, model.getPropertyValue(propID));
}
// init Y-Axis
for (AxisProperty axisProperty : AxisProperty.values()) {
String propID = IntensityGraphModel.makeAxisPropID(IntensityGraphModel.Y_AXIS_ID, axisProperty.propIDPre);
setAxisProperty(graph.getYAxis(), axisProperty, model.getPropertyValue(propID));
}
if (getExecutionMode() == ExecutionMode.RUN_MODE) {
// add profile data listener
if (model.getHorizonProfileYPV().trim().length() > 0 || model.getVerticalProfileYPV().trim().length() > 0) {
graph.addProfileDataListener(new IProfileDataChangeLisenter() {
@Override
public void profileDataChanged(double[] xProfileData, double[] yProfileData, Range xAxisRange, Range yAxisRange) {
// horizontal
setPVValue(IntensityGraphModel.PROP_HORIZON_PROFILE_Y_PV_NAME, xProfileData);
double[] horizonXData = new double[xProfileData.length];
double d = (xAxisRange.getUpper() - xAxisRange.getLower()) / (xProfileData.length - 1);
for (int i = 0; i < xProfileData.length; i++) {
horizonXData[i] = xAxisRange.getLower() + d * i;
}
setPVValue(IntensityGraphModel.PROP_HORIZON_PROFILE_X_PV_NAME, horizonXData);
// vertical
setPVValue(IntensityGraphModel.PROP_VERTICAL_PROFILE_Y_PV_NAME, yProfileData);
double[] verticalXData = new double[yProfileData.length];
d = (yAxisRange.getUpper() - yAxisRange.getLower()) / (yProfileData.length - 1);
for (int i = 0; i < yProfileData.length; i++) {
verticalXData[i] = yAxisRange.getUpper() - d * i;
}
setPVValue(IntensityGraphModel.PROP_VERTICAL_PROFILE_X_PV_NAME, verticalXData);
}
});
}
if (model.getPixelInfoPV().trim().length() > 0) {
// Listen to pixel info, forward to PV
graph.addPixelInfoListener(new IPixelInfoListener() {
@Override
public void pixelInfoChanged(final PixelInfo pixel_info, final boolean selected) {
// TODO "Selected" column should be boolean, but there is no 'ArrayBoolean', and List<Boolean>
// also fails
final List<Object> values = Arrays.<Object>asList(new ArrayDouble(pixel_info.xcoord), new ArrayDouble(pixel_info.ycoord), new ArrayDouble(pixel_info.value), new ArrayInt(selected ? 1 : 0));
final Object value = ValueFactory.newVTable(pixel_info_table_types, pixel_info_table_columns, values);
setPVValue(IntensityGraphModel.PROP_PIXEL_INFO_PV_NAME, value);
}
});
}
}
updatePropSheet();
return graph;
}
use of org.csstudio.swt.widgets.figures.IntensityGraphFigure 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);
}
use of org.csstudio.swt.widgets.figures.IntensityGraphFigure in project yamcs-studio by yamcs.
the class IntensityGraphEditPart method innerUpdateGraphAreaSizeProperty.
private synchronized void innerUpdateGraphAreaSizeProperty() {
Dimension d = ((IntensityGraphFigure) figure).getGraphAreaInsets();
innerTrig = true;
getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_GRAPH_AREA_WIDTH, getWidgetModel().getSize().width - d.width);
// recover innerTrig
innerTrig = true;
getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_GRAPH_AREA_HEIGHT, getWidgetModel().getSize().height - d.height);
// reset innerTrig to false after each inner triggering
innerTrig = false;
}
use of org.csstudio.swt.widgets.figures.IntensityGraphFigure in project yamcs-studio by yamcs.
the class IntensityGraphEditPart method registerAxisPropertyChangeHandler.
private void registerAxisPropertyChangeHandler() {
for (String axisID : new String[] { IntensityGraphModel.X_AXIS_ID, IntensityGraphModel.Y_AXIS_ID }) {
for (AxisProperty axisProperty : AxisProperty.values()) {
final IWidgetPropertyChangeHandler handler = new AxisPropertyChangeHandler(axisID.equals(IntensityGraphModel.X_AXIS_ID) ? ((IntensityGraphFigure) getFigure()).getXAxis() : ((IntensityGraphFigure) getFigure()).getYAxis(), axisProperty);
// must use listener instead of handler because the prop sheet need to be
// refreshed immediately.
getWidgetModel().getProperty(IntensityGraphModel.makeAxisPropID(axisID, axisProperty.propIDPre)).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
UIBundlingThread.getInstance().addRunnable(getViewer().getControl().getDisplay(), new Runnable() {
@Override
public void run() {
getFigure().repaint();
}
});
}
});
}
}
}
Aggregations