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;
}
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);
}
Aggregations