Search in sources :

Example 1 with PolygonFigure

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

the class PolygonEditPart method doCreateFigure.

/**
 * {@inheritDoc}
 */
@Override
protected IFigure doCreateFigure() {
    PolygonFigure polygon = new PolygonFigure();
    PolygonModel model = getWidgetModel();
    polygon.setPoints(model.getPoints());
    polygon.setFill(model.getFillLevel());
    polygon.setHorizontalFill(model.isHorizontalFill());
    polygon.setTransparent(model.isTransparent());
    polygon.setLineColor(model.getLineColor());
    return polygon;
}
Also used : PolygonFigure(org.csstudio.swt.widgets.figures.PolygonFigure) PolygonModel(org.csstudio.opibuilder.widgets.model.PolygonModel)

Example 2 with PolygonFigure

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

the class PolygonEditPart 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) {
            PolygonFigure polygon = (PolygonFigure) refreshableFigure;
            polygon.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) {
            PolygonFigure figure = (PolygonFigure) 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) {
            PolygonFigure figure = (PolygonFigure) refreshableFigure;
            figure.setTransparent((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(AbstractShapeModel.PROP_TRANSPARENT, transparentHandler);
    // line color
    IWidgetPropertyChangeHandler lineColorHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ((PolygonFigure) refreshableFigure).setLineColor(((OPIColor) newValue).getSWTColor());
            return true;
        }
    };
    setPropertyChangeHandler(AbstractShapeModel.PROP_LINE_COLOR, lineColorHandler);
}
Also used : PolygonFigure(org.csstudio.swt.widgets.figures.PolygonFigure) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

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