JGraph X 1.2.0.8


com.mxgraph.layout
Class mxCompactTreeLayout

java.lang.Object
  extended by com.mxgraph.layout.mxGraphLayout
      extended by com.mxgraph.layout.mxCompactTreeLayout
All Implemented Interfaces:
mxIGraphLayout

public class mxCompactTreeLayout
extends mxGraphLayout


Nested Class Summary
protected static class mxCompactTreeLayout.Polygon
           
protected static class mxCompactTreeLayout.Polyline
           
protected static class mxCompactTreeLayout.TreeNode
           
 
Field Summary
protected  boolean horizontal
          Specifies the orientation of the layout.
protected  boolean invert
          Specifies if edge directions should be inverted.
protected  int levelDistance
          Holds the levelDistance.
protected  boolean moveTree
          Specifies if the tree should be moved to the top, left corner if it is inside a top-level layer.
protected  int nodeDistance
          Holds the nodeDistance.
protected  boolean resetEdges
          Specifies if all edge points of traversed edges should be removed.
protected  boolean resizeParent
          If the parent should be resized to match the width/height of the tree.
 
Fields inherited from class com.mxgraph.layout.mxGraphLayout
graph, useBoundingBox
 
Constructor Summary
mxCompactTreeLayout(mxGraph graph)
           
mxCompactTreeLayout(mxGraph graph, boolean horizontal)
           
mxCompactTreeLayout(mxGraph graph, boolean horizontal, boolean invert)
           
 
Method Summary
protected  mxRectangle apply(mxCompactTreeLayout.TreeNode node, mxRectangle bounds)
           
protected  void attachParent(mxCompactTreeLayout.TreeNode node, double height)
           
protected  mxCompactTreeLayout.Polyline bridge(mxCompactTreeLayout.Polyline line1, double x1, double y1, mxCompactTreeLayout.Polyline line2, double x2, double y2)
           
protected  mxCompactTreeLayout.Polyline createLine(double dx, double dy, mxCompactTreeLayout.Polyline next)
           
protected  mxCompactTreeLayout.TreeNode createNode(Object cell)
           
protected  mxCompactTreeLayout.TreeNode dfs(Object cell, Object parent, Set<Object> visited)
          Does a depth first search starting at the specified cell.
 void execute(Object parent)
          Executes the layout for the children of the specified parent.
 void execute(Object parent, Object root)
          Implements .
 int getLevelDistance()
           
 int getNodeDistance()
           
protected  mxRectangle horizontalLayout(mxCompactTreeLayout.TreeNode node, double x0, double y0, mxRectangle bounds)
           
 boolean isHorizontal()
           
 boolean isInvert()
           
 boolean isMoveTree()
           
 boolean isResetEdges()
           
 boolean isResizeParent()
           
 boolean isVertexIgnored(Object vertex)
          Returns a boolean indicating if the given should be ignored as a vertex.
protected  double join(mxCompactTreeLayout.TreeNode node)
           
protected  void layout(mxCompactTreeLayout.TreeNode node)
          Starts the actual compact tree layout algorithm at the given node.
protected  void layoutLeaf(mxCompactTreeLayout.TreeNode node)
           
protected  double merge(mxCompactTreeLayout.Polygon p1, mxCompactTreeLayout.Polygon p2)
           
protected  void moveNode(mxCompactTreeLayout.TreeNode node, double dx, double dy)
          Moves the specified node and all of its children by the given amount.
protected  double offset(double p1, double p2, double a1, double a2, double b1, double b2)
           
 void setHorizontal(boolean horizontal)
           
 void setInvert(boolean invert)
           
 void setLevelDistance(int levelDistance)
           
 void setMoveTree(boolean moveTree)
           
 void setNodeDistance(int nodeDistance)
           
 void setResetEdges(boolean resetEdges)
           
 void setResizeParent(boolean resizeParent)
           
protected  mxRectangle verticalLayout(mxCompactTreeLayout.TreeNode node, Object parent, double x0, double y0, mxRectangle bounds)
           
 
Methods inherited from class com.mxgraph.layout.mxGraphLayout
getConstraint, getConstraint, getGraph, getVertexBounds, isEdgeIgnored, isUseBoundingBox, isVertexMovable, moveCell, setEdgePoints, setEdgeStyleEnabled, setUseBoundingBox, setVertexLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

horizontal

protected boolean horizontal
Specifies the orientation of the layout. Default is true.


invert

protected boolean invert
Specifies if edge directions should be inverted. Default is false.


resizeParent

protected boolean resizeParent
If the parent should be resized to match the width/height of the tree. Default is true.


moveTree

protected boolean moveTree
Specifies if the tree should be moved to the top, left corner if it is inside a top-level layer. Default is true.


resetEdges

