Search in sources :

Example 1 with RoundedRectangleFigure

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

the class RoundedRectangleEditpart method registerPropertyChangeHandlers.

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

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

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            RoundedRectangleFigure figure = (RoundedRectangleFigure) 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) {
            RoundedRectangleFigure figure = (RoundedRectangleFigure) refreshableFigure;
            figure.setTransparent((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(RoundedRectangleModel.PROP_TRANSPARENT, transparentHandler);
    // line color
    IWidgetPropertyChangeHandler lineColorHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ((RoundedRectangleFigure) refreshableFigure).setLineColor(((OPIColor) newValue).getSWTColor());
            return true;
        }
    };
    setPropertyChangeHandler(AbstractShapeModel.PROP_LINE_COLOR, lineColorHandler);
    // corner width
    IWidgetPropertyChangeHandler cornerWidthHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            RoundedRectangleFigure figure = (RoundedRectangleFigure) refreshableFigure;
            figure.setCornerWidth((Integer) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(RoundedRectangleModel.PROP_CORNER_WIDTH, cornerWidthHandler);
    // corner height
    IWidgetPropertyChangeHandler cornerHeightHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            RoundedRectangleFigure figure = (RoundedRectangleFigure) refreshableFigure;
            figure.setCornerHeight((Integer) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(RoundedRectangleModel.PROP_CORNER_HEIGHT, cornerHeightHandler);
    IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((RoundedRectangleFigure) figure).setGradient((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(RoundedRectangleModel.PROP_GRADIENT, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((RoundedRectangleFigure) figure).setBackGradientStartColor(((OPIColor) newValue).getSWTColor());
            return false;
        }
    };
    setPropertyChangeHandler(RoundedRectangleModel.PROP_BACKGROUND_GRADIENT_START_COLOR, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((RoundedRectangleFigure) figure).setForeGradientStartColor(((OPIColor) newValue).getSWTColor());
            return false;
        }
    };
    setPropertyChangeHandler(RoundedRectangleModel.PROP_FOREGROUND_GRADIENT_START_COLOR, handler);
}
Also used : RoundedRectangleFigure(org.csstudio.swt.widgets.figures.RoundedRectangleFigure) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) OPIColor(org.csstudio.opibuilder.util.OPIColor) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with RoundedRectangleFigure

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

the class RoundedRectangleEditpart method doCreateFigure.

@Override
protected IFigure doCreateFigure() {
    RoundedRectangleFigure figure = new RoundedRectangleFigure();
    RoundedRectangleModel model = getWidgetModel();
    figure.setFill(model.getFillLevel());
    figure.setHorizontalFill(model.isHorizontalFill());
    figure.setTransparent(model.isTransparent());
    figure.setCornerDimensions(new Dimension(model.getCornerWidth(), model.getCornerHeight()));
    figure.setLineColor(model.getLineColor());
    figure.setGradient(model.isGradient());
    figure.setBackGradientStartColor(model.getBackgroundGradientStartColor());
    figure.setForeGradientStartColor(model.getForegroundGradientStartColor());
    return figure;
}
Also used : RoundedRectangleModel(org.csstudio.opibuilder.widgets.model.RoundedRectangleModel) RoundedRectangleFigure(org.csstudio.swt.widgets.figures.RoundedRectangleFigure) Dimension(org.eclipse.draw2d.geometry.Dimension)

Aggregations

RoundedRectangleFigure (org.csstudio.swt.widgets.figures.RoundedRectangleFigure)2 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)1 OPIColor (org.csstudio.opibuilder.util.OPIColor)1 RoundedRectangleModel (org.csstudio.opibuilder.widgets.model.RoundedRectangleModel)1 IFigure (org.eclipse.draw2d.IFigure)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1