Search this API

y.layout.tree
Class ARTreeLayouter

java.lang.Object
  extended by y.layout.CanonicMultiStageLayouter
      extended by y.layout.tree.ARTreeLayouter
All Implemented Interfaces:
Layouter

public class ARTreeLayouter
extends CanonicMultiStageLayouter

This tree layouter tries to generate compact tree layouts with a certain aspect ratio. The ratio can be specified for each subtree.

Here is a sample layout output (using an aspect ratio of 1 by 2)


Field Summary
protected  LayoutGraph graph
           
static Object PLACEMENT_CORNER
          A data provider value used to specify the placement of the root.
static Object PLACEMENT_CORNER_SIDE
          A data provider value used to specify the placement of the root.
static Object PLACEMENT_CORNER_TOP
          A data provider value used to specify the placement of the root.
static Object PLACEMENT_TOP
          A data provider value used to specify the placement of the root.
static Object RATIO
          The data provider key used to specify target aspect ratio.
static Object ROOT_PLACEMENT
          The data provider key used to specify the placement of each subtree root.
static Object ROUTING_HORIZONTAL
          A data provider value used to specify the routing policy of each subtree.
static Object ROUTING_POLICY
          The data provider key used to specify the routing policy of each subtree root.
static Object ROUTING_VERTICAL
          A data provider value used to specify the routing policy of each subtree.
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
ARTreeLayouter()
           
 
Method Summary
 boolean canLayoutCore(LayoutGraph graph)
          The core layouter can layout trees.
protected  void createBends(EdgeLayout el, Node root, Node child, Object rootPlacement, Object routingPolicy)
           
 void doLayoutCore(LayoutGraph graph)
          Core layout routine.
 double getAspectRatio()
          Returns the preferred aspect ratio for this ARTreeLayouter.
protected  double getAspectRatio(Node v)
          Returns the aspectRatio that should be used for the subtree starting at the given node.
 double getBendDistance()
          Returns the preferred distance between any two bends of an edge.
 Comparator getComparator()
          Returns the Comparator that will be used to sort the outgoing edges of each local root in the tree before they are being arranged.
 double getHorizontalSpace()
          Returns the horizontal distance between adjacent nodes.
 Object getRootPlacement()
          Returns the desired placement of the tree's root node.
protected  Object getRootPlacement(Object root)
          Returns the desired placement for the given subtree root.
 Object getRoutingPolicy()
          Returns the routing policy used by this ARTreeLayouter.
protected  Object getRoutingPolicy(Object root)
          Returns the routing policy used by this ARTreeLayouter for the given subtree root.
protected  NodeCursor getSuccessors(Node localRoot)
           
 double getVerticalSpace()
          Returns the vertical distance between adjacent nodes.
 void setAspectRatio(double aspectRatio)
          Specifies the preferred aspect ratio for this ARTreeLayouter.
 void setBendDistance(double bendDistance)
          Specifies the preferred distance between any two bends of an edge.
 void setComparator(Comparator comparator)
          Sets the Comparator that will be used to sort the outgoing edges of each local root in the tree before they are being arranged.
 void setHorizontalSpace(double hspace)
          Sets the horizontal distance between adjacent nodes.
 void setRootPlacement(Object rootPlacement)
          Specifies the desired placement of the tree's root node.
 void setRoutingPolicy(Object routingPolicy)
          Specifies the routing policy used by this ARTreeLayouter.
 void setVerticalSpace(double vspace)
          Sets the vertical distance between adjacent nodes.
 
Methods inherited from class y.layout.CanonicMultiStageLayouter
appendStage, calcLayout, calcLayout, canLayout, checkGroupNodeSize, checkNodeSize, doLayout, doLayout, enableOnlyCore, getComponentLayouter, getGroupNodeHider, getLabelLayouter, getLayoutOrientation, getOrientationLayouter, getParallelEdgeLayouter, getSelfLoopLayouter, getSubgraphLayouter, isComponentLayouterEnabled, isGroupNodeHidingEnabled, isLabelLayouterEnabled, isOrientationLayouterEnabled, isParallelEdgeLayouterEnabled, isSelfLoopLayouterEnabled, isSubgraphLayouterEnabled, prependStage, removeStage, setComponentLayouter, setComponentLayouterEnabled, setGroupNodeHider, setGroupNodeHidingEnabled, setLabelLayouter, setLabelLayouterEnabled, setLayoutOrientation, setOrientationLayouter, setOrientationLayouterEnabled, setParallelEdgeLayouter, setParallelEdgeLayouterEnabled, setSelfLoopLayouter, setSelfLoopLayouterEnabled, setSubgraphLayouter, setSubgraphLayouterEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RATIO

public static final Object RATIO
The data provider key used to specify target aspect ratio. Values larger than 1 produce layouts that are wider than high


ROOT_PLACEMENT

public static final Object ROOT_PLACEMENT
The data provider key used to specify the placement of each subtree root.


PLACEMENT_TOP

public static final Object PLACEMENT_TOP
A data provider value used to specify the placement of the root.


PLACEMENT_CORNER

