use of org.csstudio.swt.widgets.figures.LEDFigure in project yamcs-studio by yamcs.
the class LEDEditPart method doCreateFigure.
@Override
protected IFigure doCreateFigure() {
final LEDModel model = getWidgetModel();
LEDFigure led = new LEDFigure();
initializeCommonFigureProperties(led, model);
led.setEffect3D(model.isEffect3D());
led.setSquareLED(model.isSquareLED());
return led;
}
use of org.csstudio.swt.widgets.figures.LEDFigure in project yamcs-studio by yamcs.
the class LEDEditPart method initializeCommonFigureProperties.
@Override
protected void initializeCommonFigureProperties(final AbstractBoolFigure abstractFigure, final AbstractBoolWidgetModel abstractModel) {
super.initializeCommonFigureProperties(abstractFigure, abstractModel);
LEDModel model = (LEDModel) abstractModel;
LEDFigure figure = (LEDFigure) abstractFigure;
initializeStateBulbBorderColor(model.getBulbBorderColor(), figure, model);
initializeStateBulbBorderWidth(model.getBulbBorderWidth(), figure, model);
initializeNStatesProperties(LEDFigure.MAX_NSTATES, model.getNStates(), figure, model);
initializeStateFallbackLabel(null, model.getStateFallbackLabel(), figure, model);
initializeStateFallbackColor(null, model.getStateFallbackColor(), figure, model);
for (int state = 0; state < LEDFigure.MAX_NSTATES; state++) {
initializeStateColor(state, null, model.getStateColor(state), figure, model);
initializeStateLabel(state, null, model.getStateLabel(state), figure, model);
initializeStateValue(state, 0.0, model.getStateValue(state), figure, model);
}
}
use of org.csstudio.swt.widgets.figures.LEDFigure in project yamcs-studio by yamcs.
the class LEDEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
setPropertyChangeHandler(PROP_EFFECT3D, (oldValue, newValue, refreshableFigure) -> {
var led = (LEDFigure) refreshableFigure;
led.setEffect3D((Boolean) newValue);
return true;
});
setPropertyChangeHandler(PROP_SQUARE_LED, (oldValue, newValue, refreshableFigure) -> {
var led = (LEDFigure) refreshableFigure;
led.setSquareLED((Boolean) newValue);
if (!(Boolean) newValue) {
var width = Math.min(getWidgetModel().getWidth(), getWidgetModel().getHeight());
getWidgetModel().setSize(width, width);
}
return true;
});
// force square size
IWidgetPropertyChangeHandler sizeHandler = (oldValue, newValue, figure) -> {
if (getWidgetModel().isSquareLED()) {
return false;
}
if (((Integer) newValue) < LEDModel.MINIMUM_SIZE) {
newValue = LEDModel.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);
getWidgetModel().getProperty(PROP_NSTATES).addPropertyChangeListener(evt -> initializeNStatesProperties((Integer) evt.getOldValue(), (Integer) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel()));
getWidgetModel().getProperty(PROP_STATE_FALLBACK_LABEL).addPropertyChangeListener(evt -> initializeStateFallbackLabel((String) evt.getOldValue(), (String) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel()));
getWidgetModel().getProperty(PROP_STATE_FALLBACK_COLOR).addPropertyChangeListener(evt -> initializeStateFallbackColor(((OPIColor) evt.getOldValue()).getSWTColor(), ((OPIColor) evt.getNewValue()).getSWTColor(), (LEDFigure) getFigure(), getWidgetModel()));
getWidgetModel().getProperty(PROP_BULB_BORDER).addPropertyChangeListener(evt -> initializeStateBulbBorderWidth((Integer) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel()));
getWidgetModel().getProperty(PROP_BULB_BORDER_COLOR).addPropertyChangeListener(evt -> initializeStateBulbBorderColor(((OPIColor) evt.getNewValue()).getSWTColor(), (LEDFigure) getFigure(), getWidgetModel()));
for (var idx = 0; idx < LEDFigure.MAX_NSTATES; idx++) {
var state = idx;
getWidgetModel().getProperty(String.format(PROP_STATE_LABEL, state)).addPropertyChangeListener(evt -> initializeStateLabel(state, (String) evt.getOldValue(), (String) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel()));
getWidgetModel().getProperty(String.format(PROP_STATE_COLOR, state)).addPropertyChangeListener(evt -> initializeStateColor(state, ((OPIColor) evt.getOldValue()).getSWTColor(), ((OPIColor) evt.getNewValue()).getSWTColor(), (LEDFigure) getFigure(), getWidgetModel()));
getWidgetModel().getProperty(String.format(PROP_STATE_VALUE, state)).addPropertyChangeListener(evt -> initializeStateValue(state, (Double) evt.getOldValue(), (Double) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel()));
}
}
Aggregations