Search this API

y.layout.hierarchic.incremental
Class MultiComponentLayerer

java.lang.Object
  extended by y.layout.hierarchic.incremental.MultiComponentLayerer
All Implemented Interfaces:
Layerer

public class MultiComponentLayerer
extends java.lang.Object
implements Layerer

This class is a wrapper Layerer implementation that delegates the actual layering to a delegate Layerer.

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 Layerer instance. After that they will all be merged using the specified LayeredComponentsMerger instance.

 

Constructor Summary
MultiComponentLayerer(Layerer singleComponentLayerer)
          Creates a new instance of MultiComponentLayerer using the given delegate Layerer.
MultiComponentLayerer(Layerer singleComponentLayerer, LayeredComponentsMerger merger, java.util.Comparator componentComparator)
          Creates a new instance of MultiComponentLayerer using the given LayeredComponentsMerger and Comparator instances.
 
Method Summary
 void assignLayers(LayoutGraph graph, Layers layers, LayoutDataProvider ldp)
          Assigns all nodes of the graph to layers and adds them to the Layers instance.
 java.util.Comparator getComponentComparator()
          Returns the component Comparator instance.
 LayeredComponentsMerger getMerger()
          Returns the merger instance.
 Layerer getSingleComponentLayerer()
          Returns the delegate Layerer instance.
 void setComponentComparator(java.util.Comparator componentComparator)
          Specifies the component Comparator instance.
 void setMerger(LayeredComponentsMerger merger)
          Specifies the merger instance.
 void setSingleComponentLayerer(Layerer singleComponentLayerer)
          Specifies the delegate Layerer instance.
protected  void sort(NodeList[] nodeLists, DataProvider componentIndexProvider)
          Sorts an array which consists of NodeLists each of which contains nodes that belong to the same component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiComponentLayerer

public MultiComponentLayerer(Layerer singleComponentLayerer)
Creates a new instance of MultiComponentLayerer using the given delegate Layerer.

A new instance of DefaultLayeredComponentsMerger will be used as merger while no component Comparator will be used.

Throws:
java.lang.IllegalArgumentException - if the given layerer is null

MultiComponentLayerer

public MultiComponentLayerer(Layerer singleComponentLayerer,
                             LayeredComponentsMerger merger,
                             java.util.Comparator componentComparator)
Creates a new instance of MultiComponentLayerer using the given LayeredComponentsMerger and Comparator instances.

Throws:
java.lang.IllegalArgumentException - if the given layerer or merger is null
Method Detail

assignLayers

public void assignLayers(LayoutGraph graph,
                         Layers layers,
                         LayoutDataProvider ldp)
Description copied from interface: Layerer
Assigns all nodes of the graph to layers and adds them to the Layers instance.

In order to create new layers, factory method Layers.insert(byte, int) has to be used.

Information about the nodes is provided by a LayoutDataProvider. However, positional information (see NodeData.getPosition() and NodeData.getLayer()) is not available during this phase.

Specified by:
assignLayers in interface Layerer
Parameters:
graph - the input graph
layers - the Layers instance that will be filled with the results of the calculation
ldp - the LayoutDataProvider used for querying information about the nodes and edges
See Also:
Layers.insert(byte, int), Layer.add(y.base.Node)

sort

protected void sort(NodeList[] nodeLists,
                    DataProvider componentIndexProvider)
Sorts an array which consists of NodeLists each of which contains nodes that belong to the same component.

It is called during assignLayers(LayoutGraph, Layers, LayoutDataProvider).

By default this method uses the ComponentComparator to sort the list and has no effect if the instance is null.

Parameters:
nodeLists - the array of NodeLists each of which containing nodes that belong to the same component
componentIndexProvider - the DataProvider that returns an object (the component index) for each node (this value can be either integer or object)

getSingleComponentLayerer

public Layerer getSingleComponentLayerer()
Returns the delegate Layerer instance.

Returns:
the given Layerer instance
See Also:
setSingleComponentLayerer(Layerer)

setSingleComponentLayerer

public void setSingleComponentLayerer(Layerer singleComponentLayerer)
Specifies the delegate Layerer instance.

Parameters:
singleComponentLayerer - the given Layerer instance
Throws:
java.lang.IllegalArgumentException - if the specified Layerer is null

getMerger

public LayeredComponentsMerger getMerger()
Returns the merger instance.

Returns:
the merger instance
See Also:
setMerger(LayeredComponentsMerger)

setMerger

public void setMerger(LayeredComponentsMerger merger)
Specifies the merger instance.

Parameters:
merger - the merger instance
Throws:
java.lang.IllegalArgumentException - if the specified LayeredComponentsMerger is null

getComponentComparator

public java.util.Comparator getComponentComparator()
Returns the component Comparator instance.

Returns:
the component Comparator or null if no specific Comparator exists

setComponentComparator

public void setComponentComparator(java.util.Comparator componentComparator)
Specifies the component Comparator instance.

Parameters:
componentComparator - the component Comparator or null if no specific Comparator is desired

© Copyright 2000-2021,
yWorks GmbH.
All rights reserved.