Class TreeLayout

GoDiagram®
v10.0.8
by Northwoods Software®

This layout positions nodes of a tree-structured graph in layers (rows or columns).

Namespace: Northwoods.Go.Layouts
Assembly: Northwoods.GoDiagram.WinForms.TreeLayout.dll
Syntax
public class TreeLayout : NetworkLayout<TreeNetwork, TreeVertex, TreeEdge, TreeLayout>
Remarks

For a discussion and examples of the most commonly used properties, see Trees page in the Introduction. If you want to experiment interactively with most of the properties, try the Tree Layout sample. See samples that make use of TreeLayout in the samples index.

This layout makes use of a Network<V, E, Y> of TreeVertexes and TreeEdges that normally correspond to the Nodes and Links of the Diagram.

The most commonly set properties for controlling the results of a TreeLayout are:

  • Angle: the direction in which the tree grows, from parent to child; the default value of zero means that the tree grows towards the right, with the children of a node arranged in a layer that is a column. An angle of 0 or 180 means that children form vertical layers -- breadth is height and depth is width; an angle of 90 or 270 means that children form horizontal layers -- breadth is width and depth is height.
  • LayerSpacing: the distance between layers -- between a parent node and its child nodes.
  • NodeSpacing: the distance between nodes within a layer -- between siblings.
  • Alignment: the relative position of a parent node with its children.
  • Sorting and Comparer: specify the order of the immediate children of a parent node.
  • Compaction: whether subtrees should be packed closer together if there is room.
  • LayerStyle: whether the children of one node are aligned with the children of a sibling node.
  • SetsPortSpot, PortSpot, SetsChildPortSpot, and ChildPortSpot: this controls whether to set the FromSpot and ToSpot to be sensible for the Angle.
  • NodeIndent and NodeIndentPastParent: if the Alignment is Start or End, control how much extra space the first child is given when positioned.
  • BreadthLimit, RowSpacing: try to limit the total breadth of a subtree to a certain distance; when there are too many children or when they are too broad, this puts children into additional rows (or columns, depending on the angle) thereby limiting the breadth while increasing the depth of the tree.

When you set one of the TreeLayout properties listed above, that property normally applies to all of the nodes in the tree. What if you want Alignment to be CenterChildren for the root node but Bus for the other nodes in the tree? Or what if you want want LayerSpacing to be 50 for all layers except for the layer separating "leaf" nodes from their parent?

One common solution is to set TreeStyle. For the former scenario, you could set TreeStyle to RootOnly; the value of Alignment would only apply to the root node. For the latter scenario, you could set it to LastParents; the value of LayerSpacing would apply to all nodes except those that have children but that do not have grandchildren. How do you then set the Alignment or LayerSpacing for the other nodes? By setting the TreeLayout properties whose names start with "Alternate...". In these cases that would mean setting AlternateAlignment or AlternateLayerSpacing.

These TreeLayout properties actually apply to the TreeVertex that the TreeLayout uses to represent a Node within the TreeNetwork. All of those TreeLayout properties are actually stored in RootDefaults; all of the "Alternate..." properties are stored in AlternateDefaults. Depending on the value of TreeStyle, the actual TreeVertex properties for each Node are copied appropriately from either RootDefaults or AlternateDefaults. In the default case where TreeStyle is Layered, the AlternateDefaults are ignored. (Note that TreeStyle, and a few other properties such as Path and Arrangement, apply to the whole layout, not to an individual node/vertex.)

The use of TreeStyle and "Alternate..." TreeLayout properties will cover a lot of common needs for tree layout customization. However, there may be times when that is not enough. Imagine a situation where you want a special TreeVertex property value for a particular Node. The solution is to override AssignTreeVertexValues(TreeVertex), where you can examine the given TreeVertex, including its corresponding Node, to decide what TreeVertex property values should apply.

Constructors

TreeLayout()

Constructs a TreeLayout with no Network and with no owning Diagram.

Declaration
public TreeLayout()

Properties

Alignment

Gets or sets the default alignment of parents relative to their children.

Declaration
public TreeAlignment Alignment { get; set; }
Property Value
Type Description
TreeAlignment
Remarks

Must be a value of TreeAlignment.

The default value is CenterChildren.

This sets the RootDefaults" property of the same name.

AlternateAlignment

Gets or sets the alternate alignment of parents relative to their children.

