use of org.csstudio.opibuilder.widgets.model.ImageBoolButtonModel in project yamcs-studio by yamcs.
the class ImageBoolButtonEditPart 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;
}
ImageBoolButtonModel model = getWidgetModel();
Dimension d = imageFigure.getAutoSizedDimension();
if (model.isAutoSize() && !model.isStretch() && d != null)
model.setSize(d.width, d.height);
}
};
Display.getDefault().timerExec(100, task);
}
use of org.csstudio.opibuilder.widgets.model.ImageBoolButtonModel in project yamcs-studio by yamcs.
the class ImageBoolButtonEditPart method doCreateFigure.
/**
* {@inheritDoc}
*/
@Override
protected IFigure doCreateFigure() {
ImageBoolButtonModel model = getWidgetModel();
// create AND initialize the view properly
final ImageBoolButtonFigure figure = new ImageBoolButtonFigure();
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.addManualValueChangeListener(new IManualValueChangeListener() {
@Override
public void manualValueChanged(double newValue) {
if (getExecutionMode() == ExecutionMode.RUN_MODE)
autoSizeWidget(figure);
}
});
figure.setOnImagePath(model.getOnImagePath());
figure.setOffImagePath(model.getOffImagePath());
return figure;
}
Aggregations