use of org.csstudio.opibuilder.widgets.model.ImageModel.PROP_FLIP_VERTICAL in project yamcs-studio by yamcs.
the class ImageEditPart method registerImageRotationPropertyHandlers.
/**
* Registers image rotation property change handlers for the properties defined in MonitorBoolSymbolModel
*/
public void registerImageRotationPropertyHandlers() {
// degree rotation property
IWidgetPropertyChangeHandler handler = (oldValue, newValue, figure) -> {
if (oldValue == null || newValue == null) {
return false;
}
var imageFigure = (ImageFigure) figure;
var newDegree = getWidgetModel().getDegree((Integer) newValue);
var oldDegree = getWidgetModel().getDegree((Integer) oldValue);
var oldMatrix = new PermutationMatrix((double[][]) getPropertyValue(ImageModel.PERMUTATION_MATRIX));
var newMatrix = PermutationMatrix.generateRotationMatrix(newDegree - oldDegree);
var 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(PROP_DEGREE, newValue);
imageFigure.setPermutationMatrix(result);
autoSizeWidget(imageFigure);
return false;
};
setPropertyChangeHandler(PROP_DEGREE, handler);
// flip horizontal rotation property
handler = (oldValue, newValue, figure) -> {
if (oldValue == null || newValue == null) {
return false;
}
var imageFigure = (ImageFigure) figure;
// imageFigure.setFlipH((Boolean) newValue);
var newMatrix = PermutationMatrix.generateFlipHMatrix();
var oldMatrix = imageFigure.getPermutationMatrix();
var 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(PROP_FLIP_HORIZONTAL, newValue);
imageFigure.setPermutationMatrix(result);
autoSizeWidget(imageFigure);
return false;
};
setPropertyChangeHandler(PROP_FLIP_HORIZONTAL, handler);
// flip vertical rotation property
handler = (oldValue, newValue, figure) -> {
if (oldValue == null || newValue == null) {
return false;
}
var imageFigure = (ImageFigure) figure;
// imageFigure.setFlipV((Boolean) newValue);
var newMatrix = PermutationMatrix.generateFlipVMatrix();
var oldMatrix = imageFigure.getPermutationMatrix();
var 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(PROP_FLIP_VERTICAL, newValue);
imageFigure.setPermutationMatrix(result);
autoSizeWidget(imageFigure);
return false;
};
setPropertyChangeHandler(PROP_FLIP_VERTICAL, handler);
}
Aggregations