Link drawing problem

I’m having a problem where links between nodes are not getting drawn correctly.
I’ve created a rather large directed graph (1000 nodes) and am using JGoLabeledLink to connect the nodes in the graph. When I view my JGoDocument through a JGoView, most of the links are all routed incorrectly… some link are correct, others are being terminated to empty places in my viewer where there is no JGoNode.
The strange thing is that when I drag/move a JGoNode in the viewer, then the links are redrawn correctly.
How can I fix this?
Thank you,
Richard

Well, a couple of possibilities.
First: Have you turned on JGoDocument.setSuspendUpdates? Or overridden JGoLink.calculateStroke or JGoLink.portChange or JGoPort.portChange so that it does nothing sometimes?
Second: Are your links Orthogonal and AvoidsNodes?
The node-avoidance routing that happens for links only works after the link has been added to the document. Otherwise JGoLink.calculateStroke won’t know what nodes to avoid. So after adding a new link to the document, you need to call calculateStroke explicitly. This call is just needed for this case; there are other cases, such as loading a diagram from a file or database, where you do NOT want to have calculateStroke be called at all!

I do turn on setSuspendUpdates when building the directed graph (from a database), but I turn it off when finished. I commented out my call to setSuspendUpdates to see if that would fix the problem–unfortunately, it did not.
I am not over-riding any methods on JGoLink.
I did not have AvoidsNodes turned on, but I tried it both ways to see if that would have an impact, and unfortunately, it did not.
I also did not set the links to be Orthogonal. Again, I just tried to both ways to see if it fixes the problem… to no avail.
If this helps diagnose, here is my link Object that I use:

public class DagLink extends JGoLink{
public DagLink(JGoPort from, JGoPort to)
{
super(from,to);
super.setPen(DagParameters.normalLinkPen);
super.setArrowHeads(false, true);
super.setVisible(true);
}
}

…and here is how it gets loaded…

protected DagLink addLink(EdgeImpl impl)
{
DagNode fromNode = this.vertexToNodeMap.get(impl.getSourceVertex());
DagNode toNode = this.vertexToNodeMap.get(impl.getDestVertex());
DagLink l = new DagLink(fromNode.getOutputPort(),toNode.getInputPort());
this.dagDoc.addObjectAtTail(l);
return l;
}

…as I type this out, I think I solved the problem. I added my nodes, then added my links, and laid out my nodes. Switching the order to layout my nodes before adding links seemed to fix the problem…

My guess is that the order would not have mattered if you hadn’t called setSuspendUpdates(true).
Also, you don’t need to call setVisible(true). Maybe you were just trying different things.