Merging nodes


#1

Hi
In my application, I want to be able to merge nodes into a parent node, eg a diagram of people may include a person and some aliases. Thus only one node should be displayed and all of the links of the merged nodes should appear attached to it.
Is there an easy way to have this done?
I was thinking about hiding the merged nodes and then tracking any layout changes to ensure they are always under the parent, but this seems a lot of effort to go to.


#2

Is there some reason that you couldn’t use a GoSubGraph? Or do you need to select one of the existing nodes as the main node representing all of them?
But you could do what you suggest–that doesn’t sound like a lot of work.
Not exactly what you want, but you might find the following kind of node useful. You might conditionally use the LayoutChildren code in your own node instead.
[Serializable]
public class CoalescingNode : GoNode {
public CoalescingNode() {}
public override void LayoutChildren(GoObject childchanged) {
float maxw = 0;
float maxh = 0;
foreach (GoObject x in this) {
if (x.Width > maxw) maxw = x.Width;
if (x.Height > maxh) maxh = x.Height;
}
PointF c = new PointF(this.Left + maxw/2, this.Top + maxh/2);
foreach (GoObject x in this) {
x.Center = c;
}
}
}
To use this, add an instance of a CoalescingNode to your document, call AddCollection with the collection of nodes you want to add to this CoalescingNode, and then decide which child should stay Visible, and make the rest not Visible.
Caveat: I’m just a monkey typing at random.