Class DoubleTreeLayout
- Namespace
- Northwoods.Go.Layouts.Extensions
- Assembly
- DoubleTreeWinForms.dll
Perform two TreeLayouts, one going rightwards and one going leftwards.
public class DoubleTreeLayout : Layout
- Inheritance
-
DoubleTreeLayout
- Inherited Members
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.
public DoubleTreeLayout()
Properties
BottomRightOptions
Gets or sets the options to be applied to a TreeLayout.
public TreeLayout BottomRightOptions { get; set; }
Property Value
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.
public Func<Node, bool> DirectionFunction { get; set; }
Property Value
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.
public TreeLayout TopLeftOptions { get; set; }
Property Value
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.
public bool Vertical { get; set; }
Property Value
Remarks
The default value is false.
Methods
CreateTreeLayout(bool)
This just returns an instance of TreeLayout. The caller will set the Angle and Arrangement.
protected TreeLayout CreateTreeLayout(bool positive)
Parameters
positive
booltrue for growth downward or rightward, false otherwise
Returns
DoLayout(IEnumerable<Part>)
Perform two TreeLayouts by splitting the collection of Parts into two separate subsets but sharing only a single root Node.
public override void DoLayout(IEnumerable<Part> coll = null)
Parameters
coll
IEnumerable<Part>
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.
protected bool IsPositiveDirection(Node child)
Parameters
child
Node
Returns
- 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.
protected void SeparatePartsForLayout(HashSet<Part> coll, HashSet<Part> leftParts, HashSet<Part> rightParts)