use of org.csstudio.opibuilder.widgets.figures.ImageFigure 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.csstudio.opibuilder.widgets.figures.ImageFigure 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.csstudio.opibuilder.widgets.figures.ImageFigure in project yamcs-studio by yamcs.
the class ImageEditPart method registerCropPropertyHandlers.
/**
* Register change handlers for the four crop properties.
*/
protected void registerCropPropertyHandlers() {
// top
IWidgetPropertyChangeHandler handle = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
ImageFigure imageFigure = (ImageFigure) figure;
imageFigure.setTopCrop((Integer) newValue);
autoSizeWidget(imageFigure);
return false;
}
};
setPropertyChangeHandler(ImageModel.PROP_TOPCROP, handle);
// bottom
handle = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
ImageFigure imageFigure = (ImageFigure) figure;
imageFigure.setBottomCrop((Integer) newValue);
autoSizeWidget(imageFigure);
return false;
}
};
setPropertyChangeHandler(ImageModel.PROP_BOTTOMCROP, handle);
// left
handle = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
ImageFigure imageFigure = (ImageFigure) figure;
imageFigure.setLeftCrop((Integer) newValue);
autoSizeWidget(imageFigure);
return false;
}
};
setPropertyChangeHandler(ImageModel.PROP_LEFTCROP, handle);
// right
handle = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
ImageFigure imageFigure = (ImageFigure) figure;
imageFigure.setRightCrop((Integer) newValue);
autoSizeWidget(imageFigure);
return false;
}
};
setPropertyChangeHandler(ImageModel.PROP_RIGHTCROP, handle);
}
use of org.csstudio.opibuilder.widgets.figures.ImageFigure in project yamcs-studio by yamcs.
the class ImageEditPart method registerImageRotationPropertyHandlers.
/**
* Registers image rotation property change handlers for the properties defined in {@link MonitorBoolSymbolModel}.
*/
public void registerImageRotationPropertyHandlers() {
// degree rotation property
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
if (oldValue == null || newValue == null)
return false;
ImageFigure imageFigure = (ImageFigure) figure;
int newDegree = getWidgetModel().getDegree((Integer) newValue);
int oldDegree = getWidgetModel().getDegree((Integer) oldValue);
PermutationMatrix oldMatrix = new PermutationMatrix((double[][]) getPropertyValue(ImageModel.PERMUTATION_MATRIX));
PermutationMatrix newMatrix = PermutationMatrix.generateRotationMatrix(newDegree - oldDegree);
PermutationMatrix result = newMatrix.multiply(oldMatrix);
// As we use only % Pi/2 angles, we can round to integer values
// => equals work better
result.roundToIntegers();
setPropertyValue(ImageModel.PERMUTATION_MATRIX, result.getMatrix());
setPropertyValue(ImageModel.PROP_DEGREE, (Integer) newValue);
imageFigure.setPermutationMatrix(result);
autoSizeWidget(imageFigure);
return false;
}
};
setPropertyChangeHandler(ImageModel.PROP_DEGREE, handler);
// flip horizontal rotation property
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
if (oldValue == null || newValue == null)
return false;
ImageFigure imageFigure = (ImageFigure) figure;
// imageFigure.setFlipH((Boolean) newValue);
PermutationMatrix newMatrix = PermutationMatrix.generateFlipHMatrix();
PermutationMatrix oldMatrix = imageFigure.getPermutationMatrix();
PermutationMatrix result = newMatrix.multiply(oldMatrix);
// As we use only % Pi/2 angles, we can round to integer values
// => equals work better
result.roundToIntegers();
setPropertyValue(ImageModel.PERMUTATION_MATRIX, result.getMatrix());
setPropertyValue(ImageModel.PROP_FLIP_HORIZONTAL, (Boolean) newValue);
imageFigure.setPermutationMatrix(result);
autoSizeWidget(imageFigure);
return false;
}
};
setPropertyChangeHandler(ImageModel.PROP_FLIP_HORIZONTAL, handler);
// flip vertical rotation property
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
if (oldValue == null || newValue == null)
return false;
ImageFigure imageFigure = (ImageFigure) figure;
// imageFigure.setFlipV((Boolean) newValue);
PermutationMatrix newMatrix = PermutationMatrix.generateFlipVMatrix();
PermutationMatrix oldMatrix = imageFigure.getPermutationMatrix();
PermutationMatrix result = newMatrix.multiply(oldMatrix);
// As we use only % Pi/2 angles, we can round to integer values
// => equals work better
result.roundToIntegers();
setPropertyValue(ImageModel.PERMUTATION_MATRIX, result.getMatrix());
setPropertyValue(ImageModel.PROP_FLIP_VERTICAL, (Boolean) newValue);
imageFigure.setPermutationMatrix(result);
autoSizeWidget(imageFigure);
return false;
}
};
setPropertyChangeHandler(ImageModel.PROP_FLIP_VERTICAL, handler);
}
Aggregations