public class MultiComponentLayerer extends Object implements ILayerer
ILayerer
implementation that delegates the actual layering to a delegate
ILayerer
.
If the graph consists of multiple components, they will be identified and sorted and each of the components will be
layered separately using the delegate ILayerer
instance. After that they will all be merged using the specified
ILayeredComponentsMerger
instance.
Constructor and Description |
---|
MultiComponentLayerer(ILayerer singleComponentLayerer)
Creates a new instance of
MultiComponentLayerer using the given delegate ILayerer . |
MultiComponentLayerer(ILayerer singleComponentLayerer,
ILayeredComponentsMerger merger,
Comparator<Object> componentComparator)
Creates a new instance of
MultiComponentLayerer using the given ILayeredComponentsMerger and Comparator
instances. |
Modifier and Type | Method and Description |
---|---|
void |
assignLayers(LayoutGraph graph,
ILayers layers,
ILayoutDataProvider ldp)
Assigns all nodes of the graph to layers and adds them to the
ILayers instance. |
Comparator<Object> |
getComponentComparator()
Gets the component
Comparator instance. |
ILayeredComponentsMerger |
getMerger()
Gets the
merger instance. |
ILayerer |
getSingleComponentLayerer()
Gets the delegate
ILayerer instance. |
void |
setComponentComparator(Comparator<Object> value)
Sets the component
Comparator instance. |
void |
setMerger(ILayeredComponentsMerger value)
Sets the
merger instance. |
void |
setSingleComponentLayerer(ILayerer value)
Sets the delegate
ILayerer instance. |
protected void |
sort(NodeList[] nodeLists,
IDataProvider componentIndexProvider)
Sorts an array which consists of
NodeList s each of which contains nodes that belong to the same component. |
public MultiComponentLayerer(ILayerer singleComponentLayerer)
MultiComponentLayerer
using the given delegate ILayerer
.
A new instance of DefaultLayeredComponentsMerger
will be used as merger while no component Comparator
will be used.
IllegalArgumentException
- if the given layerer is null
public MultiComponentLayerer(ILayerer singleComponentLayerer, ILayeredComponentsMerger merger, Comparator<Object> componentComparator)
MultiComponentLayerer
using the given ILayeredComponentsMerger
and Comparator
instances.IllegalArgumentException
- if the given layerer or merger is null
public void assignLayers(LayoutGraph graph, ILayers layers, ILayoutDataProvider ldp)
ILayerer
ILayers
instance.
In order to create new layers, factory method ILayers.insert(com.yworks.yfiles.layout.hierarchic.LayerType, int)
has to be used.
Information about the nodes is provided by a ILayoutDataProvider
. However, positional information (see Position
and Layer
) is not available during this phase.
assignLayers
in interface ILayerer
graph
- the input graphlayers
- the ILayers
instance that will be filled with the results of the calculationldp
- the ILayoutDataProvider
used for querying information about the nodes and edgesILayers.insert(com.yworks.yfiles.layout.hierarchic.LayerType, int)
,
ILayer.add(com.yworks.yfiles.algorithms.Node)
public Comparator<Object> getComponentComparator()
Comparator
instance.Comparator
or null
if no specific Comparator
existssetComponentComparator(Comparator)
public ILayeredComponentsMerger getMerger()
merger
instance.IllegalArgumentException
- if the specified ILayeredComponentsMerger
is null
merger
instancesetMerger(ILayeredComponentsMerger)
public ILayerer getSingleComponentLayerer()
ILayerer
instance.IllegalArgumentException
- if the specified ILayerer
is null
ILayerer
instancesetSingleComponentLayerer(ILayerer)
public void setComponentComparator(Comparator<Object> value)
Comparator
instance.value
- the component Comparator
or null
if no specific Comparator
existsgetComponentComparator()
public void setMerger(ILayeredComponentsMerger value)
merger
instance.IllegalArgumentException
- if the specified ILayeredComponentsMerger
is null
value
- the merger
instancegetMerger()
public void setSingleComponentLayerer(ILayerer value)
ILayerer
instance.IllegalArgumentException
- if the specified ILayerer
is null
value
- the given ILayerer
instancegetSingleComponentLayerer()
protected void sort(NodeList[] nodeLists, IDataProvider componentIndexProvider)
NodeList
s each of which contains nodes that belong to the same component.
It is called during assignLayers(LayoutGraph, ILayers, ILayoutDataProvider)
.
By default this method uses the ComponentComparator
to sort the list and has no effect
if the instance is null
.
nodeLists
- the array of NodeList
s each of which containing nodes that belong to the same componentcomponentIndexProvider
- the IDataProvider
that returns an object (the component index) for each node (this value can be either integer
or object)