Search this API

y.layout.hierarchic
Class TreeDrawer

java.lang.Object
  extended by y.layout.hierarchic.AbstractDrawer
      extended by y.layout.hierarchic.TreeDrawer
All Implemented Interfaces:
Drawer

public class TreeDrawer
extends AbstractDrawer

This class implements the drawing phase of the HierarchicLayouter (i.e., the assignment of nodes' coordinates) for trees.

If the input graph is not a tree, an alternative drawer is invoked.

 

Nested Class Summary
static class TreeDrawer.HierarchicTreePlacer
          This class places nodes on their given layers (does not change the y-coordinates) if the layout style of the hierarchic layout algorithm is set to HierarchicLayouter.TREE.
 
Field Summary
 
Fields inherited from class y.layout.hierarchic.AbstractDrawer
distanceToNextNode, dummyMap, edgeLengthKey, graph, minimalEdgeDistance, minimalLayerDistance, minimalMultiEdgeDistance, minimalNodeDistance
 
Fields inherited from interface y.layout.hierarchic.Drawer
NODE_BORDER_BOTTOM, NODE_BORDER_LEFT, NODE_BORDER_RIGHT, NODE_BORDER_TOP, NODE_DISTANCE
 
Constructor Summary
TreeDrawer()
          Creates a new instance of TreeDrawer with default settings.
 
Method Summary
protected  void assignCoordinates(NodeList[] layerLists, DataProvider layerID)
          Assigns the final coordinates to the objects of the graph if the input graph is a tree.
 Drawer getAlternativeDrawer()
          Returns the Drawer called when the given graph is not a tree.
 void setAlternativeDrawer(Drawer alternativeDrawer)
          Specifies the Drawer called when the given graph is not a tree.
 void setMinimalEdgeDistance(double d)
          Specifies the minimum distance between two edges that span the same layer.
 void setMinimalLayerDistance(double d)
          Specifies the minimum distance between two layers.
 void setMinimalMultiEdgeDistance(double d)
          Specifies the minimum distance between two edges sharing source/target in the same layer.
 void setMinimalNodeDistance(double d)
          Specifies the minimum distance between two nodes in the same layer.
 
Methods inherited from class y.layout.hierarchic.AbstractDrawer
assignCoordinates, assignYCoords, assignYCoords, dispose, getBottomBorder, getBottomHalf, getBottomY, getDistanceToNextNode, getFullHeight, getFullWidth, getLeftBorder, getLeftHalf, getLeftX, getMinimalEdgeDistance, getMinimalLayerDistance, getMinimalMultiEdgeDistance, getMinimalNodeDistance, getRightBorder, getRightHalf, getRightX, getTopBorder, getTopHalf, getTopY, initializeDistancesToNextNode, setDummyMap, setEdgeLengthKey
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeDrawer

public TreeDrawer()
Creates a new instance of TreeDrawer with default settings.

Method Detail

setMinimalEdgeDistance

public void setMinimalEdgeDistance(double d)
Specifies the minimum distance between two edges that span the same layer.

Minimum distance must be non-negative.

Specified by:
setMinimalEdgeDistance in interface Drawer
Overrides:
setMinimalEdgeDistance in class AbstractDrawer
Default Value:
The default value is 5.0.
Parameters:
d - the minimum distance between two edges
Throws:
java.lang.IllegalArgumentException - if the minimum distance is negative
Sample Graphs:

Edge distance 10

Edge distance 100

setMinimalMultiEdgeDistance

public void setMinimalMultiEdgeDistance(double d)
Specifies the minimum distance between two edges sharing source/target in the same layer.

Minimum distance must be non-negative.

Specified by:
setMinimalMultiEdgeDistance in interface Drawer
Overrides:
setMinimalMultiEdgeDistance in class AbstractDrawer
Default Value:
The default value is 0.0.
Parameters:
d - the minimum distance between two edges sharing source/target
Throws:
java.lang.IllegalArgumentException - if the minimum distance is negative
Sample Graphs:

Multi-edge distance 10

Multi-edge distance 200

setMinimalNodeDistance

public void setMinimalNodeDistance(double d)
Specifies the minimum distance between two nodes in the same layer.

Minimum distance must be non-negative.

Specified by:
setMinimalNodeDistance in interface Drawer
Overrides:
setMinimalNodeDistance in class AbstractDrawer
Default Value:
The default value is 20.0.
Parameters:
d - the minimum distance between two edges sharing source/target
Throws:
java.lang.IllegalArgumentException - if the minimum distance is negative
Sample Graphs:

Node distance 20

Node distance 100

setMinimalLayerDistance

public void setMinimalLayerDistance(double d)
Specifies the minimum distance between two layers.

Minimum distance must be non-negative.

Specified by:
setMinimalLayerDistance in interface Drawer
Overrides:
setMinimalLayerDistance in class AbstractDrawer
Default Value:
The default value is 60.0.
Parameters:
d - the minimum distance between two edges sharing source/target
Throws:
java.lang.IllegalArgumentException - if the minimum distance is negative
Sample Graphs:

Layer distance 40

Layer distance 100

setAlternativeDrawer

public void setAlternativeDrawer(Drawer alternativeDrawer)
Specifies the Drawer called when the given graph is not a tree.

Default Value:
The default value is MedianLinearSegmentDrawer
Parameters:
alternativeDrawer - the alternative Drawer instance

getAlternativeDrawer

public Drawer getAlternativeDrawer()
Returns the Drawer called when the given graph is not a tree.

Returns:
the alternative Drawer instance
See Also:
setAlternativeDrawer(Drawer)

assignCoordinates

protected void assignCoordinates(NodeList[] layerLists,
                                 DataProvider layerID)
Assigns the final coordinates to the objects of the graph if the input graph is a tree.

Specified by:
assignCoordinates in class AbstractDrawer
Parameters:
layerLists - an array of NodeLists each of which contains nodes that belong to the same layer
layerID - the DataProvider that returns the zero-based index of the layer to which each node belongs

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