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 Object
implements Layerer

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 in order using the specified LayeredComponentsMerger instance.


Constructor Summary
MultiComponentLayerer(Layerer singleComponentLayerer)
          Creates a new instance of MultiComponentLayerer using the given delegate and a new instance of DefaultLayeredComponentsMerger as the merger and no component comparator.
MultiComponentLayerer(Layerer singleComponentLayerer, LayeredComponentsMerger merger, Comparator componentComparator)
          Creates a new instance of MultiComponentLayerer using the given delegates.
 
Method Summary
 void assignLayers(LayoutGraph graph, Layers layers, LayoutDataProvider ldp)
          This method assigns all nodes in the graph to layers and registers them in the Layers instance.
 Comparator getComponentComparator()
          Returns the current component Comparator or null.
 LayeredComponentsMerger getMerger()
          Returns the merger.
 Layerer getSingleComponentLayerer()
          Returns the Layerer instance that is used for delegation.
 void setComponentComparator(Comparator componentComparator)
          Sets the component Comparator instance, may be null
 void setMerger(LayeredComponentsMerger merger)
          Sets the new merger instance.
 void setSingleComponentLayerer(Layerer singleComponentLayerer)
          Sets the new delegate Layerer instance.
protected  void sort(NodeList[] nodeLists, DataProvider componentIndexProvider)
          Callback method that is called during assignLayers(LayoutGraph, Layers, LayoutDataProvider).
 
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 and a new instance of DefaultLayeredComponentsMerger as the merger and no component comparator.


MultiComponentLayerer

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

Method Detail

assignLayers

public void assignLayers(LayoutGraph graph,
                         Layers layers,
                         LayoutDataProvider ldp)
Description copied from interface: Layerer
This method assigns all nodes in the graph to layers and registers them in the Layers instance. In order to create new layers, the factory method Layers.insert(byte, int) must be used.

Specified by:
assignLayers in interface Layerer
Parameters:
graph - the graph that contains the nodes that should be distributed into the layers
layers - the object that will be filled with the results of the calculation
ldp - LayoutDataProvider that can be used to query information about the nodes - note that positional information (see NodeData.getPosition() and NodeData.getLayer()) cannot be available at any time.
See Also:
Layers.insert(byte, int), Layer.add(y.base.Node)

sort

protected void sort(NodeList[] nodeLists,
                    DataProvider componentIndexProvider)
Callback method that is called during assignLayers(LayoutGraph, Layers, LayoutDataProvider). It is responsible for sorting an array consisting of NodeLists, each containing nodes that belong to a different component. By default this method uses the ComponentComparator to sort the list or does nothing if that instance is null.

Parameters:
nodeLists - the array of NodeLists each containing all nodes that belong to the same component
componentIndexProvider - a DataProvider that can be used to query the nodes' component indices via DataProvider.getInt(Object) and/or DataProvider.get(Object).

getSingleComponentLayerer

public Layerer getSingleComponentLayerer()
Returns the Layerer instance that is used for delegation.

Returns:
the delegate instance

setSingleComponentLayerer

public void setSingleComponentLayerer(Layerer singleComponentLayerer)
Sets the new delegate Layerer instance.

Throws:
NullPointerException - if the argument is null
Parameters:
singleComponentLayerer - the new instance.

getMerger

public LayeredComponentsMerger getMerger()
Returns the merger.

Returns:
the current merger instance

setMerger

public void setMerger(LayeredComponentsMerger merger)
Sets the new merger instance.

Throws:
NullPointerException - if the argument is null
Parameters:
merger - the new instance.

getComponentComparator

public Comparator getComponentComparator()
Returns the current component Comparator or null.

Returns:
the current comparator or null

setComponentComparator

public void setComponentComparator(Comparator componentComparator)
Sets the component Comparator instance, may be null

Parameters:
componentComparator - the new instance or null

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