Declaration
public TreeAlignment AlternateAlignment { get; set; }
Property Value
Type Description
TreeAlignment
Remarks

Must be a value of TreeAlignment.

The default value is CenterChildren.

This sets the AlternateDefaults" property of the same name.

AlternateAngle

Gets or sets the alternate direction for tree growth.

Declaration
public double AlternateAngle { get; set; }
Property Value
Type Description
double
Remarks

The default value is 0; the value must be one of: 0, 90, 180, 270.

These values are in degrees, where 0 is along the positive X axis, and where 90 is along the positive Y axis.

This sets the AlternateDefaults" property of the same name.

AlternateBreadthLimit

Gets or sets an alternate limit on how broad a tree should be.

Declaration
public double AlternateBreadthLimit { get; set; }
Property Value
Type Description
double
Remarks

A value of zero (the default) means there is no limit; a positive value specifies a limit. The default value is zero.

This property is just a suggested constraint on how broadly the tree will be laid out. When there isn't enough breadth for all of the children of a node, the children are placed in as many rows as needed to try to stay within the given breadth limit. If the value is too small, since this layout algorithm does not modify the size or shape of any node, the nodes will just be laid out in a line, one per row, and the breadth is determined by the broadest node. The distance between rows is specified by AlternateRowSpacing. To make room for the links that go around earlier rows to get to later rows, when the alignment is not a "center" alignment, the AlternateRowIndent property specifies that space at the start of each row.

This sets the AlternateDefaults" property of the same name.

AlternateChildPortSpot

Gets or sets the alternate spot that children nodes' ports get as their ToSpot.

Declaration
public Spot AlternateChildPortSpot { get; set; }
Property Value
Type Description
Spot
Remarks

The default value is Default.

A value of Default will cause the TreeLayout to assign a ToSpot based on the parent node's Angle.

If the value is other than NoSpot, it is just assigned. When Path is Source, the port's FromSpot is set instead of the ToSpot.

This sets the AlternateDefaults" property of the same name.

AlternateCommentMargin

Gets or sets the alternate distance between a node and its comments.

Declaration
public double AlternateCommentMargin { get; set; }
Property Value
Type Description
double
Remarks

The default value is 20.

This is used by AddComments(TreeVertex) and LayoutComments(TreeVertex).

This sets the AlternateDefaults" property of the same name.

AlternateCommentSpacing

Gets or sets the alternate distance between comments.

Declaration
public double AlternateCommentSpacing { get; set; }
Property Value
Type Description
double
Remarks

The default value is 10.

This is used by AddComments(TreeVertex) and LayoutComments(TreeVertex).

This sets the AlternateDefaults" property of the same name.

AlternateCompaction

Gets or sets how closely to pack the child nodes of a subtree.

Declaration
public TreeCompaction AlternateCompaction { get; set; }
Property Value
Type Description
TreeCompaction
Remarks

Must be either Block or None.

The default value is Block.

This sets the AlternateDefaults" property of the same name.

AlternateComparer

Gets or sets the alternate comparison function used for sorting the immediate children of a vertex.

Declaration
public Comparison<TreeVertex> AlternateComparer { get; set; }
Property Value
Type Description
Comparison<TreeVertex>
Remarks

The default comparer compares the Node Text values.

This sets the AlternateDefaults" property of the same name. Whether this comparison function is used is determined by the value of AlternateSorting.

AlternateDefaults

Gets or sets the object holding the default values for alternate layer TreeVertexes, used when the TreeStyle is Alternating or LastParents.

Declaration
public TreeVertex AlternateDefaults { get; set; }
Property Value
Type Description
TreeVertex
Remarks

See the list of inheritable properties in the documentation for RootDefaults. The other properties of this TreeVertex are ignored.

AlternateLayerSpacing

Gets or sets the alternate distance between a parent node and its children.

Declaration
public double AlternateLayerSpacing { get; set; }
Property Value
Type Description
double
Remarks

The default value is 50.

This is the distance between a parent node and its first row of children, in case there are multiple rows of its children. The AlternateNodeSpacing property determines the distance between siblings. The AlternateRowSpacing property determines the distance between rows of children. Negative values may cause children to overlap with the parent.

This sets the AlternateDefaults" property of the same name.

AlternateLayerSpacingParentOverlap

