Search this API

y.layout.hierarchic
Class GivenLayersLayerer

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

public class GivenLayersLayerer
extends Object
implements Layerer, Layerer

This layerer implementation layers the nodes by given layer IDs. The layer IDs are given by a DataProvider that returns the integral layer ID of each node in the graph.


Field Summary
static Object LAYER_ID_KEY
          The key used by this class to query a graph for a DataProvider that yields the layerID for each node in the graph.
 
Constructor Summary
GivenLayersLayerer()
           
 
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.
 int assignNodeLayer(LayoutGraph g, NodeMap layerMap, EdgeList reversedEdges)
          Assigns layers to the graph that were given by the DataProvider g.getDataProvider(LAYER_ID_KEY).
 int normalize(Graph g, DataProvider layerId, DataAcceptor normalizedLayerId)
          Convenience method which removes empty layers and ensures that the smallest layer has value 0.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LAYER_ID_KEY

public static final Object LAYER_ID_KEY
The key used by this class to query a graph for a DataProvider that yields the layerID for each node in the graph.

Constructor Detail

GivenLayersLayerer

public GivenLayersLayerer()
Method Detail

normalize

public int normalize(Graph g,
                     DataProvider layerId,
                     DataAcceptor normalizedLayerId)
Convenience method which removes empty layers and ensures that the smallest layer has value 0.

Parameters:
layerId - provides the current layer ids for nodes in g
normalizedLayerId - accepts the new layer ids that result after normalization.
Returns:
The amount of layers left after removing all empty layers.

assignNodeLayer

public int assignNodeLayer(LayoutGraph g,
                           NodeMap layerMap,
                           EdgeList reversedEdges)
Assigns layers to the graph that were given by the DataProvider g.getDataProvider(LAYER_ID_KEY). The returned layerMap will be a normalized variant of the user given data provider. A normalized variant has no empty layers and a minimum layerID 0.


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)

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