Search in sources :

Example 1 with XYGraphModel

use of org.csstudio.opibuilder.widgets.model.XYGraphModel in project yamcs-studio by yamcs.

the class XYGraphEditPart method registerAxisPropertyChangeHandlers.

private void registerAxisPropertyChangeHandlers() {
    XYGraphModel model = (XYGraphModel) getModel();
    // set prop handlers and init all the potential axes
    for (int i = 0; i < XYGraphModel.MAX_AXES_AMOUNT; 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);
            IWidgetPropertyChangeHandler handler = new AxisPropertyChangeHandler(i, axisProperty);
            setPropertyChangeHandler(propID, handler);
        }
    }
    for (int i = XYGraphModel.MAX_AXES_AMOUNT - 1; i >= model.getAxesAmount(); i--) {
        for (AxisProperty axisProperty : AxisProperty.values()) {
            String propID = XYGraphModel.makeAxisPropID(axisProperty.propIDPre, i);
            model.setPropertyVisible(propID, false);
        }
    }
}
Also used : AxisProperty(org.csstudio.opibuilder.widgets.model.XYGraphModel.AxisProperty) XYGraphModel(org.csstudio.opibuilder.widgets.model.XYGraphModel) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)

Example 2 with XYGraphModel

use of org.csstudio.opibuilder.widgets.model.XYGraphModel 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 3 with XYGraphModel

use of org.csstudio.opibuilder.widgets.model.XYGraphModel in project yamcs-studio by yamcs.

the class DropPVtoXYGraphEditPolicy method getCommand.

@Override
public Command getCommand(Request request) {
    if (request.getType() == DropPVRequest.REQ_DROP_PV && request instanceof DropPVRequest) {
        DropPVRequest dropPVRequest = (DropPVRequest) request;
        if (dropPVRequest.getTargetWidget() != null && dropPVRequest.getTargetWidget() instanceof XYGraphEditPart) {
            CompoundCommand command = new CompoundCommand("Add Traces");
            XYGraphModel xyGraphModel = (XYGraphModel) dropPVRequest.getTargetWidget().getWidgetModel();
            int existTraces = xyGraphModel.getTracesAmount();
            if (existTraces >= XYGraphModel.MAX_TRACES_AMOUNT)
                return null;
            command.add(new SetWidgetPropertyCommand(xyGraphModel, XYGraphModel.PROP_TRACE_COUNT, dropPVRequest.getPvNames().length + existTraces));
            int i = existTraces;
            for (String pvName : dropPVRequest.getPvNames()) {
                command.add(new SetWidgetPropertyCommand(xyGraphModel, XYGraphModel.makeTracePropID(XYGraphModel.TraceProperty.YPV.propIDPre, i), pvName));
                command.add(new SetWidgetPropertyCommand(xyGraphModel, XYGraphModel.makeTracePropID(XYGraphModel.TraceProperty.NAME.propIDPre, i), pvName));
                if (++i >= XYGraphModel.MAX_TRACES_AMOUNT)
                    break;
            }
            return command;
        }
    }
    return super.getCommand(request);
}
Also used : SetWidgetPropertyCommand(org.csstudio.opibuilder.commands.SetWidgetPropertyCommand) XYGraphModel(org.csstudio.opibuilder.widgets.model.XYGraphModel) DropPVRequest(org.csstudio.opibuilder.dnd.DropPVRequest) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 4 with XYGraphModel

use of org.csstudio.opibuilder.widgets.model.XYGraphModel 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);
        }
    }
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) XYGraphModel(org.csstudio.opibuilder.widgets.model.XYGraphModel) PropertyChangeListener(java.beans.PropertyChangeListener) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) TraceProperty(org.csstudio.opibuilder.widgets.model.XYGraphModel.TraceProperty)

Example 5 with XYGraphModel

use of org.csstudio.opibuilder.widgets.model.XYGraphModel 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)

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