Gets or sets the alternate fraction of the node's depth for which the children's layer starts overlapped with the parent's layer.

Declaration
public double AlternateLayerSpacingParentOverlap { get; set; }
Property Value
Type Description
double
Remarks

The default value is 0.0 -- there is overlap between layers only if AlternateLayerSpacing is negative. A value of 1.0 and a zero AlternateLayerSpacing will cause child nodes to completely overlap the parent.

A value greater than zero may still cause overlap between layers, unless the value of AlternateLayerSpacing is large enough. A value of zero might still allow overlap between layers, if AlternateLayerSpacing is negative.

This sets the AlternateDefaults" property of the same name.

AlternateNodeIndent

Gets or sets the alternate indentation of the first child.

Declaration
public double AlternateNodeIndent { get; set; }
Property Value
Type Description
double
Remarks

The default value is zero. The value should be non-negative.

This property is only sensible when the Alignment is Start or End. Having a positive value is useful if you want to reserve space at the start of the row of children for some reason. For example, if you want to pretend the parent node is infinitely deep, you can set this to be the breadth of the parent node.

This sets the AlternateDefaults" property of the same name.

AlternateNodeIndentPastParent

Gets or sets the fraction of this node's breadth is added to AlternateNodeIndent to determine any spacing at the start of the children.

Declaration
public double AlternateNodeIndentPastParent { get; set; }
Property Value
Type Description
double
Remarks

The default value is 0.0 -- the only indentation is specified by AlternateNodeIndent. When the value is 1.0, the children will be indented past the breadth of the parent node.

This property is only sensible when the Alignment is Start or End.

AlternateNodeSpacing

Gets or sets the alternate distance between child nodes.

Declaration
public double AlternateNodeSpacing { get; set; }
Property Value
Type Description
double
Remarks

The default value is 20.

A negative value causes sibling nodes to overlap.

This sets the AlternateDefaults" property of the same name.

AlternatePortSpot

Gets or sets the alternate spot that this node's port gets as its FromSpot.

Declaration
public Spot AlternatePortSpot { get; set; }
Property Value
Type Description
Spot
Remarks

The default value is Default.

A value of Default will cause the TreeLayout to assign a FromSpot based on the parent node's Angle. If the value is other than NoSpot, it is just assigned. When Path is Source, the port's ToSpot is set instead of the FromSpot.

This sets the AlternateDefaults" property of the same name.

AlternateRowIndent

Gets or sets the alternate indentation of the first child of each row, if the Alignment is not a "Center" alignment.

Declaration
public double AlternateRowIndent { get; set; }
Property Value
Type Description
double
Remarks

The default value is 10. The value should be non-negative.

This is used to leave room for the links that connect a parent node with the child nodes that are in additional rows.

This sets the AlternateDefaults" property of the same name.

AlternateRowSpacing

Gets or sets the alternate distance between rows of children.

Declaration
public double AlternateRowSpacing { get; set; }
Property Value
Type Description
double
Remarks

The default value is 25.

This property is only used when there is more than one row of children for a given parent node. The AlternateLayerSpacing property determines the distance between the parent node and its first row of child nodes.

This sets the AlternateDefaults" property of the same name.

AlternateSetsChildPortSpot

Gets or sets whether the TreeLayout should set the ToSpot for each child node port.

Declaration
public bool AlternateSetsChildPortSpot { get; set; }
Property Value
Type Description
bool
Remarks

The default value is true -- this may modify the spot of the ports of the children nodes, if the node has only a single port.

The spot used depends on the value of AlternateChildPortSpot.

This sets the AlternateDefaults" property of the same name.

AlternateSetsPortSpot

Gets or sets whether the TreeLayout should set the FromSpot for this parent node port.

Declaration
public bool AlternateSetsPortSpot { get; set; }
Property Value
Type Description
bool
Remarks

The default value is true -- this may modify the spot of the port of this node, the parent, if the node has only a single port.

The spot used depends on the value of AlternatePortSpot.

This sets the AlternateDefaults" property of the same name.

AlternateSorting

Gets or sets the alternate sorting policy for ordering the immediate children of a vertex.

Declaration
public TreeSorting AlternateSorting { get; set; }
Property Value
Type Description
TreeSorting
Remarks

Must be Forwards, Reverse, Ascending, or Descending.

The default value is Forwards.

This sets the AlternateDefaults" property of the same name. The sort order is determined by AlternateComparer.

