Class JGraphCompactTreeLayout
java.lang.Object
com.jgraph.layout.tree.JGraphAbstractTreeLayout
com.jgraph.layout.tree.JGraphCompactTreeLayout
- All Implemented Interfaces:
JGraphLayout
- Direct Known Subclasses:
JGraphMoenLayout
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
Nested ClassesModifier and TypeClassDescriptionprotected classAbstraction of node in a tree structureNested classes/interfaces inherited from class JGraphAbstractTreeLayout
JGraphAbstractTreeLayout.TreeNodeNested classes/interfaces inherited from interface JGraphLayout
JGraphLayout.Stoppable -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDeprecated.use SwingConstants compass directions insteadstatic final intDeprecated.use SwingConstants.WEST insteadstatic final intDeprecated.use SwingConstants.NORTH insteadFields inherited from class JGraphAbstractTreeLayout
graph, levelDistance, lowerLevelValues, nodeDistance, nodes, oldOrigin, orientation, positionMultipleTrees, routeTreeEdges, treeBoundary, treeDistance, upperLevelValuesFields inherited from interface JGraphLayout
VERSION -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor, sets level distance and orientation to defaults -
Method Summary
Modifier and TypeMethodDescriptionprotected voidattachParent(JGraphCompactTreeLayout.CompactTreeNode t, double h) Attaches the specified tree node in a parent-child relationship taking into account node shapeprotected voidbranch(JGraphCompactTreeLayout.CompactTreeNode parent, JGraphCompactTreeLayout.CompactTreeNode child, JGraphCompactTreeLayout.CompactTreeNode sibling) protected com.jgraph.layout.tree.JGraphCompactTreeLayout.PolyLinebridge(com.jgraph.layout.tree.JGraphCompactTreeLayout.PolyLine line1, double x1, double y1, com.jgraph.layout.tree.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.doubleDeprecated.use getLevelDistancedoubleintprotected JGraphCompactTreeLayout.CompactTreeNodegetTreeLayoutNode(Object cell) Obtains the mapped node from the internal tree representation used from the cell specifiedprotected JGraphCompactTreeLayout.CompactTreeNodegetTreeLayoutNode(Object cell, boolean createIfNotPresent) Obtains the mapped node from the internal tree representation used from the cell specifiedprotected doublejoins the specified tree nodeprotected voidLaids out the specified tree node in the internal tree representationprotected voidLaids out a tree node as a leaf, taking into account node shapeprotected voidTop-level layout method for Moenprotected voidleftRightNodeLayout(JGraphCompactTreeLayout.CompactTreeNode node, double off_x, double off_y) Lays out a Moen in the left-right orientationprotected doublemerge(com.jgraph.layout.tree.JGraphCompactTreeLayout.Polygon c1, com.jgraph.layout.tree.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) Deprecated.use setLevelDistancevoidsetNodeBorder(double nodeBorder) voidsetOrientation(int orientation) SwingConstants.NORTH SwingConstants.WEST are valid inputs to this methodtoString()ReturnsCompact Tree, the name of this algorithm.protected voidprotected voidupDownNodeLayout(JGraphCompactTreeLayout.CompactTreeNode node, JGraphCompactTreeLayout.CompactTreeNode parent, double off_x, double off_y) Lays out a Moen in the up-down orientationprotected void
-
Field Details
-
LEFT_TO_RIGHT
public static final int LEFT_TO_RIGHTDeprecated.use SwingConstants.WEST insteadValue of left to right orientation- See Also:
-
UP_TO_DOWN
public static final int UP_TO_DOWNDeprecated.use SwingConstants.NORTH insteadValue of up to down orientation- See Also:
-
DEFAULT_ORIENTATION
public static final int DEFAULT_ORIENTATIONDeprecated.use SwingConstants compass directions insteadValue of default orientation- See Also:
-
-
Constructor Details
-
JGraphCompactTreeLayout
public JGraphCompactTreeLayout()Default constructor, sets level distance and orientation to defaults
-
-
Method Details
-
run
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]- Specified by:
runin interfaceJGraphLayout- Overrides:
runin classJGraphAbstractTreeLayout- Parameters:
graph- the facade describing the graph and its configuration
-
layoutTree
Top-level layout method for Moen- Parameters:
root- the root node of the tree
-
getTreeLayoutNode
Obtains the mapped node from the internal tree representation used from the cell specified- Parameters:
cell- the cell whoseTreeLayoutNodeis 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 whoseTreeLayoutNodeis to be foundcreateIfNotPresent- whether or not to create the internal node if it doesn't already exist- Returns:
- the internal node representation of the specified cell
-
dispatchResult
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
-
layout
Laids out the specified tree node in the internal tree representation- Parameters:
t- the node to be laid out
-
attachParent
Attaches the specified tree node in a parent-child relationship taking into account node shape- Parameters:
t- the internal tree node
-
layoutLeaf
Laids out a tree node as a leaf, taking into account node shape- Parameters:
t- the node to be laid out
-
join
joins the specified tree node- Parameters:
t- the tree node to be joined- Returns:
- Returns the size of the tree.
-
merge
protected double merge(com.jgraph.layout.tree.JGraphCompactTreeLayout.Polygon c1, com.jgraph.layout.tree.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
-
bridge
protected com.jgraph.layout.tree.JGraphCompactTreeLayout.PolyLine bridge(com.jgraph.layout.tree.JGraphCompactTreeLayout.PolyLine line1, double x1, double y1, com.jgraph.layout.tree.JGraphCompactTreeLayout.PolyLine line2, double x2, double y2) - Parameters:
line1-x1-y1-line2-x2-y2-- Returns:
- Returns a
PolyLine
-
branch
protected void branch(JGraphCompactTreeLayout.CompactTreeNode parent, JGraphCompactTreeLayout.CompactTreeNode child, JGraphCompactTreeLayout.CompactTreeNode sibling) -
unzip
-
zip
-
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 outoff_x- x-axis offsetoff_y- y-axis offset
-
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 outparent- the parent of the current nodeoff_x- the total x-axis offset of the parent nodeoff_y- the total y-axis offset of the parent node
-
setOrientation
public void setOrientation(int orientation) SwingConstants.NORTH SwingConstants.WEST are valid inputs to this method- Overrides:
setOrientationin classJGraphAbstractTreeLayout- Parameters:
orientation-
-
getOrientation
public int getOrientation()- Overrides:
getOrientationin classJGraphAbstractTreeLayout- Returns:
- Returns the orientation.
-
setChildParentDistance
public void setChildParentDistance(double distance) Deprecated.use setLevelDistanceSets 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
-
getChildParentDistance
public double getChildParentDistance()Deprecated.use getLevelDistanceGet the minimum distance between a parent from any of its children- Returns:
- the level distance
-
getNodeBorder
public double getNodeBorder()- Returns:
- Returns the nodeBorder.
-
setNodeBorder
public void setNodeBorder(double nodeBorder) - Parameters:
nodeBorder- The nodeBorder to set.
-
toString
-