Search this API

y.layout.hierarchic.incremental
Class AspectRatioComponentLayerer

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

public class AspectRatioComponentLayerer
extends java.lang.Object
implements Layerer

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

If the graph consists of multiple components, they will be identified and each of the components will be layered separately using the delegate Layerer instance. After that they will all be merged such that the desired aspect ratio is fulfilled best.


Sample output of AspectRatioComponentLayerer with default settings on a graph with two connected components.

 
For grouped graphs, the desired aspect ratio is also considered for each group node separately.
See Also:
setDesiredAspectRatio(double), MultiComponentLayerer
 

Constructor Summary
AspectRatioComponentLayerer(Layerer singleComponentLayerer)
          Creates a new instance of AspectRatioComponentLayerer using the given delegate Layerer instance.
 
Method Summary
 void assignLayers(LayoutGraph graph, Layers layers, LayoutDataProvider ldp)
          Assigns all nodes of the graph to layers and registers them to the Layers instance based on the given aspect ratio.
 double getDesiredAspectRatio()
          Returns the desired aspect ratio.
 Layerer getSingleComponentLayerer()
          Returns the delegate Layerer instance.
 boolean isConsiderNodeSize()
          Returns whether or not the size of the nodes should be considered.
 void setConsiderNodeSize(boolean considerNodeSize)
          Specifies whether or not the size of the nodes should be considered.
 void setDesiredAspectRatio(double desiredAspectRatio)
          Specifies the desired aspect ratio.
 void setSingleComponentLayerer(Layerer singleComponentLayerer)
          Specifies the delegate Layerer instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AspectRatioComponentLayerer

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

Throws:
java.lang.IllegalArgumentException - if the specified Layerer is null
Method Detail

getSingleComponentLayerer

public Layerer getSingleComponentLayerer()
Returns the delegate Layerer instance.

Returns:
a Layerer instance

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

isConsiderNodeSize

public boolean isConsiderNodeSize()
Returns whether or not the size of the nodes should be considered.

If this option is disabled, all nodes are considered to be of equal size. Hence, the given aspect ratio specifies the ratio between the number of nodes within a layer and the overall number of layers.

Default Value:
The default value is true.
Returns:
true if the size of the node is considered, false otherwise
See Also:
setConsiderNodeSize(boolean)

setConsiderNodeSize

public void setConsiderNodeSize(boolean considerNodeSize)
Specifies whether or not the size of the nodes should be considered.

If this option is disabled, all nodes are considered to be of equal size. Hence, the given aspect ratio specifies the ratio between the number of nodes within a layer and the overall number of layers.

Default Value:
The default value is true.
Parameters:
considerNodeSize - true if the size of the node should be considered, false otherwise
Sample Graphs:

false

true

getDesiredAspectRatio

public double getDesiredAspectRatio()
Returns the desired aspect ratio.

If the graph consists of multiple components, they will be identified and each of the components will be layered separately using the delegate Layerer instance. After that, they will all be merged such that the desired aspect ratio is best fulfilled.

The given aspect ratio should be greater or equal to 0.

 
For grouped graphs, the desired aspect ratio is also considered for each group node separately.
Returns:
the desired aspect ratio
See Also:
setDesiredAspectRatio(double)

setDesiredAspectRatio

public void setDesiredAspectRatio(double desiredAspectRatio)
Specifies the desired aspect ratio.

If the graph consists of multiple components, they will be identified and each of the components will be layered separately using the delegate Layerer instance. After that, they will all be merged such that the desired aspect ratio is best fulfilled.

The given aspect ratio should be greater or equal to 0.

 
For grouped graphs, the desired aspect ratio is also considered for each group node separately.
Default Value:
The default value is 1.
Parameters:
desiredAspectRatio - the desired aspect ratio
Throws:
java.lang.IllegalArgumentException - if the aspect ratio is negative
Sample Graphs:

Aspect ratio 0.1

Aspect ratio 1.0

Aspect ratio 2.0

assignLayers

public void assignLayers(LayoutGraph graph,
                         Layers layers,
                         LayoutDataProvider ldp)
Assigns all nodes of the graph to layers and registers them to the Layers instance based on the given aspect ratio.

If the graph consists of multiple components, they will be identified and each of the components will be layered separately using the delegate Layerer instance. After that, they will all be merged such that the desired aspect ratio is best fulfilled.

Specified by:
assignLayers in interface Layerer
 
For grouped graphs, the desired aspect ratio is also considered for each group node separately.
Parameters:
graph - the input graph
layers - the Layers instance that will be filled with the results of the calculation
ldp - the LayoutDataProvider used for query 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.