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 java.lang.Object
implements Layerer, Layerer

This layering algorithm implementation assigns nodes to layers given a mapping of nodes to layer IDs.

The layer IDs are given by a DataProvider that returns the integer layer ID of each node of the graph. Nodes with the same ID are in the same layer while the layers are sorted according to their IDs such that the smallest ID represents the top layer.

 
This class can be used with IncrementalHierarchicLayouter as well as HierarchicLayouter and HierarchicGroupLayouter.
 

Field Summary
static java.lang.Object LAYER_ID_KEY
          A DataProvider key for storing the layer IDs.
 
Constructor Summary
GivenLayersLayerer()
          Creates an instance of GivenLayersLayerer.
 
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.
 int assignNodeLayer(LayoutGraph graph, NodeMap layerID, EdgeList reversedEdges)
          Assigns the nodes of the graph to layers given by the DataProvider registered with the graph using key LAYER_ID_KEY.
 int normalize(Graph graph, DataProvider layerId, DataAcceptor normalizedLayerId)
          Convenience method that 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 java.lang.Object LAYER_ID_KEY
A DataProvider key for storing the layer IDs.

This DataProvider stores for each node the layer ID to which it belongs. Nodes with the same ID are in the same layer while the layers are sorted according to their IDs such that the smallest ID represents the top layer.

Constructor Detail

GivenLayersLayerer

public GivenLayersLayerer()
Creates an instance of GivenLayersLayerer.

Method Detail

normalize

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

Parameters:
graph - the graph
layerId - the DataProvider that returns an integer value (layer) for each node; the first layer has the number 0
normalizedLayerId - the DataAcceptor that will be filled by the layout algorithm and holds an integer value (layer ID after normalization) for each node
Returns:
the number of layers after the removal of empty layers

assignNodeLayer

public int assignNodeLayer(LayoutGraph graph,
                           NodeMap layerID,
                           EdgeList reversedEdges)
Assigns the nodes of the graph to layers given by the DataProvider registered with the graph using key LAYER_ID_KEY.

Parameters:
graph - the graph
layerID - the NodeMap that will be filled during the execution and holds the zero-based index of the layer to which each node belongs; this NodeMap is a normalized variant of the given DataProvider registered with the graph using key LAYER_ID_KEY and the first layer has the number 0
reversedEdges - the EdgeList containing the edges that have been reversed
Returns:
the number of layers after the removal of empty layers
Throws:
java.lang.IllegalArgumentException - if no DataProvider with key LAYER_ID_KEY is registered with the given graph

assignLayers

public void assignLayers(LayoutGraph graph,
                         Layers layers,
                         LayoutDataProvider ldp)
Assigns all nodes of the graph to layers and adds them to the Layers instance.

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)

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