Auto Layout from a specified node

Hello,

I’m wondering if I can have a layout align all nodes connected to a
particular node lined up in a column to one side of the node.

Pardon my terminology, I’m new to all this, but what I’m looking to do
eventually is add a context menu to a node that will allow someone to
select it (say something like “arrange nodes”) and have all the
children nodes of that particular node line up in a column to the right
of the selected node… Does that make sense?

Is there a way that I can go about accomplishing this?

Thanks,
Mike

GoNode selectedNode = goView1.Selection.Primary as GoNode;
if (selectedNode != null) {
float y = selectedNode.Top;
foreach (IGoNode n in selectedNode.Destinations) {
n.GoObject.Position = new PointF(selectedNode.Right + 30, y);
y += n.GoObject.Height + 10;
}
}
Of course you can adjust the 30 and 10 constants as you see fit, and you might want to get/set the Location instead of the Position of the nodes.

Thanks very much… that code snipped helped with my next question too… Greatly appreciated!

Mike

Is there a way, using this, to determine the number of children of the particular node prior to enumerating through them?

What I want to do is have the children blow out directly to the right,
but the column vert. centered on the parent node. I can calculate
this but I cannot seem to figure out how to get a count of the items
in .Destinations

Thanks,
Mike

No, you need to iterate over them to count them.
Actually, in the general case you’ll want to do that anyway, so you can add up the heights of each node, unless you can be sure they are all the same height.

A brute force method of copying all objects from one layer and linkslayer to a new GoDocument for running an auto-layout on and then re-adjusting each object and link in the original document to the coordinates of the new layed out GoDocument.
This could then be done on each layer or all layers the user wants to be auto-layed out.