|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.gui.graphvisualizer.HierarchicalBCEngine
This class lays out the vertices of a graph in a hierarchy of vertical levels, with a number of nodes in each level. The number of levels is the depth of the deepest child reachable from some parent at level 0. It implements a layout technique as described by K. Sugiyama, S. Tagawa, and M. Toda. in "Methods for visual understanding of hierarchical systems", IEEE Transactions on Systems, Man and Cybernetics, SMC-11(2):109-125, Feb. 1981.
There have been a few modifications made, however. The crossings function is changed as it was non-linear in time complexity. Furthermore, we don't have any interconnection matrices for each level, instead we just have one big interconnection matrix for the whole graph and a int[][] array which stores the vertices present in each level.
Nested Class Summary | |
private class |
HierarchicalBCEngine.MyList
The following classes implement a double linked list to be used in the crossings function. |
private class |
HierarchicalBCEngine.MyListNode
|
Field Summary | |
protected int[][] |
graphMatrix
Interconnection matrix for the graph |
protected FastVector |
layoutCompleteListeners
FastVector containing listeners for layoutCompleteEvent generated by this LayoutEngine |
protected boolean |
m_completeReLayout
This tells the the LayoutGraph method if a completeReLayout should be performed when it is called. |
protected javax.swing.JPanel |
m_controlsPanel
The panel containing extra options, specific to this LayoutEngine, for greater control over layout of the graph |
protected FastVector |
m_edges
FastVector containing nodes and edges |
protected javax.swing.JCheckBox |
m_jCbEdgeConcentration
controls edge concentration by concentrating multilple singular dummy child nodes into one plural dummy child node |
protected javax.swing.JRadioButton |
m_jRbBottomup
|
protected javax.swing.JRadioButton |
m_jRbNaiveLayout
|
protected javax.swing.JRadioButton |
m_jRbPriorityLayout
|
protected javax.swing.JRadioButton |
m_jRbTopdown
|
protected int |
m_nodeHeight
The nodeWidth and nodeHeight |
protected FastVector |
m_nodes
FastVector containing nodes and edges |
protected int |
m_nodeWidth
The nodeWidth and nodeHeight |
protected javax.swing.JProgressBar |
m_progress
The progress bar to show the progress of the layout process |
protected int[][] |
nodeLevels
Array containing the indices of nodes in each level. |
private int |
origNodesSize
This contains the original size of the nodes vector when it was passed in through the constructor, before adding all the dummy vertices |
Fields inherited from interface weka.gui.graphvisualizer.GraphConstants |
DIRECTED, DOUBLE, NORMAL, PLURAL_DUMMY, REVERSED, SINGULAR_DUMMY |
Constructor Summary | |
HierarchicalBCEngine()
SimpleConstructor If we want to instantiate the class first, and if information for nodes and edges is not available. |
|
HierarchicalBCEngine(FastVector nodes,
FastVector edges,
int nodeWidth,
int nodeHeight)
Constructor - takes in FastVectors of nodes and edges, and the initial width and height of a node |
|
HierarchicalBCEngine(FastVector nodes,
FastVector edges,
int nodeWidth,
int nodeHeight,
boolean edgeConcentration)
Constructor - takes in FastVectors of nodes and edges, the initial width and height of a node, and a boolean value to indicate if the edges should be concentrated. |
Method Summary | |
void |
addLayoutCompleteEventListener(LayoutCompleteEventListener l)
Method to add a LayoutCompleteEventListener |
protected void |
assignLevels(int[] levels,
int depth,
int i,
int j)
This method assigns a vertical level to each node. |
protected float[] |
calcColBC(int lindex,
int[][] levels)
See Sugiyama et al. 1981 (full reference give at top) |
protected float[] |
calcRowBC(int lindex,
int[][] levels)
See Sugiyama et al. 1981 (full reference give at top) |
protected void |
clearTemps_and_EdgesFromNodes()
This method removes the temporary nodes that were added to fill in the gaps, and removes all edges from all nodes in their edges[][] array |
protected void |
copy2DArray(int[][] from,
int[][] to)
Copies one array of type int[][] to another. |
protected void |
copyMatrix(int[][] from,
int[][] to)
Copies one Matrix of type int[][] to another. |
protected int |
crossings(int[][] levels)
Computes the number of edge crossings in the whole graph Takes as an argument levels of nodes. |
void |
fireLayoutCompleteEvent(LayoutCompleteEvent e)
Fires a LayoutCompleteEvent. |
javax.swing.JPanel |
getControlPanel()
This method returns a handle to the extra controls panel, so that the visualizing class can add it to some of it's own gui panel. |
javax.swing.JProgressBar |
getProgressBar()
Returns a handle to the progressBar of this LayoutEngine. |
private int |
indexOfElementInLevel(int element,
int[] level)
Returns the index of an element in a level. |
protected static void |
isort(int[] level,
float[] BC)
This methods sorts the vertices in level[] according to their barycenters in BC[], using insertion sort. |
void |
layoutGraph()
This method does a complete layout of the graph which includes removing cycles, assigning levels to nodes, reducing edge crossings and laying out the vertices horizontally for better visibility. |
protected int |
lBCenter(int lindex,
int eindex,
int[] horPositions)
|
protected int |
lConnectivity(int lindex,
int eindex)
|
protected void |
makeGUIPanel(boolean edgeConc)
This methods makes the gui extra controls panel "m_controlsPanel" |
protected void |
makeProperHierarchy()
|
private int[][] |
minimizeCrossings(boolean reversed,
int[][] nodeLevels)
This method minimizes the number of edge crossings using the BaryCenter heuristics given by Sugiyama et al. 1981 This method processes the graph topdown if reversed is false, otherwise it does bottomup. |
protected void |
naiveLayout()
This method lays out the vertices horizontally, in each level. |
protected void |
phaseID(int lindex,
int[][] levels)
See Sugiyama et al. 1981 (full reference give at top) lindex is the index of the level we want to process. |
void |
phaseIID(int lindex,
int[][] levels)
See Sugiyama et al. 1981 (full reference give at top) |
void |
phaseIIU(int lindex,
int[][] levels)
See Sugiyama et al. 1981 (full reference give at top) |
void |
phaseIU(int lindex,
int[][] levels)
See Sugiyama et al. 1981 (full reference give at top) lindex is the index of the level we want to process. |
protected void |
printMatrices(int[][] levels)
Prints out the interconnection matrix at each level. |
protected void |
priorityLayout1()
This method lays out the vertices horizontally, in each level. |
private void |
priorityLayout2(int[] level,
int[] priorities,
int[] bCenters,
int[] horPositions)
This method is used by priorityLayout1(). |
protected void |
processGraph()
This method makes the "graphMatrix" interconnection matrix for the graph given by m_nodes and m_edges vectors. |
protected void |
removeCycles()
The following two methods remove cycles from the graph. |
private void |
removeCycles2(int nindex,
int[] visited)
This method should not be called directly. |
private void |
removeGaps(int[] nodesLevel)
This method removes gaps from the graph. |
private void |
removeGapsWithEdgeConcentration(int[] nodesLevel)
This method removes gaps from the graph. |
void |
removeLayoutCompleteEventListener(LayoutCompleteEventListener e)
Method to remove a LayoutCompleteEventListener. |
void |
setNodesEdges(FastVector nodes,
FastVector edges)
Sets the nodes and edges for this LayoutEngine. |
void |
setNodeSize(int nodeWidth,
int nodeHeight)
Sets the size of a node. |
private void |
tempMethod(int[] horPositions)
|
protected int |
uBCenter(int lindex,
int eindex,
int[] horPositions)
|
protected int |
uConnectivity(int lindex,
int eindex)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected FastVector m_nodes
protected FastVector m_edges
protected FastVector layoutCompleteListeners
protected int[][] graphMatrix
protected int[][] nodeLevels
protected int m_nodeWidth
protected int m_nodeHeight
protected javax.swing.JRadioButton m_jRbNaiveLayout
protected javax.swing.JRadioButton m_jRbPriorityLayout
protected javax.swing.JRadioButton m_jRbTopdown
protected javax.swing.JRadioButton m_jRbBottomup
protected javax.swing.JCheckBox m_jCbEdgeConcentration
protected javax.swing.JPanel m_controlsPanel
protected javax.swing.JProgressBar m_progress
protected boolean m_completeReLayout
private int origNodesSize
Constructor Detail |
public HierarchicalBCEngine(FastVector nodes, FastVector edges, int nodeWidth, int nodeHeight)
public HierarchicalBCEngine(FastVector nodes, FastVector edges, int nodeWidth, int nodeHeight, boolean edgeConcentration)
nodes
- - FastVector containing all the nodesedges
- - FastVector containing all the edgesnodeWidth
- - A node's allowed widthnodeHeight
- - A node's allowed heightedgeConcentration
- - True: if want to concentrate edges, False: otherwisepublic HierarchicalBCEngine()
Method Detail |
protected void makeGUIPanel(boolean edgeConc)
public javax.swing.JPanel getControlPanel()
getControlPanel
in interface LayoutEngine
public javax.swing.JProgressBar getProgressBar()
getProgressBar
in interface LayoutEngine
public void setNodesEdges(FastVector nodes, FastVector edges)
setNodesEdges
in interface LayoutEngine
nodes
- - FastVector containing all the nodesedges
- - FastVector containing all the edgespublic void setNodeSize(int nodeWidth, int nodeHeight)
setNodeSize
in interface LayoutEngine
nodeWidth
- - A node's allowed widthnodeHeight
- - A node's allowed heightpublic void addLayoutCompleteEventListener(LayoutCompleteEventListener l)
addLayoutCompleteEventListener
in interface LayoutEngine
l
- - Listener to receive the LayoutCompleteEvent by this
class.public void removeLayoutCompleteEventListener(LayoutCompleteEventListener e)
removeLayoutCompleteEventListener
in interface LayoutEngine
e
- - The LayoutCompleteEventListener to remove.public void fireLayoutCompleteEvent(LayoutCompleteEvent e)
fireLayoutCompleteEvent
in interface LayoutEngine
e
- - The LayoutCompleteEvent to firepublic void layoutGraph()
The layout is performed in a separate thread and the progress bar of the class is updated for each of the steps as the process continues.
layoutGraph
in interface LayoutEngine
protected void clearTemps_and_EdgesFromNodes()
protected void processGraph()
protected void makeProperHierarchy()
private void removeGaps(int[] nodesLevel)
private void removeGapsWithEdgeConcentration(int[] nodesLevel)
private int indexOfElementInLevel(int element, int[] level) throws java.lang.Exception
java.lang.Exception
protected int crossings(int[][] levels)
protected void removeCycles()
private void removeCycles2(int nindex, int[] visited)
protected void assignLevels(int[] levels, int depth, int i, int j)
private int[][] minimizeCrossings(boolean reversed, int[][] nodeLevels)
protected void phaseID(int lindex, int[][] levels)
public void phaseIU(int lindex, int[][] levels)
public void phaseIID(int lindex, int[][] levels)
public void phaseIIU(int lindex, int[][] levels)
protected float[] calcRowBC(int lindex, int[][] levels)
protected float[] calcColBC(int lindex, int[][] levels)
protected void printMatrices(int[][] levels)
protected static void isort(int[] level, float[] BC)
protected void copyMatrix(int[][] from, int[][] to)
protected void copy2DArray(int[][] from, int[][] to)
protected void naiveLayout()
protected int uConnectivity(int lindex, int eindex)
protected int lConnectivity(int lindex, int eindex)
protected int uBCenter(int lindex, int eindex, int[] horPositions)
protected int lBCenter(int lindex, int eindex, int[] horPositions)
private void tempMethod(int[] horPositions)
protected void priorityLayout1()
private void priorityLayout2(int[] level, int[] priorities, int[] bCenters, int[] horPositions)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |