use of org.csstudio.opibuilder.widgets.model.XYGraphModel.TraceProperty in project yamcs-studio by yamcs.
the class XYGraphEditPart method registerTracePropertyChangeHandlers.
protected void registerTracePropertyChangeHandlers() {
XYGraphModel model = (XYGraphModel) getModel();
// set prop handlers and init all the potential axes
for (int i = 0; i < XYGraphModel.MAX_TRACES_AMOUNT; i++) {
boolean concatenate = (Boolean) getWidgetModel().getProperty(XYGraphModel.makeTracePropID(TraceProperty.CONCATENATE_DATA.propIDPre, i)).getPropertyValue();
String xPVPropID = XYGraphModel.makeTracePropID(TraceProperty.XPV.propIDPre, i);
String yPVPropID = XYGraphModel.makeTracePropID(TraceProperty.YPV.propIDPre, i);
for (TraceProperty traceProperty : TraceProperty.values()) {
final String propID = XYGraphModel.makeTracePropID(traceProperty.propIDPre, i);
final IWidgetPropertyChangeHandler handler = new TracePropertyChangeHandler(i, traceProperty, xPVPropID, yPVPropID);
if (concatenate) {
// cannot use setPropertyChangeHandler because the PV value has to be buffered
// which means that it cannot be ignored.
getWidgetModel().getProperty(propID).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent evt) {
UIBundlingThread.getInstance().addRunnable(getViewer().getControl().getDisplay(), new Runnable() {
@Override
public void run() {
if (isActive()) {
handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
}
}
});
}
});
} else
setPropertyChangeHandler(propID, handler);
}
}
for (int i = XYGraphModel.MAX_TRACES_AMOUNT - 1; i >= model.getTracesAmount(); i--) {
for (TraceProperty traceProperty : TraceProperty.values()) {
String propID = XYGraphModel.makeTracePropID(traceProperty.propIDPre, i);
model.setPropertyVisible(propID, false);
}
}
}
use of org.csstudio.opibuilder.widgets.model.XYGraphModel.TraceProperty in project yamcs-studio by yamcs.
the class XYGraphEditPart method registerTraceAmountChangeHandler.
private void registerTraceAmountChangeHandler() {
final IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
XYGraphModel model = (XYGraphModel) getModel();
IXYGraph xyGraph = ((ToolbarArmedXYGraph) refreshableFigure).getXYGraph();
int currentTracesAmount = xyGraph.getPlotArea().getTraceList().size();
// add trace
if ((Integer) newValue > currentTracesAmount) {
for (int i = 0; i < (Integer) newValue - currentTracesAmount; i++) {
for (TraceProperty traceProperty : TraceProperty.values()) {
if (traceProperty == TraceProperty.XPV_VALUE || traceProperty == TraceProperty.YPV_VALUE)
continue;
String propID = XYGraphModel.makeTracePropID(traceProperty.propIDPre, i + currentTracesAmount);
model.setPropertyVisible(propID, true);
}
xyGraph.addTrace(traceList.get(i + currentTracesAmount));
}
} else if ((Integer) newValue < currentTracesAmount) {
// remove trace
for (int i = 0; i < currentTracesAmount - (Integer) newValue; i++) {
for (TraceProperty traceProperty : TraceProperty.values()) {
String propID = XYGraphModel.makeTracePropID(traceProperty.propIDPre, i + (Integer) newValue);
model.setPropertyVisible(propID, false);
}
xyGraph.removeTrace(traceList.get(i + (Integer) newValue));
}
}
return true;
}
};
getWidgetModel().getProperty(XYGraphModel.PROP_TRACE_COUNT).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
}
});
// setPropertyChangeHandler(XYGraphModel.PROP_TRACES_AMOUNT, handler);
}
use of org.csstudio.opibuilder.widgets.model.XYGraphModel.TraceProperty in project yamcs-studio by yamcs.
the class XYGraphEditPart method doCreateFigure.
@Override
protected IFigure doCreateFigure() {
final XYGraphModel model = getWidgetModel();
ToolbarArmedXYGraph xyGraphFigure = new ToolbarArmedXYGraph();
IXYGraph xyGraph = xyGraphFigure.getXYGraph();
xyGraph.setTitle(model.getTitle());
xyGraph.setTitleFont(CustomMediaFactory.getInstance().getFont(model.getTitleFont().getFontData()));
xyGraph.getPlotArea().setShowBorder(model.isShowPlotAreaBorder());
xyGraph.getPlotArea().setBackgroundColor(CustomMediaFactory.getInstance().getColor(model.getPlotAreaBackColor()));
xyGraph.setShowLegend(model.isShowLegend());
xyGraphFigure.setShowToolbar(model.isShowToolbar());
xyGraphFigure.setTransparent(model.isTransprent());
axisList = new ArrayList<>();
axisList.add(xyGraph.getPrimaryXAxis());
axisList.add(xyGraph.getPrimaryYAxis());
traceList = new ArrayList<>();
// init all axes
for (int i = 0; i < XYGraphModel.MAX_AXES_AMOUNT; i++) {
if (i >= 2) {
axisList.add(new Axis("", true));
if (i < model.getAxesAmount())
xyGraphFigure.getXYGraph().addAxis(axisList.get(i));
}
for (AxisProperty axisProperty : AxisProperty.values()) {
// there is no primary and y-axis property for primary axes.
if (i < 2 && (axisProperty == AxisProperty.PRIMARY || axisProperty == AxisProperty.Y_AXIS)) {
continue;
}
String propID = XYGraphModel.makeAxisPropID(axisProperty.propIDPre, i);
setAxisProperty(axisList.get(i), axisProperty, model.getProperty(propID).getPropertyValue());
}
}
// init all traces
for (int i = 0; i < XYGraphModel.MAX_TRACES_AMOUNT; i++) {
traceList.add(new Trace("", xyGraph.getPrimaryXAxis(), xyGraph.getPrimaryYAxis(), new CircularBufferDataProvider(false)));
if (i < model.getTracesAmount()) {
xyGraph.addTrace(traceList.get(i));
}
String xPVPropID = XYGraphModel.makeTracePropID(TraceProperty.XPV.propIDPre, i);
String yPVPropID = XYGraphModel.makeTracePropID(TraceProperty.YPV.propIDPre, i);
for (TraceProperty traceProperty : TraceProperty.values()) {
String propID = XYGraphModel.makeTracePropID(traceProperty.propIDPre, i);
setTraceProperty(traceList.get(i), traceProperty, model.getProperty(propID).getPropertyValue(), xPVPropID, yPVPropID);
}
}
// all values should be buffered
getPVWidgetEditpartDelegate().setAllValuesBuffered(true);
return xyGraphFigure;
}
Aggregations