Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Ellipsis shown in Text when using BoxRelativeAnchor
Ellipsis shown in Text when using BoxRelativeAnchor [message #760264] Thu, 01 December 2011 17:32 Go to next message
Patrick Talbot is currently offline Patrick TalbotFriend
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
Re: Ellipsis shown in Text when using BoxRelativeAnchor [message #760672 is a reply to message #760264] Sun, 04 December 2011 05:03 Go to previous messageGo to next message
Maqsood Ahmed is currently offline Maqsood AhmedFriend
Messages: 41
Registered: September 2010
Member
Hi,
Try using MultiText instead of Text. Here currently Graphiti doesn't add ellipses even if your text exceeds the limit then it's chopped at the limit. You must manually manage ellipses in case you use it. However if this fits your usecase then it's worth a workaround Very Happy
Re: Ellipsis shown in Text when using BoxRelativeAnchor [message #760740 is a reply to message #760672] Mon, 05 December 2011 00:57 Go to previous messageGo to next message
Patrick Talbot is currently offline Patrick TalbotFriend
Messages: 36
Registered: November 2011
Member
That's a good one! Smile

Unfortunately it's even worse: I don't even see the text anymore!

Still I believe this is a bug.
Will file a report on bugzilla.

Thanks,
-Patrick
Re: Ellipsis shown in Text when using BoxRelativeAnchor [message #760744 is a reply to message #760740] Mon, 05 December 2011 02:45 Go to previous message
Patrick Talbot is currently offline Patrick TalbotFriend
Messages: 36
Registered: November 2011
Member
Buf report #365536 filed.
Previous Topic:Using CreateConnectionCommand
Next Topic:Moving Bendpoints
Goto Forum:
  


Current Time: Thu Dec 18 21:17:19 GMT 2014

Powered by FUDForum. Page generated in 0.01622 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software