public static final Object PLACEMENT_CORNER
A data provider value used to specify the placement of the root.


PLACEMENT_CORNER_SIDE

public static final Object PLACEMENT_CORNER_SIDE
A data provider value used to specify the placement of the root.


PLACEMENT_CORNER_TOP

public static final Object PLACEMENT_CORNER_TOP
A data provider value used to specify the placement of the root.


ROUTING_POLICY

public static final Object ROUTING_POLICY
The data provider key used to specify the routing policy of each subtree root.


ROUTING_HORIZONTAL

public static final Object ROUTING_HORIZONTAL
A data provider value used to specify the routing policy of each subtree.


ROUTING_VERTICAL

public static final Object ROUTING_VERTICAL
A data provider value used to specify the routing policy of each subtree.


graph

protected LayoutGraph graph
Constructor Detail

ARTreeLayouter

public ARTreeLayouter()
Method Detail

setHorizontalSpace

public void setHorizontalSpace(double hspace)
Sets the horizontal distance between adjacent nodes. By default a value of 10 is set.


getHorizontalSpace

public double getHorizontalSpace()
Returns the horizontal distance between adjacent nodes.

See Also:
setHorizontalSpace(double)

setVerticalSpace

public void setVerticalSpace(double vspace)
Sets the vertical distance between adjacent nodes. By default a value of 10 is set.


getVerticalSpace

public double getVerticalSpace()
Returns the vertical distance between adjacent nodes.

See Also:
setVerticalSpace(double)

doLayoutCore

public void doLayoutCore(LayoutGraph graph)
Core layout routine.

Specified by:
doLayoutCore in class CanonicMultiStageLayouter

canLayoutCore

public boolean canLayoutCore(LayoutGraph graph)
The core layouter can layout trees.

Specified by:
canLayoutCore in class CanonicMultiStageLayouter

getAspectRatio

protected double getAspectRatio(Node v)
Returns the aspectRatio that should be used for the subtree starting at the given node.


getSuccessors

protected NodeCursor getSuccessors(Node localRoot)

getComparator

public Comparator getComparator()
Returns the Comparator that will be used to sort the outgoing edges of each local root in the tree before they are being arranged. Note that the algorithm will only use the order induced by the comparator, if the nodes (or better their whole subtrees) have equal size. The default value is null which indicates that the algorithm should use its built-in logic, only.

Returns:
The comparator to use or null if the default order should be used.
See Also:
setComparator(java.util.Comparator)

setComparator

public void setComparator(Comparator comparator)
Sets the Comparator that will be used to sort the outgoing edges of each local root in the tree before they are being arranged. Note that the algorithm will only use the order induced by the comparator, if the nodes (or better their whole subtrees) have equal size. The default value is null which indicates that the algorithm should use its built-in logic, only.

Parameters:
comparator - the new comparator to use or null if the default order should be used.
See Also:
getComparator()

createBends

protected void createBends(EdgeLayout el,
                           Node root,
                           Node child,
                           Object rootPlacement,
                           Object routingPolicy)

getRoutingPolicy

protected Object getRoutingPolicy(Object root)
Returns the routing policy used by this ARTreeLayouter for the given subtree root. Should be one of

Parameters:
root - the subtree root.
Returns:
the routing policy used for the given subtree root.

getRootPlacement

protected Object getRootPlacement(Object root)
Returns the desired placement for the given subtree root. Should be one of

Parameters:
root - the subtree root.
Returns:
a symbolic constant representing the desired placement for the given subtree root.

getAspectRatio

public double getAspectRatio()
Returns the preferred aspect ratio for this ARTreeLayouter.

Returns:
the preferred aspect ratio for this ARTreeLayouter.

setAspectRatio

public void setAspectRatio(double aspectRatio)
Specifies the preferred aspect ratio for this ARTreeLayouter.

Parameters:
aspectRatio - the preferred aspect ratio.

getRootPlacement

public Object getRootPlacement()
Returns the desired placement of the tree's root node. Should be one of

Returns:
a symbolic constant representing the desired placement of the tree's root node.

setRootPlacement

public void setRootPlacement(Object rootPlacement)
Specifies the desired placement of the tree's root node.

Parameters:
rootPlacement - the desired root placement. Should be one of

getRoutingPolicy

public Object getRoutingPolicy()
Returns the routing policy used by this ARTreeLayouter. Should be one of

Returns:
the routing policy used by this ARTreeLayouter.

setRoutingPolicy

public void setRoutingPolicy(Object routingPolicy)
Specifies the routing policy used by this ARTreeLayouter.

Parameters:
routingPolicy - the routing policy. Should be one of

getBendDistance

public double getBendDistance()
Returns the preferred distance between any two bends of an edge. Additionally, the preferred bend distance governs the distance between the first and last edges and the corresponding ports.

Returns:
the preferred distance between any two bends of an edge.

setBendDistance

public void setBendDistance(double bendDistance)
Specifies the preferred distance between any two bends of an edge. Additionally, the preferred bend distance governs the distance between the first and last edges and the corresponding ports.

Parameters:
bendDistance - the preferred bend distance.

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