Prevent bends in links during layout?

Hi, all.

I am using the Layered Digraph auto layout. I would like to be able to prevent it from ever putting bends in a link line.
Is there any way to do that?
Cheers,
Brian

There are a couple of options. You could override JGoLayeredDigraphAutoLayout.layoutLinks() to not insert the bend points.

But an easier solution would probably be to just itereate through the network of nodes after calling performLayout. For every link, call JGoLink.calculateStroke(), something like the following:
JGoDocument doc = goView.getDocument();
for (JGoListPosition pos = doc.getFirstObjectPos(); pos != null; pos = doc.getNextObjectPosAtTop(pos)) {
JGoObject obj = doc.getObjectAtPos(pos);
if (obj instanceof JGoLink) {
JGoLink link = (JGoLink)obj;
link.calculateStroke();
}
}
The above code will cause the normal link-routing algorithm to be called. Note that this might result in links crossing nodes in some cases.

Hi, Scott.

I used a variant of your easier solution. I had already overridden the Layered Digraph network and network node, so I also overrode the Layered Digraph network link. In commitPosition on the network link, I called calculateStroke() on the associated JGoObject after the normal commitPosition code fired.
This seems to work for removing the bends and I really appreciate the help.
On another tack, I was hoping there would be a solution where the layout algorithm could be told not to use bends so that it would then optimize the link paths knowing that they cannot have any bends. I don't supposed there is any way to do this?
Cheers,
Brian

There’s no built-in option to the Layered Digraph layout class to do this. The layoutLinks() method of JGoLayeredDigraphAutoLayout occurs at the very end of the layout algorithm and it is the place where the bend points are currently added. As I mentioned in my earlier response, you could override this method to not add the bend points, but it would have no other effect on the layout, so the result would be the same as the results you’re currently getting.