Search in sources :

Example 6 with XYGraphModel

use of org.csstudio.opibuilder.widgets.model.XYGraphModel 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;
}
Also used : Trace(org.eclipse.nebula.visualization.xygraph.figures.Trace) AxisProperty(org.csstudio.opibuilder.widgets.model.XYGraphModel.AxisProperty) XYGraphModel(org.csstudio.opibuilder.widgets.model.XYGraphModel) IXYGraph(org.eclipse.nebula.visualization.xygraph.figures.IXYGraph) ToolbarArmedXYGraph(org.eclipse.nebula.visualization.xygraph.figures.ToolbarArmedXYGraph) TraceProperty(org.csstudio.opibuilder.widgets.model.XYGraphModel.TraceProperty) CircularBufferDataProvider(org.eclipse.nebula.visualization.xygraph.dataprovider.CircularBufferDataProvider) Axis(org.eclipse.nebula.visualization.xygraph.figures.Axis)

Aggregations

XYGraphModel (org.csstudio.opibuilder.widgets.model.XYGraphModel)6 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)4 PropertyChangeEvent (java.beans.PropertyChangeEvent)3 PropertyChangeListener (java.beans.PropertyChangeListener)3 AxisProperty (org.csstudio.opibuilder.widgets.model.XYGraphModel.AxisProperty)3 TraceProperty (org.csstudio.opibuilder.widgets.model.XYGraphModel.TraceProperty)3 IXYGraph (org.eclipse.nebula.visualization.xygraph.figures.IXYGraph)3 ToolbarArmedXYGraph (org.eclipse.nebula.visualization.xygraph.figures.ToolbarArmedXYGraph)3 IFigure (org.eclipse.draw2d.IFigure)2 SetWidgetPropertyCommand (org.csstudio.opibuilder.commands.SetWidgetPropertyCommand)1 DropPVRequest (org.csstudio.opibuilder.dnd.DropPVRequest)1 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1 CircularBufferDataProvider (org.eclipse.nebula.visualization.xygraph.dataprovider.CircularBufferDataProvider)1 Axis (org.eclipse.nebula.visualization.xygraph.figures.Axis)1 Trace (org.eclipse.nebula.visualization.xygraph.figures.Trace)1