Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.jgraph.layout
Class SugiyamaLayoutAlgorithm  view SugiyamaLayoutAlgorithm download SugiyamaLayoutAlgorithm.java

java.lang.Object
  extended bycom.jgraph.layout.SugiyamaLayoutAlgorithm
All Implemented Interfaces:
LayoutAlgorithm

public class SugiyamaLayoutAlgorithm
extends java.lang.Object
implements LayoutAlgorithm

Arranges the nodes with the Sugiyama Layout Algorithm.
Link to the algorithm

Version:
1.0 init

Nested Class Summary
(package private)  class SugiyamaLayoutAlgorithm.CellWrapper
          cell wrapper contains all values for one node
 
Field Summary
protected  ProgressDialog dlgProgress
          Progressbar is shown while the algorithm is running
protected  int gridAreaSize
          represents the size of the grid in horizontal grid elements
(package private)  int iteration
          Represents the current loop number It was needed for the progress dialog
(package private)  java.util.Vector movements
          A vector with Integer Objects.
(package private)  int movementsCurrentLoop
          Represents the movements in the current loop.
(package private)  int movementsMax
          Represents the maximum of movements in the current loop.
static java.lang.String SUGIYAMA_CELL_WRAPPER
          Const to add the Cell Wrapper to the Nodes
static java.lang.String SUGIYAMA_VISITED
          Const to add Attributes at the Nodes
protected  boolean verbose
          Field for debug output
 
Constructor Summary
SugiyamaLayoutAlgorithm()
           
 
Method Summary
protected  void displayEdgeCrossesValues(java.util.Vector levels)
          Debugdisplay for the edge crosses indicators on the System out
protected  void displayGridPositions(java.util.Vector levels)
          Debugdisplay for the grid positions on the System out
protected  void displayPriorities(java.util.Vector levels)
          Debugdisplay for the priorities on the System out
protected  void drawGraph(JGraph jgraph, java.util.Vector levels, java.awt.Point min, java.awt.Point spacing)
          This Method draws the graph.
protected  java.util.Vector fillLevels(JGraph jgraph, CellView[] selectedCellViews, java.util.Vector rootVertexViews)
          Method fills the levels and stores them in the member levels.
protected  void fillLevels(JGraph jgraph, java.util.Vector levels, int level, VertexView vertexView)
          Fills the Vector for the specified level with a wrapper for the MyGraphCell.
protected  java.awt.Point findMinimumAndSpacing(CellView[] graphCellViews, java.awt.Point spacing)
          calculates the minimum for the paint area.
protected  boolean move(boolean toRight, java.util.Vector currentLevel, int currentIndexInTheLevel, int currentPriority)
           
protected  void moveToBarycenter(JGraph jgraph, CellView[] allSelectedViews, java.util.Vector levels)
           
protected  int moveToBarycenter(JGraph jgraph, java.util.Vector levels, int levelIndex)
           
 void perform(JGraph jgraph, boolean applyToAll, java.util.Properties configuration)
          Implementation.
protected  java.util.Vector searchRoots(JGraph jgraph, CellView[] selectedCellViews)
          Searches all Roots for the current Graph First the method marks any Node as not visited.
protected  void searchRoots(JGraph jgraph, VertexView vertexViewToInspect, java.util.Vector roots)
          Searches Roots for the current Cell.
protected  int solveEdgeCrosses(JGraph jgraph, boolean down, java.util.Vector levels, int levelIndex)
           
protected  void solveEdgeCrosses(JGraph jgraph, java.util.Vector levels)
           
protected  void updateProgress4Movements()
          Updates the progress based on the movements count
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

verbose

protected final boolean verbose
Field for debug output

See Also:
Constant Field Values

SUGIYAMA_VISITED

public static final java.lang.String SUGIYAMA_VISITED
Const to add Attributes at the Nodes

See Also:
Constant Field Values

SUGIYAMA_CELL_WRAPPER

public static final java.lang.String SUGIYAMA_CELL_WRAPPER
Const to add the Cell Wrapper to the Nodes

See Also:
Constant Field Values

gridAreaSize

protected int gridAreaSize
represents the size of the grid in horizontal grid elements


