Search in sources :

Example 1 with PROP_RAMP_GRADIENT

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

the class KnobEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    registerCommonPropertyChangeHandlers();
    setPropertyChangeHandler(PROP_KNOB_COLOR, (oldValue, newValue, refreshableFigure) -> {
        var knob = (KnobFigure) refreshableFigure;
        knob.setBulbColor(((OPIColor) newValue).getSWTColor());
        return false;
    });
    setPropertyChangeHandler(PROP_THUMB_COLOR, (oldValue, newValue, refreshableFigure) -> {
        var knob = (KnobFigure) refreshableFigure;
        knob.setThumbColor(((OPIColor) newValue).getSWTColor());
        return false;
    });
    setPropertyChangeHandler(PROP_EFFECT3D, (oldValue, newValue, refreshableFigure) -> {
        var knob = (KnobFigure) refreshableFigure;
        knob.setEffect3D((Boolean) newValue);
        return false;
    });
    setPropertyChangeHandler(PROP_SHOW_VALUE_LABEL, (oldValue, newValue, refreshableFigure) -> {
        var knob = (KnobFigure) refreshableFigure;
        knob.setValueLabelVisibility((Boolean) newValue);
        return false;
    });
    setPropertyChangeHandler(PROP_RAMP_GRADIENT, (oldValue, newValue, refreshableFigure) -> {
        var knob = (KnobFigure) refreshableFigure;
        knob.setGradient((Boolean) newValue);
        return false;
    });
    setPropertyChangeHandler(PROP_INCREMENT, (oldValue, newValue, refreshableFigure) -> {
        var knob = (KnobFigure) refreshableFigure;
        knob.setIncrement((Double) newValue);
        return false;
    });
    // force square size
    IWidgetPropertyChangeHandler sizeHandler = (oldValue, newValue, figure) -> {
        if (((Integer) newValue) < KnobModel.MINIMUM_SIZE) {
            newValue = KnobModel.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 : PROP_PVVALUE(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVVALUE) PROP_EFFECT3D(org.csstudio.opibuilder.widgets.model.KnobModel.PROP_EFFECT3D) PROP_THUMB_COLOR(org.csstudio.opibuilder.widgets.model.KnobModel.PROP_THUMB_COLOR) PROP_KNOB_COLOR(org.csstudio.opibuilder.widgets.model.KnobModel.PROP_KNOB_COLOR) PROP_RAMP_GRADIENT(org.csstudio.opibuilder.widgets.model.KnobModel.PROP_RAMP_GRADIENT) PROP_HEIGHT(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT) PROP_INCREMENT(org.csstudio.opibuilder.widgets.model.KnobModel.PROP_INCREMENT) KnobFigure(org.csstudio.swt.widgets.figures.KnobFigure) PROP_PVNAME(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVNAME) IFigure(org.eclipse.draw2d.IFigure) KnobModel(org.csstudio.opibuilder.widgets.model.KnobModel) PropertyChangeListener(java.beans.PropertyChangeListener) OPIColor(org.csstudio.opibuilder.util.OPIColor) PROP_SHOW_VALUE_LABEL(org.csstudio.opibuilder.widgets.model.KnobModel.PROP_SHOW_VALUE_LABEL) PROP_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH) ExecutionMode(org.csstudio.opibuilder.editparts.ExecutionMode) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) PropertyChangeListener(java.beans.PropertyChangeListener) KnobFigure(org.csstudio.swt.widgets.figures.KnobFigure) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)

Aggregations

PropertyChangeListener (java.beans.PropertyChangeListener)1 ExecutionMode (org.csstudio.opibuilder.editparts.ExecutionMode)1 PROP_HEIGHT (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT)1 PROP_WIDTH (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH)1 PROP_PVNAME (org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVNAME)1 PROP_PVVALUE (org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVVALUE)1 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)1 OPIColor (org.csstudio.opibuilder.util.OPIColor)1 KnobModel (org.csstudio.opibuilder.widgets.model.KnobModel)1 PROP_EFFECT3D (org.csstudio.opibuilder.widgets.model.KnobModel.PROP_EFFECT3D)1 PROP_INCREMENT (org.csstudio.opibuilder.widgets.model.KnobModel.PROP_INCREMENT)1 PROP_KNOB_COLOR (org.csstudio.opibuilder.widgets.model.KnobModel.PROP_KNOB_COLOR)1 PROP_RAMP_GRADIENT (org.csstudio.opibuilder.widgets.model.KnobModel.PROP_RAMP_GRADIENT)1 PROP_SHOW_VALUE_LABEL (org.csstudio.opibuilder.widgets.model.KnobModel.PROP_SHOW_VALUE_LABEL)1 PROP_THUMB_COLOR (org.csstudio.opibuilder.widgets.model.KnobModel.PROP_THUMB_COLOR)1 KnobFigure (org.csstudio.swt.widgets.figures.KnobFigure)1 IFigure (org.eclipse.draw2d.IFigure)1