Class DoubleTreeLayout

GoDiagram®
v10.0.8
by Northwoods Software®

Perform two TreeLayouts, one going rightwards and one going leftwards.

Inheritance
DoubleTreeLayout
Namespace: Northwoods.Go.Layouts.Extensions
Assembly: DoubleTreeWinForms.dll
Syntax
public class DoubleTreeLayout : Layout
Remarks

The choice of direction is determined by the mandatory predicate DirectionFunction, which is called on each child Node of the root Node.

You can also set Vertical to true if you want the DoubleTreeLayout to perform TreeLayouts both downwards and upwards.

Normally there should be a single root node. Hoewver if there are multiple root nodes found in the nodes and links that this layout is responsible for, this will pretend that there is a real root node and make all of the apparent root nodes children of that pretend root.

If there is no root node, all nodes are involved in cycles, so the first given node is chosen.

Constructors

DoubleTreeLayout()

Create a DoubleTree layout.

Declaration
public DoubleTreeLayout()

Properties

BottomRightOptions

Gets or sets the options to be applied to a TreeLayout.

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

By default this is null -- no properties are set on the TreeLayout other than the Angle, depending on Vertical and the result of calling DirectionFunction.

DirectionFunction

This function is called on each child node of the root node in order to determine whether the subtree starting from that child node will grow towards larger coordinates or towards smaller ones.

Declaration
public Func<Node, bool> DirectionFunction { get; set; }
Property Value
Type Description
Func<Node, bool>
Remarks

The value must be a function and must not be null.

It must return true if IsPositiveDirection(Node) should return true, otherwise it should return false.

TopLeftOptions

Gets or sets the options to be applied to a TreeLayout.

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

By default this is null -- no properties are set on the TreeLayout other than the Angle, depending on Vertical and the result of calling DirectionFunction.

Vertical

When false, the layout should grow towards the left and towards the right, when true, the layout should grow upwards and downwards.

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

The default value is false.

Methods

CreateTreeLayout(bool)

This just returns an instance of TreeLayout. The caller will set the Angle and Arrangement.

Declaration
protected TreeLayout CreateTreeLayout(bool positive)
Parameters
Type Name Description
bool positive

true for growth downward or rightward, false otherwise

Returns
Type Description
TreeLayout

DoLayout(IEnumerable<Part>)

Perform two TreeLayouts by splitting the collection of Parts into two separate subsets but sharing only a single root Node.

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

IsPositiveDirection(Node)

This predicate is called on each child node of the root node, and only on immediate children of the root. It should return true if this child node is the root of a subtree that should grow rightwards or downwards, or false otherwise.

Declaration
protected bool IsPositiveDirection(Node child)
Parameters
Type Name Description
Node child
Returns
Type Description
bool

true if it grows towards right or towards bottom; false otherwise

SeparatePartsForLayout(HashSet<Part>, HashSet<Part>, HashSet<Part>)

This is called by DoLayout(IEnumerable<Part>) to split the collection of Nodes and links into two subsets, one for the subtrees growing towards the left or upwards, and one for the subtrees growing towards the right or downwards.

Declaration
protected void SeparatePartsForLayout(HashSet<Part> coll, HashSet<Part> leftParts, HashSet<Part> rightParts)
Parameters
Type Name Description
HashSet<Part> coll
HashSet<Part> leftParts
HashSet<Part> rightParts