Search in sources :

Example 1 with PolylineFigure

use of org.csstudio.swt.widgets.figures.PolylineFigure in project yamcs-studio by yamcs.

the class PolylineEditPart method registerPropertyChangeHandlers.

/**
 * {@inheritDoc}
 */
@Override
protected void registerPropertyChangeHandlers() {
    super.registerPropertyChangeHandlers();
    // fill
    IWidgetPropertyChangeHandler fillHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            PolylineFigure polyline = (PolylineFigure) refreshableFigure;
            polyline.setFill((Double) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(AbstractPolyModel.PROP_FILL_LEVEL, fillHandler);
    // fill orientaion
    IWidgetPropertyChangeHandler fillOrientHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            PolylineFigure figure = (PolylineFigure) refreshableFigure;
            figure.setHorizontalFill((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(AbstractShapeModel.PROP_HORIZONTAL_FILL, fillOrientHandler);
    // transparent
    IWidgetPropertyChangeHandler transparentHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            PolylineFigure figure = (PolylineFigure) refreshableFigure;
            figure.setTransparent((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(AbstractShapeModel.PROP_TRANSPARENT, transparentHandler);
    // arrow Type
    IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            PolylineFigure figure = (PolylineFigure) refreshableFigure;
            figure.setArrowType(ArrowType.values()[(Integer) newValue]);
            getWidgetModel().updateBounds();
            return true;
        }
    };
    setPropertyChangeHandler(PolyLineModel.PROP_ARROW, handler);
    // arrow length
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            PolylineFigure figure = (PolylineFigure) refreshableFigure;
            figure.setArrowLineLength((Integer) newValue);
            getWidgetModel().updateBounds();
            return true;
        }
    };
    setPropertyChangeHandler(PolyLineModel.PROP_ARROW_LENGTH, handler);
    // Fill Arrow
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            PolylineFigure figure = (PolylineFigure) refreshableFigure;
            figure.setFillArrow((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(PolyLineModel.PROP_FILL_ARROW, handler);
}
Also used : IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) PolylineFigure(org.csstudio.swt.widgets.figures.PolylineFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with PolylineFigure

use of org.csstudio.swt.widgets.figures.PolylineFigure in project yamcs-studio by yamcs.

the class PolylineEditPart method doCreateFigure.

/**
 * {@inheritDoc}
 */
@Override
protected IFigure doCreateFigure() {
    PolylineFigure polyline = new PolylineFigure();
    PolyLineModel model = getWidgetModel();
    polyline.setPoints(model.getPoints());
    polyline.setFill(model.getFillLevel());
    polyline.setHorizontalFill(model.isHorizontalFill());
    polyline.setTransparent(model.isTransparent());
    polyline.setArrowLineLength(model.getArrowLength());
    polyline.setArrowType(ArrowType.values()[model.getArrowType()]);
    polyline.setFillArrow(model.isFillArrow());
    return polyline;
}
Also used : PolyLineModel(org.csstudio.opibuilder.widgets.model.PolyLineModel) PolylineFigure(org.csstudio.swt.widgets.figures.PolylineFigure)

Aggregations

PolylineFigure (org.csstudio.swt.widgets.figures.PolylineFigure)2 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)1 PolyLineModel (org.csstudio.opibuilder.widgets.model.PolyLineModel)1 IFigure (org.eclipse.draw2d.IFigure)1