Bug when Adding anchors to ConnectionDecorators [message #1736184] |
Mon, 27 June 2016 11:28 |
Roel Heirman 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 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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03948 seconds