prefuse.action.layout.graph
Class NodeLinkTreeLayout

java.lang.Object
  extended by prefuse.activity.Activity
      extended by prefuse.action.Action
          extended by prefuse.action.GroupAction
              extended by prefuse.action.layout.Layout
                  extended by prefuse.action.layout.graph.TreeLayout
                      extended by prefuse.action.layout.graph.NodeLinkTreeLayout

public class NodeLinkTreeLayout
extends TreeLayout

TreeLayout that computes a tidy layout of a node-link tree diagram. This algorithm lays out a rooted tree such that each depth level of the tree is on a shared line. The orientation of the tree can be set such that the tree goes left-to-right (default), right-to-left, top-to-bottom, or bottom-to-top.

The algorithm used is that of Christoph Buchheim, Michael Jünger, and Sebastian Leipert from their research paper Improving Walker's Algorithm to Run in Linear Time, Graph Drawing 2002. This algorithm corrects performance issues in Walker's algorithm, which generalizes Reingold and Tilford's method for tidy drawings of trees to support trees with an arbitrary number of children at any given node.

Author:
jeffrey heer

Nested Class Summary
static class NodeLinkTreeLayout.Params
          Wrapper class holding parameters used for each node in this layout.
 
Field Summary
static java.lang.String PARAMS
          The data field in which the parameters used by this layout are stored.
static Schema PARAMS_SCHEMA
          The schema for the parameters used by this layout.
 
Fields inherited from class prefuse.action.layout.graph.TreeLayout
m_root
 
Fields inherited from class prefuse.action.layout.Layout
m_anchor, m_bounds, m_bpts, m_insets, m_margin, m_tmpa, m_tmpb
 
Fields inherited from class prefuse.action.GroupAction
m_group
 
Fields inherited from class prefuse.action.Action
m_vis
 
Fields inherited from class prefuse.activity.Activity
DEFAULT_STEP_TIME, INFINITY
 
Constructor Summary
NodeLinkTreeLayout(java.lang.String group)
          Create a new NodeLinkTreeLayout.
NodeLinkTreeLayout(java.lang.String group, int orientation, double dspace, double bspace, double tspace)
          Create a new NodeLinkTreeLayout.
 
Method Summary
 double getBreadthSpacing()
          Get the spacing between neighbor nodes.
 double getDepthSpacing()
          Get the spacing between depth levels.
 java.awt.geom.Point2D getLayoutAnchor()
          Return the layout anchor at which to center or root the layout.
 int getOrientation()
          Get the orientation of the tree layout.
 double getRootNodeOffset()
          Get the offset value for placing the root node of the tree.
 double getSubtreeSpacing()
          Get the spacing between neighboring subtrees.
protected  void initSchema(TupleSet ts)
           
 void run(double frac)
          Runs this Action, triggering whatever processing this Action performs.
 void setBreadthSpacing(double b)
          Set the spacing between neighbor nodes.
 void setDepthSpacing(double d)
          Set the spacing between depth levels.
 void setOrientation(int orientation)
          Set the orientation of the tree layout.
 void setRootNodeOffset(double o)
          Set the offset value for placing the root node of the tree.
 void setSubtreeSpacing(double s)
          Set the spacing between neighboring subtrees.
 
Methods inherited from class prefuse.action.layout.graph.TreeLayout
getLayoutRoot, setLayoutRoot
 
Methods inherited from class prefuse.action.layout.Layout
getLayoutBounds, setLayoutAnchor, setLayoutBounds, setMargin, setX, setY
 
Methods inherited from class prefuse.action.GroupAction
getGroup, setGroup
 
Methods inherited from class prefuse.action.Action
getVisualization, run, setVisualization
 
Methods inherited from class prefuse.activity.Activity
addActivityListener, alwaysRunAfter, cancel, fireActivityCancelled, fireActivityFinished, fireActivityScheduled, fireActivityStarted, fireActivityStepped, getDuration, getNextTime, getPace, getPacingFunction, getStartTime, getStepTime, getStopTime, isEnabled, isRunning, isScheduled, removeActivityListener, run, runAfter, runAt, setDuration, setEnabled, setPacingFunction, setStartTime, setStepTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAMS

