DefaultNodePlacer is the default implementation of interface ITreeLayoutNodePlacer.
Remarks
Layout Style
With its default settings, this placer generates tree layouts with orthogonal edge routes and child nodes that are placed next to each other and below their parent node.
The layout style can be customized in several ways. Subtrees sharing the same local root node are either placed above or below each other.
Features
SubtreeShapes can be arranged in each main direction specified in childPlacement. That way, the subtrees of the same graph can have different directions.
This node placer aligns the local root node according to a chosen alignment.
There are various routing styles that result in different edge routes.
Default Values of Properties
childPlacement | HORIZONTAL_DOWNWARD
| |
minimumChannelSegmentDistance | 0 | |
rootAlignment | CENTER
| |
routingStyle | FORK
| |
verticalAlignment | -1 | Nodes are not aligned. |
Type Details
- yfiles module
- layout-tree
- yfiles-umd modules
- layout-orthogonal-compact, layout-orthogonal, layout-tree, layout
- Legacy UMD name
- yfiles.tree.DefaultNodePlacer
See Also
Constructors
Creates a new DefaultNodePlacer instance with default settings.
Parameters
A map of options to pass to the method.
- minimumChannelSegmentDistance - number
The minimum (non-negative) distance between edge segments that are routed orthogonally in the channel between the root node and the child nodes (see FORK). This option sets the minimumChannelSegmentDistance property on the created object.
- alignPorts - boolean
Whether or not nodes are placed so that the source and target port of an edge are aligned. This option sets the alignPorts property on the created object.
- childPlacement - ChildPlacement
The direction in which the child nodes are placed with respect to their parent node. This option sets the childPlacement property on the created object.
- rootAlignment - RootAlignment
How the root node is aligned with its children and their SubtreeShapes. This option sets the rootAlignment property on the created object.
- verticalAlignment - number
The relative vertical alignment of nodes with the same parent. This option sets the verticalAlignment property on the created object.
- routingStyle - TreeLayoutEdgeRoutingStyle
The style in which edge paths are routed. This option sets the routingStyle property on the created object.
- verticalDistance - number
The vertical distance between nodes or SubtreeShapes. This option sets the verticalDistance property on the created object.
- minimumFirstSegmentLength - number
The minimum length for the first segment of an edge. This option sets the minimumFirstSegmentLength property on the created object.
- minimumLastSegmentLength - number
The minimum length for the last segment of an edge. This option sets the minimumLastSegmentLength property on the created object.
- minimumSlope - number
The minimum slope of the edge segments. This option sets the minimumSlope property on the created object.
- minimumSlopeHeight - number
The minimum height for sloped edge segments. This option sets the minimumSlopeHeight property on the created object.
- horizontalDistance - number
The horizontal distance between nodes or SubtreeShapes. This option sets the horizontalDistance property on the created object.
DefaultNodePlacer
(childPlacement: ChildPlacement, verticalDistance: number, horizontalDistance: number)Creates a new DefaultNodePlacer instance with customized child placement, vertical and horizontal distance.
Parameters
A map of options to pass to the method.
- childPlacement - ChildPlacement
- the child placement specifier describing the style of the arrangement
- verticalDistance - number
- the vertical distance between the SubtreeShapes
- horizontalDistance - number
- the horizontal distance between the SubtreeShapes
Throws
- Exception({ name: 'ArgumentError' })
- if the placement specifier is unknown or if the horizontal/vertical distance is negative
See Also
DefaultNodePlacer
(childPlacement: ChildPlacement, rootAlignment: RootAlignment, verticalDistance: number, horizontalDistance: number)Creates a new DefaultNodePlacer instance with customized child placement, root alignment, vertical and horizontal distance.
Parameters
A map of options to pass to the method.
- childPlacement - ChildPlacement
- the child placement specifier describing the style of the arrangement
- rootAlignment - RootAlignment
- the alignment specifier describing how the root node is aligned with its child nodes
- verticalDistance - number
- the vertical distance between the SubtreeShapes
- horizontalDistance - number
- the horizontal distance between the SubtreeShapes
Throws
- Exception({ name: 'ArgumentError' })
- if the placement specifier or the root alignment specifier is unknown or if the horizontal/vertical distance is negative
See Also
DefaultNodePlacer
(childPlacement: ChildPlacement, rootAlignment: RootAlignment, routingStyle: TreeLayoutEdgeRoutingStyle, verticalDistance?: number, horizontalDistance?: number, minFirstSegmentLength?: number, minLastSegmentLength?: number, minSlope?: number, minSlopeHeight?: number)Creates a new DefaultNodePlacer instance with custom settings.
Parameters
A map of options to pass to the method.
- childPlacement - ChildPlacement
- the child placement specifier describing the style of the arrangement
- rootAlignment - RootAlignment
- the alignment specifier describing how the root node is aligned with its child nodes
- routingStyle - TreeLayoutEdgeRoutingStyle
- the routing style specifier
- verticalDistance - number
- the vertical distance between the SubtreeShapes
- horizontalDistance - number
- the horizontal distance between the SubtreeShapes
- minFirstSegmentLength - number
- the minimum length of the first edge segment (connected to the root node)
- minLastSegmentLength - number
- the minimum length of the last edge segment (connected to the child node)
- minSlope - number
- the minimum slope between the root node and the SubtreeShapes
- minSlopeHeight - number
- the minimum vertical height of sloped edge segments
Throws
- Exception({ name: 'ArgumentError' })
- if the placement specifier or the root alignment or the routing style is unknown or if the horizontal/vertical distance or the minimum first/last segment length or the minimum slope or the minimum vertical height is negative
See Also
Properties
Gets or sets whether or not nodes are placed so that the source and target port of an edge are aligned.
Remarks
Dependent on the root alignment the subtree root is moved in a way that the edge connecting the root to one of its children is straightened.
This setting only applies to the following root alignments:
Default Value
false
.Ports are not aligned.
See Also
Sample Graphs
Gets or sets the direction in which the child nodes are placed with respect to their parent node.
Remarks
Default Value
HORIZONTAL_DOWNWARD.Throws
- Exception({ name: 'ArgumentError' })
- if an unknown placement specifier is set
Gets or sets the horizontal distance between nodes or SubtreeShapes.
Remarks
Default Value
20
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified distance is negative
Sample Graphs
Gets or sets the minimum (non-negative) distance between edge segments that are routed orthogonally in the channel between the root node and the child nodes (see FORK).
Remarks
0
, all segments are routed in a bus-like style.Default Value
0
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified distance is smaller than
0
Sample Graphs
0
, minimumSlopeHeight is equal to 0
, routingStyle is FORK and rootAlignment is not equal to LEADING_ON_BUS or TRAILING_ON_BUS.0
are especially useful if the ITreeLayoutPortAssignment distributes the ports at the nodes' border.Gets or sets the minimum length for the first segment of an edge.
Remarks
During layout calculation, the edges of the tree are directed. Hence, the first segment is always the segment that is attached to the source, which is the local root node.
The length needs to be non-negative.
Default Value
20
.Throws
- Exception({ name: 'ArgumentError' })
- if the minimum segment length is negative
See Also
Sample Graphs
Gets or sets the minimum length for the last segment of an edge.
Remarks
During layout calculation, the edges of the tree are directed. Hence, the last segment is always the segment that is attached to the target, which is a child node.
The length needs to be non-negative.
Default Value
20
.Throws
- Exception({ name: 'ArgumentError' })
- if the minimum segment length is negative
Sample Graphs
Gets or sets the minimum slope of the edge segments.
Remarks
These sloped segments are between the vertical first and last segment of the edge.
The segments may become steeper but they will have at least the specified slope. Negative minimum slopes can lead to edge routes looking like spider legs.
Default Value
0
.See Also
Sample Graphs
Gets or sets the minimum height for sloped edge segments.
Remarks
These sloped segments are between the vertical first and last segment of the edge.
The segments may become steeper to reach the specified height.
Default Value
0
.See Also
Sample Graphs
Gets or sets how the root node is aligned with its children and their SubtreeShapes.
Gets or sets the relative vertical alignment of nodes with the same parent.
Remarks
All values between 0
and 1
result in a valid alignment.
0
- nodes are top-aligned0.5
- nodes are center-aligned1
- nodes are bottom-aligned
Values outside the interval [0,1]
will result in a more compact node placement with unaligned nodes.
Default Value
-1
.Nodes are not aligned.
Sample Graphs
Gets or sets the vertical distance between nodes or SubtreeShapes.
Remarks
Default Value
20
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified distance is negative
See Also
Sample Graphs
Methods
calculateParentConnector
(graph: LayoutGraph, localRoot: YNode, rootLayout: INodeLayout, subtreeShape: SubtreeShape, parentEdge: Edge, parentEdgeLayout: IEdgeLayout, direction: number)Calculates the bends for the connector to the parent node.
Remarks
This implementation adds bends to the connector for edges that route the edges around the child node in case there are PortConstraints that conflict with the direction of the child placement.
This method is called in placeSubtreeOfNode to route the edges after the SubtreeShapes are arranged. It may be overridden to customize the routing style.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
- localRoot - YNode
- the local root node whose connector is calculated and stored in the given subtree shape
- rootLayout - INodeLayout
- the INodeLayout of the root node
- subtreeShape - SubtreeShape
- the shape of the whole subtree of the local root
- parentEdge - Edge
- the incoming edge of the local root node that will be the connector for the given subtree shape
- parentEdgeLayout - IEdgeLayout
- the current IEdgeLayout of the connector edge
- direction - number
- the direction specifier as defined in the ITreeLayoutNodePlacer interface which should be used for the connector
See Also
calculateSlopedSourceEdgeLayout
(rootLayout: INodeLayout, childShape: SubtreeShape, edge: Edge, childForkCoordinate: number, rootForkCoordinate: number)Calculates the routing of the source side of the edge to the given child node.
Remarks
Parameters
A map of options to pass to the method.
- rootLayout - INodeLayout
- the INodeLayout of the local root node
- childShape - SubtreeShape
- the SubtreeShape instance of the corresponding child's subtree
- edge - Edge
- the edge
- childForkCoordinate - number
- the y-coordinate of the second (= last) bend of the edge if the placement is horizontal, the x-coordinate otherwise
- rootForkCoordinate - number
- the y-coordinate of the first bend of the edge if the placement is horizontal, the x-coordinate otherwise
Calculates the routing of the source side of the edge to the given child node.
Remarks
This implementation adds bends to the IEdgeLayout of the given edge according to the specified routing style and child placement. It also updates the target points in the SubtreeShape.
This method is called by calculateSlopedSourceEdgeLayout to route the edges. It may be overridden to implement a custom edge routing style.
Parameters
A map of options to pass to the method.
- rootLayout - INodeLayout
- the INodeLayout of the local root node
- childShape - SubtreeShape
- the SubtreeShape of the child's subtree that is connected through the given edge
- edge - Edge
- the edge
Calculates the routing of the target side of the edge to the given child node.
Remarks
This implementation just resets the current IEdgeLayout.
This method is called by placeSubtreeOfNode after the shapes of the local root's children are placed. It may be overridden to add some target points to the edge.
Parameters
A map of options to pass to the method.
- rootLayout - INodeLayout
- the INodeLayout of the local root node
- childShape - SubtreeShape
- the SubtreeShape of the child's subtree that is connected through the given edge
- edge - Edge
- the edge
Returns a clone of this ITreeLayoutNodePlacer instance.
Creates a IComparer<T> for outgoing edges which takes the initial coordinates of the edges' targets into account.
Remarks
Returns
- ↪IComparer<any>
- a IComparer<T> that considers the initial coordinates of the nodes
Delegates to createComparer.
Creates an optional IProcessor for pre- and post-processing.
Remarks
null
. Hence, no pre- or post-processing will be done.Parameters
A map of options to pass to the method.
- layouter - TreeLayout
- the current TreeLayout instance
- graph - LayoutGraph
- the input graph
- currentRoot - YNode
- the root node handled by this ITreeLayoutNodePlacer
Returns
- ↪IProcessor
null
Implements
Determines a connector direction for the given child node depending on the selected child placement.
Remarks
Parameters
A map of options to pass to the method.
- child - YNode
- the child node
Returns
- ↪ParentConnectorDirection
- the connector direction depending on the child placement
See Also
Implements
Provides the direction of the connector to the SubtreeShape for each child node.
Remarks
Parameters
A map of options to pass to the method.
- localRoot - YNode
- the local root node
- connectorMap - IDataMap
- the map that must be used for storing the direction specifiers of the child nodes
Domain YNode a child node of the local root Values number the direction specifier assigned to the child node
Implements
Returns the SubtreeShape for the given node.
Remarks
This is a convenience method that retrieves a SubtreeShape for a single node from the corresponding IDataProvider.
This method is used in placeSubtreeOfNode for retrieving the SubtreeShapes for the local root nodes. It may be overridden to return a custom implementation of SubtreeShape.
Parameters
A map of options to pass to the method.
- node - YNode
- the node
Returns
- ↪SubtreeShape
- the SubtreeShape for the given node
Defined in
Returns the SubtreeShape for the subtree rooted at the given node.
Remarks
This is a convenience method that retrieves a SubtreeShape of a complete subtree from the corresponding IDataProvider.
This method is used in placeSubtreeOfNode for retrieving the SubtreeShapes for the subtrees that are arranged. It may be overridden to return a custom implementation of SubtreeShape.
Parameters
A map of options to pass to the method.
- node - YNode
- the local root node
Returns
- ↪SubtreeShape
- the SubtreeShape of the subtree rooted at the given local root node
Defined in
placeSubtree
(nodeShapeProvider: IDataProvider, subtreeShapeProvider: IDataProvider, graph: LayoutGraph, localRoot: YNode, parentConnectorDirection: ParentConnectorDirection) : SubtreeShapeInitializes the local data structures and then delegates the work to the abstract variant of this method (placeSubtreeOfNode)
Parameters
A map of options to pass to the method.
- nodeShapeProvider - IDataProvider
- the IDataProvider for obtaining an initial shape of the root node
Domain YNode Values SubtreeShape the shape of the node - subtreeShapeProvider - IDataProvider
- the IDataProvider for accessing the pre-calculated shapes of the subtrees
Domain YNode Values SubtreeShape the shape of the subtree rooted at the node - graph - LayoutGraph
- the input graph
- localRoot - YNode
- the root of the subtree that should be arranged by this method
- parentConnectorDirection - ParentConnectorDirection
- the direction specifier for the connector of the local root node to its parent node
Returns
- ↪SubtreeShape
- the merged SubtreeShape for the subtree rooted at the local root node
See Also
Implements
placeSubtreeOfNode
(localRoot: YNode, parentConnectorDirection: ParentConnectorDirection) : SubtreeShapeArranges the root node and its children.
Parameters
A map of options to pass to the method.
- localRoot - YNode
- the local root node
- parentConnectorDirection - ParentConnectorDirection
- the direction of the connector
Returns
- ↪SubtreeShape
- the merged SubtreeShape containing the local root and all its subtrees
Implements
Fields
The graph instance this class is working on.