Search in sources :

Example 1 with ImageBoolIndicatorModel

use of org.csstudio.opibuilder.widgets.model.ImageBoolIndicatorModel 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 2 with ImageBoolIndicatorModel

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

the class ImageBoolIndicatorEditPart method autoSizeWidget.

private void autoSizeWidget(final ImageBoolButtonFigure imageFigure) {
    if (!getWidgetModel().isAutoSize())
        return;
    maxAttempts = 10;
    Runnable task = new Runnable() {

        @Override
        public void run() {
            if (maxAttempts-- > 0 && imageFigure.isLoadingImage()) {
                Display.getDefault().timerExec(100, this);
                return;
            }
            ImageBoolIndicatorModel model = getWidgetModel();
            Dimension d = imageFigure.getAutoSizedDimension();
            if (model.isAutoSize() && !model.isStretch() && d != null)
                model.setSize(d.width, d.height);
        }
    };
    Display.getDefault().timerExec(100, task);
}
Also used : ImageBoolIndicatorModel(org.csstudio.opibuilder.widgets.model.ImageBoolIndicatorModel) Dimension(org.eclipse.draw2d.geometry.Dimension)

Aggregations

ImageBoolIndicatorModel (org.csstudio.opibuilder.widgets.model.ImageBoolIndicatorModel)2 ImageBoolButtonFigure (org.csstudio.opibuilder.widgets.figures.ImageBoolButtonFigure)1 SymbolImageProperties (org.csstudio.swt.widgets.symbol.SymbolImageProperties)1 IImageListener (org.csstudio.swt.widgets.symbol.util.IImageListener)1 IFigure (org.eclipse.draw2d.IFigure)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1 Color (org.eclipse.swt.graphics.Color)1