Search this API

y.layout.tree
Class BalloonLayouter

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

public class BalloonLayouter
extends CanonicMultiStageLayouter

A tree layouter that lays out the subtrees of the tree in a balloon-like fashion.

Here is a sample layout output


Nested Class Summary
static class BalloonLayouter.NodeInfo
          Encapsulates information bound to a node during the algorithm calculates a layout
 
Field Summary
static byte CENTER_ROOT
          Root node policy specifier constant.
static byte CHILD_ORDERING_POLICY_COMPACT
          Child ordering policy specifier constant.
static byte CHILD_ORDERING_POLICY_SYMMETRIC
          Child ordering policy specifier constant.
static byte DIRECTED_ROOT
          Root node policy specifier constant.
protected  LayoutGraph graph
          The layout graph being acted upon.
static byte WEIGHTED_CENTER_ROOT
          Root node policy specifier constant.
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
BalloonLayouter()
           
 
Method Summary
protected  double calcAngles(Node root)
          Calculates the angle wedge that has to be reserved for the subtree rooted at the given node.
protected  void calcChildArrangement(Node root)
          Calculates the child nodes arrangement for a given root node of the tree.
 boolean canLayoutCore(LayoutGraph graph)
          Returns true iff the core layouter can layout the given graph structure.
protected  Node determineRoot()
          Determines the root node of graph according to the chosen root node policy.
 void doLayoutCore(LayoutGraph graph)
          Core layout routine.
 boolean getAllowOverlaps()
          Returns whether or not to allow partially overlapping nodes.
 byte getChildOrderingPolicy()
          Returns the current policy for sorting the children around the local roots.
 double getCompactnessFactor()
          Returns the compactness factor for this layouter.
 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.
protected  BalloonLayouter.NodeInfo getInfo(Node v)
          Returns the NodeInfo object that is associated with the given node while the layouter is active.
 int getMinimalEdgeLength()
          Returns the minimal edge length that this layouter assigns to laid out edges.
 int getMinimalNodeDistance()
          Returns the distance to keep between the nodes in the tree.
 int getPreferredChildWedge()
          Returns the preferred child wedge angle.
protected  double getPreferredChildWedge(Node root)
          Returns the preferred child wedge angle in degrees that is used for the children of the given root node.
 int getPreferredRootWedge()
          Returns the preferred radial amount in degrees that stay unoccupied around the root node of the graph.
 byte getRootNodePolicy()
          Returns the root node policy that determines which node is chosen as (virtual) tree root for the layout process.
 boolean isConsiderNodeLabelsEnabled()
          Determines whether or not the layouter considers node labels for the next layout run.
 boolean isFromSketchModeEnabled()
          Returns whether or not to take the coordinates of the input diagram into account when arranging the nodes of the elements of the tree.
 void setAllowOverlaps(boolean allow)
          Specifies whether or not this layouter should allow (partially) overlapping nodes.
 void setChildOrderingPolicy(byte childOrderingPolicy)
          Sets the policy for sorting the children around the local roots.
 void setCompactnessFactor(double factor)
          Sets the compactness factor for this layouter.
 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 setConsiderNodeLabelsEnabled(boolean considerNodeLabelsEnabled)
          Specifies whether or not the layouter considers node labels for the next layout run.
 void setFromSketchModeEnabled(boolean fromSketchModeEnabled)
          Determines whether or not to take the coordinates of the input diagram into account when arranging the nodes of the elements of the tree.
 void setMinimalEdgeLength(int length)
          Sets the minimal edge length that this layouter assigns to laid out edges.
 void setMinimalNodeDistance(int minimalNodeDistance)
          Sets the minimal distance to keep between the nodes in the tree.
 void setPreferredChildWedge(int wedgeAngle)
          Set the preferred radial amount in degrees that all child nodes may occupy around a parent node.
 void setPreferredRootWedge(int wedgeAngle)
          Sets the preferred radial amount in degrees that stay unoccupied around the root node of the graph

Allowed values lie within 0 and 360 degrees.

 void setRootNodePolicy(byte policy)
          Sets the root node policy that determines which node is chosen as (virtual) tree root for the layout process.
protected  void sortChildNodes(Node root)
          Sorts the child nodes of the given node.
 
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

CHILD_ORDERING_POLICY_COMPACT

public static final byte CHILD_ORDERING_POLICY_COMPACT
Child ordering policy specifier constant. This policy sorts the child nodes according to the size of the subtree rooted by them in an interleaved fashion. Using this policy the produced results are often more compact.

