More overlapping links

Hello,

I am having some more problems with links overlapping. In this case, we have a dialog that allows us to select what types of links should be visible in the view.

The first screenshot is when links of type ‘A’ are displayed:


The next screenshot is when links of type ‘B’ are displayed:


And the final image is when they are both displayed:


Note the links between ‘Business Units’ and ‘An Example Business Unit’ are overlapping.

Basically when the user modifies their preferences, we iterate over each node and call deleteAllLinks();

Then we construct links and add to the document as follows:

TooltipLink link = new TooltipLink();
link.setArrowHeads(arrowFrom, arrowTo);
link.setSelectable(selectable);
link.setRelinkable(relinkable);
link.setAdjustingStyle(JGoLink.AdjustingStyleStretch);
link.setToolTipText(title);
link.setPen(pen);
link.setBrush(brush);
link.setToPort(toPort);
link.setFromPort(fromPort);

document.addObjectAtHead(link);

We also observe this behaviour with a custom layout that i wrote that basically places nodes in absolute positions as saved previously.

Any ideas how i can make the links not overlap like that? If i do a digraph layout they separate fine.

regards,
Paul.

The natural thing to do is to make each link be curved differently.
So call JGoLink.setCubic(true) for all of your links. Then iterate over all the links connected to each node, in either direction. Call JGoLink.setCurviness with different values (say multiples of 10) for each of the links that connect to the same node. A Curviness value of zero results in a straight line. A negative value causes it to curve in the opposite direction.
Although the BasicApp sample doesn’t permit interactively drawing “duplicate” links from one node to another node, it demonstrates what I’m talking about when you have a link going from A to B and another link going from B to A.
Then imagine that when there’s a second link from A to B, it has a curviness of 20. A third link from A to B would have a curviness of 30. A second link from B to A would have a curviness of 20. This would ensure that no links would be coincident, unless both nodes/ports were.