Search in sources :

Example 1 with PROP_EFFECT3D

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

the class GaugeEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    registerCommonPropertyChangeHandlers();
    setPropertyChangeHandler(PROP_NEEDLE_COLOR, (oldValue, newValue, refreshableFigure) -> {
        var gauge = (GaugeFigure) refreshableFigure;
        gauge.setNeedleColor(((OPIColor) newValue).getSWTColor());
        return false;
    });
    setPropertyChangeHandler(PROP_EFFECT3D, (oldValue, newValue, refreshableFigure) -> {
        var gauge = (GaugeFigure) refreshableFigure;
        gauge.setEffect3D((Boolean) newValue);
        return false;
    });
    setPropertyChangeHandler(PROP_RAMP_GRADIENT, (oldValue, newValue, refreshableFigure) -> {
        var gauge = (GaugeFigure) refreshableFigure;
        gauge.setGradient((Boolean) newValue);
        return false;
    });
    IWidgetPropertyChangeHandler sizeHandler = (oldValue, newValue, figure) -> {
        if (((Integer) newValue) < GaugeModel.MINIMUM_SIZE) {
            newValue = GaugeModel.MINIMUM_SIZE;
        }
        getWidgetModel().setSize((Integer) newValue, (Integer) newValue);
        return false;
    };
    PropertyChangeListener sizeListener = evt -> sizeHandler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
    getWidgetModel().getProperty(PROP_WIDTH).addPropertyChangeListener(sizeListener);
    getWidgetModel().getProperty(PROP_HEIGHT).addPropertyChangeListener(sizeListener);
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) GaugeFigure(org.csstudio.swt.widgets.figures.GaugeFigure) PROP_HEIGHT(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT) GaugeModel(org.csstudio.opibuilder.widgets.model.GaugeModel) PROP_EFFECT3D(org.csstudio.opibuilder.widgets.model.GaugeModel.PROP_EFFECT3D) PROP_NEEDLE_COLOR(org.csstudio.opibuilder.widgets.model.GaugeModel.PROP_NEEDLE_COLOR) OPIColor(org.csstudio.opibuilder.util.OPIColor) PROP_RAMP_GRADIENT(org.csstudio.opibuilder.widgets.model.GaugeModel.PROP_RAMP_GRADIENT) CustomMediaFactory(org.csstudio.ui.util.CustomMediaFactory) IFigure(org.eclipse.draw2d.IFigure) PROP_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) PropertyChangeListener(java.beans.PropertyChangeListener) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) GaugeFigure(org.csstudio.swt.widgets.figures.GaugeFigure)

Aggregations

PropertyChangeListener (java.beans.PropertyChangeListener)1 PROP_HEIGHT (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT)1 PROP_WIDTH (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH)1 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)1 OPIColor (org.csstudio.opibuilder.util.OPIColor)1 GaugeModel (org.csstudio.opibuilder.widgets.model.GaugeModel)1 PROP_EFFECT3D (org.csstudio.opibuilder.widgets.model.GaugeModel.PROP_EFFECT3D)1 PROP_NEEDLE_COLOR (org.csstudio.opibuilder.widgets.model.GaugeModel.PROP_NEEDLE_COLOR)1 PROP_RAMP_GRADIENT (org.csstudio.opibuilder.widgets.model.GaugeModel.PROP_RAMP_GRADIENT)1 GaugeFigure (org.csstudio.swt.widgets.figures.GaugeFigure)1 CustomMediaFactory (org.csstudio.ui.util.CustomMediaFactory)1 IFigure (org.eclipse.draw2d.IFigure)1