com.jgraph.layout.tree

Class JGraphCompactTreeLayout

public class JGraphCompactTreeLayout extends JGraphAbstractTreeLayout

The compact tree layout is a Moen layout, which concentrates on making the graph as compact as possible whilst still allowing correctly for varations in node shapes and sizes The paper by Moen is called "Drawing Dynamic Trees" and may be purchased from http://csdl.computer.org/comp/mags/so/1990/04/s4021abs.htm
Nested Class Summary
protected classJGraphCompactTreeLayout.CompactTreeNode
Abstraction of node in a tree structure
Field Summary
static intDEFAULT_ORIENTATION
Value of default orientation
static intLEFT_TO_RIGHT
Value of left to right orientation
static intUP_TO_DOWN
Value of up to down orientation
Constructor Summary
JGraphCompactTreeLayout()
Default constructor, sets level distance and orientation to defaults
Method Summary
protected voidattachParent(JGraphCompactTreeLayout.CompactTreeNode t, double h)
Attaches the specified tree node in a parent-child relationship taking into account node shape
protected voidbranch(JGraphCompactTreeLayout.CompactTreeNode parent, JGraphCompactTreeLayout.CompactTreeNode child, JGraphCompactTreeLayout.CompactTreeNode sibling)
protected JGraphCompactTreeLayout.PolyLinebridge(JGraphCompactTreeLayout.PolyLine line1, double x1, double y1, JGraphCompactTreeLayout.PolyLine line2, double x2, double y2)
protected voiddispatchResult(Collection treeLayoutNodes)
Sets the new positions of the cells in the graph based on the information from the interal tree nodes.
doublegetChildParentDistance()
Get the minimum distance between a parent from any of its children
doublegetNodeBorder()
intgetOrientation()
protected JGraphCompactTreeLayout.CompactTreeNodegetTreeLayoutNode(Object cell)
Obtains the mapped node from the internal tree representation used from the cell specified
protected JGraphCompactTreeLayout.CompactTreeNodegetTreeLayoutNode(Object cell, boolean createIfNotPresent)
Obtains the mapped node from the internal tree representation used from the cell specified
protected doublejoin(JGraphCompactTreeLayout.CompactTreeNode t)
joins the specified tree node
protected voidlayout(JGraphCompactTreeLayout.CompactTreeNode t)
Laids out the specified tree node in the internal tree representation
protected voidlayoutLeaf(JGraphCompactTreeLayout.CompactTreeNode t)
Laids out a tree node as a leaf, taking into account node shape
protected voidlayoutTree(JGraphCompactTreeLayout.CompactTreeNode root)
Top-level layout method for Moen
protected voidleftRightNodeLayout(JGraphCompactTreeLayout.CompactTreeNode node, double off_x, double off_y)
Lays out a Moen in the left-right orientation
protected doublemerge(JGraphCompactTreeLayout.Polygon c1, JGraphCompactTreeLayout.Polygon c2)
protected doubleoffset(double p1, double p2, double a1, double a2, double b1, double b2)
voidrun(JGraphFacade graph)
The run method of this layout that executes a Moen using the cell data and configuration information in the specified facade It first builds a representation of the tree using the inner tree class by doing a depth first search of the graph from the root.
voidsetChildParentDistance(double distance)
Sets the minimum distance, upon the axis of orientation of the layout, that a parent will be from any of its children
voidsetNodeBorder(double nodeBorder)
voidsetOrientation(int orientation)
SwingConstants.NORTH SwingConstants.WEST are valid inputs to this method
StringtoString()
Returns Compact Tree, the name of this algorithm.
protected voidunzip(JGraphCompactTreeLayout.CompactTreeNode node)
protected voidupDownNodeLayout(JGraphCompactTreeLayout.CompactTreeNode node, JGraphCompactTreeLayout.CompactTreeNode parent, double off_x, double off_y)
Lays out a Moen in the up-down orientation
protected voidzip(JGraphCompactTreeLayout.CompactTreeNode node)

Field Detail

DEFAULT_ORIENTATION

public static final int DEFAULT_ORIENTATION

Deprecated: use SwingConstants compass directions instead

Value of default orientation

LEFT_TO_RIGHT

public static final int LEFT_TO_RIGHT

Deprecated: use SwingConstants.WEST instead

Value of left to right orientation

UP_TO_DOWN

public static final int UP_TO_DOWN

Deprecated: use SwingConstants.NORTH instead

Value of up to down orientation

Constructor Detail

JGraphCompactTreeLayout

public JGraphCompactTreeLayout()
Default constructor, sets level distance and orientation to defaults

Method Detail

attachParent

protected void attachParent(JGraphCompactTreeLayout.CompactTreeNode t, double h)
Attaches the specified tree node in a parent-child relationship taking into account node shape

