Search in sources :

Example 96 with IFigure

use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.

the class ImageBoolIndicatorEditPart method registerPropertyChangeHandlers.

/**
 * {@inheritDoc}
 */
@Override
protected void registerPropertyChangeHandlers() {
    registerCommonPropertyChangeHandlers();
    // Don't autosize to save CPU usage
    // removeAllPropertyChangeHandlers(AbstractPVWidgetModel.PROP_PVVALUE);
    // value
    // IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
    // public boolean handleChange(final Object oldValue,
    // final Object newValue,
    // final IFigure refreshableFigure) {
    // if(newValue == null)
    // return false;
    // ImageBoolButtonFigure figure = (ImageBoolButtonFigure) refreshableFigure;
    // //                autoSizeWidget(figure);
    // return true;
    // }
    // };
    // setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVVALUE, handler);
    // changes to the on image property
    IWidgetPropertyChangeHandler handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            IPath absolutePath = (IPath) newValue;
            if (!absolutePath.isAbsolute())
                absolutePath = ResourceUtil.buildAbsolutePath(getWidgetModel(), absolutePath);
            imageFigure.setOnImagePath(absolutePath);
            autoSizeWidget(imageFigure);
            return true;
        }
    };
    setPropertyChangeHandler(ImageBoolIndicatorModel.PROP_ON_IMAGE, handle);
    // changes to the off image property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            IPath absolutePath = (IPath) newValue;
            if (!absolutePath.isAbsolute())
                absolutePath = ResourceUtil.buildAbsolutePath(getWidgetModel(), absolutePath);
            imageFigure.setOffImagePath(absolutePath);
            autoSizeWidget(imageFigure);
            return true;
        }
    };
    setPropertyChangeHandler(ImageBoolIndicatorModel.PROP_OFF_IMAGE, handle);
    // changes to the stretch property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            imageFigure.setStretch((Boolean) newValue);
            autoSizeWidget(imageFigure);
            return true;
        }
    };
    setPropertyChangeHandler(ImageBoolIndicatorModel.PROP_STRETCH, handle);
    // changes to the autosize property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            autoSizeWidget(imageFigure);
            return true;
        }
    };
    setPropertyChangeHandler(ImageBoolIndicatorModel.PROP_AUTOSIZE, handle);
    // changes to the stop animation property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            imageFigure.setAnimationDisabled((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ImageBoolIndicatorModel.PROP_NO_ANIMATION, handle);
    // changes to the align to nearest second property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            imageFigure.setAlignedToNearestSecond((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ImageBoolIndicatorModel.PROP_ALIGN_TO_NEAREST_SECOND, handle);
    // changes to the border width property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            autoSizeWidget(imageFigure);
            return true;
        }
    };
    setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_WIDTH, handle);
    setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_STYLE, handle);
    // size change handlers - so we can stretch accordingly
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            autoSizeWidget(imageFigure);
            return true;
        }
    };
    setPropertyChangeHandler(AbstractWidgetModel.PROP_HEIGHT, handle);
    setPropertyChangeHandler(AbstractWidgetModel.PROP_WIDTH, handle);
    FigureTransparencyHelper.addHandler(this, figure);
}
Also used : IPath(org.eclipse.core.runtime.IPath) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) ImageBoolButtonFigure(org.csstudio.opibuilder.widgets.figures.ImageBoolButtonFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 97 with IFigure

use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.

the class ImageBoolIndicatorEditPart method doCreateFigure.

/**
 * {@inheritDoc}
 */
@Override
protected IFigure doCreateFigure() {
    ImageBoolIndicatorModel model = getWidgetModel();
    // create AND initialize the view properly
    final ImageBoolButtonFigure figure = new ImageBoolButtonFigure(true);
    initializeCommonFigureProperties(figure, model);
    SymbolImageProperties sip = new SymbolImageProperties();
    sip.setStretch(model.isStretch());
    sip.setAutoSize(model.isAutoSize());
    sip.setAnimationDisabled(model.isStopAnimation());
    sip.setAlignedToNearestSecond(model.isAlignedToNearestSecond());
    sip.setBackgroundColor(new Color(Display.getDefault(), model.getBackgroundColor()));
    figure.setSymbolProperties(sip, model);
    figure.setImageLoadedListener(new IImageListener() {

        @Override
        public void imageResized(IFigure figure) {
            ImageBoolButtonFigure symbolFigure = (ImageBoolButtonFigure) figure;
            autoSizeWidget(symbolFigure);
        }
    });
    figure.setOnImagePath(model.getOnImagePath());
    figure.setOffImagePath(model.getOffImagePath());
    return figure;
}
Also used : SymbolImageProperties(org.csstudio.swt.widgets.symbol.SymbolImageProperties) ImageBoolIndicatorModel(org.csstudio.opibuilder.widgets.model.ImageBoolIndicatorModel) Color(org.eclipse.swt.graphics.Color) ImageBoolButtonFigure(org.csstudio.opibuilder.widgets.figures.ImageBoolButtonFigure) IImageListener(org.csstudio.swt.widgets.symbol.util.IImageListener) IFigure(org.eclipse.draw2d.IFigure)

Example 98 with IFigure

use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.

the class ImageEditPart method registerPropertyChangeHandlers.

/**
 * {@inheritDoc}
 */
@Override
protected void registerPropertyChangeHandlers() {
    // changes to the filename property
    IWidgetPropertyChangeHandler handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageFigure imageFigure = (ImageFigure) figure;
            IPath absolutePath = (IPath) newValue;
            if (!absolutePath.isAbsolute())
                absolutePath = ResourceUtil.buildAbsolutePath(getWidgetModel(), absolutePath);
            imageFigure.setFilePath(absolutePath);
            autoSizeWidget(imageFigure);
            return false;
        }
    };
    setPropertyChangeHandler(ImageModel.PROP_IMAGE_FILE, handle);
    // changes to the stretch property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageFigure imageFigure = (ImageFigure) figure;
            imageFigure.setStretch((Boolean) newValue);
            autoSizeWidget(imageFigure);
            return false;
        }
    };
    setPropertyChangeHandler(ImageModel.PROP_STRETCH, handle);
    // changes to the autosize property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageFigure imageFigure = (ImageFigure) figure;
            imageFigure.setAutoSize((Boolean) newValue);
            ImageModel model = (ImageModel) getModel();
            Dimension d = imageFigure.getAutoSizedDimension();
            if ((Boolean) newValue && !model.getStretch() && d != null)
                model.setSize(d.width, d.height);
            return false;
        }
    };
    setPropertyChangeHandler(ImageModel.PROP_AUTOSIZE, handle);
    // changes to the stop animation property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageFigure imageFigure = (ImageFigure) figure;
            imageFigure.setAnimationDisabled((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ImageModel.PROP_NO_ANIMATION, handle);
    // changes to the align to nearest second property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageFigure imageFigure = (ImageFigure) figure;
            imageFigure.setAlignedToNearestSecond((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ImageModel.PROP_ALIGN_TO_NEAREST_SECOND, handle);
    // changes to the border width property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageFigure imageFigure = (ImageFigure) figure;
            imageFigure.resizeImage();
            autoSizeWidget(imageFigure);
            return false;
        }
    };
    setPropertyChangeHandler(ImageModel.PROP_BORDER_WIDTH, handle);
    setPropertyChangeHandler(ImageModel.PROP_BORDER_STYLE, handle);
    // size change handlers - so we can stretch accordingly
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageFigure imageFigure = (ImageFigure) figure;
            imageFigure.resizeImage();
            autoSizeWidget(imageFigure);
            return false;
        }
    };
    setPropertyChangeHandler(ImageModel.PROP_HEIGHT, handle);
    setPropertyChangeHandler(ImageModel.PROP_WIDTH, handle);
    FigureTransparencyHelper.addHandler(this, figure);
    registerCropPropertyHandlers();
    registerImageRotationPropertyHandlers();
}
Also used : IPath(org.eclipse.core.runtime.IPath) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) ImageFigure(org.csstudio.opibuilder.widgets.figures.ImageFigure) Dimension(org.eclipse.draw2d.geometry.Dimension) ImageModel(org.csstudio.opibuilder.widgets.model.ImageModel) IFigure(org.eclipse.draw2d.IFigure)

