Search in sources :

Example 1 with PROP_DEGREE

use of org.csstudio.opibuilder.widgets.model.ImageModel.PROP_DEGREE 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);
}
Also used : AbstractWidgetEditPart(org.csstudio.opibuilder.editparts.AbstractWidgetEditPart) PROP_AUTOSIZE(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_AUTOSIZE) PROP_BORDER_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_WIDTH) PROP_HEIGHT(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT) PROP_LEFTCROP(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_LEFTCROP) ImageModel(org.csstudio.opibuilder.widgets.model.ImageModel) ResourceUtil(org.csstudio.opibuilder.util.ResourceUtil) IFigure(org.eclipse.draw2d.IFigure) PROP_FLIP_HORIZONTAL(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_FLIP_HORIZONTAL) PROP_ALIGN_TO_NEAREST_SECOND(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_ALIGN_TO_NEAREST_SECOND) PROP_TOPCROP(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_TOPCROP) FigureTransparencyHelper(org.csstudio.opibuilder.widgets.FigureTransparencyHelper) PROP_FLIP_VERTICAL(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_FLIP_VERTICAL) PROP_RIGHTCROP(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_RIGHTCROP) PROP_DEGREE(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_DEGREE) PROP_BOTTOMCROP(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_BOTTOMCROP) Display(org.eclipse.swt.widgets.Display) PROP_IMAGE_FILE(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_IMAGE_FILE) PROP_NO_ANIMATION(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_NO_ANIMATION) ImageFigure(org.csstudio.opibuilder.widgets.figures.ImageFigure) Color(org.eclipse.swt.graphics.Color) Path(org.eclipse.core.runtime.Path) PROP_STRETCH(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_STRETCH) PermutationMatrix(org.csstudio.swt.widgets.symbol.util.PermutationMatrix) PROP_BORDER_STYLE(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE) SymbolImageProperties(org.csstudio.swt.widgets.symbol.SymbolImageProperties) PROP_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) ImageFigure(org.csstudio.opibuilder.widgets.figures.ImageFigure) PermutationMatrix(org.csstudio.swt.widgets.symbol.util.PermutationMatrix)

Aggregations

AbstractWidgetEditPart (org.csstudio.opibuilder.editparts.AbstractWidgetEditPart)1 PROP_BORDER_STYLE (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE)1 PROP_BORDER_WIDTH (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_WIDTH)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 ResourceUtil (org.csstudio.opibuilder.util.ResourceUtil)1 FigureTransparencyHelper (org.csstudio.opibuilder.widgets.FigureTransparencyHelper)1 ImageFigure (org.csstudio.opibuilder.widgets.figures.ImageFigure)1 ImageModel (org.csstudio.opibuilder.widgets.model.ImageModel)1 PROP_ALIGN_TO_NEAREST_SECOND (org.csstudio.opibuilder.widgets.model.ImageModel.PROP_ALIGN_TO_NEAREST_SECOND)1 PROP_AUTOSIZE (org.csstudio.opibuilder.widgets.model.ImageModel.PROP_AUTOSIZE)1 PROP_BOTTOMCROP (org.csstudio.opibuilder.widgets.model.ImageModel.PROP_BOTTOMCROP)1 PROP_DEGREE (org.csstudio.opibuilder.widgets.model.ImageModel.PROP_DEGREE)1 PROP_FLIP_HORIZONTAL (org.csstudio.opibuilder.widgets.model.ImageModel.PROP_FLIP_HORIZONTAL)1 PROP_FLIP_VERTICAL (org.csstudio.opibuilder.widgets.model.ImageModel.PROP_FLIP_VERTICAL)1 PROP_IMAGE_FILE (org.csstudio.opibuilder.widgets.model.ImageModel.PROP_IMAGE_FILE)1 PROP_LEFTCROP (org.csstudio.opibuilder.widgets.model.ImageModel.PROP_LEFTCROP)1 PROP_NO_ANIMATION (org.csstudio.opibuilder.widgets.model.ImageModel.PROP_NO_ANIMATION)1 PROP_RIGHTCROP (org.csstudio.opibuilder.widgets.model.ImageModel.PROP_RIGHTCROP)1