GoLayout and GoShape objects


#1

Is there a way to have one of the GoLayout derived classes also layout objects other than Nodes and Links?


#2

As a practical matter, no, although there are probably cases where you could make it work, such as with force-directed. But I’m not sure anyone has tested this.
That shouldn’t be an impediment to doing what you want, though.


#3
Can you elaborate a little more on using the force-directed method then. I'm not sure where to start at so a pointer would be great.

#4
Let me explain a little further what I'm trying to accomplish. Maybe then you can point me in the right direction.
I have several GoIconicNodes in a document (they may or may not have links). I also have a shape object in the document. When the shape object was created it was given a list of nodes it should contain, or nodes that should appear inside of this shape.
I would like the shape object to automically move and resize based on the final results of the autolayout on the node objects. So, I would like the shape object, in the end, to be displayed, and all of the nodes that belong to it to be layed out inside of it.
Will auto layout work for this? I'm getting the type of layout I want with the GoLayoutLayeredDigraph, but I need to handle this placement of shape objects.
Thanks!

#5

OK, so you want to do the regular autolayout, and then in the background fit some shapes to surround some of those nodes.
If you can identify the collection of nodes that you want to gather together inside one shape, you can determine the rectangular area needed to cover them all by using the GoDocument.ComputeBounds method.
That’s just fine for rectangular shapes, and you can adjust for similar shapes such as hexagons, diamonds, and ellipses, but if your shapes want to be irregular, that will be more difficult to code. And you’ll need to worry about overlaps between those shapes.