See Also:
setChildOrderingPolicy(byte), Constant Field Values

CHILD_ORDERING_POLICY_SYMMETRIC

public static final byte CHILD_ORDERING_POLICY_SYMMETRIC
Child ordering policy specifier constant. This policy sorts the child nodes according to their wedge angle sizes. The node with the biggest angle receives median position in the sorting order. The smaller the wedges the further away a node will be placed from the median position. Using this policy the produced results are often more symmetric.

See Also:
setChildOrderingPolicy(byte), Constant Field Values

DIRECTED_ROOT

public static final byte DIRECTED_ROOT
Root node policy specifier constant. A node with indegree 0 is chosen as root node of the tree. If no node with that property is present the an arbitrary node is chosen.

See Also:
Constant Field Values

CENTER_ROOT

public static final byte CENTER_ROOT
Root node policy specifier constant. A center node will be chosen as root node of the tree.

See Also:
Trees.getCenterRoot(Graph), Constant Field Values

WEIGHTED_CENTER_ROOT

public static final byte WEIGHTED_CENTER_ROOT
Root node policy specifier constant. A weighted center node will be chosen as root node of the tree.

See Also:
Trees.getCenterRoot(Graph), Constant Field Values

graph

protected LayoutGraph graph
The layout graph being acted upon.

Constructor Detail

BalloonLayouter

public BalloonLayouter()
Method Detail

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. The default value is null which indicates that the algorithm should use its built-in logic.

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. The default value is null which indicates that the algorithm should use its built-in logic.

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

getChildOrderingPolicy

public byte getChildOrderingPolicy()
Returns the current policy for sorting the children around the local roots. Possible values are CHILD_ORDERING_POLICY_COMPACT and CHILD_ORDERING_POLICY_SYMMETRIC. Note: the policy is only considered if sketch mode is disabled (see method setFromSketchModeEnabled(boolean)) and no comparator is set (see method setComparator(java.util.Comparator)).

Returns:
the policy for sorting the children.

setChildOrderingPolicy

public void setChildOrderingPolicy(byte childOrderingPolicy)
Sets the policy for sorting the children around the local roots. Possible values are CHILD_ORDERING_POLICY_COMPACT and CHILD_ORDERING_POLICY_SYMMETRIC. Note: the policy is only considered if sketch mode is disabled (see method setFromSketchModeEnabled(boolean)) and no comparator is set (see method setComparator(java.util.Comparator)).

Parameters:
childOrderingPolicy - the policy for sorting the children

getMinimalNodeDistance

public int getMinimalNodeDistance()
Returns the distance to keep between the nodes in the tree. The default distance is 0.0.


setMinimalNodeDistance

public void setMinimalNodeDistance(int minimalNodeDistance)
Sets the minimal distance to keep between the nodes in the tree. Note that this distance is not always considered if setAllowOverlaps(boolean) is set to true. The default distance is 0.0.

See Also:
setAllowOverlaps(boolean)

isFromSketchModeEnabled

public boolean isFromSketchModeEnabled()
Returns whether or not to take the coordinates of the input diagram into account when arranging the nodes of the elements of the tree.

See Also:
setFromSketchModeEnabled(boolean)

setFromSketchModeEnabled

public void setFromSketchModeEnabled(boolean fromSketchModeEnabled)
Determines whether or not to take the coordinates of the input diagram into account when arranging the nodes of the elements of the tree. If this features is enabled, the original circular order of child nodes around each parent node will be maintained.

By default this feature is disabled.


setRootNodePolicy

public void setRootNodePolicy(byte policy)
Sets the root node policy that determines which node is chosen as (virtual) tree root for the layout process.

By default DIRECTED_ROOT is set.

Parameters:
policy - one of DIRECTED_ROOT, CENTER_ROOT, WEIGHTED_CENTER_ROOT.

getRootNodePolicy

public byte getRootNodePolicy()
Returns the root node policy that determines which node is chosen as (virtual) tree root for the layout process.

See Also:
setRootNodePolicy(byte)

setPreferredChildWedge

public void setPreferredChildWedge(int wedgeAngle)
Set the preferred radial amount in degrees that all child nodes may occupy around a parent node. This value controls the degree to which the child nodes may radiate away from the center of layout. By default the wedge is 340 degrees which means that the child nodes may radiate in almost any direction from a parent node.

Allowed values lie within 0 and 360 degrees.

