This class is a wrapper ILayerAssigner implementation that delegates the actual layering to a delegate ILayerAssigner.
Remarks
Default Values of Properties
mergingPolicy | ADD_RIGHT_TOP_ALIGNED
| Nodes of the source |
Type Details
- yFiles module
- algorithms
Constructors
Creates a new instance of MultiComponentLayerAssigner.
Parameters
A map of options to pass to the method.
- singleComponentLayerAssigner - ILayerAssigner
- The layer assigner to be used for single components.
- componentComparator - function(YList<LayoutNode>, YList<LayoutNode>):number
- The comparison function to sort the lists of nodes that form a component. This option sets the componentComparator property on the created object.
Signature Details
function(x: YList<LayoutNode>, y: YList<LayoutNode>) : number
Encapsulates a method that compares two objects.Parameters
- x - YList<LayoutNode>
- The first object to compare.
- y - YList<LayoutNode>
- The second object to compare.
Returns
- number
- An integer value which is
<0
ifx
is less thany
,0
ifx
is equal toy
, or>0
ifx
is greater thany
- mergingPolicy - LayerMergingPolicy
- The merging policy that is obeyed by the default implementation of merge. This option sets the mergingPolicy property on the created object.
Throws
- Exception({ name: 'ArgumentError' })
- if the given layer assigner is
null
Properties
Gets or sets the comparison function to sort the lists of nodes that form a component.
Property Value
null
if no specific comparison existsSignature Details
function(x: YList<LayoutNode>, y: YList<LayoutNode>) : number
Parameters
- x - YList<LayoutNode>
- The first object to compare.
- y - YList<LayoutNode>
- The second object to compare.
Returns
- number
- An integer value which is
<0
ifx
is less thany
,0
ifx
is equal toy
, or>0
ifx
is greater thany
Gets or sets the merging policy that is obeyed by the default implementation of merge.
Default Value
ADD_RIGHT_TOP_ALIGNED.Nodes of the source
Property Value
Gets or sets the delegate ILayerAssigner instance.
Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified
is null
Methods
Assigns all nodes of the graph to layers and adds them to the layers in the given layoutContext
.
Remarks
In order to create new layers, factory method insertLayer has to be used.
Information about the nodes is provided by a HierarchicalLayoutContext instance. However, positional information (see position and layer) is not available during this phase.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
- layoutContext - HierarchicalLayoutContext
- The HierarchicalLayoutContext instance providing access to context information for the graph elements, as well as the layers the nodes are assigned to.
See Also
Implements
merge
(graph: LayoutGraph, sourceLayersContext: HierarchicalLayoutContext, targetLayersContext: HierarchicalLayoutContext)Merges the two layer lists contained in the two given HierarchicalLayoutContext instances.
Remarks
All nodes that belong to the source and target layers are part of the graph at the moment of invocation.
The state of the source HierarchicalLayoutContext instance is discarded after this call and does not need to be updated to reflect the changes. The target HierarchicalLayoutContext instance must be updated accordingly.
By default, this method takes into account the mergingPolicy to merge layers. It can be overridden to implement a custom merging strategy.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph containing the nodes of both contexts/layerings
- sourceLayersContext - HierarchicalLayoutContext
- the HierarchicalLayoutContext that holds the source layers that will be merged into the target layers
- targetLayersContext - HierarchicalLayoutContext
- the HierarchicalLayoutContext that holds the target layers that will be modified to contain the resulting (merged) layering
Sorts an array which consists of YList<T>s, where each list contains nodes that belong to the same component.
Remarks
It is called during assignLayers.
By default, this method uses the componentComparator to sort the list and has no effect if the instance is null
. This means it ignores the componentIndexProvider
parameter.
The method may be overridden to implement a custom ordering of the components.
Parameters
A map of options to pass to the method.
- nodeLists - YList<LayoutNode>[]
- the array of YList<T> with LayoutNodes each of which containing nodes that belong to the same component
- componentIndexProvider - IMapper<LayoutNode,number>
- the IMapper<K,V> that returns an object representing the component index for each node (this value can be either integer or object)