public static final java.lang.String PARAMS
The data field in which the parameters used by this layout are stored.

See Also:
Constant Field Values

PARAMS_SCHEMA

public static final Schema PARAMS_SCHEMA
The schema for the parameters used by this layout.

Constructor Detail

NodeLinkTreeLayout

public NodeLinkTreeLayout(java.lang.String group)
Create a new NodeLinkTreeLayout. A left-to-right orientation is assumed.

Parameters:
group - the data group to layout. Must resolve to a Graph instance.

NodeLinkTreeLayout

public NodeLinkTreeLayout(java.lang.String group,
                          int orientation,
                          double dspace,
                          double bspace,
                          double tspace)
Create a new NodeLinkTreeLayout.

Parameters:
group - the data group to layout. Must resolve to a Graph instance.
orientation - the orientation of the tree layout. One of Constants.ORIENT_LEFT_RIGHT, Constants.ORIENT_RIGHT_LEFT, Constants.ORIENT_TOP_BOTTOM, or Constants.ORIENT_BOTTOM_TOP.
dspace - the spacing to maintain between depth levels of the tree
bspace - the spacing to maintain between sibling nodes
tspace - the spacing to maintain between neighboring subtrees
Method Detail

setOrientation

public void setOrientation(int orientation)
Set the orientation of the tree layout.

Parameters:
orientation - the orientation value. One of Constants.ORIENT_LEFT_RIGHT, Constants.ORIENT_RIGHT_LEFT, Constants.ORIENT_TOP_BOTTOM, or Constants.ORIENT_BOTTOM_TOP.

getOrientation

public int getOrientation()
Get the orientation of the tree layout.

Returns:
the orientation value. One of Constants.ORIENT_LEFT_RIGHT, Constants.ORIENT_RIGHT_LEFT, Constants.ORIENT_TOP_BOTTOM, or Constants.ORIENT_BOTTOM_TOP.

setDepthSpacing

public void setDepthSpacing(double d)
Set the spacing between depth levels.

Parameters:
d - the depth spacing to use

getDepthSpacing

public double getDepthSpacing()
Get the spacing between depth levels.

Returns:
the depth spacing

setBreadthSpacing

public void setBreadthSpacing(double b)
Set the spacing between neighbor nodes.

Parameters:
b - the breadth spacing to use

getBreadthSpacing

public double getBreadthSpacing()
Get the spacing between neighbor nodes.

Returns:
the breadth spacing

setSubtreeSpacing

public void setSubtreeSpacing(double s)
Set the spacing between neighboring subtrees.

Parameters:
s - the subtree spacing to use

getSubtreeSpacing

public double getSubtreeSpacing()
Get the spacing between neighboring subtrees.

Returns:
the subtree spacing

setRootNodeOffset

public void setRootNodeOffset(double o)
Set the offset value for placing the root node of the tree. The dimension in which this offset is applied is dependent upon the orientation of the tree. For example, in a left-to-right orientation, the offset will a horizontal offset from the left edge of the layout bounds.

Parameters:
o - the value by which to offset the root node of the tree

getRootNodeOffset

public double getRootNodeOffset()
Get the offset value for placing the root node of the tree.

Returns:
the value by which the root node of the tree is offset

getLayoutAnchor

public java.awt.geom.Point2D getLayoutAnchor()
Description copied from class: Layout
Return the layout anchor at which to center or root the layout. How this point is used (if it is used at all) is dependent on the particular Layout implementation. If no anchor point has been explicitly set, the center coordinate for the first display found in this action's associated Visualization is used, if available.

Overrides:
getLayoutAnchor in class Layout
Returns:
the layout anchor point.
See Also:
Layout.getLayoutAnchor()

run

public void run(double frac)
Description copied from class: Action
Runs this Action, triggering whatever processing this Action performs. Subclass this method to create custom Actions.

Specified by:
run in class GroupAction
Parameters:
frac - the fraction of this Action's duration that has elapsed.
See Also:
Action.run(double)

initSchema

protected void initSchema(TupleSet ts)


Copyright © 2007 Regents of the University of California