Search in sources :

Example 1 with PROP_ALIGN_TO_NEAREST_SECOND

use of org.csstudio.opibuilder.widgets.model.ImageModel.PROP_ALIGN_TO_NEAREST_SECOND in project yamcs-studio by yamcs.

the class ImageEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    setPropertyChangeHandler(PROP_IMAGE_FILE, (oldValue, newValue, figure) -> {
        var imageFigure = (ImageFigure) figure;
        var absolutePath = (String) newValue;
        if (!absolutePath.contains("://")) {
            var path = Path.fromPortableString(absolutePath);
            if (!path.isAbsolute()) {
                path = ResourceUtil.buildAbsolutePath(getWidgetModel(), path);
                absolutePath = path.toPortableString();
            }
        }
        imageFigure.setFilePath(absolutePath);
        autoSizeWidget(imageFigure);
        return false;
    });
    setPropertyChangeHandler(PROP_STRETCH, (oldValue, newValue, figure) -> {
        var imageFigure = (ImageFigure) figure;
        imageFigure.setStretch((Boolean) newValue);
        autoSizeWidget(imageFigure);
        return false;
    });
    setPropertyChangeHandler(PROP_AUTOSIZE, (oldValue, newValue, figure) -> {
        var imageFigure = (ImageFigure) figure;
        imageFigure.setAutoSize((Boolean) newValue);
        var model = (ImageModel) getModel();
        var d = imageFigure.getAutoSizedDimension();
        if ((Boolean) newValue && !model.getStretch() && d != null) {
            model.setSize(d.width, d.height);
        }
        return false;
    });
    setPropertyChangeHandler(PROP_NO_ANIMATION, (oldValue, newValue, figure) -> {
        var imageFigure = (ImageFigure) figure;
        imageFigure.setAnimationDisabled((Boolean) newValue);
        return false;
    });
    setPropertyChangeHandler(PROP_ALIGN_TO_NEAREST_SECOND, (oldValue, newValue, figure) -> {
        var imageFigure = (ImageFigure) figure;
        imageFigure.setAlignedToNearestSecond((Boolean) newValue);
        return false;
    });
    // changes to the border width property
    IWidgetPropertyChangeHandler handle = (oldValue, newValue, figure) -> {
        var imageFigure = (ImageFigure) figure;
        imageFigure.resizeImage();
        autoSizeWidget(imageFigure);
        return false;
    };
    setPropertyChangeHandler(PROP_BORDER_WIDTH, handle);
    setPropertyChangeHandler(PROP_BORDER_STYLE, handle);
    // size change handlers - so we can stretch accordingly
    handle = (oldValue, newValue, figure) -> {
        var imageFigure = (ImageFigure) figure;
        imageFigure.resizeImage();
        autoSizeWidget(imageFigure);
        return false;
    };
    setPropertyChangeHandler(PROP_HEIGHT, handle);
    setPropertyChangeHandler(PROP_WIDTH, handle);
    FigureTransparencyHelper.addHandler(this, figure);
    registerCropPropertyHandlers();
    registerImageRotationPropertyHandlers();
}
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) ImageModel(org.csstudio.opibuilder.widgets.model.ImageModel)

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