aminePlatform.util.graph
Class RelaxOntology

java.lang.Object
  extended byaminePlatform.util.graph.RelaxOntology

public class RelaxOntology
extends java.lang.Object

Arranges the nodes with the Sugiyama Layout Algorithm.


Nested Class Summary
(package private)  class RelaxOntology.CellWrapper
          cell wrapper contains all values for one node
 
Field Summary
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.List levels
           
(package private)  int MaxChild
           
(package private)  java.util.List movements
          A list 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.
(package private)  java.util.ArrayList selectedCellViews
           
 
Constructor Summary
RelaxOntology()
           
 
Method Summary
protected  java.util.List fillLevels(java.util.ArrayList selectedCellViews, java.util.List rootVertexViews)
          Method fills the levels and stores them in the member levels.
protected  void fillLevels(java.util.List levels, int level, VisualNode vertexView)
          Fills the Vector for the specified level with a wrapper for the VGraph.
 java.awt.Point getSpacing()
          Returns the spacing.
 void initRelaxOntology()
           
protected  boolean isSelected(VisualNode cell)
          Detects whether the specified cell has been marked selected.
protected  void markSelected(java.util.ArrayList selectedCellViews, boolean addMark)
          Adds an attribute to the specified selected cell views.
protected  boolean move(boolean toRight, java.util.List currentLevel, int currentIndexInTheLevel, int currentPriority)
           
protected  void moveToBarycenter(java.util.ArrayList allSelectedViews, java.util.List levels)
           
protected  int moveToBarycenter(java.util.List levels, int levelIndex)
           
protected  java.util.ArrayList NeighbourInLevel(java.util.List level, RelaxOntology.CellWrapper wrapper)
           
protected  void relaxGraph(java.util.List levels, java.awt.Point min, java.awt.Point spacing)
          This Method relax the graph.
 void run(VisualGraph graph)
          Implementation.
protected  java.util.List searchRoots(java.util.ArrayList selectedCellViews)
          Searches all Roots for the current Graph The Roots are stored in the Vector named roots
protected  void searchRoots(VisualNode vertexViewToInspect, java.util.List roots)
          Searches Roots for the current Cell.
 void setSpacing(java.awt.Point spacing)
          Sets grid spacing.
protected  int solveEdgeCrosses(boolean down, java.util.List levels, int levelIndex)
           
protected  void solveEdgeCrosses(java.util.List 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

gridAreaSize

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


movements

java.util.List movements
A list with Integer Objects. The list 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


selectedCellViews

java.util.ArrayList selectedCellViews

levels

java.util.List levels

MaxChild

int MaxChild
Constructor Detail

RelaxOntology

public RelaxOntology()
Method Detail

initRelaxOntology

public void initRelaxOntology()

run

public void run(VisualGraph graph)
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.

Parameters:
graph - VisualGraph instance

markSelected

protected void markSelected(java.util.ArrayList selectedCellViews,
                            boolean addMark)
Adds an attribute to the specified selected cell views.

Parameters:
selectedCellViews - the specified cell views
addMark - true to add the mark, false to remove the mark

isSelected

protected boolean isSelected(VisualNode cell)
Detects whether the specified cell has been marked selected.

Parameters:
cell - the cell to inspect
Returns:
true if the view has been marked selected and false otherwise.

searchRoots

protected java.util.List searchRoots(java.util.ArrayList selectedCellViews)
Searches all Roots for the current Graph The Roots are stored in the Vector named roots

Returns:
returns a Vector with the roots

searchRoots

protected void searchRoots(VisualNode vertexViewToInspect,
                           java.util.List 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.List fillLevels(java.util.ArrayList selectedCellViews,
                                    java.util.List 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(java.util.List levels,
                          int level,
                          VisualNode vertexView)
Fills the Vector for the specified level with a wrapper for the VGraph.


updateProgress4Movements

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


solveEdgeCrosses

protected void solveEdgeCrosses(java.util.List levels)

solveEdgeCrosses

protected int solveEdgeCrosses(boolean down,
                               java.util.List levels,
                               int levelIndex)
Returns:
movements

moveToBarycenter

protected void moveToBarycenter(java.util.ArrayList allSelectedViews,
                                java.util.List levels)

moveToBarycenter

protected int moveToBarycenter(java.util.List levels,
                               int levelIndex)

move

protected boolean move(boolean toRight,
                       java.util.List currentLevel,
                       int currentIndexInTheLevel,
                       int currentPriority)
Parameters:
toRight - true = try to move the currentWrapper to right; false = try to move the currentWrapper to left;
currentLevel - List which contains the CellWrappers for the current level
currentIndexInTheLevel -
currentPriority -
Returns:
The free GridPosition or -1 is position is not free.

NeighbourInLevel

protected java.util.ArrayList NeighbourInLevel(java.util.List level,
                                               RelaxOntology.CellWrapper wrapper)

relaxGraph

protected void relaxGraph(java.util.List levels,
                          java.awt.Point min,
                          java.awt.Point spacing)
This Method relax 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.


getSpacing

public java.awt.Point getSpacing()
Returns the spacing.

See Also:
setSpacing(java.awt.Point)

setSpacing

public void setSpacing(java.awt.Point spacing)
Sets grid spacing. The Algorithm distributes the nodes on a grid. For this grid you can configure the vertical and horizontal spacing.