Manual layout

Hi,
It’s been a while since I’ve looked at the JGO APIs…
We have a small issue with some of the side-effects of the layout managers…In the past we have customized to ensure existing columns do not switch (following addition of a new node), but there remains problems (like having to live with “extended” branches rather than a more natural tree) [please see my previous posts].
So I’m now considering writing my own layout logic. The underlying business rules are fairly straightforward…but the JGo APIs don’t seem to support “simple” assignment of node position in a grid-like layout (specifying node position by row and column position).
Can you supply an example of how I specify node position (x,y)?
We’re still on Jgo 5.0.
Thanks.
Mike

If you know how large each grid cell is, you can just multiply the X and Y appropriately and call JGoObject.setTopLeft or JGoObject.setLocation, depending on whether you want to set the top-left corner or the object’s natural spot to be at that Point.
You might find the grid methods of JGoView useful.

That seems to be working well…the positioning of nodes are now determined by my layout code…
I have one outstanding problem…
My layout logic is driven by one set of relationships, which are instantiated as links between nodes.
There is also a seconday set of relationships which do not define node position. I want to create links for these relationships and route the links “cleanly”, without affecting my pre-determined node position.
Is there a way that I can modify the layout manager to route links in this manner?

Are you using Orthogonal links? If so, you could try setting JGoLink.setAvoidsNodes(true). You might need to iterate over all of the links to call JGoLink.calculateStroke(), after having placed all of the nodes.

We weren’t using orthogonal link. I tried using them for the secondary
relationships. Kinda works…but I then run into problems if there is
more than one relationship to the same node…the links always end up
running on top of each other - making selection of the link impossible.

Unless there’s a way to disable that behaviour then I assume the only other way is to override calculateStrokes().

Do you have any example code that does this (the override)…I want to
get my seconday links to avoid overlapping (nodes and links), ideally
without having to make them orthogonal.

Search for calculateStroke method definitions. Including, of course, in JGoLink.java itself.