Example 99 with IFigure

use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.

the class ImageEditPart method doCreateFigure.

/**
 * {@inheritDoc}
 */
@Override
protected IFigure doCreateFigure() {
    ImageModel model = getWidgetModel();
    // create AND initialize the view properly
    final ImageFigure figure = new ImageFigure();
    // Resize when new image is loaded
    figure.setImageLoadedListener(new IImageListener() {

        @Override
        public void imageResized(IFigure figure) {
            ImageFigure imageFigure = (ImageFigure) figure;
            autoSizeWidget(imageFigure);
        }
    });
    // Image default parameters
    SymbolImageProperties sip = new SymbolImageProperties();
    sip.setTopCrop(model.getTopCrop());
    sip.setBottomCrop(model.getBottomCrop());
    sip.setLeftCrop(model.getLeftCrop());
    sip.setRightCrop(model.getRightCrop());
    sip.setStretch(model.getStretch());
    sip.setAutoSize(model.isAutoSize());
    sip.setMatrix(model.getPermutationMatrix());
    sip.setAlignedToNearestSecond(model.isAlignedToNearestSecond());
    sip.setBackgroundColor(new Color(Display.getDefault(), model.getBackgroundColor()));
    sip.setAnimationDisabled(model.isStopAnimation());
    figure.setSymbolProperties(sip, model);
    figure.setFilePath(model.getFilename());
    return figure;
}
Also used : SymbolImageProperties(org.csstudio.swt.widgets.symbol.SymbolImageProperties) Color(org.eclipse.swt.graphics.Color) ImageFigure(org.csstudio.opibuilder.widgets.figures.ImageFigure) ImageModel(org.csstudio.opibuilder.widgets.model.ImageModel) IImageListener(org.csstudio.swt.widgets.symbol.util.IImageListener) IFigure(org.eclipse.draw2d.IFigure)