By default a child wedge of 340 degrees is used.


setPreferredRootWedge

public void setPreferredRootWedge(int wedgeAngle)
Sets the preferred radial amount in degrees that stay unoccupied around the root node of the graph

Allowed values lie within 0 and 360 degrees. By default a root wedge of 360 degrees is used.


getPreferredRootWedge

public int getPreferredRootWedge()
Returns the preferred radial amount in degrees that stay unoccupied around the root node of the graph.

See Also:
setPreferredRootWedge(int)

getPreferredChildWedge

public int getPreferredChildWedge()
Returns the preferred child wedge angle.

See Also:
setPreferredChildWedge(int)

setAllowOverlaps

public void setAllowOverlaps(boolean allow)
Specifies whether or not this layouter should allow (partially) overlapping nodes. Activating this feature results in a more compact layout. The price for this feature is that some nodes may partially overlap. By default this feature is set to false.


getAllowOverlaps

public boolean getAllowOverlaps()
Returns whether or not to allow partially overlapping nodes.

See Also:
setAllowOverlaps(boolean)

setCompactnessFactor

public void setCompactnessFactor(double factor)
Sets the compactness factor for this layouter. This factor has to be a double value between 0 and 1. The smaller the factor the more compact will the layout potentially be. The price for a more compact layout is a potentially higher running time.


getCompactnessFactor

public double getCompactnessFactor()
Returns the compactness factor for this layouter.

See Also:
setCompactnessFactor(double)

setMinimalEdgeLength

public void setMinimalEdgeLength(int length)
Sets the minimal edge length that this layouter assigns to laid out edges.

By default a minimal edge length of 40 is set.


getMinimalEdgeLength

public int getMinimalEdgeLength()
Returns the minimal edge length that this layouter assigns to laid out edges.

See Also:
setMinimalEdgeLength(int)

isConsiderNodeLabelsEnabled

public boolean isConsiderNodeLabelsEnabled()
Determines whether or not the layouter considers node labels for the next layout run.

Returns:
true, if the layouter considers node labels for the next layout run, false otherwise.
See Also:
setConsiderNodeLabelsEnabled(boolean)

setConsiderNodeLabelsEnabled

public void setConsiderNodeLabelsEnabled(boolean considerNodeLabelsEnabled)
Specifies whether or not the layouter considers node labels for the next layout run.

Parameters:
considerNodeLabelsEnabled - true, if the layouter shall consider node labels for the next layout run, false otherwise.

doLayoutCore

public void doLayoutCore(LayoutGraph graph)
Core layout routine.

Specified by:
doLayoutCore in class CanonicMultiStageLayouter

canLayoutCore

public boolean canLayoutCore(LayoutGraph graph)
Returns true iff the core layouter can layout the given graph structure. This is the case iff the graph is a tree.

Specified by:
canLayoutCore in class CanonicMultiStageLayouter

getInfo

protected BalloonLayouter.NodeInfo getInfo(Node v)
Returns the NodeInfo object that is associated with the given node while the layouter is active. Subclasses may want to use this information to refine the behavior of this algorithm.


determineRoot

protected Node determineRoot()
Determines the root node of graph according to the chosen root node policy.

Returns:
the root node of graph.
See Also:
getRootNodePolicy(), setRootNodePolicy(byte)

calcChildArrangement

protected void calcChildArrangement(Node root)
Calculates the child nodes arrangement for a given root node of the tree. Subclasses may overwrite this method to perform a custom child node arrangement.


sortChildNodes

protected void sortChildNodes(Node root)
Sorts the child nodes of the given node. This method uses the original node coordinates if fromSketchMode is enabled. Otherwise, it sorts the child nodes according to their wedge angle sizes, or, if present uses the specified comparator to sort the outgoing edges of the local root node. The biggest one receives median position in the sorting order. The smaller the wedges the further away a node will be placed from the median position.

This method gets called within method calcChildArrangement(Node) before coordinates are assigned and just after the wedges sizes for all subgraphs rooted at root were determined.


getPreferredChildWedge

protected double getPreferredChildWedge(Node root)
Returns the preferred child wedge angle in degrees that is used for the children of the given root node.

Subclasses may overwrite this method to provide a custom child wedge function.


calcAngles

protected double calcAngles(Node root)
Calculates the angle wedge that has to be reserved for the subtree rooted at the given node.

Subclasses may overwrite this method to perform a custom angle wedge assignment scheme.


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