Layout problem

Hi

I have a diagram with many unlinked GoNode in it. They are added by the document.Add(GoObject) method and would always be at (0,0). I’m wondering if there is any easy way or API to make these nodes to be laid automatically??

I just want to make them seperate away from each other and I don’t care how the layout is.



Cheers

Ken

public void TableLayout(GoDocument doc) {<BR>      doc.StartTransaction();<BR>      int nodes = 0;   // count the number of nodes<BR>      float maxw = 0;  // record the maximum node width and height<BR>      float maxh = 0;<BR>      foreach (GoObject obj in doc) {<BR>        if (obj is IGoNode) {<BR>          nodes++;<BR>          maxw = Math.Max(maxw, obj.Width);<BR>          maxh = Math.Max(maxh, obj.Height);<BR>        }<BR>      }<BR>      maxw += 20;  // provide for spacing between nodes<BR>      maxh += 20;<BR>      int sqrt = (int)Math.Ceiling(Math.Sqrt(nodes));<BR>      int i = 0;<BR>      int j = 0;<BR>      foreach (GoObject obj in doc) {<BR>        if (obj is IGoNode) {<BR>          obj.Position = new PointF(i*maxw, j*maxh);<BR>          i++;<BR>          if (i >= sqrt) {  // next row<BR>              i = 0;<BR>              j++;<BR>          }<BR>        }<BR>      }<BR>      doc.FinishTransaction("grid layout");<BR>    }<BR>

WOW… many thanks!! It really save me a lot of time!!