protected boolean resetEdges
Specifies if all edge points of traversed edges should be removed. Default is true.


levelDistance

protected int levelDistance
Holds the levelDistance. Default is 10.


nodeDistance

protected int nodeDistance
Holds the nodeDistance. Default is 20.

Constructor Detail

mxCompactTreeLayout

public mxCompactTreeLayout(mxGraph graph)
Parameters:
graph -

mxCompactTreeLayout

public mxCompactTreeLayout(mxGraph graph,
                           boolean horizontal)
Parameters:
graph -
horizontal -

mxCompactTreeLayout

public mxCompactTreeLayout(mxGraph graph,
                           boolean horizontal,
                           boolean invert)
Parameters:
graph -
horizontal -
invert -
Method Detail

isVertexIgnored

public boolean isVertexIgnored(Object vertex)
Returns a boolean indicating if the given should be ignored as a vertex. This returns true if the cell has no connections.

Overrides:
isVertexIgnored in class mxGraphLayout
Parameters:
vertex - Object that represents the vertex to be tested.
Returns:
Returns true if the vertex should be ignored.

isHorizontal

public boolean isHorizontal()
Returns:
the horizontal

setHorizontal

public void setHorizontal(boolean horizontal)
Parameters:
horizontal - the horizontal to set

isInvert

public boolean isInvert()
Returns:
the invert

setInvert

public void setInvert(boolean invert)
Parameters:
invert - the invert to set

isResizeParent

public boolean isResizeParent()
Returns:
the resizeParent

setResizeParent

public void setResizeParent(boolean resizeParent)
Parameters:
resizeParent - the resizeParent to set

isMoveTree

public boolean isMoveTree()
Returns:
the moveTree

setMoveTree

public void setMoveTree(boolean moveTree)
Parameters:
moveTree - the moveTree to set

isResetEdges

public boolean isResetEdges()
Returns:
the resetEdges

setResetEdges

public void setResetEdges(boolean resetEdges)
Parameters:
resetEdges - the resetEdges to set

getLevelDistance

public int getLevelDistance()
Returns:
the levelDistance

setLevelDistance

public void setLevelDistance(int levelDistance)
Parameters:
levelDistance - the levelDistance to set

getNodeDistance

public int getNodeDistance()
Returns:
the nodeDistance

setNodeDistance

public void setNodeDistance(int nodeDistance)
Parameters:
nodeDistance - the nodeDistance to set

execute

public void execute(Object parent)
Description copied from interface: mxIGraphLayout
Executes the layout for the children of the specified parent.

Parameters:
parent - Parent cell that contains the children to be layed out.

execute

public void execute(Object parent,
                    Object root)
Implements . If the parent has any connected edges, then it is used as the root of the tree. Else, will be used to find a suitable root node within the set of children of the given parent.


moveNode

protected void moveNode(mxCompactTreeLayout.TreeNode node,
                        double dx,
                        double dy)
Moves the specified node and all of its children by the given amount.


dfs

protected mxCompactTreeLayout.TreeNode dfs(Object cell,
                                           Object parent,
                                           Set<Object> visited)
Does a depth first search starting at the specified cell. Makes sure the specified swimlane is never left by the algorithm.


layout

protected void layout(mxCompactTreeLayout.TreeNode node)
Starts the actual compact tree layout algorithm at the given node.


horizontalLayout

protected mxRectangle horizontalLayout(mxCompactTreeLayout.TreeNode node,
                                       double x0,
                                       double y0,
                                       mxRectangle bounds)

verticalLayout

protected mxRectangle verticalLayout(mxCompactTreeLayout.TreeNode node,
                                     Object parent,
                                     double x0,
                                     double y0,
                                     mxRectangle bounds)

attachParent

protected void attachParent(mxCompactTreeLayout.TreeNode node,
                            double height)

layoutLeaf

protected void layoutLeaf(mxCompactTreeLayout.TreeNode node)

join

protected double join(mxCompactTreeLayout.TreeNode node)

merge

protected double merge(mxCompactTreeLayout.Polygon p1,
                       mxCompactTreeLayout.Polygon p2)

offset

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

bridge

protected mxCompactTreeLayout.Polyline bridge(mxCompactTreeLayout.Polyline line1,
                                              double x1,
                                              double y1,
                                              mxCompactTreeLayout.Polyline line2,
                                              double x2,
                                              double y2)

createNode

protected mxCompactTreeLayout.TreeNode createNode(Object cell)

apply

protected mxRectangle apply(mxCompactTreeLayout.TreeNode node,
                            mxRectangle bounds)

createLine

protected mxCompactTreeLayout.Polyline createLine(double dx,
                                                  double dy,
                                                  mxCompactTreeLayout.Polyline next)

JGraph X 1.2.0.8


Copyright (c) 2008 Gaudenz Alder. All rights reserved.