use of org.csstudio.opibuilder.widgets.figures.ImageBoolButtonFigure 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);
}
use of org.csstudio.opibuilder.widgets.figures.ImageBoolButtonFigure 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.figures.ImageBoolButtonFigure 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;
}
use of org.csstudio.opibuilder.widgets.figures.ImageBoolButtonFigure in project yamcs-studio by yamcs.
the class ImageBoolButtonEditPart method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
// 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;
// //figure.setValue(ValueUtil.getDouble((IValue)newValue));
// 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(ImageBoolButtonModel.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(ImageBoolButtonModel.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(ImageBoolButtonModel.PROP_STRETCH, handle);
FigureTransparencyHelper.addHandler(this, figure);
// 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(ImageBoolButtonModel.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(ImageBoolButtonModel.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(ImageBoolButtonModel.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);
}
Aggregations