dlgProgress

protected ProgressDialog dlgProgress
Progressbar is shown while the algorithm is running


movements

java.util.Vector movements
A vector with Integer Objects. The Vector contains the history of movements per loop It was needed for the progress dialog


movementsCurrentLoop

int movementsCurrentLoop
Represents the movements in the current loop. It was needed for the progress dialog


movementsMax

int movementsMax
Represents the maximum of movements in the current loop. It was needed for the progress dialog


iteration

int iteration
Represents the current loop number It was needed for the progress dialog

Constructor Detail

SugiyamaLayoutAlgorithm

public SugiyamaLayoutAlgorithm()
Method Detail

perform

public void perform(JGraph jgraph,
                    boolean applyToAll,
                    java.util.Properties configuration)
Implementation. First of all the Algorithm searches the roots from the Graph. Starting from this roots the Algorithm creates levels and stores them in the member levels. The Member levels contains Vector Objects and the Vector per level contains Cell Wrapper Objects. After that the Algorithm tries to solve the edge crosses from level to level and goes top down and bottom up. After minimization of the edge crosses the algorithm moves each node to its bary center. Last but not Least the method draws the Graph.

Specified by:
perform in interface LayoutAlgorithm

displayEdgeCrossesValues

protected void displayEdgeCrossesValues(java.util.Vector levels)
Debugdisplay for the edge crosses indicators on the System out


displayGridPositions

protected void displayGridPositions(java.util.Vector levels)
Debugdisplay for the grid positions on the System out


displayPriorities

protected void displayPriorities(java.util.Vector levels)
Debugdisplay for the priorities on the System out


searchRoots

protected java.util.Vector searchRoots(JGraph jgraph,
                                       CellView[] selectedCellViews)
Searches all Roots for the current Graph First the method marks any Node as not visited. Than calls searchRoots(MyGraphCell) for each not visited Cell. The Roots are stored in the Vector named roots


searchRoots

protected void searchRoots(JGraph jgraph,
                           VertexView vertexViewToInspect,
                           java.util.Vector roots)
Searches Roots for the current Cell. Therefore he looks at all Ports from the Cell. At the Ports he looks for Edges. At the Edges he looks for the Target. If the Ports of the current Cell contains the target ReViewNodePort he follows the edge to the source and looks at the Cell for this source.


fillLevels

protected java.util.Vector fillLevels(JGraph jgraph,
                                      CellView[] selectedCellViews,
                                      java.util.Vector rootVertexViews)
Method fills the levels and stores them in the member levels. Each level was represended by a Vector with Cell Wrapper objects. These Vectors are the elements in the levels Vector.


fillLevels

protected void fillLevels(JGraph jgraph,
                          java.util.Vector levels,
                          int level,
                          VertexView vertexView)
Fills the Vector for the specified level with a wrapper for the MyGraphCell. After that the method called for each neighbor graph cell.


findMinimumAndSpacing

protected java.awt.Point findMinimumAndSpacing(CellView[] graphCellViews,
                                               java.awt.Point spacing)
calculates the minimum for the paint area.


updateProgress4Movements

protected void updateProgress4Movements()
Updates the progress based on the movements count


solveEdgeCrosses

protected void solveEdgeCrosses(JGraph jgraph,
                                java.util.Vector levels)

solveEdgeCrosses

protected int solveEdgeCrosses(JGraph jgraph,
                               boolean down,
                               java.util.Vector levels,
                               int levelIndex)

moveToBarycenter

protected void moveToBarycenter(JGraph jgraph,
                                CellView[] allSelectedViews,
                                java.util.Vector levels)

moveToBarycenter

protected int moveToBarycenter(JGraph jgraph,
                               java.util.Vector levels,
                               int levelIndex)

move

protected boolean move(boolean toRight,
                       java.util.Vector currentLevel,
                       int currentIndexInTheLevel,
                       int currentPriority)

drawGraph

protected void drawGraph(JGraph jgraph,
                         java.util.Vector levels,
                         java.awt.Point min,
                         java.awt.Point spacing)
This Method draws the graph. For the horizontal position we are using the grid position from each graphcell. For the vertical position we are using the level position.