Angle

Gets or sets the default direction for tree growth.

Declaration
public double Angle { get; set; }
Property Value
Type Description
double
Remarks

The default value is 0; the value must be one of: 0, 90, 180, 270.

These values are in degrees, where 0 is along the positive X axis, and where 90 is along the positive Y axis.

This sets the RootDefaults" property of the same name.

Arrangement

Gets or sets how ArrangeTrees() should lay out the separate trees.

Declaration
public TreeArrangement Arrangement { get; set; }
Property Value
Type Description
TreeArrangement
Remarks

Must be Vertical, Horizontal, or FixedRoots.

The default value is Vertical

ArrangementSpacing

Gets or sets the space between which ArrangeTrees() will position the trees.

Declaration
public Size ArrangementSpacing { get; set; }
Property Value
Type Description
Size
Remarks

This defaults to the Size(10, 10).

This property is ignored if Arrangement is FixedRoots.

BreadthLimit

Gets or sets a limit on how broad a tree should be.

Declaration
public double BreadthLimit { get; set; }
Property Value
Type Description
double
Remarks

A value of zero (the default) means there is no limit; a positive value specifies a limit. The default value is zero.

This property is just a suggested constraint on how broadly the tree will be laid out. When there isn't enough breadth for all of the children of a node, the children are placed in as many rows as needed to try to stay within the given breadth limit. If the value is too small, since this layout algorithm does not modify the size or shape of any node, the nodes will just be laid out in a line, one per row, and the breadth is determined by the broadest node. The distance between rows is specified by RowSpacing. To make room for the links that go around earlier rows to get to later rows, when the alignment is not a "center" alignment, the RowIndent property specifies that space at the start of each row.

This sets the RootDefaults" property of the same name.

ChildPortSpot

Gets or sets the spot that children nodes' ports get as their ToSpot.

Declaration
public Spot ChildPortSpot { get; set; }
Property Value
Type Description
Spot
Remarks

The default value is Default.

A value of Default will cause the TreeLayout to assign a ToSpot based on the parent node's Angle. If the value is other than NoSpot, it is just assigned. When Path is Source, the port's FromSpot is set instead of the ToSpot.

This sets the RootDefaults" property of the same name.

CommentMargin

Gets or sets the distance between a node and its comments.

Declaration
public double CommentMargin { get; set; }
Property Value
Type Description
double
Remarks

The default value is 20.

This is used by AddComments(TreeVertex) and LayoutComments(TreeVertex).

This sets the RootDefaults" property of the same name.

Comments

Gets or sets whether this layout should find all Nodes whose category is "Comment" and whose anchors are nodes represented in the network, and increase the size of the corresponding TreeVertex to make room for the comment nodes.

Declaration
public bool Comments { get; set; }
Property Value
Type Description
bool
Remarks

The default value is true.

CommentSpacing

Gets or sets the distance between comments.

Declaration
public double CommentSpacing { get; set; }
Property Value
Type Description
double
Remarks

The default value is 10.

This is used by AddComments(TreeVertex) and LayoutComments(TreeVertex).

This sets the RootDefaults" property of the same name.

Compaction

Gets or sets how closely to pack the child nodes of a subtree.

Declaration
public TreeCompaction Compaction { get; set; }
Property Value
Type Description
TreeCompaction
Remarks

Must be either Block or None.

The default value is Block.

This sets the RootDefaults" property of the same name.

Comparer

Gets or sets the default comparison function used for sorting the immediate children of a vertex.

Declaration
public Comparison<TreeVertex> Comparer { get; set; }
Property Value
Type Description
Comparison<TreeVertex>
Remarks

The default comparer compares the Node Text values.

This sets the RootDefaults" property of the same name. Whether this comparison function is used is determined by the value of Sorting.

new TreeLayout {
  Sorting = TreeSorting.Ascending,
  Comparer = (va, vb) => {
    var da = va.Node.Data as NodeData;
    var db = vb.Node.Data as NodeData;
    if (da.SomeProperty < db.SomeProperty) return -1;
    if (da.SomeProperty > db.SomeProperty) return 1;
    return 0;
  }
}

LayerSpacing

Gets or sets the distance between a parent node and its children.

Declaration
public double LayerSpacing { get; set; }
Property Value
Type Description
double
Remarks

