The AspectRatioTreeLayout arranges tree graphs in a compact fashion.
Remarks
Layout Style
This layout algorithm tries to generate compact tree layouts with a certain preferred aspect ratio.
0.5
Concept
The layout algorithm starts from the root and recursively assigns coordinates to all tree nodes. In this manner, leaf nodes will be placed first, while each parent node is placed centered above its child nodes.
Features
The aspect ratio of each subtree can be specified individually. A IDataProvider registered with SUBTREE_ASPECT_RATIO_DP_KEY returns the aspect ratio for each local root node.
A custom node can be defined as root of the tree using a IDataProvider registered with the graph with key SELECTED_ROOT_DP_KEY.
Default Values of Properties
aspectRatio | 1.41 | |
bendDistance | 20 | |
componentLayoutEnabled | true | The stage that arranges connected graph components is activated. |
hideGroupsStageEnabled | true | The stage responsible for hiding group nodes is activated. |
horizontalDistance | 10 | |
parallelEdgeRouterEnabled | true | The stage that routes parallel edges is activated. |
rootPlacement | CORNER
| |
selfLoopRouterEnabled | true | The stage that routes self-loops is activated. |
subtreeArrangement | HORIZONTAL
| |
verticalDistance | 10 |
Type Details
- yfiles module
- layout-tree
- yfiles-umd modules
- layout-orthogonal-compact, layout-orthogonal, layout-tree, layout
- Legacy UMD name
- yfiles.tree.AspectRatioTreeLayout
See Also
Constructors
Creates a new AspectRatioTreeLayout instance with default settings.
Parameters
A map of options to pass to the method.
- horizontalDistance - number
The horizontal distance between adjacent nodes. This option sets the horizontalDistance property on the created object.
- verticalDistance - number
The vertical distance between adjacent nodes. This option sets the verticalDistance property on the created object.
- componentLayoutEnabled - boolean
Whether or not the ILayoutStage used for arranging the components of the graph is activated. This option sets the componentLayoutEnabled property on the created object.
- hideGroupsStageEnabled - boolean
Whether or not the ILayoutStage used for hiding group nodes is activated. This option sets the hideGroupsStageEnabled property on the created object.
- parallelEdgeRouterEnabled - boolean
Whether or not the ILayoutStage used for routing parallel edges is activated. This option sets the parallelEdgeRouterEnabled property on the created object.
- selfLoopRouterEnabled - boolean
Whether or not the ILayoutStage used for routing self-loops is activated. This option sets the selfLoopRouterEnabled property on the created object.
- comparer - IComparer<Object>
The IComparer<T> that will be used for sorting the outgoing edges of each local root in the tree before they are being arranged. This option sets the comparer property on the created object.
- aspectRatio - number
The default aspect ratio for this AspectRatioTreeLayout. This option sets the aspectRatio property on the created object.
- rootPlacement - RootPlacement
The desired placement of the tree's root node. This option sets the rootPlacement property on the created object.
- subtreeArrangement - SubtreeArrangement
How the children of a local root are arranged and how the edges between them are routed. This option sets the subtreeArrangement property on the created object.
- bendDistance - number
The preferred distance between any two bends of an edge. This option sets the bendDistance property on the created object.
- labeling - ILayoutStage
The ILayoutStage that places the labels of the input graph. This option sets the labeling property on the created object.
- selfLoopRouter - ILayoutStage
The ILayoutStage that routes self-loops. This option sets the selfLoopRouter property on the created object.
- parallelEdgeRouter - ILayoutStage
The ILayoutStage that routes parallel edges. This option sets the parallelEdgeRouter property on the created object.
- componentLayout - ILayoutStage
The ILayoutStage that arranges the connected components of an input graph. This option sets the componentLayout property on the created object.
- subgraphLayout - ILayoutStage
The ILayoutStage that constrains the layout process to a subgraph of the input graph. This option sets the subgraphLayout property on the created object.
- hideGroupsStage - ILayoutStage
The ILayoutStage that hides the group nodes of the input graph. This option sets the hideGroupsStage property on the created object.
- orientationLayout - ILayoutStage
The ILayoutStage that modifies the orientation of a computed layout. This option sets the orientationLayout property on the created object.
- orientationLayoutEnabled - boolean
Whether or not the ILayoutStage that modifies the orientation of the layout is activated. This option sets the orientationLayoutEnabled property on the created object.
- layoutOrientation - LayoutOrientation
The main orientation of the layout. This option sets the layoutOrientation property on the created object.
- labelingEnabled - boolean
Whether or not the ILayoutStage used for placing the labels of the input graph is activated. This option sets the labelingEnabled property on the created object.
- subgraphLayoutEnabled - boolean
Whether or not the ILayoutStage used for constraining the layout process to a subgraph of the input graph is activated. This option sets the subgraphLayoutEnabled property on the created object.
Properties
Gets or sets the default aspect ratio for this AspectRatioTreeLayout.
Remarks
This aspect ratio is used for all subtrees for which there is no specific aspect ratio defined in a IDataProvider registered with SUBTREE_ASPECT_RATIO_DP_KEY.
The aspect ratio needs to have a positive value.
Default Value
1.41
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified aspect ratio is
0
or negative
See Also
Sample Graphs
Gets or sets the preferred distance between any two bends of an edge.
Remarks
Additionally, the preferred bend distance governs the distance between the first and last edges and the corresponding ports.
The distance needs to be non-negative.
Default Value
20
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified distance is negative
See Also
Sample Graphs
Gets or sets the IComparer<T> that will be used for sorting the outgoing edges of each local root in the tree before they are being arranged.
Default Value
null
.Only the built-in logic of the layout algorithm is used.
Gets or sets the ILayoutStage that arranges the connected components of an input graph.
Default Value
ComponentLayout.See Also
Defined in
Sets whether or not the ILayoutStage used for arranging the components of the graph is activated.
Default Value
true
.The stage that arranges connected graph components is activated.
See Also
Overrides
Gets or sets the ILayoutStage that hides the group nodes of the input graph.
Default Value
HideGroupsStage.See Also
Defined in
Sets whether or not the ILayoutStage used for hiding group nodes is activated.
Default Value
true
.The stage responsible for hiding group nodes is activated.
See Also
Overrides
Gets or sets the horizontal distance between adjacent nodes.
Remarks
Default Value
10
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified distance is negative
See Also
Sample Graphs
Gets or sets the ILayoutStage that places the labels of the input graph.
Default Value
See Also
Defined in
Gets or sets whether or not the ILayoutStage used for placing the labels of the input graph is activated.
Remarks
Default Value
false
.The stage responsible for label placement is deactivated.
See Also
Defined in
Gets or sets the main orientation of the layout.
Remarks
Default Value
TOP_TO_BOTTOM.Throws
- Exception({ name: 'ArgumentError' })
- if the specified orientation does not match a default layout orientation
See Also
Defined in
Gets or sets the ILayoutStage that modifies the orientation of a computed layout.
Default Value
OrientationLayout.See Also
Defined in
Gets or sets whether or not the ILayoutStage that modifies the orientation of the layout is activated.
Remarks
Default Value
true
.The orientation
See Also
Defined in
Gets or sets the ILayoutStage that routes parallel edges.
Default Value
ParallelEdgeRouter.See Also
Defined in
Sets whether or not the ILayoutStage used for routing parallel edges is activated.
Default Value
true
.The stage that routes parallel edges is activated.
See Also
Overrides
Gets or sets the ILayoutStage that routes self-loops.
Default Value
SelfLoopRouter.See Also
Defined in
Sets whether or not the ILayoutStage used for routing self-loops is activated.
Default Value
true
.The stage that routes self-loops is activated.
See Also
Overrides
Gets or sets the ILayoutStage that constrains the layout process to a subgraph of the input graph.
Default Value
SubgraphLayout.See Also
Defined in
Gets or sets whether or not the ILayoutStage used for constraining the layout process to a subgraph of the input graph is activated.
Remarks
Default Value
false
.The stage that constrains the input graph to a subgraph is deactivated.
See Also
Defined in
Gets or sets how the children of a local root are arranged and how the edges between them are routed.
Default Value
HORIZONTAL.Throws
- Exception({ name: 'ArgumentError' })
- if the specified routing policy is unknown
Gets or sets the vertical distance between adjacent nodes.
Remarks
Default Value
10
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified distance is negative
See Also
Sample Graphs
Methods
Appends the given ILayoutStage to the layout pipeline.
Remarks
Parameters
A map of options to pass to the method.
- stage - ILayoutStage
- the ILayoutStage instance to be added
See Also
Defined in
Calculates a layout for the given graph and applies it directly to the graph.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
See Also
Implements
Arranges the given graph considering the specified aspect ratio.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
Throws
- Exception({ name: 'InvalidGraphStructureError' })
- if the input graph is not a tree
Implements
Checks the sizes of the nodes to be non-zero.
Parameters
A map of options to pass to the method.
- g - LayoutGraph
- The graph to check.
Defined in
createBends
(edgeLayout: IEdgeLayout, localRoot: YNode, child: YNode, rootPlacement: RootPlacement, routingPolicy: SubtreeArrangement)Adds bends to the given IEdgeLayout.
Remarks
Parameters
A map of options to pass to the method.
- edgeLayout - IEdgeLayout
- the layout of the edge that is routed
- localRoot - YNode
- the local root of the subtree
- child - YNode
- the child connected to the local root with the given edge
- rootPlacement - RootPlacement
- the placement specifier of the local root
- routingPolicy - SubtreeArrangement
- the direction specifier for the routing
Deactivates all predefined ILayoutStages so that upon applyLayout only the layout algorithm will be executed.
See Also
Defined in
Retrieves the aspect ratio for the subtree that is rooted at the given node.
Remarks
If there is an individual aspect ratio for the subtree provided by a IDataProvider registered with key SUBTREE_ASPECT_RATIO_DP_KEY, that ratio will be returned. Otherwise, the default aspect ratio will be returned.
This method is called by applyLayoutCore before a subtree is arranged. It may be overridden to use another approach to define the aspect ratio for subtrees.
Parameters
A map of options to pass to the method.
- localRoot - YNode
- the root node of the subtree
Returns
- ↪number
- the aspect ratio of the subtree rooted at the local root node
See Also
Retrieves the root placement for the subtree that is rooted at the given node.
Remarks
Either an individual root placement for the subtree (defined via a IDataProvider registered with ROOT_PLACEMENT_DP_KEY), or if there is none, the default root placement is returned.
This method is called by applyLayoutCore after a subtree is arranged to align the local root node. It may be overridden to use another approach to define the root placement for a subtree.
Parameters
A map of options to pass to the method.
- localRoot - Object
- the root of the subtree
Returns
- ↪RootPlacement
- the root placement of the subtree
See Also
Retrieves the routing for the subtree that is rooted at the given node.
Remarks
Either an individual routing for the subtree (defined via a IDataProvider registered with SUBTREE_ROUTING_POLICY_DP_KEY), or if there is none, the default routing is returned.
This method is called by applyLayoutCore to determine the direction of the subtrees. It may be overridden to use another approach to define the routing for a subtree.
Parameters
A map of options to pass to the method.
- localRoot - Object
- the root of the subtree
Returns
- ↪SubtreeArrangement
- the routing policy for the subtree
See Also
Retrieves all children of the given local root.
Remarks
Parameters
A map of options to pass to the method.
- localRoot - YNode
- the root of a subtree
Returns
- ↪INodeCursor
- all successors of the given node
Prepends the given ILayoutStage to the layout pipeline.
Remarks
Parameters
A map of options to pass to the method.
- stage - ILayoutStage
- the ILayoutStage instance to be added
See Also
Defined in
Removes the given ILayoutStage from the layout pipeline.
Remarks
Parameters
A map of options to pass to the method.
- stage - ILayoutStage
- a ILayoutStage to be removed from the layout pipeline
See Also
Defined in
Fields
The input graph this algorithm is handling.
Constants
A data provider key for specifying the placement of each subtree root.
Remarks
Domain | YNode | |
Values | Object | the root placement specifier for the node |
See Also
A data provider key for marking the node that will be used as root node of the tree.
Domain | YNode | |
Values | boolean | true if the node should be considered as the root node of the tree, false otherwise |
A data provider key for specifying a target aspect ratio for each subtree.
Remarks
The aspect ratio needs to be greater than 0
.
- aspect ratio
1
: width and height of the layout should be the same - aspect ratio between
0
and1
: the height of the layout should be greater than its width - aspect ratio greater than
1
: the width of the layout should be greater than its height
If no specific ratio is defined for a subtree, the layout algorithm falls back to the default aspect ratio.
Domain | YNode | |
Values | number | the preferred aspect ratio for the subtree rooted at the node |
See Also
A data provider key for specifying the routing direction for each subtree root.
Remarks
The children in a subtree are arranged either horizontally or vertically. The edges are routed to the top of the child nodes or at the side, respectively. Directions depend on the layout orientation and refer to TOP_TO_BOTTOM for this description.
If no specific routing policy is specified for a subtree root, the layout algorithm uses the default routing direction.
Domain | YNode | |
Values | Object | routing style |