Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Bug when Adding anchors to ConnectionDecorators
Bug when Adding anchors to ConnectionDecorators [message #1736184] Mon, 27 June 2016 11:28 Go to next message
Roel Heirman is currently offline Roel HeirmanFriend
Messages: 5
Registered: May 2016
Junior Member
In my project I want to support ConnectionDecorators implemented as polygons that are not filled. If i just create a connection with a polygon connectionDecorator in the middle, the line from the connection goes straight through the connectionDecorator, as shown in attachment 1. Although is this exprected behaviour, it is not what I want. What I want to achieve is that the line of the connection does not cross the connectionDecorator.

I'm currenty trying the following approach, but I can't get it to work. Say you have node 'a', and node 'b' and you want to create a connection between a and b, with a decorator 'd' in the middle. First you create an invisible connection between a and b, that has d as visible decorator in the middle. Then you create a visible connection between a and d, and a visible connection between d and b. To be able to add connections to decorator d, d should have anchors. When I was testing this approach, I could not attach the connection with the anchor of decorator d, while graphiti does seem to support adding anchors to decorators. The problem seems to be that Graphiti does not recognise the location of the anchor of d, as is shown in attachment 2.

This is the code i've written:

		//add the main connection
		connection.setStart(addConContext.getSourceAnchor());
		connection.setEnd(addConContext.getTargetAnchor());	
		connection.getGraphicsAlgorithm().setTransparency(1.0); //make main line invisible
		
		//create an anchor for the connectionDecorator
		ConnectionDecorator decorator =  connection.getConnectionDecorators().get(0);
		ChopboxAnchor anchor = Graphiti.getPeCreateService().createChopboxAnchor(decorator);

		Connection connection1 = Graphiti.getPeCreateService().createFreeFormConnection(getDiagram());
		Graphiti.getGaService().createPolyline(connection1);
		Connection connection2 = Graphiti.getPeCreateService().createFreeFormConnection(getDiagram());
		Graphiti.getGaService().createPolyline(connection2);
		
		//add the connection from a to d
		connection1.setStart(addConContext.getSourceAnchor());
		connection1.setEnd(anchor);
		
		//add the connection from d to b
		connection2.setStart(anchor);
		connection2.setEnd(addConContext.getTargetAnchor());


Anyone knows why this happens? Is it a bug or am I doing something wrong? Help would be greatly appreciated Smile If there is another approach to achieve the same thing as I wan't I'm also very interested.










[Updated on: Fri, 01 July 2016 20:41]

Report message to a moderator

Re: Bug when Adding anchors to ConnectionDecorators [message #1736943 is a reply to message #1736184] Mon, 04 July 2016 13:55 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Roel,

that is actually the expected behavior. All Graphiti connections are drawn on top of all other elements on the diagram. On the other hand anchors are only supported for shapes not for connection decorators.

I would suggest you create an intermediate shape with 2 anchors in the middle and connect your shapes from both ends. Working with the invisible connection behind will not help here.

HTH,
Michael
Re: Bug when Adding anchors to ConnectionDecorators [message #1737180 is a reply to message #1736943] Wed, 06 July 2016 08:56 Go to previous message
Roel Heirman is currently offline Roel HeirmanFriend
Messages: 5
Registered: May 2016
Junior Member
Michael,

Thanks for your reply. I guess that'll be the only option then. The disadvantage I see with that approach is that the shape meant as decorator will not move and rotate after one of the nodes is moved, like it would when using a real decorator. Maybe I can write some code to achieve the same.

Regards,
Roel
Previous Topic:How to Manually Update Graphiti RulerFigure
Next Topic:Save as ... Image, without editor
Goto Forum:
  


Current Time: Tue Oct 15 09:41:37 GMT 2024

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

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

Back to the top