|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdiva.graph.layout.AbstractGlobalLayout
diva.graph.layout.LevelLayout
public class LevelLayout
A level-based layout algorithm originally implemented by Ulfar Erlingsson at Cornell/RPI and modified to fit into this system.
The algorithm is structured in the following way:
Red |
Nested Class Summary | |
---|---|
class |
LevelLayout.LevelData
|
static class |
LevelLayout.LevelInfo
The semantic object of each node in the graph copy that is being laid out. |
Field Summary | |
---|---|
private BasicGraphModel |
_local
The graph implementation of the graph copy, for adding dummy nodes/edges to the graph copy. |
protected int |
_orientation
Keep track of the orientation; vertical by default. |
private boolean |
_randomizedPlacement
A flag to determine whether or not we want to randomize the placement of the nodes. |
static int |
HORIZONTAL
Layout the graph in levels from left to right. |
static int |
VERTICAL
Layout the graph in levels from top to bottom. |
Fields inherited from class diva.graph.layout.AbstractGlobalLayout |
---|
_layoutTarget |
Constructor Summary | |
---|---|
LevelLayout(LayoutTarget target)
Construct a new levelizing layout with a vertical orientation. |
Method Summary | |
---|---|
private void |
addDummies(LevelLayout.LevelData levelData)
Add dummy nodes between nodes along edges that span multiple levels. |
private void |
addSubGraphReverseDFS(LevelLayout.LevelData levelData,
java.lang.Object node)
Add this node and all of its parent nodes to the levels array in a reverse DFS. |
void |
applyLayout(LevelLayout.LevelData levelData,
java.lang.Object g)
Place the nodes in the target environment according to their levels and sorting order which are specified in levelData. |
void |
applyLayout(LevelLayout.LevelData levelData,
java.lang.Object g,
boolean useDummies)
Place the nodes in the target environment according to their levels and sorting order which are specified in levelData. |
private void |
ASSERT(boolean b,
java.lang.String err)
Assert the given condition and throw a runtime exception with the given string if the assertion fails. |
private void |
breakCycles(java.lang.Object composite,
GraphModel model)
Inefficient algorithm to break cycles in the graph. |
LevelLayout.LevelData |
calculateLayout(java.lang.Object composite)
This method performs levelizing layout on the given composite. |
private boolean |
checkAndBreak(java.lang.Object edge,
java.lang.Object node)
Return true if a cycle was broken. |
private void |
computeLevels(LevelLayout.LevelData levelData)
Topological sort of graph and then set level numbers for the nodes. |
protected java.lang.Object |
copyComposite(java.lang.Object origComposite)
Copy the given graph and make the nodes/edges in the copied graph point to the nodes/edges in the original. |
protected void |
copyLayout(java.lang.Object origComposite,
java.lang.Object copyComposite)
Take the layout generated by the core layout algorithm and copy it back into the view of the original composite passed in by the user. |
private int |
getLevel(java.lang.Object node)
Get the level of n in the graph. |
private LevelLayout.LevelInfo |
getLevelInfo(java.lang.Object node)
|
BasicGraphModel |
getLocalGraphModel()
Return the local graph model. |
int |
getOrientation()
Return the orientation in which the graph is to be laid out, either VERTICAL or HORIZONTAL. |
boolean |
getRandomizedPlacement()
Return whether or not placement will be randomized. |
private int |
getUsage(java.lang.Object node)
Get the level of n in the graph. |
private void |
initialOrderNodes(LevelLayout.LevelData levelData,
java.lang.Object maxNode)
Assign an initial ordering to the nodes. |
private boolean |
isDummy(java.lang.Object node)
Return whether or not the given node is a dummy. |
boolean |
isVisited(java.lang.Object node)
|
void |
layout(java.lang.Object composite)
Perform the levelizing layout on the given composite in the given target environment. |
private void |
makeLevels(LevelLayout.LevelData levelData)
Get the level of n in the graph. |
private void |
makeMeta(LevelLayout.LevelData levelData)
Create a meta-node and add it to the graph, connecting it to each existing node in the graph. |
private void |
placeNode(java.lang.Object node,
double x,
double y)
|
private void |
placeNodes(LevelLayout.LevelData levelData,
java.awt.geom.Rectangle2D vp,
boolean useDummies)
Place the nodes in the graph, based on the previous level calculations and the order of the nodes in the _levels array. |
private void |
removeMeta(LevelLayout.LevelData levelData)
Remove the meta-node from the graph. |
void |
setAllVisited(java.lang.Object composite,
boolean val)
|
private void |
setLevel(java.lang.Object node,
int l)
Set the level of n in the graph. |
void |
setOrientation(int o)
Set the orientation in which the graph is to be laid out, either VERTICAL or HORIZONTAL. |
void |
setRandomizedPlacement(boolean flag)
Set whether or not placement will be randomized. |
private void |
setUsage(java.lang.Object node,
int val)
Set the level of n in the graph. |
void |
setVisited(java.lang.Object node,
boolean val)
|
private void |
topoSort(java.lang.Object node,
java.util.ArrayList topo)
Topologically sort from the given node and place the results in the given array list. |
Methods inherited from class diva.graph.layout.AbstractGlobalLayout |
---|
getLayoutTarget, setLayoutTarget |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int VERTICAL
setOrientation(int)
,
Constant Field Valuespublic static final int HORIZONTAL
setOrientation(int)
,
Constant Field Valuesprotected int _orientation
private BasicGraphModel _local
private boolean _randomizedPlacement
Constructor Detail |
---|
public LevelLayout(LayoutTarget target)
Method Detail |
---|
protected java.lang.Object copyComposite(java.lang.Object origComposite)
protected void copyLayout(java.lang.Object origComposite, java.lang.Object copyComposite)
public BasicGraphModel getLocalGraphModel()
public int getOrientation()
public boolean getRandomizedPlacement()
public void layout(java.lang.Object composite)
layout
in interface GlobalLayout
layout
in class AbstractGlobalLayout
public LevelLayout.LevelData calculateLayout(java.lang.Object composite)
public void applyLayout(LevelLayout.LevelData levelData, java.lang.Object g)
public void applyLayout(LevelLayout.LevelData levelData, java.lang.Object g, boolean useDummies)
public void setOrientation(int o)
public void setRandomizedPlacement(boolean flag)
private void ASSERT(boolean b, java.lang.String err) throws java.lang.RuntimeException
java.lang.RuntimeException
private void breakCycles(java.lang.Object composite, GraphModel model)
private boolean checkAndBreak(java.lang.Object edge, java.lang.Object node)
private void addDummies(LevelLayout.LevelData levelData)
o from o from o from | | | <------ original edge | | o dum1 | ==> | ==> | ==> ... | o dum1 o dum2 | <- e --> | | o to o to o to
private void makeLevels(LevelLayout.LevelData levelData)
private void initialOrderNodes(LevelLayout.LevelData levelData, java.lang.Object maxNode)
private void addSubGraphReverseDFS(LevelLayout.LevelData levelData, java.lang.Object node)
private void placeNodes(LevelLayout.LevelData levelData, java.awt.geom.Rectangle2D vp, boolean useDummies)
private void placeNode(java.lang.Object node, double x, double y)
private LevelLayout.LevelInfo getLevelInfo(java.lang.Object node)
private int getLevel(java.lang.Object node)
private void setLevel(java.lang.Object node, int l)
private int getUsage(java.lang.Object node)
private boolean isDummy(java.lang.Object node)
private void setUsage(java.lang.Object node, int val)
private void topoSort(java.lang.Object node, java.util.ArrayList topo)
private void makeMeta(LevelLayout.LevelData levelData)
private void removeMeta(LevelLayout.LevelData levelData)
public void setVisited(java.lang.Object node, boolean val)
public void setAllVisited(java.lang.Object composite, boolean val)
public boolean isVisited(java.lang.Object node)
private void computeLevels(LevelLayout.LevelData levelData)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |