GoDiagram 2.2.1 SubGraph Content Layout


I have a GoSubGraphs that have been added vertically to a GoListGroup.
The GoSubGraphs contain GoIconicNodes that I layout in a matrix.
Problem: when I attempt to set the positions of the GoIconicNodes for the matrix in the SubGraph
ie… GO.Position = new PointF(x,y);
GoPosition never accepts the new values and has a value which doesnt correspond to the PointF x and y that were specified…
Any ideas?
Joe Licata


Did you override LayoutChildren in your class that inherits from GoSubGraph, in order to automatically position those child iconic nodes?
That’s the natural thing to do, but the implementation has to be careful not to depend on the ever-shifting bounds of the subgraph while moving the children. This is discussed in the FAQ.
At the beginning of LayoutChildren, figure out the bounds for where the children should go, before actually moving any children. If your code isn’t naturally recursively re-entrant, you should protect it. Checking the GoObject.Initializing flag, by doing nothing if Initializing is true and then binding Initializing to true around layout code, is the most common way of doing that.
Here’s some code I found that does a vertical layout of the children in a subgraph:
public override void LayoutChildren(GoObject child) {
if (this.IsExpanded && !this.Initializing) {
this.Initializing = true;
GoObject first = null;
PointF pos = new PointF();
foreach (GoObject c in this) {
if (c is IGoNode) {
first = c;
pos = c.Position;
pos.X += c.Width/2;
pos.Y += c.Height;
foreach (GoObject c in this) {
if (c == first) continue;
if (c is IGoNode) {
c.SetSpotLocation(MiddleTop, pos);
pos.Y += c.Height;
this.Initializing = false;