GoIconicNode and Autolayout

Hi
I have a diagram using GoSimpleNodes and when I use either GoLayoutForceDirected or GoLayoutLayeredDiagram it gets displayed OK.
I changed to using GoIconicNodes. When I now do either Layout method, the nodes get placed in the correct positions, but the links are not remaining ‘attached’ to the nodes. If I then select any node and then move it on the diagram, the its link will reattach back to the it and the other node it joins.
Any idea what may be wrong?

It seems to work fine for me, but I’m sure our programs are different.
Are you using a GoLink, a GoLabeledLink, or a subclass of one of them, to connect the nodes? What Style do the links have? Are they Orthogonal?

After playing around with link type and styles, I changed the code to use the newer 2.1 versions of Diagram and Layout and it now works.
I should have known to try the latest version!!

I’m curious–are your links Orthogonal? I believe that’s the only relevant change that was made for 2.1. Otherwise, I’m mystified why there would be a difference.

Oops… I spoke too soon!
I have been doing my own layouts of diagrams and the same thing happens.
I.E. I set the nodes out into a circle and some of the links are displayed ‘detached’ from the node they belong to. Again, if I move the effected mode (manually using the mouse as opposed to programaticly) the links reattach.
The links are not Orthogonal. i.e. the .Orthogonal property if left at default.
I can email you a bitmap of the ‘problem’ if you want to see it.
Thanks
Ian McVay

Also,
The ‘problem’ represents differently based on the starting config of the diagram.
So, for my diagram, I do an initial layout, then my circle layout -> three links are ‘disconnected’
If I do my initial layout, then golayeredlayout (which works ok) then circle layout -> one link is ‘disconnected’
Hope this makes sense.

If you are doing your own layout algorithm, then you might want to consider calling GoLink.CalculateStroke on each link afterwards.
I’m wondering if the problem is caused by the default CalculateStroke being called too “early”, which might result in a different layout than what you would get if you called CalculateStroke later. The reason is that some versions of CalculateStroke depend on the intermediate points of the stroke, and those might not yet be updated. This is particularly true when the AdjustingStyle is “End”.
Anyway, I can’t explain the behavior you see any other way, so I am suggesting calling CalculateStroke on all the affected links. Of course the layered-digraph autolayout can’t do that, because it really wants to specify the path of each link.

I am not ‘touching’ the links in the diagram so using calculatestroke could add a fair bit of overhead.
The problem should be easily reproducable. Create 5 nodes A to E. Link A to B,C,D,E and B to C.
layout the diagram using Golayoutlayereddiagram.
Then move the nodes into a circle using code like the following :
Private Sub CircleLayout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CircleLayout.Click
Dim newEntity As GoObject
Dim centre_x As Double
Dim centre_y As Double
Dim circle_radius As Double
Dim angle As Double
Dim node_counter As Integer
’ set the radius based on the number of nodes
circle_radius = 50
’ set the centre based on the radius
centre_x = 150
centre_y = 150
’ find the angle between each node
angle = 360 / 5
For node_counter = 1 To 5
newEntity = goView1.Document.FindNode(node_counter.ToString)
newEntity.Location = New PointF(centre_x + circle_radius * Math.Cos((node_counter - 1) * angle * Math.PI / 180), centre_y + circle_radius * Math.Sin((node_counter - 1) * angle * Math.PI / 180))
Next
’ goView1.Refresh()
End Sub

before:

afterwards:

public override void PerformLayout() {
if (this.Document == null)
throw new InvalidOperationException(“Must set the Document property to non-null”);
if (this.Network == null)
this.Network = new GoLayoutNetwork(this.Document);
RaiseProgress(0);
int num = this.Network.NodeCount;
int i = 0;
float radius = 150;
double angle = 360.0/num;
foreach (GoLayoutNetworkNode node in this.Network.Nodes) {
node.Center = new PointF(300 + radius * (float)Math.Cos(i * angle * Math.PI / 180),
300 + radius * (float)Math.Sin(i * angle * Math.PI / 180));
node.CommitPosition();
i++;
}
RaiseProgress(1);
}