| 
 | Search this API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecty.layout.CanonicMultiStageLayouter
y.layout.tree.ARTreeLayouter
public class ARTreeLayouter
The ARTreeLayouter arranges tree graphs in a compact fashion.
 
 
This layout algorithm tries to generate compact tree layouts with a certain preferred aspect ratio.
 
 Example layout with an aspect ratio of 0.5
 
The layout algorithm starts from the root and recursively assigns coordinates to all tree nodes. In this manner, leaf nodes will be placed first, while each parent node is placed centered above its child nodes.
   The aspect ratio of each subtree can be specified individually. A DataProvider registered with
   RATIO returns the aspect ratio for each local root node.
 
    A custom node can be defined as root of the tree using a DataProvider registered with the graph with 
    key SELECTED_ROOT_DPKEY.
 
| Field Summary | |
|---|---|
| protected  LayoutGraph | graphThe input graph this algorithm is handling. | 
| static java.lang.Object | PLACEMENT_CORNERA root placement specifier for placing the root in the upper left corner of the subtree bounds with respect to the actual layout orientation. | 
| static java.lang.Object | PLACEMENT_CORNER_SIDEA root placement specifier for placing the root in the upper left corner of the subtree bounds with respect to the actual layout orientation. | 
| static java.lang.Object | PLACEMENT_CORNER_TOPA root placement specifier for placing the root of a subtree in the upper left corner of the subtree bounds with respect to the actual layout orientation. | 
| static java.lang.Object | PLACEMENT_TOPA root placement specifier for placing the root centered above its subtree, depending on the actual layout orientation. | 
| static java.lang.Object | RATIOA DataProviderkey for specifying a target aspect ratio for each subtree
 The aspect ratio needs to be greater than0. | 
| static java.lang.Object | ROOT_PLACEMENTA DataProviderkey for specifying the placement of each subtree root
 
   If no root placement is specified for one of the subtree roots, the defaultroot placementwill be used. | 
| static java.lang.Object | ROUTING_HORIZONTALA direction specifier for placing the child nodes next to each other in direction of the actual layout orientation, with the edges connecting in the direction of flow. | 
| static java.lang.Object | ROUTING_POLICYA DataProviderkey for specifying the routing direction for each subtree root
 
 The children in a subtree are arranged either horizontally or vertically. | 
| static java.lang.Object | ROUTING_VERTICALA direction specifier for placing the child nodes above each other in direction of the actual layout orientation, with the edges connecting orthogonally to the
 direction of flow. | 
| static java.lang.Object | SELECTED_ROOT_DPKEYA DataProviderkey for marking the node that will be used as root node of the tree. | 
| Fields inherited from interface y.layout.Layouter | 
|---|
| EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES | 
| Constructor Summary | |
|---|---|
| ARTreeLayouter()Creates a new ARTreeLayouterinstance with default settings. | |
| Method Summary | |
|---|---|
|  boolean | canLayoutCore(LayoutGraph graph)Accepts all graphs with a tree structure. | 
| protected  void | createBends(EdgeLayout edgeLayout,
            Node localRoot,
            Node child,
            java.lang.Object rootPlacement,
            java.lang.Object routingPolicy)Adds bends to the given EdgeLayout. | 
