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