y.layout.tree
Class BalloonLayouter

java.lang.Object
  |
  +--y.layout.CanonicMultiStageLayouter
        |
        +--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 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 chld 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()
           
 void doLayoutCore(LayoutGraph graph)
          Core layout routine.
 boolean getAllowOverlaps()
          Returns whether or not to allow partially overlapping nodes.
 double getCompactnessFactor()
          Returns the compactness factor for this layouter.
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 layed out edges.
 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 preferrred 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.
 void setAllowOverlaps(boolean allow)
          Whether or not this layouter should allow (partially) overlapping nodes.
 void setCompactnessFactor(double factor)
          Sets the compactness factor for this layouter.
 void setMinimalEdgeLength(int length)
          Sets the minimal edge length that this layouter assigns to layed out edges.
 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)
          Sort child nodes according to their wedge angle sizes.
 
Methods inherited from class y.layout.CanonicMultiStageLayouter
appendStage, calcLayout, calcLayout, canLayout, 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

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

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 BalloonLayouter.DIRECTED_ROOT is set.

Parameters:
policy - one of BalloonLayouter.DIRECTED_ROOT, BalloonLayouter.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:
BalloonLayouter.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 preferrred radial amount in degrees that stay unoccupied around the root node of the graph.

See Also:
BalloonLayouter.setPreferredRootWedge(int)

getPreferredChildWedge

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

See Also:
BalloonLayouter.setPreferredChildWedge(int)

setAllowOverlaps

public void setAllowOverlaps(boolean allow)
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:
BalloonLayouter.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:
BalloonLayouter.setCompactnessFactor(double)

setMinimalEdgeLength

public void setMinimalEdgeLength(int length)
Sets the minimal edge length that this layouter assigns to layed 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 layed out edges.

See Also:
BalloonLayouter.setMinimalEdgeLength(int)

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 thius information to refine the behaviour of this algorithm.


determineRoot

protected Node determineRoot()

calcChildArrangement

protected void calcChildArrangement(Node root)
Calculates the chld 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)
Sort child nodes according to their wedge angle sizes. Biggest one in the center. decreasing size in both directions This method gets called within method BalloonLayouter.calcChildArrangement(Node) 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-2003,
yWorks GmbH.
All rights reserved.

2003