Specifies custom data for the RecursiveGroupLayout.
Examples
The following example shows how to create a new instance of RecursiveGroupLayoutData and use it with an RecursiveGroupLayout:
In many cases the complete initialization of RecursiveGroupLayoutData can also be done in a single object initializer:
Another fairly useful way of using RecursiveGroupLayout is to just do a top-level layout and leave the contents of the group nodes alone. This can be done by using NULL_LAYOUT as the layout algorithm for group nodes:
const layoutData = new RecursiveGroupLayoutData()
layoutData.groupNodeLayouts.constant = RecursiveGroupLayout.NULL_LAYOUT
graphComponent.graph.applyLayout(
new RecursiveGroupLayout(new OrthogonalLayout()),
layoutData
)
Type Details
- yfiles module
- view-layout-bridge
- yfiles-umd modules
- view-layout-bridge
- Legacy UMD name
- yfiles.layout.RecursiveGroupLayoutData
Constructors
Creates a new instance of RecursiveGroupLayoutData which helps configuring RecursiveGroupLayout.
Parameters
A map of options to pass to the method.
- groupNodeLayouts - ItemMapping<INode,ILayoutAlgorithm>
The mapping from group nodes to the ILayoutAlgorithm used for their child nodes. This option sets the groupNodeLayouts property on the created object.
- nodeHalos - ItemMapping<INode,NodeHalo>
- sourceSplitIds - ItemMapping<IEdge,Object>
A mapping from edges connecting to group nodes to source split ids. This option sets the sourceSplitIds property on the created object.
- targetSplitIds - ItemMapping<IEdge,Object>
A mapping from edges connecting to group nodes to target split ids. This option sets the targetSplitIds property on the created object.
- sourcePortConstraints - ItemMapping<IEdge,PortConstraint>
A mapping from edges to their source PortConstraint. This option sets the sourcePortConstraints property on the created object.
- targetPortConstraints - ItemMapping<IEdge,PortConstraint>
A mapping from edges to their target PortConstraint. This option sets the targetPortConstraints property on the created object.
- sourcePortCandidates - ItemMapping<IEdge,ICollection<PortCandidate>>
A mapping from edges to a collection of their source port candidates. This option sets the sourcePortCandidates property on the created object.
- targetPortCandidates - ItemMapping<IEdge,ICollection<PortCandidate>>
A mapping from edges to a collection of their target port candidates. This option sets the targetPortCandidates property on the created object.
- nodePortCandidateSets - ItemMapping<INode,PortCandidateSet>
A mapping from nodes to their PortCandidateSet. This option sets the nodePortCandidateSets property on the created object.
- abortHandler - AbortHandler
The AbortHandler used during the layout. This option sets the abortHandler property on the created object.
- partitionGridData - PartitionGridData
The partition grid layout data. This option sets the partitionGridData property on the created object.
- groupNodePartitionGrids - ItemMapping<INode,PartitionGridData>
A mapping from group nodes to the PartitionGridData used for their content. This option sets the groupNodePartitionGrids property on the created object.
Properties
Gets or sets the AbortHandler used during the layout.
Remarks
An AbortHandler can be used to gracefully stop or cancel a running layout and offers options for automatically doing so after a predetermined time.
An AbortHandler configured or set here overrides the one on LayoutExecutor.
Examples
The most common use case would be to just configure the AbortHandler here, e.g. to set timeouts for a graceful stop or canceling the running layout:
layoutData.abortHandler.stopDuration = TimeSpan.fromSeconds(10) layoutData.abortHandler.cancelDuration = TimeSpan.fromSeconds(30)
layoutData.abortHandler!.stopDuration = TimeSpan.fromSeconds(10) layoutData.abortHandler!.cancelDuration = TimeSpan.fromSeconds(30)
If there's already an AbortHandler instance that's pre-configured or will be used in a different place to, e.g., cancel the layout when the user presses a button, you can also set one explicitly:
layoutData.abortHandler = abortHandler
See Also
Gets or sets the mapping from group nodes to the ILayoutAlgorithm used for their child nodes.
Remarks
The specified layout is applied to the content of the group node. To arrange the top level elements the core layout algorithm is used.
The core layout is also applied to group nodes if there are no groupNodeLayouts defined at all. Importantly, this must be distinguished from the case that the mapping is defined but null
is mapped with a group. Then, RecursiveGroupLayout handles this group node non-recursively. The group node and its content is arranged using the ILayoutAlgorithm instance specified for the nearest ancestor of the group node which is associated with a layout algorithm.
Examples
The layout algorithms for individual group nodes can be specified in various ways, depending on which option is the most convenient. The easiest way would be to set the same layout algorithm for all group nodes:
For scenarios where only some group nodes should have a specific layout algorithm the mapper is usually the best option. However, due to RecursiveGroupLayout's handling of individual group node layout's as described above, this can be a bit complicated to specify since the IMapper<K,V> by default returns null
.
So when only the mapped group nodes should have a layout algorithm applied to their contents a new Mapper<K,V> would have to be created:
const mapper = new Mapper()
mapper.defaultValue = RecursiveGroupLayout.NULL_LAYOUT
mapper.set(groupNode1, new OrthogonalLayout())
mapper.set(groupNode2, new HierarchicLayout())
layoutData.groupNodeLayouts = mapper
const mapper = new Mapper<INode, ILayoutAlgorithm>()
mapper.defaultValue = RecursiveGroupLayout.NULL_LAYOUT
mapper.set(groupNode1, new OrthogonalLayout())
mapper.set(groupNode2, new HierarchicLayout())
layoutData.groupNodeLayouts = mapper
In cases where all group node's contents should be laid out, most of them with the coreLayout and only some customized, the predefined IMapper<K,V> can be used as is:
layoutData.groupNodeLayouts.mapper.set(groupNode1, new OrthogonalLayout())
layoutData.groupNodeLayouts.mapper.set(groupNode2, new HierarchicLayout())
If the desired layout algorithm for a group node can be readily inferred from the node itself, the delegate is usually the easiest to use:
See Also
Gets or set a mapping from group nodes to the PartitionGridData used for their content.
Remarks
Each recursively handled group node can get its own local PartitionGrid. The grid is then valid for the child nodes of the group and only visible for the layout algorithm that is responsible for the group's content. Thus, to properly consider the grid it is required that the responsible algorithm supports the partition grid structure.
In addition to the local partition grids it is also allowed to have a global grid which can be defined by using partitionGridData.
Gets or sets the mapping from nodes to their NodeHalo.
Remarks
Examples
The easiest option is to reserve the same space around all nodes, by setting a constant NodeHalo:
Handling only certain nodes differently can be done easily by using the mapper property:
In cases where the NodeHalo for each node can be determined by looking at the node itself it's often easier to just set a delegate instead of preparing a mapper:
See Also
Gets or sets a mapping from nodes to their PortCandidateSet.
Examples
The simplest way to define node port candidate sets is to use the same PortCandidateSet for all nodes, if suitable for the use case:
The same effect can be achieved with a delegate as well, however, a more useful way to use a delegate would be to decide whether a node should get a port candidate set based on some data at the node, e.g., found in its tag:
If specific nodes should get a certain PortCandidateSet, it may sometimes be easier to use the mapper to set them:
See Also
Gets or sets the partition grid layout data.
Remarks
This property defines the top-level global partition grid. To define a local partition grid for each recursively handled group node use groupNodePartitionGrids. A top-level grid should only be registered if the layout algorithm responsible for the top-level hierarchy i.e. the core layout algorithm supports a PartitionGrid.
Note that if you use LayoutExecutor's configureTableLayout feature this property should not be used as it overrides the PartitionGrid set by TableLayoutConfigurator.
Gets or sets a mapping from edges to a collection of their source port candidates.
Remarks
Port constraints allow to define where an edge can connect to its source node and allow fine control over port placement.
If all that is needed is to fix the source port in its location or on a node side, port constraints are easier to work with, since they are a slightly simpler concept.
Examples
Source port candidates are effectively a collection of possible port placements with different costs and the layout algorithm is free to choose the candidate that fits best into the overall layout, while also preferring candidates with a lower cost. To set the same candidate list for all edges, it's easiest to use the constant property:
If certain edges need specific port candidates, it's usually convenient to use the mapper property:
For cases when the desired configuration of port candidates can be readily created from the edge itself, the delegate is often the most convenient option:
See Also
Sample Graphs
Gets or sets a mapping from edges to their source PortConstraint.
Remarks
Port constraints allow to define where an edge attaches to its source node and can either restrict that to one of the node's sides, or to a fixed port position.
A more general concept which allows finer control over where ports are placed, are port candidates.
Examples
If all edges should exit their source node on the same side, you can simply set a constant constraint for all edges:
To change the constraints for individual edges, it's usually easiest to use the mapper:
If a PortConstraint can readily be created from an edge, using a delegate is often easier:
See Also
Sample Graphs
Gets or sets a mapping from edges connecting to group nodes to source split ids.
Remarks
See Also
Gets or sets a mapping from edges to a collection of their target port candidates.
Remarks
Port constraints allow to define where an edge can connect to its target node and allow fine control over port placement.
If all that is needed is to fix the target port in its location or on a node side, port constraints are easier to work with, since they are a slightly simpler concept.
Examples
Target port candidates are effectively a collection of possible port placements with different costs and the layout algorithm is free to choose the candidate that fits best into the overall layout, while also preferring candidates with a lower cost. To set the same candidate list for all edges, it's easiest to use the constant property:
If certain edges need specific port candidates, it's usually convenient to use the mapper property:
For cases when the desired configuration of port candidates can be readily created from the edge itself, the delegate is often the most convenient option:
See Also
Sample Graphs
Gets or sets a mapping from edges to their target PortConstraint.
Remarks
Port constraints allow to define where an edge attaches to its target node and can either restrict that to one of the node's sides, or to a fixed port position.
A more general concept which allows finer control over where ports are placed, are port candidates.
Examples
If all edges should exit their source node on the same side, you can simply set a constant constraint for all edges:
To change the constraints for individual edges, it's usually easiest to use the mapper:
If a PortConstraint can readily be created from an edge, using a delegate is often easier:
See Also
Sample Graphs
Gets or sets a mapping from edges connecting to group nodes to target split ids.
Remarks
See Also
Methods
Combines this instance with the given layout data.
Remarks
Parameters
A map of options to pass to the method.
- data - LayoutData
- The LayoutData to combine this instance with.
Returns
- ↪LayoutData
- The combined layout data.