|  void | doLayoutCore(LayoutGraph graph)Arranges the given graph considering the specified aspect ratio. | 
|  double | getAspectRatio()Returns the default aspect ratio for this ARTreeLayouter. | 
| protected  double | getAspectRatio(Node localRoot)Retrieves the aspect ratio for the subtree that is rooted at the given node. | 
|  double | getBendDistance()Returns the preferred distance between any two bends of an edge. | 
|  java.util.Comparator | getComparator()Returns the Comparatorthat will be used for sorting theoutgoing edgesof each local root in the tree before they are being arranged. | 
|  double | getHorizontalSpace()Returns the horizontal distance between adjacent nodes. | 
|  java.lang.Object | getRootPlacement()Returns the desired placement of the tree's root node. | 
| protected  java.lang.Object | getRootPlacement(java.lang.Object localRoot)Retrieves the root placement for the subtree that is rooted at the given node. | 
|  java.lang.Object | getRoutingPolicy()Returns how the children of a local root are arranged and how the edges between them are routed. | 
| protected  java.lang.Object | getRoutingPolicy(java.lang.Object localRoot)Retrieves the routing for the subtree that is rooted at the given node. | 
| protected  NodeCursor | getSuccessors(Node localRoot)Retrieves all children of the given local root. | 
|  double | getVerticalSpace()Returns the vertical distance between adjacent nodes. | 
|  void | setAspectRatio(double aspectRatio)Specifies the default aspect ratio for this ARTreeLayouter. | 
|  void | setBendDistance(double bendDistance)Specifies the preferred distance between any two bends of an edge. | 
|  void | setComparator(java.util.Comparator comparator)Specifies the Comparatorthat will be used for sorting theoutgoing edgesof each local root in the tree before they are being arranged. | 
|  void | setComponentLayouterEnabled(boolean enabled)Specifies whether or not the LayoutStageused for arranging the components of the graph is activated. | 
|  void | setGroupNodeHidingEnabled(boolean groupNodeHidingEnabled)Specifies whether or not the LayoutStageused for hiding group nodes is activated. | 
|  void | setHorizontalSpace(double distance)Specifies the horizontal distance between adjacent nodes. | 
|  void | setParallelEdgeLayouterEnabled(boolean enabled)Specifies whether or not the LayoutStageused for routing parallel edges is activated. | 
|  void | setRootPlacement(java.lang.Object rootPlacement)Specifies the desired placement of the tree's root node. | 
|  void | setRoutingPolicy(java.lang.Object routingPolicy)Specifies how the children of a local root are arranged and how the edges between them are routed. | 
|  void | setSelfLoopLayouterEnabled(boolean enabled)Specifies whether or not the LayoutStageused for routing self-loops is activated. | 
|  void | setVerticalSpace(double distance)Specifies the vertical distance between adjacent nodes. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static final java.lang.Object RATIO
DataProvider key for specifying a target aspect ratio for each subtree
 The aspect ratio needs to be greater than 0.
 1: width and height of the layout should be the same0 and 1: the height of the layout should be greater than its width1: the width of the layout should be greater than its height
 If no specific ratio is defined for a subtree, the layout algorithm falls back to the default
 aspect ratio.
 
public static final java.lang.Object ROOT_PLACEMENT
DataProvider key for specifying the placement of each subtree root
 
   If no root placement is specified for one of the subtree roots, the default 
   root placement will be used.
 
public static final java.lang.Object PLACEMENT_TOP
layout orientation.
public static final java.lang.Object PLACEMENT_CORNER
layout orientation.
 Whether the root is placed entirely beside the subtree with no horizontal overlaps or entirely above the subtree without vertical overlaps will be determined by the layout of the subtree. The layout algorithm tries to minimize the bounds of the subtree.
ROOT_PLACEMENT, 
PLACEMENT_CORNER_TOP, 
PLACEMENT_CORNER_SIDEpublic static final java.lang.Object PLACEMENT_CORNER_SIDE
layout orientation.
 The root is placed entirely beside the subtree with no horizontal overlaps. This might by important if the root's height is very large while its width is small.
public static final java.lang.Object PLACEMENT_CORNER_TOP
layout orientation.
 The root is placed entirely above the subtree with no vertical overlaps. This might by important if the root's width is very large while its height is small.
public static final java.lang.Object ROUTING_POLICY
DataProvider key for specifying the routing direction for each subtree root
 
 The children in a subtree are arranged either horizontally or vertically. The edges are routed to the top of the child
 nodes or at the side, respectively. Directions depend on the 
 layout orientation and refer to 
 LayoutOrientation.TOP_TO_BOTTOM for this description.
 
   If no specific routing policy is specified for a subtree root, the layout algorithm uses the default
   routing direction.
 
public static final java.lang.Object ROUTING_HORIZONTAL
layout orientation, with the edges connecting in the direction of flow.
public static final java.lang.Object ROUTING_VERTICAL
layout orientation, with the edges connecting orthogonally to the
 direction of flow.
