use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class ImageEditPart method registerImageRotationPropertyHandlers.
/**
* Registers image rotation property change handlers for the properties defined in {@link MonitorBoolSymbolModel}.
*/
public void registerImageRotationPropertyHandlers() {
// degree rotation property
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
if (oldValue == null || newValue == null)
return false;
ImageFigure imageFigure = (ImageFigure) figure;
int newDegree = getWidgetModel().getDegree((Integer) newValue);
int oldDegree = getWidgetModel().getDegree((Integer) oldValue);
PermutationMatrix oldMatrix = new PermutationMatrix((double[][]) getPropertyValue(ImageModel.PERMUTATION_MATRIX));
PermutationMatrix newMatrix = PermutationMatrix.generateRotationMatrix(newDegree - oldDegree);
PermutationMatrix result = newMatrix.multiply(oldMatrix);
// As we use only % Pi/2 angles, we can round to integer values
// => equals work better
result.roundToIntegers();
setPropertyValue(ImageModel.PERMUTATION_MATRIX, result.getMatrix());
setPropertyValue(ImageModel.PROP_DEGREE, (Integer) newValue);
imageFigure.setPermutationMatrix(result);
autoSizeWidget(imageFigure);
return false;
}
};
setPropertyChangeHandler(ImageModel.PROP_DEGREE, handler);
// flip horizontal rotation property
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
if (oldValue == null || newValue == null)
return false;
ImageFigure imageFigure = (ImageFigure) figure;
// imageFigure.setFlipH((Boolean) newValue);
PermutationMatrix newMatrix = PermutationMatrix.generateFlipHMatrix();
PermutationMatrix oldMatrix = imageFigure.getPermutationMatrix();
PermutationMatrix result = newMatrix.multiply(oldMatrix);
// As we use only % Pi/2 angles, we can round to integer values
// => equals work better
result.roundToIntegers();
setPropertyValue(ImageModel.PERMUTATION_MATRIX, result.getMatrix());
setPropertyValue(ImageModel.PROP_FLIP_HORIZONTAL, (Boolean) newValue);
imageFigure.setPermutationMatrix(result);
autoSizeWidget(imageFigure);
return false;
}
};
setPropertyChangeHandler(ImageModel.PROP_FLIP_HORIZONTAL, handler);
// flip vertical rotation property
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
if (oldValue == null || newValue == null)
return false;
ImageFigure imageFigure = (ImageFigure) figure;
// imageFigure.setFlipV((Boolean) newValue);
PermutationMatrix newMatrix = PermutationMatrix.generateFlipVMatrix();
PermutationMatrix oldMatrix = imageFigure.getPermutationMatrix();
PermutationMatrix result = newMatrix.multiply(oldMatrix);
// As we use only % Pi/2 angles, we can round to integer values
// => equals work better
result.roundToIntegers();
setPropertyValue(ImageModel.PERMUTATION_MATRIX, result.getMatrix());
setPropertyValue(ImageModel.PROP_FLIP_VERTICAL, (Boolean) newValue);
imageFigure.setPermutationMatrix(result);
autoSizeWidget(imageFigure);
return false;
}
};
setPropertyChangeHandler(ImageModel.PROP_FLIP_VERTICAL, handler);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class IntensityGraphEditPart method registerAxisPropertyChangeHandler.
private void registerAxisPropertyChangeHandler() {
for (String axisID : new String[] { IntensityGraphModel.X_AXIS_ID, IntensityGraphModel.Y_AXIS_ID }) {
for (AxisProperty axisProperty : AxisProperty.values()) {
final IWidgetPropertyChangeHandler handler = new AxisPropertyChangeHandler(axisID.equals(IntensityGraphModel.X_AXIS_ID) ? ((IntensityGraphFigure) getFigure()).getXAxis() : ((IntensityGraphFigure) getFigure()).getYAxis(), axisProperty);
// must use listener instead of handler because the prop sheet need to be
// refreshed immediately.
getWidgetModel().getProperty(IntensityGraphModel.makeAxisPropID(axisID, axisProperty.propIDPre)).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
UIBundlingThread.getInstance().addRunnable(getViewer().getControl().getDisplay(), new Runnable() {
@Override
public void run() {
getFigure().repaint();
}
});
}
});
}
}
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class LEDEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
// effect 3D
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
LEDFigure led = (LEDFigure) refreshableFigure;
led.setEffect3D((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(LEDModel.PROP_EFFECT3D, handler);
// Sqaure LED
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
LEDFigure led = (LEDFigure) refreshableFigure;
led.setSquareLED((Boolean) newValue);
if (!(Boolean) newValue) {
int width = Math.min(getWidgetModel().getWidth(), getWidgetModel().getHeight());
getWidgetModel().setSize(width, width);
}
return true;
}
};
setPropertyChangeHandler(LEDModel.PROP_SQUARE_LED, handler);
// force square size
final IWidgetPropertyChangeHandler sizeHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure 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 = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
sizeHandler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
}
};
getWidgetModel().getProperty(AbstractWidgetModel.PROP_WIDTH).addPropertyChangeListener(sizeListener);
getWidgetModel().getProperty(AbstractWidgetModel.PROP_HEIGHT).addPropertyChangeListener(sizeListener);
// nStates
getWidgetModel().getProperty(LEDModel.PROP_NSTATES).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
initializeNStatesProperties((Integer) evt.getOldValue(), (Integer) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel());
}
});
// stateFallbackLabel
getWidgetModel().getProperty(LEDModel.PROP_STATE_FALLBACK_LABEL).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
initializeStateFallbackLabel((String) evt.getOldValue(), (String) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel());
}
});
// stateFallbackColor
getWidgetModel().getProperty(LEDModel.PROP_STATE_FALLBACK_COLOR).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
initializeStateFallbackColor(((OPIColor) evt.getOldValue()).getSWTColor(), ((OPIColor) evt.getNewValue()).getSWTColor(), (LEDFigure) getFigure(), getWidgetModel());
}
});
// bulbBorderWidth
getWidgetModel().getProperty(LEDModel.PROP_BULB_BORDER).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
initializeStateBulbBorderWidth((Integer) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel());
}
});
// bulbBorderColor
getWidgetModel().getProperty(LEDModel.PROP_BULB_BORDER_COLOR).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
initializeStateBulbBorderColor(((OPIColor) evt.getNewValue()).getSWTColor(), (LEDFigure) getFigure(), getWidgetModel());
}
});
for (int idx = 0; idx < LEDFigure.MAX_NSTATES; idx++) {
final int state = idx;
// stateLabelN
getWidgetModel().getProperty(String.format(LEDModel.PROP_STATE_LABEL, state)).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
initializeStateLabel(state, (String) evt.getOldValue(), (String) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel());
}
});
// stateColorN
getWidgetModel().getProperty(String.format(LEDModel.PROP_STATE_COLOR, state)).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
initializeStateColor(state, ((OPIColor) evt.getOldValue()).getSWTColor(), ((OPIColor) evt.getNewValue()).getSWTColor(), (LEDFigure) getFigure(), getWidgetModel());
}
});
// stateValueN
getWidgetModel().getProperty(String.format(LEDModel.PROP_STATE_VALUE, state)).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
initializeStateValue(state, (Double) evt.getOldValue(), (Double) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel());
}
});
}
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler 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);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class PolylineEditPart 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) {
PolylineFigure polyline = (PolylineFigure) refreshableFigure;
polyline.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) {
PolylineFigure figure = (PolylineFigure) 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) {
PolylineFigure figure = (PolylineFigure) refreshableFigure;
figure.setTransparent((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(AbstractShapeModel.PROP_TRANSPARENT, transparentHandler);
// arrow Type
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
PolylineFigure figure = (PolylineFigure) refreshableFigure;
figure.setArrowType(ArrowType.values()[(Integer) newValue]);
getWidgetModel().updateBounds();
return true;
}
};
setPropertyChangeHandler(PolyLineModel.PROP_ARROW, handler);
// arrow length
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
PolylineFigure figure = (PolylineFigure) refreshableFigure;
figure.setArrowLineLength((Integer) newValue);
getWidgetModel().updateBounds();
return true;
}
};
setPropertyChangeHandler(PolyLineModel.PROP_ARROW_LENGTH, handler);
// Fill Arrow
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
PolylineFigure figure = (PolylineFigure) refreshableFigure;
figure.setFillArrow((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(PolyLineModel.PROP_FILL_ARROW, handler);
}
Aggregations