Recalculating ports on GoIconicNode

Hi,



I created a method that puts the nodes in a circular shape. This works fine, but when I call the treelayout method and afterwards my cirlcular method the links are messed up. It seems that my method uses the same ports the treelayout definde it.

Is it possible to let the node recalculate the ports?

Here is the layout method I used:





private void DoCircularLayout()

{

GoLayoutNetwork layout = new GoLayoutNetwork(diagramView.Document);

diagramView.Document.StartTransaction();



int nrNodes = layout.NodeCount;

int i=0;

float radius = 150;

if(diagramView.Width.Value < diagramView.Height.Value)

radius = (float)((diagramView.Width.Value /4) );

else

radius = (float)((diagramView.Height.Value /4));



float midPointx = (float)diagramView.Width.Value/2;

float midPointy = (float)diagramView.Height.Value/2;



double angle = 360.0/nrNodes;

foreach(GoLayoutNetworkNode node in layout.Nodes)

{

node.Center = new PointF(midPointx + radius * (float)Math.Cos(i * angle * Math.PI / 180), midPointy + radius * (float)Math.Sin(i * angle * Math.PI / 180));

node.CommitPosition();

i++;

}



diagramView.RescaleToFit();

//diagramView.RescaleToFit();

diagramView.Document.FinishTransaction(“CircularLayout”);

}

That looks pretty similar to http://www.nwoods.com/forum/forum_posts.asp?TID=44.

By default GoLayoutTree also sets the GoPort.FromSpot and GoPort.ToSpot properties of the (single) ports on the nodes. When you do your circular layout, you can reset both properties to be GoObject.NoSpot on each GoPort.

Thanks it works. And that method is indeed based upon the example you provided.