|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jgraph.layout.JGraphLayoutAlgorithm
edu.iastate.metnet.graphmodel.MyTreeAlgorithm
public class MyTreeAlgorithm
copy from JGraph, modified for pathway category. Add comments since original code do not contain any comment. I try to make the tree more compact and easy for navigation
| Nested Class Summary | |
|---|---|
protected class |
MyTreeAlgorithm.PolyLine
the polyline structure |
protected class |
MyTreeAlgorithm.TreeNode
tree node contains the relative position in the tree |
| Field Summary | |
|---|---|
protected int |
alignment
default alignment |
protected java.util.Map |
cell2node
CellView -> TreeNode |
protected boolean |
centerRoot
center root, if we put the root in the center of the screen border, depending on the orientation of the root |
protected boolean |
combineLevelNodes
combine level, if align same level nodes, if false, may save spaces |
protected org.jgraph.JGraph |
graph
graph to be layout |
protected int |
levelDistance
default level distance |
(package private) static org.apache.log4j.Logger |
logger
log4j facility |
protected int |
nodeDistance
default node distance |
protected int |
orientation
default orientation, this decide the position of the root in the whole screen |
| Fields inherited from class org.jgraph.layout.JGraphLayoutAlgorithm |
|---|
LAYOUT_ATTRIBUTES |
| Constructor Summary | |
|---|---|
MyTreeAlgorithm()
|
|
| Method Summary | |
|---|---|
protected MyTreeAlgorithm.TreeNode |
buildTree(org.jgraph.graph.CellView view)
build the tree for one cell view recursively |
protected java.util.List |
buildTrees(java.util.List roots)
build tree for each root |
protected int |
distance(MyTreeAlgorithm.PolyLine right,
MyTreeAlgorithm.PolyLine left)
accumulate the delta x of both contour |
int |
getAlignment()
|
protected java.util.List |
getChildren(org.jgraph.graph.CellView view)
get the children cell view of one cell view |
java.lang.String |
getHint()
Get a human readable hint for using this layout. |
protected MyTreeAlgorithm.TreeNode |
getLeftMostX(MyTreeAlgorithm.TreeNode node)
get the most left child tree node in this tree specified by the root node |
int |
getLevelDistance()
|
int |
getNodeDistance()
|
int |
getOrientation()
|
protected MyTreeAlgorithm.TreeNode |
getRightMostX(MyTreeAlgorithm.TreeNode node)
get the most right child tree node in this tree specified by the root node |
protected MyTreeAlgorithm.TreeNode |
getTreeNode(org.jgraph.graph.CellView view)
get the tree node of cell view, which contains the position and children node information |
boolean |
isCenterRoot()
|
boolean |
isCombineLevelNodes()
|
protected void |
join(MyTreeAlgorithm.TreeNode node)
joining tree contour |
protected void |
layout(MyTreeAlgorithm.TreeNode node)
layout a group of cell views which compose of a tree structure |
protected void |
layoutTrees(java.util.List roots)
layout the trees |
protected void |
merge(MyTreeAlgorithm.PolyLine main,
MyTreeAlgorithm.PolyLine left,
int distance)
|
void |
run(org.jgraph.JGraph graph,
java.lang.Object[] dynamic_cells,
java.lang.Object[] static_cells)
main entry point of the layout algorithm |
void |
setAlignment(int alignment)
set alignment as SwingConstants.TOP SwingConstants.CENTER SwingConstants.BOTTOM |
void |
setCenterRoot(boolean b)
if put the root in the center of the screen border |
void |
setCombineLevelNodes(boolean combineLevelNodes)
|
void |
setLevelDistance(int distance)
set distance between the tree level |
protected void |
setLevelHeights(java.util.List roots)
change the level height to make it more compact. |
void |
setNodeDistance(int distance)
set distance between the nodes |
void |
setOrientation(int orientation)
SwingConstants.NORTH SwingConstants.EAST SwingConstants.SOUTH SwingConstants.WEST |
protected void |
setPosition(java.util.List roots)
set position for a list of trees |
java.lang.String |
toString()
Returns the name of this algorithm in human readable form. |
| Methods inherited from class org.jgraph.layout.JGraphLayoutAlgorithm |
|---|
applyLayout, applyLayout, createDialog, createDialog, createSettings, getMaximumProgress, getProgress, isAllowedToRun, populateDialog, run, setAllowedToRun, setMaximumProgress, setProgress |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
static org.apache.log4j.Logger logger
protected int alignment
protected int orientation
protected int levelDistance
protected int nodeDistance
protected boolean centerRoot
protected boolean combineLevelNodes
protected org.jgraph.JGraph graph
protected java.util.Map cell2node
| Constructor Detail |
|---|
public MyTreeAlgorithm()
| Method Detail |
|---|
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getHint()
getHint in class org.jgraph.layout.JGraphLayoutAlgorithmpublic void setAlignment(int alignment)
alignment - the alignment of the nodepublic void setOrientation(int orientation)
orientation - the orientation of the rootpublic void setLevelDistance(int distance)
distance - the level distancepublic void setNodeDistance(int distance)
distance - the node distancepublic void setCenterRoot(boolean b)
b - true or false
public void run(org.jgraph.JGraph graph,
java.lang.Object[] dynamic_cells,
java.lang.Object[] static_cells)
run in class org.jgraph.layout.JGraphLayoutAlgorithmgraph - JGraph instancedynamic_cells - List of all nodes the layout should movestatic_cells - List of node the layout should not move but allow for rotate?protected java.util.List buildTrees(java.util.List roots)
roots - the roots, may be disjoint
protected MyTreeAlgorithm.TreeNode buildTree(org.jgraph.graph.CellView view)
view - the cell view of the root node
protected java.util.List getChildren(org.jgraph.graph.CellView view)
view - the cell view to extend
protected MyTreeAlgorithm.TreeNode getTreeNode(org.jgraph.graph.CellView view)
view - the cell view
protected void layoutTrees(java.util.List roots)
roots - the root of treesprotected void layout(MyTreeAlgorithm.TreeNode node)
node - protected void join(MyTreeAlgorithm.TreeNode node)
node - unknownprotected MyTreeAlgorithm.TreeNode getLeftMostX(MyTreeAlgorithm.TreeNode node)
node - the root node of this sub tree
protected MyTreeAlgorithm.TreeNode getRightMostX(MyTreeAlgorithm.TreeNode node)
node - the root node of this sub tree
protected void merge(MyTreeAlgorithm.PolyLine main,
MyTreeAlgorithm.PolyLine left,
int distance)
protected int distance(MyTreeAlgorithm.PolyLine right,
MyTreeAlgorithm.PolyLine left)
right - the right contourleft - the left contour
protected void setPosition(java.util.List roots)
protected void setLevelHeights(java.util.List roots)
roots - the root of treespublic boolean isCombineLevelNodes()
public void setCombineLevelNodes(boolean combineLevelNodes)
combineLevelNodes - The combineLevelNodes to set.public int getAlignment()
public boolean isCenterRoot()
public int getLevelDistance()
public int getNodeDistance()
public int getOrientation()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||