This is the distance between a parent node and the layer of its children. Negative values may cause children to overlap with the parent. The default value is 50.

The NodeSpacing property determines the distance between siblings.

The RowSpacing property determines the distance between multiple rows or columns of children.

This sets the RootDefaults" property of the same name.

LayerSpacingParentOverlap

Gets or sets the fraction of the node's depth for which the children's layer starts overlapped with the parent's layer.

Declaration
public double LayerSpacingParentOverlap { get; set; }
Property Value
Type Description
double
Remarks

The default value is 0.0 -- there is overlap between layers only if LayerSpacing is negative. A value of 1.0 and a zero LayerSpacing will cause child nodes to completely overlap the parent.

A value greater than zero may still cause overlap between layers, unless the value of LayerSpacing is large enough. A value of zero might still allow overlap between layers, if LayerSpacing is negative.

This sets the RootDefaults" property of the same name.

LayerStyle

Gets or sets the manner in which the nodes are aligned in layers.

Declaration
public TreeLayerStyle LayerStyle { get; set; }
Property Value
Type Description
TreeLayerStyle
Remarks

Must be Individual, Siblings, or Uniform.

The default value is Individual.

NodeIndent

Gets or sets the default indentation of the first child.

Declaration
public double NodeIndent { get; set; }
Property Value
Type Description
double
Remarks

The default value is zero. The value should be non-negative.

This property is only sensible when the Alignment is Start or End. Having a positive value is useful if you want to reserve space at the start of the row of children for some reason. For example, if you want to pretend the parent node is infinitely deep, you can set this to be the breadth of the parent node.

This sets the RootDefaults" property of the same name.

NodeIndentPastParent

Gets or sets the fraction of this node's breadth is added to NodeIndent to determine any spacing at the start of the children.

Declaration
public double NodeIndentPastParent { get; set; }
Property Value
Type Description
double
Remarks

The default value is 0.0 -- the only indentation is specified by NodeIndent. When the value is 1.0, the children will be indented past the breadth of the parent node.

This property is only sensible when the Alignment is Start or End.

This sets the RootDefaults" property of the same name.

NodeSpacing

Gets or sets the distance between child nodes.

Declaration
public double NodeSpacing { get; set; }
Property Value
Type Description
double
Remarks

This is the distance between sibling nodes. A negative value causes sibling nodes to overlap. The default value is 20.

The LayerSpacing property determines the distance between a parent node and the layer of its children.

This sets the RootDefaults" property of the same name.

Path

Gets or sets how the tree should be constructed from the TreeEdges connecting TreeVertexes.

Declaration
public TreePath Path { get; set; }
Property Value
Type Description
TreePath
Remarks

Must be Destination or Source or Default.

The default value is Default, where the value of IsTreePathToChildren determines the effective value of this property.

PortSpot

Gets or sets the spot that this node's port gets as its FromSpot.

Declaration
public Spot PortSpot { get; set; }
Property Value
Type Description
Spot
Remarks

The default value is Default.

A value of Default will cause the TreeLayout to assign a FromSpot based on the parent node's Angle. If the value is other than NoSpot, it is just assigned. When Path is Source, the port's ToSpot is set instead of the FromSpot.

This sets the RootDefaults" property of the same name.

RootDefaults

Gets or sets the object holding the default values for root TreeVertexes.

Declaration
public TreeVertex RootDefaults { get; set; }
Property Value
Type Description
TreeVertex
Remarks

The values for the following inheritable properties are actually stored in this object: Sorting, Comparer, Angle, Alignment, NodeIndent, NodeIndentPastParent, NodeSpacing, LayerSpacing, LayerSpacingParentOverlap, Compaction, BreadthLimit, RowSpacing, RowIndent, CommentSpacing, CommentMargin, SetsPortSpot, PortSpot, SetsChildPortSpot, ChildPortSpot. The other properties of this TreeVertex are ignored.

Roots

Gets or sets the collection of root vertexes.

Declaration
public ICollection<TreeVertex> Roots { get; set; }
Property Value
Type Description
ICollection<TreeVertex>
Remarks

Initially this will be an empty set.

If the Path is either Destination or Source, this layout can easily determine all of the tree roots by searching the whole network. Otherwise, you should explicitly initialize this collection with one or more TreeVertexes.

RowIndent

Gets or sets the default indentation of the first child of each row, if the Alignment is not a "Center" alignment.