Example 100 with IFigure

use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.

the class IntensityGraphEditPart method registerROIPropertyChangeHandlers.

private void registerROIPropertyChangeHandlers() {
    for (int i = 0; i < IntensityGraphModel.MAX_ROIS_AMOUNT; i++) {
        final String roiName = getROIName(i);
        for (final ROIProperty roiProperty : ROIProperty.values()) {
            String propID = IntensityGraphModel.makeROIPropID(roiProperty.propIDPre, i);
            if (i >= (Integer) getPropertyValue(IntensityGraphModel.PROP_ROI_COUNT)) {
                getWidgetModel().setPropertyVisible(propID, false);
            }
            setPropertyChangeHandler(propID, new IWidgetPropertyChangeHandler() {

                @Override
                public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
                    setROIProperty(roiName, roiProperty, newValue);
                    return false;
                }
            });
        }
    }
}
Also used : ROIProperty(org.csstudio.opibuilder.widgets.model.IntensityGraphModel.ROIProperty) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

IFigure (org.eclipse.draw2d.IFigure)225 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)61 Rectangle (org.eclipse.draw2d.geometry.Rectangle)42 Point (org.eclipse.draw2d.geometry.Point)36 Dimension (org.eclipse.draw2d.geometry.Dimension)30 PropertyChangeEvent (java.beans.PropertyChangeEvent)25 PropertyChangeListener (java.beans.PropertyChangeListener)25 List (java.util.List)20 Figure (org.eclipse.draw2d.Figure)17 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)13 DefaultSizeNodeFigure (org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure)12 NodeFigure (org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure)12 StackLayout (org.eclipse.draw2d.StackLayout)11 Iterator (java.util.Iterator)10 VType (org.diirt.vtype.VType)10 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)9 OPIColor (org.csstudio.opibuilder.util.OPIColor)9 EditPart (org.eclipse.gef.EditPart)9 ArrayList (java.util.ArrayList)7 Label (org.eclipse.draw2d.Label)7