Ellipsis shown in Text when using BoxRelativeAnchor [message #760264] |
Thu, 01 December 2011 17:32 |
Patrick Talbot Messages: 36 Registered: November 2011 |
Member |
|
|
Using Graphiti 0.8.1
I'm facing a weird issue when using BoxRelativeAnchor on a PictogramElement, that has this hierarchy:
ContainerShape
> Shape
>> Polyline
> Shape
>> Text
> ContainerShape
>> BoxRelativeAnchor
>>> Rectangle
>> Text
The text that has the BoxRelativeAnchor is showing ellipsis even though the width of the Text is more than sufficient to show the whole text...
See attached a capture of one shape (the main one contains many others, 'Column' in my EMF model) showing the issue and the BoxRelativeRectangle, then the same showing the text in DirectEdit mode, clearly showing that the text size is correct, and a capture of the hierarchy in the Outline view...
The code I use in my IAddFeature implementation looks like this:
public PictogramElement add(IAddContext context) {
final Column column = (Column) context.getNewObject();
Shape target = context.getTargetContainer();
Object object = getBusinessObjectForPictogramElement(target);
ContainerShape containerShape = (ContainerShape) ((object instanceof Column) ? target.getContainer() : target);
int width = target.getGraphicsAlgorithm().getWidth();
// CONTAINER SHAPE WITH ROUNDED RECTANGLE
IPeCreateService peCreateService = Graphiti.getPeCreateService();
IGaService gaService = Graphiti.getGaService();
int index = containerShape.getChildren().size() -1;
// create shape for text
ContainerShape shape = peCreateService.createContainerShape(containerShape,true);
PropertyUtil.setTextBoxShape(shape);
shape.setVisible(true);
containerShape.getChildren().add(shape);
// create and set text graphics algorithm
Text text = gaService.createDefaultText(getDiagram(), shape,
column.getIdentifier());
PropertyUtil.setColumnText(text);
if (column.isPk()) {
text.setStyle(StyleUtil.getStyleForPKClassText(getDiagram()));
} else {
if (column.isAllowNull()) {
text.setStyle(StyleUtil.getStyleForNullableClassText(getDiagram()));
} else {
text.setStyle(StyleUtil.getStyleForEClassText(getDiagram()));
}
}
text.setHorizontalAlignment(Orientation.ALIGNMENT_LEFT);
text.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
gaService.setLocationAndSize(text, 3, index*16, width-6, 16);
// create link and wire it
link(shape, column);
if (!Preferences.getInstance().isReadOnly()) {
// provide information to support direct-editing directly
// after object creation (must be activated additionally)
IDirectEditingInfo directEditingInfo =
getFeatureProvider().getDirectEditingInfo();
// set container shape for direct editing after object creation
directEditingInfo.setMainPictogramElement(shape);
// set shape and graphics algorithm where the editor for
// direct editing shall be opened after object creation
directEditingInfo.setPictogramElement(shape);
directEditingInfo.setGraphicsAlgorithm(text);
}
// add a chopbox anchor to the shape
// peCreateService.createChopboxAnchor(shape);
BoxRelativeAnchor anchor = peCreateService.createBoxRelativeAnchor(shape);
PropertyUtil.setAnchorRight(anchor);
anchor.setRelativeHeight(0.5);
anchor.setRelativeWidth(1.0);
anchor.setVisible(false);
anchor.setReferencedGraphicsAlgorithm(text);
Rectangle rect = gaService.createRectangle(anchor);
rect.setFilled(false);
rect.setLineVisible(false);
gaService.setLocationAndSize(rect, 0, 0, 1, 1);
layoutPictogramElement(containerShape);
return containerShape;
}
The text displays fine if I use a ChopBoxAnchor, or if I use setRelativeWidth(0.0) - putting the anchor on the left side, but as soon as I put it on the right side, the text shows the ellipsis...
Anyone would know what I'm doing wrong?
Thanks for your help,
-Patrick
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04057 seconds