Search this API

y.layout.hierarchic
Class AsIsLayerer

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

public class AsIsLayerer
extends java.lang.Object
implements Layerer, Layerer

AsIsLayerer assigns nodes to layers by analyzing already existing node coordinates.

Nodes whose bounding boxes overlap in the main layout direction are assigned to the same layer. To influence to which amount the boxes need to overlap, the nodes can temporarily be scaled. Alternatively, a minimum and maximum size or a halo can be specified for the nodes.


Initial graph


Hierarchic layout when the initial drawing is used as sketch


Hierarchic layout when the initial drawing is not used as sketch

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

Constructor Summary
AsIsLayerer()
          Creates an instance of AsIsLayerer with default settings.
 
Method Summary
 void assignLayers(LayoutGraph graph, Layers layers, LayoutDataProvider ldp)
          Assigns all nodes of the graph to layers by analyzing already existing node coordinates and adds them to the Layers instance.
 int assignNodeLayer(LayoutGraph graph, NodeMap layerID, EdgeList reversedEdges)
          Assigns all nodes of the graph to layers.
 double getHalo()
          Returns the size of the halo around a node, that means the insets that are used for calculating layer overlaps.
protected  double getMax(LayoutGraph graph, Node node)
          Callback used for calculating the lower (max) value of a given node.
 double getMaximumNodeSize()
          Returns the maximum size of a node used for calculating layer overlaps.
protected  double getMin(LayoutGraph graph, Node node)
          Callback used for calculating the upper (min) value of a given node.
 double getMinimumNodeSize()
          Returns the minimum size of a node used for calculating layer overlaps.
 double getNodeScalingFactor()
          Returns the scaling factor used for scaling the size of the nodes.
 void setMaximumNodeSize(double max)
          Specifies the maximum size of a node used for calculating layer overlaps.
 void setMinimumNodeSize(double min)
          Specifies the minimum size of a node used for calculating layer overlaps.
 void setNodeHalo(double halo)
          Specifies the size of the halo around a node, that means the insets that are used for calculating layer overlaps.
 void setNodeScalingFactor(double factor)
          Specifies the scaling factor used for scaling the size of the nodes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsIsLayerer

public AsIsLayerer()
Creates an instance of AsIsLayerer with default settings.

Method Detail

getNodeScalingFactor

public double getNodeScalingFactor()
Returns the scaling factor used for scaling the size of the nodes.

Nodes are being scaled from their center. This can be used for more fuzzy layering.

The scaling factor can take positive values. Factors smaller than 1 only consider large overlaps of the nodes' bounding boxes in the main layout direction. Factors larger than 1 also combine nodes with some distance between them.

Returns:
a positive double value
See Also:
setNodeScalingFactor(double), getMinimumNodeSize(), getMaximumNodeSize(), getHalo()

setNodeScalingFactor

public void setNodeScalingFactor(double factor)
Specifies the scaling factor used for scaling the size of the nodes.

Nodes are being scaled from their center. This can be used for more fuzzy layering.

The scaling factor can take positive values. Factors smaller than 1 only consider large overlaps of the nodes' bounding boxes in the main layout direction. Factors larger than 1 also combine nodes with some distance between them.

Default Value:
The default value is 1.0.
Parameters:
factor - a positive double value
Throws:
java.lang.IllegalArgumentException - if the specified value is less than 0
See Also:
getMinimumNodeSize(), getMaximumNodeSize(), getHalo()
Sample Graphs:

Initial graph

Node scaling factor 1.0

Node scaling factor 3.0

getMaximumNodeSize

public double getMaximumNodeSize()
Returns the maximum size of a node used for calculating layer overlaps.

This can be used for more fuzzy layering.

The maximum size can take positive values.

Returns:
a positive double value
See Also:
setMaximumNodeSize(double), setNodeScalingFactor(double), setNodeHalo(double)

setMaximumNodeSize

public void setMaximumNodeSize(double max)
Specifies the maximum size of a node used for calculating layer overlaps.

This can be used for more fuzzy layering.

The maximum size can take positive values.

Default Value:
The default value is Double.MAX_VALUE.
Parameters:
max - a positive double value
Throws:
java.lang.IllegalArgumentException - if the specified value is less than 0
See Also:
setNodeScalingFactor(double), setNodeHalo(double)
Sample Graphs:

Initial graph

Maximum node size 100

Maximum node size 1000

getMinimumNodeSize

public double getMinimumNodeSize()
Returns the minimum size of a node used for calculating layer overlaps.

This can be used for more fuzzy layering.

The minimum size can take positive values.

Returns:
a positive double value
See Also:
setMinimumNodeSize(double), setNodeScalingFactor(double), setNodeHalo(double)

setMinimumNodeSize

public void setMinimumNodeSize(double min)
Specifies the minimum size of a node used for calculating layer overlaps.

This can be used for more fuzzy layering.

The minimum size can take positive values.

Default Value:
The default value is 0.0.
Parameters:
min - a positive double value
Throws:
java.lang.IllegalArgumentException - if the specified value is less than 0
See Also:
setNodeScalingFactor(double), setNodeHalo(double)
Sample Graphs:

Initial graph

Minimum node size 0

Minimum node size 100

setNodeHalo

public void setNodeHalo(double halo)
Specifies the size of the halo around a node, that means the insets that are used for calculating layer overlaps.

If the value of the halo is positive, it specifies a border around a node. In case it is negative, it is considered as an inset that defines a smaller area inside the node.

This can be used for more fuzzy layering.

Default Value:
The default value is 0.0d.
Parameters:
halo - the size of a node's halo
See Also:
setNodeScalingFactor(double), setMinimumNodeSize(double), setMaximumNodeSize(double)
Sample Graphs:

Initial graph

Node halo 0

Node halo 100

getHalo

public double getHalo()
Returns the size of the halo around a node, that means the insets that are used for calculating layer overlaps.

If the value of the halo is positive, it specifies a border around a node. In case it is negative, it is considered as an inset that defines a smaller area inside the node.

This can be used for more fuzzy layering.

Returns:
the size of a node's halo
See Also:
setNodeHalo(double), setNodeScalingFactor(double), setMinimumNodeSize(double), setMaximumNodeSize(double)

assignNodeLayer

public int assignNodeLayer(LayoutGraph graph,
                           NodeMap layerID,
                           EdgeList reversedEdges)
Assigns all nodes of the graph to layers.

Parameters:
graph - the given graph
layerID - the NodeMap that will be filled by the layout algorithm and returns the zero-based index of the layer to which each node belongs
reversedEdges - an EdgeList containing the edges which had been reversed
Returns:
the number of layers

getMin

protected double getMin(LayoutGraph graph,
                        Node node)
Callback used for calculating the upper (min) value of a given node.

It is called by method assignNodeLayer(LayoutGraph, NodeMap, EdgeList).

Parameters:
graph - the graph
node - the node
Returns:
the upper (min) value of a given node

getMax

protected double getMax(LayoutGraph graph,
                        Node node)
Callback used for calculating the lower (max) value of a given node.

It is called by method assignNodeLayer(LayoutGraph, NodeMap, EdgeList).

Parameters:
graph - the graph
node - the node
Returns:
the lower (max) of a given node

assignLayers

public void assignLayers(LayoutGraph graph,
                         Layers layers,
                         LayoutDataProvider ldp)
Assigns all nodes of the graph to layers by analyzing already existing node coordinates and adds them to the Layers instance.

Nodes whose bounding boxes overlap in the main layout direction are assigned to the same layer. To influence to which amount the boxes need to overlap, the nodes can temporarily be scaled.

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.