Declaration
public double RowIndent { get; set; }
Property Value
Type Description
double
Remarks

The default value is 10. The value should be non-negative.

This is used to leave room for the links that connect a parent node with the child nodes that are in additional rows.

This sets the RootDefaults" property of the same name.

RowSpacing

Gets or sets the distance between rows or columns of a parent node's immediate children.

Declaration
public double RowSpacing { get; set; }
Property Value
Type Description
double
Remarks

The default value is 25.

This property is only used when there is more than one row of children for a given parent node. The NodeSpacing property determines the distance between siblings. The LayerSpacing property determines the distance between the parent node and its first row or column of child nodes.

This sets the RootDefaults" property of the same name.

SetsChildPortSpot

Gets or sets whether the TreeLayout should set the ToSpot for each child node port.

Declaration
public bool SetsChildPortSpot { get; set; }
Property Value
Type Description
bool
Remarks

The default value is true -- this may modify the spot of the ports of the children nodes, if the node has only a single port.

The spot used depends on the value of ChildPortSpot.

This sets the RootDefaults" property of the same name.

SetsPortSpot

Gets or sets whether the TreeLayout should set the FromSpot for this parent node port.

Declaration
public bool SetsPortSpot { get; set; }
Property Value
Type Description
bool
Remarks

The default value is true -- this may modify the spot of the port of this node, the parent, if the node has only a single port.

The spot used depends on the value of PortSpot.

This sets the RootDefaults" property of the same name.

Sorting

Gets or sets the default sorting policy for ordering the immediate children of a vertex.

Declaration
public TreeSorting Sorting { get; set; }
Property Value
Type Description
TreeSorting
Remarks

Must be Forwards, Reverse, Ascending, or Descending.

The default value is Forwards.

This sets the RootDefaults" property of the same name. The sort order is determined by Comparer.

TreeStyle

Gets or sets the style for the resulting trees.

Declaration
public TreeStyle TreeStyle { get; set; }
Property Value
Type Description
TreeStyle
Remarks

Must be Layered, Alternating, LastParents, or RootOnly.

The default value is Layered.

Methods

AddComments(TreeVertex)

Find any associated objects to be positioned along with the Node.

Declaration
public virtual void AddComments(TreeVertex v)
Parameters
Type Name Description
TreeVertex v
Remarks

This looks for visible Node"s whose category is "Comment" and that refer to the tree vertex's Node. This method is only called when Comments is true.

You may want to override this method in order to customize how any associated objects are found and how the node's Bounds are set to reserve space for those associated objects. This method should not walk the tree, since it is called for each TreeVertex in an indeterminate order. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

ArrangeTrees()

Position each separate tree.

Declaration
protected virtual void ArrangeTrees()
Remarks

This is called after each tree has been laid out and thus each subtree bounds are known. The Arrangement and ArrangementSpacing and ArrangementOrigin properties affect this method's behavior. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

AssignTreeVertexValues(TreeVertex)

Assign final property values for a TreeVertex.

Declaration
protected virtual void AssignTreeVertexValues(TreeVertex v)
Parameters
Type Name Description
TreeVertex v
Remarks

This method is commonly overridden in order to provide tree layout properties for particular nodes. This method is called after values have been inherited from other TreeVertexes, so you can examine and modify the values of related tree nodes. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

However, when Alignment is BusBranching, changing the Sorting or Comparer properties in this method will have no effect.

This method should not walk the tree, since it is called for each TreeVertex in a depth-first manner starting at a root.

Here is an example where the children are squeezed together if there are many of them, but only on nodes that have no grandchildren. This makes use of two TreeVertex properties that are automatically computed for you, ChildrenCount and DescendantCount.

public class SqueezingTreeLayout : TreeLayout {
  public override void AssignTreeVertexValues(TreeVertex v) {
    if (v.ChildrenCount > 6 && v.ChildrenCount == v.DescendantCount) {
      v.Alignment = TreeAlignment.BottomRightBus;
      v.LayerSpacing = 10;
      v.RowSpacing = 0;
    }
  }
}

If you need to assign TreeVertex values and also have them be "inherited" by the child vertexes, you should override InitializeTreeVertexValues(TreeVertex) instead. However at the time that method is called, the computed properties of TreeVertex will not be available.

CommitLayers(List<Rect>, Point)

