Search in sources :

Example 1 with ToolbarArmedXYGraph

use of org.eclipse.nebula.visualization.xygraph.figures.ToolbarArmedXYGraph in project yamcs-studio by yamcs.

the class XYGraphEditPart method registerAxesAmountChangeHandler.

private void registerAxesAmountChangeHandler() {
    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 currentAxisAmount = xyGraph.getAxisList().size();
            // add axis
            if ((Integer) newValue > currentAxisAmount) {
                for (int i = 0; i < (Integer) newValue - currentAxisAmount; i++) {
                    for (AxisProperty axisProperty : AxisProperty.values()) {
                        String propID = XYGraphModel.makeAxisPropID(axisProperty.propIDPre, i + currentAxisAmount);
                        model.setPropertyVisible(propID, true);
                    }
                    xyGraph.addAxis(axisList.get(i + currentAxisAmount));
                }
            } else if ((Integer) newValue < currentAxisAmount) {
                // remove axis
                for (int i = 0; i < currentAxisAmount - (Integer) newValue; i++) {
                    for (AxisProperty axisProperty : AxisProperty.values()) {
                        String propID = XYGraphModel.makeAxisPropID(axisProperty.propIDPre, i + (Integer) newValue);
                        model.setPropertyVisible(propID, false);
                    }
                    xyGraph.removeAxis(axisList.get(i + (Integer) newValue));
                }
            }
            return true;
        }
    };
    getWidgetModel().getProperty(XYGraphModel.PROP_AXIS_COUNT).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
        }
    });
// setPropertyChangeHandler(XYGraphModel.PROP_AXES_AMOUNT, handler);
}
Also used : AxisProperty(org.csstudio.opibuilder.widgets.model.XYGraphModel.AxisProperty) PropertyChangeEvent(java.beans.PropertyChangeEvent) XYGraphModel(org.csstudio.opibuilder.widgets.model.XYGraphModel) ToolbarArmedXYGraph(org.eclipse.nebula.visualization.xygraph.figures.ToolbarArmedXYGraph) PropertyChangeListener(java.beans.PropertyChangeListener) IXYGraph(org.eclipse.nebula.visualization.xygraph.figures.IXYGraph) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with ToolbarArmedXYGraph

use of org.eclipse.nebula.visualization.xygraph.figures.ToolbarArmedXYGraph in project yamcs-studio by yamcs.

the class XYGraphEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    registerAxisPropertyChangeHandlers();
    registerTracePropertyChangeHandlers();
    // Title
    IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ToolbarArmedXYGraph graph = (ToolbarArmedXYGraph) refreshableFigure;
            graph.getXYGraph().setTitle((String) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(XYGraphModel.PROP_TITLE, handler);
    // Title Font
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ToolbarArmedXYGraph graph = (ToolbarArmedXYGraph) refreshableFigure;
            graph.getXYGraph().setTitleFont(CustomMediaFactory.getInstance().getFont(((OPIFont) newValue).getFontData()));
            return true;
        }
    };
    setPropertyChangeHandler(XYGraphModel.PROP_TITLE_FONT, handler);
    // Show plot area border
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ToolbarArmedXYGraph graph = (ToolbarArmedXYGraph) refreshableFigure;
            graph.getXYGraph().getPlotArea().setShowBorder((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(XYGraphModel.PROP_SHOW_PLOTAREA_BORDER, handler);
    // Plot area background color
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ToolbarArmedXYGraph graph = (ToolbarArmedXYGraph) refreshableFigure;
            graph.getXYGraph().getPlotArea().setBackgroundColor(CustomMediaFactory.getInstance().getColor(((OPIColor) newValue).getRGBValue()));
            return true;
        }
    };
    setPropertyChangeHandler(XYGraphModel.PROP_PLOTAREA_BACKCOLOR, handler);
    // Transparent
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ToolbarArmedXYGraph graph = (ToolbarArmedXYGraph) refreshableFigure;
            graph.setTransparent((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(XYGraphModel.PROP_TRANSPARENT, handler);
    // Show legend
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ToolbarArmedXYGraph graph = (ToolbarArmedXYGraph) refreshableFigure;
            graph.getXYGraph().setShowLegend((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(XYGraphModel.PROP_SHOW_LEGEND, handler);
    // Show Toolbar
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ToolbarArmedXYGraph graph = (ToolbarArmedXYGraph) refreshableFigure;
            graph.setShowToolbar((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(XYGraphModel.PROP_SHOW_TOOLBAR, handler);
    // trigger pv value
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            for (int i = 0; i < getWidgetModel().getTracesAmount(); i++) {
                CircularBufferDataProvider dataProvider = (CircularBufferDataProvider) traceList.get(i).getDataProvider();
                if (dataProvider.getUpdateMode() == UpdateMode.TRIGGER) {
                    dataProvider.triggerUpdate();
                }
            }
            return false;
        }
    };
    setPropertyChangeHandler(XYGraphModel.PROP_TRIGGER_PV_VALUE, handler);
    registerAxesAmountChangeHandler();
    registerTraceAmountChangeHandler();
}
Also used : ToolbarArmedXYGraph(org.eclipse.nebula.visualization.xygraph.figures.ToolbarArmedXYGraph) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) CircularBufferDataProvider(org.eclipse.nebula.visualization.xygraph.dataprovider.CircularBufferDataProvider) IFigure(org.eclipse.draw2d.IFigure)

Example 3 with ToolbarArmedXYGraph

use of org.eclipse.nebula.visualization.xygraph.figures.ToolbarArmedXYGraph 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);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) XYGraphModel(org.csstudio.opibuilder.widgets.model.XYGraphModel) ToolbarArmedXYGraph(org.eclipse.nebula.visualization.xygraph.figures.ToolbarArmedXYGraph) PropertyChangeListener(java.beans.PropertyChangeListener) TraceProperty(org.csstudio.opibuilder.widgets.model.XYGraphModel.TraceProperty) IXYGraph(org.eclipse.nebula.visualization.xygraph.figures.IXYGraph) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) IFigure(org.eclipse.draw2d.IFigure)

Example 4 with ToolbarArmedXYGraph

use of org.eclipse.nebula.visualization.xygraph.figures.ToolbarArmedXYGraph 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

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