Parameters: t the internal tree node

branch

protected void branch(JGraphCompactTreeLayout.CompactTreeNode parent, JGraphCompactTreeLayout.CompactTreeNode child, JGraphCompactTreeLayout.CompactTreeNode sibling)

bridge

protected JGraphCompactTreeLayout.PolyLine bridge(JGraphCompactTreeLayout.PolyLine line1, double x1, double y1, JGraphCompactTreeLayout.PolyLine line2, double x2, double y2)

Parameters: line1 x1 y1 line2 x2 y2

Returns: Returns a PolyLine

dispatchResult

protected void dispatchResult(Collection treeLayoutNodes)
Sets the new positions of the cells in the graph based on the information from the interal tree nodes. Note this doesn't apply the position to the actual graph, only stores the bounds values to be applied later

Parameters: treeLayoutNodes the nodes of the internal tree structure that describe the new tree layout

getChildParentDistance

public double getChildParentDistance()

Deprecated: use getLevelDistance

Get the minimum distance between a parent from any of its children

Returns: the level distance

getNodeBorder

public double getNodeBorder()

Returns: Returns the nodeBorder.

getOrientation

public int getOrientation()

Returns: Returns the orientation.

getTreeLayoutNode

protected JGraphCompactTreeLayout.CompactTreeNode getTreeLayoutNode(Object cell)
Obtains the mapped node from the internal tree representation used from the cell specified

Parameters: cell the cell whose TreeLayoutNode is to be found

Returns: the internal node representation of the specified cell

getTreeLayoutNode

protected JGraphCompactTreeLayout.CompactTreeNode getTreeLayoutNode(Object cell, boolean createIfNotPresent)
Obtains the mapped node from the internal tree representation used from the cell specified

Parameters: cell the cell whose TreeLayoutNode is to be found createIfNotPresent whether or not to create the internal node if it doesn't already exist

Returns: the internal node representation of the specified cell

join

protected double join(JGraphCompactTreeLayout.CompactTreeNode t)
joins the specified tree node

Parameters: t the tree node to be joined

Returns: Returns the size of the tree.

layout

protected void layout(JGraphCompactTreeLayout.CompactTreeNode t)
Laids out the specified tree node in the internal tree representation

Parameters: t the node to be laid out

layoutLeaf

protected void layoutLeaf(JGraphCompactTreeLayout.CompactTreeNode t)
Laids out a tree node as a leaf, taking into account node shape

Parameters: t the node to be laid out

layoutTree

protected void layoutTree(JGraphCompactTreeLayout.CompactTreeNode root)
Top-level layout method for Moen

Parameters: root the root node of the tree

leftRightNodeLayout

protected void leftRightNodeLayout(JGraphCompactTreeLayout.CompactTreeNode node, double off_x, double off_y)
Lays out a Moen in the left-right orientation

Parameters: node the current node being laid out off_x x-axis offset off_y y-axis offset

merge

protected double merge(JGraphCompactTreeLayout.Polygon c1, JGraphCompactTreeLayout.Polygon c2)

Parameters: c1 c2

Returns: Returns the width of the layout

offset

protected double offset(double p1, double p2, double a1, double a2, double b1, double b2)

Parameters: p1 p2 a1 a2 b1 b2

Returns: Returns the actual offset

run

public void run(JGraphFacade graph)
The run method of this layout that executes a Moen using the cell data and configuration information in the specified facade It first builds a representation of the tree using the inner tree class by doing a depth first search of the graph from the root. It then lays out the graph using the obtained data and makes the data available for external collection]

Parameters: graph the facade describing the graph and its configuration

setChildParentDistance

public void setChildParentDistance(double distance)

Deprecated: use setLevelDistance

Sets the minimum distance, upon the axis of orientation of the layout, that a parent will be from any of its children

Parameters: distance the minimum distance

setNodeBorder

public void setNodeBorder(double nodeBorder)

Parameters: nodeBorder The nodeBorder to set.

setOrientation

public void setOrientation(int orientation)
SwingConstants.NORTH SwingConstants.WEST are valid inputs to this method

Parameters: orientation

toString

public String toString()
Returns Compact Tree, the name of this algorithm.

unzip

protected void unzip(JGraphCompactTreeLayout.CompactTreeNode node)

upDownNodeLayout

protected void upDownNodeLayout(JGraphCompactTreeLayout.CompactTreeNode node, JGraphCompactTreeLayout.CompactTreeNode parent, double off_x, double off_y)
Lays out a Moen in the up-down orientation

Parameters: node the current node being laid out parent the parent of the current node off_x the total x-axis offset of the parent node off_y the total y-axis offset of the parent node

zip

protected void zip(JGraphCompactTreeLayout.CompactTreeNode node)
Copyright (C) 2001-2009 JGraph Ltd. All rights reserved.