This overridable method is called by CommitLayout() if LayerStyle is LayerUniform to support custom arrangement of bands or labels across each layout layer.

Declaration
protected virtual void CommitLayers(List<Rect> layerRects, Point offset)
Parameters
Type Name Description
List<Rect> layerRects

a List of Rects with the bounds of each of the "layers"

Point offset

the position of the top-left corner of the banded area relative to the coordinates given by the layerRects

Remarks

By default this method does nothing.

The coordinates used in the resulting Rects may need to be offset by the ArrangementOrigin and/or by the arrangement of subtrees done by ArrangeTrees().

CommitLayout()

Set the FromSpot and ToSpot on each Link, position each Node according to the vertex position, and then position/route the Links.

Declaration
protected override void CommitLayout()
Overrides
Northwoods.Go.Layouts.NetworkLayout<Northwoods.Go.Layouts.TreeNetwork, Northwoods.Go.Layouts.TreeVertex, Northwoods.Go.Layouts.TreeEdge, Northwoods.Go.Layouts.TreeLayout>.CommitLayout()
Remarks

This calls the CommitNodes() and CommitLinks() methods, the latter only if IsRouting is true. You should not call this method -- it is a "protected virtual" method. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

Routes the links.

Declaration
protected virtual void CommitLinks()

This is called by CommitLayout(). This is only called if IsRouting is true. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

CommitNodes()

Commit the position of all nodes.

Declaration
protected virtual void CommitNodes()
Remarks

This is called by CommitLayout(). Please read the Introduction page on Extensions for how to override methods and how to call this base method.

See Also

DoLayout(IEnumerable<Part>)

Perform the tree layout.

Declaration
public override void DoLayout(IEnumerable<Part> coll = null)
Parameters
Type Name Description
IEnumerable<Part> coll
Overrides
Remarks

If there are no TreeVertex Roots specified, this finds all roots in the Network.

This initializes all of the TreeVertexes and TreeEdges, calling InitializeTreeVertexValues(TreeVertex) on each vertex, supporting inheritance of vertex values. Then it calls AssignTreeVertexValues(TreeVertex) on each one, to allow for node/vertex-specific customizations. Next it sorts all of the child vertexes for each parent vertex, if needed.

This also calls AddComments(TreeVertex) of each vertex, in order to find any comment nodes associated with each vertex, so that they can be accommodated by the layout.

This then actually does the "layout" of the vertexes and optionally the routing of the edges of each tree in the network. To deal with multiple roots/trees this also calls ArrangeTrees() to position each separate tree relative to each other.

Finally this calls UpdateParts() to commit the Node positions from the vertex positions and the Link routes from the edges. UpdateParts() calls CommitLayout() within a transaction.

InitializeTreeVertexValues(TreeVertex)

Assign initial property values for a TreeVertex.

Declaration
public virtual void InitializeTreeVertexValues(TreeVertex v)
Parameters
Type Name Description
TreeVertex v
Remarks

The values may be inherited, so this method is called while propagating values from the root nodes. This method should not walk the tree, since it is called for each TreeVertex in a depth-first manner starting at a root.

You probably do not need to override this method, but if you do you should call first either the base method or CopyInheritedPropertiesFrom(TreeVertex), since they assign most of the TreeVertex property values used to influence the layout. Informational properties such as DescendantCount and MaxGenerationCount will not yet have been initialized by the time this method is called. It is more common to override AssignTreeVertexValues(TreeVertex) in order to modify a property or two to customize the layout at that node. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

When the Alignment is BusBranching, this will modify the Angle appropriately depending on which side of the bus the vertex is on.

LayoutComments(TreeVertex)

Position and Comments around the vertex.

Declaration
public virtual void LayoutComments(TreeVertex v)
Parameters
Type Name Description
TreeVertex v
Remarks

This method should not walk the tree, since it is called for each TreeVertex in an indeterminate order. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

MakeNetwork(IEnumerable<Part>)

Create and initialize a TreeNetwork with the given nodes and links.

Declaration
public override TreeNetwork MakeNetwork(IEnumerable<Part> coll = null)
Parameters
Type Name Description
IEnumerable<Part> coll
Returns
Type Description
TreeNetwork
Overrides
Remarks

This does not include any nodes of category "Comment". Comment nodes are added by the AddComments(TreeVertex) method.