public static final java.lang.Object SELECTED_ROOT_DPKEY
DataProvider key for marking the node that will be used as root node of the tree.
protected LayoutGraph graph
| Constructor Detail | 
|---|
public ARTreeLayouter()
ARTreeLayouter instance with default settings.
| Method Detail | 
|---|
public void setHorizontalSpace(double distance)
The distance needs to be non-negative.
public double getHorizontalSpace()
The distance needs to be non-negative.
setHorizontalSpace(double)public void setVerticalSpace(double distance)
The distance needs to be non-negative.
public double getVerticalSpace()
The distance needs to be non-negative.
setVerticalSpace(double)public void setComponentLayouterEnabled(boolean enabled)
LayoutStage used for arranging the components of the graph is activated.
setComponentLayouterEnabled in class CanonicMultiStageLayouterARTreeLayouter can only handle single components. Disabling ComponentLayouter
            will lead to errors during execution.enabled - true if the stage that arranges the graph components is activated,
                false otherwiseCanonicMultiStageLayouter.isComponentLayouterEnabled(), 
CanonicMultiStageLayouter.setComponentLayouter(LayoutStage), 
ComponentLayouterpublic void setGroupNodeHidingEnabled(boolean groupNodeHidingEnabled)
LayoutStage used for hiding group nodes is activated.
setGroupNodeHidingEnabled in class CanonicMultiStageLayouterARTreeLayouter cannot handle group nodes. Disabling GroupNodeHider will lead to errors
            during execution.groupNodeHidingEnabled - true if the stage used for hiding group nodes is activated,
                               false otherwiseCanonicMultiStageLayouter.isGroupNodeHidingEnabled(), 
CanonicMultiStageLayouter.setGroupNodeHider(LayoutStage), 
GroupNodeHiderpublic void setParallelEdgeLayouterEnabled(boolean enabled)
LayoutStage used for routing parallel edges is activated.
setParallelEdgeLayouterEnabled in class CanonicMultiStageLayouterARTreeLayouter cannot handle parallel edges. Disabling ParallelEdgeLayouter
            will lead to errors during execution.enabled - true if the stage responsible for routing parallel edges is activated, false otherwiseCanonicMultiStageLayouter.isParallelEdgeLayouterEnabled(), 
CanonicMultiStageLayouter.setParallelEdgeLayouter(LayoutStage), 
ParallelEdgeLayouterpublic void setSelfLoopLayouterEnabled(boolean enabled)
LayoutStage used for routing self-loops is activated.
setSelfLoopLayouterEnabled in class CanonicMultiStageLayouterARTreeLayouter cannot handle self-loops. Disabling SelfLoopLayouter will lead
            to errors during execution.enabled - true if the stage responsible for routing self-loops is activated, false otherwiseCanonicMultiStageLayouter.isSelfLoopLayouterEnabled(), 
CanonicMultiStageLayouter.setSelfLoopLayouter(LayoutStage), 
SelfLoopLayouterpublic void doLayoutCore(LayoutGraph graph)
aspect ratio.
doLayoutCore in class CanonicMultiStageLayoutergraph - the input graph
WrongGraphStructure - if the input graph is not a treepublic boolean canLayoutCore(LayoutGraph graph)
canLayoutCore in class CanonicMultiStageLayoutergraph - the input graph
true if the given graph is a tree, false otherwiseTrees.isTree(y.base.Graph)protected double getAspectRatio(Node localRoot)
   If there is an individual aspect ratio for the subtree provided by a DataProvider registered
   with key RATIO, that ratio will be returned. Otherwise, the 
   default aspect ratio will be returned.
 
   This method is called by doLayoutCore(LayoutGraph) before a subtree is arranged. It may be overridden to
   use another approach to define the aspect ratio for subtrees.
 
localRoot - the root node of the subtree
RATIO, 
getAspectRatio()protected NodeCursor getSuccessors(Node localRoot)
   This method is called by doLayoutCore(LayoutGraph) to arrange the subtrees below the local root.
 
localRoot - the root of a subtree
public java.util.Comparator getComparator()
Comparator that will be used for sorting the outgoing edges
 of each local root in the tree before they are being arranged.
Comparator, if the nodes (more precisely, 
         their whole subtrees) have equal sizes. The reason is that the algorithm tries to find a
         good arrangement which optimizes the target aspect ratio. If the node ordering is already specified,
         this optimization would be impossible.Comparator or null if the default order should be usedsetComparator(Comparator)public void setComparator(java.util.Comparator comparator)
Comparator that will be used for sorting the outgoing edges
 of each local root in the tree before they are being arranged.
Comparator, if the nodes (more precisely, 
         their whole subtrees) have equal sizes. The reason is that the algorithm tries to find a
         good arrangement which optimizes the target aspect ratio. If the node ordering is already specified,
         this optimization would be impossible.comparator - a Comparator or null if the default order should be used
protected void createBends(EdgeLayout edgeLayout,
                           Node localRoot,
                           Node child,
                           java.lang.Object rootPlacement,
                           java.lang.Object routingPolicy)
EdgeLayout.
 
   This method is called by doLayoutCore(LayoutGraph) for each edge, after the nodes are placed, to route
   the path of the edges. It may be overridden to apply a custom routing style.
 
edgeLayout - the layout of the edge that is routedlocalRoot - the local root of the subtreechild - the child connected to the local root with the given edgerootPlacement - the placement specifier of the local rootroutingPolicy - the direction specifier for the routingprotected java.lang.Object getRoutingPolicy(java.lang.Object localRoot)
   Either an individual routing for the subtree (defined via a DataProvider registered with
   ROUTING_POLICY), or if there is none, the 
   default routing is returned.
 
   This method is called by doLayoutCore(LayoutGraph) to determine the direction of the subtrees.
   It may be overridden to use another approach to define the routing for a subtree.
 
localRoot - the root of the subtree
ROUTING_POLICY, 
getRoutingPolicy()protected java.lang.Object getRootPlacement(java.lang.Object localRoot)
   Either an individual root placement for the subtree (defined via a DataProvider registered with
   ROOT_PLACEMENT), or if there is none, the default root placement is returned.
 
   This method is called by doLayoutCore(LayoutGraph) after a subtree is arranged to align the local root
   node. It may be overridden to use another approach to define the root placement for a subtree.
 
localRoot - the root of the subtree
ROOT_PLACEMENT, 
getRootPlacement()public double getAspectRatio()
ARTreeLayouter.
 
   This aspect ratio is used for all subtrees for which there is no specific aspect ratio defined in a
   DataProvider registered with RATIO.
 
The aspect ratio needs to have a positive value.
setAspectRatio(double)public void setAspectRatio(double aspectRatio)
ARTreeLayouter.
 
   This aspect ratio is used for all subtrees for which there is no specific aspect ratio defined in a
   DataProvider registered with RATIO.
 
The aspect ratio needs to have a positive value.
public java.lang.Object getRootPlacement()
PLACEMENT_TOP, PLACEMENT_CORNER, PLACEMENT_CORNER_SIDE or
         PLACEMENT_CORNER_TOPsetRootPlacement(Object)public void setRootPlacement(java.lang.Object rootPlacement)
PLACEMENT_CORNERrootPlacement - one of PLACEMENT_TOP, PLACEMENT_CORNER, PLACEMENT_CORNER_SIDE or
                      PLACEMENT_CORNER_TOP
java.lang.IllegalArgumentException - if an unknown placement specifiers is setpublic java.lang.Object getRoutingPolicy()
ROUTING_HORIZONTALROUTING_HORIZONTAL or ROUTING_VERTICALsetRoutingPolicy(Object)public void setRoutingPolicy(java.lang.Object routingPolicy)
ROUTING_HORIZONTALroutingPolicy - one of ROUTING_HORIZONTAL and ROUTING_VERTICAL
java.lang.IllegalArgumentException - if the specified routing policy is unknownpublic double getBendDistance()
The distance needs to be non-negative.
setBendDistance(double)public void setBendDistance(double bendDistance)
The distance needs to be non-negative.
| 
 | © Copyright 2000-2025, yWorks GmbH. All rights reserved. | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||