JGraph X 1.3.0.0


com.mxgraph.layout.hierarchical.stage
Class mxCoordinateAssignment

java.lang.Object
  extended by com.mxgraph.layout.hierarchical.stage.mxCoordinateAssignment
All Implemented Interfaces:
mxHierarchicalLayoutStage

public class mxCoordinateAssignment
extends Object
implements mxHierarchicalLayoutStage

Sets the horizontal locations of node and edge dummy nodes on each layer. Uses median down and up weighings as well heuristic to straighten edges as far as possible.


Nested Class Summary
protected  class mxCoordinateAssignment.AreaSpatialCache
          Utility class that stores a collection of vertices and edge points within a certain area.
protected  class mxCoordinateAssignment.WeightedCellSorter
          A utility class used to track cells whilst sorting occurs on the weighted sum of their connected edges.
 
Field Summary
protected  double currentXDelta
          The sum of x-displacements for the current iteration
protected  boolean disableEdgeStyle
          Specifies if the STYLE_NOEDGESTYLE flag should be set on edges that are modified by the result.
protected  boolean fineTuning
          Whether or not to perform local optimisations and iterate multiple times through the algorithm
protected  double initialX
          The minimum x position node placement starts at
protected  double interRankCellSpacing
          The minimum distance between cells on adjacent ranks
protected  double intraCellSpacing
          The minimum buffer between cells on the same rank
protected  mxHierarchicalLayout layout
          Reference to the enclosing layout algorithm
protected  double limitX
          The maximum x value this positioning lays up to
protected  int maxIterations
          The number of heuristic iterations to run
protected  mxGraphAbstractHierarchyCell[][] nextLayerConnectedCache
          A store of connections to the layer above for speed
protected  int orientation
          The position of the root ( start ) node(s) relative to the rest of the laid out graph
protected  double parallelEdgeSpacing
          The distance between each parallel edge on each ranks for long edges
protected  mxGraphAbstractHierarchyCell[][] previousLayerConnectedCache
          A store of connections to the layer below for speed
protected  double[] rankWidths
          The width of all the ranks
protected  double[] rankY
          The Y-coordinate of all the ranks
protected  int widestRank
          The rank that has the widest x position
protected  double widestRankValue
          The X-coordinate of the edge of the widest rank
 
Constructor Summary
mxCoordinateAssignment(mxHierarchicalLayout layout, double intraCellSpacing, double interRankCellSpacing, int orientation, double initialX, double parallelEdgeSpacing)
          Creates a coordinate assignment.
 
Method Summary
protected  void calculateWidestRank(mxGraph graph, mxGraphHierarchyModel model)
          Calculates the width rank in the hierarchy.
 void execute(Object parent)
          A basic horizontal coordinate assignment algorithm
 double getInterRankCellSpacing()
           
 double getIntraCellSpacing()
           
 double getLimitX()
           
 int getOrientation()
           
 boolean isFineTuning()
           
protected  void rankCoordinates(int rankValue, mxGraph graph, mxGraphHierarchyModel model)
          Sets up the layout in an initial positioning.
protected  void rankMedianPosition(int rankValue, mxGraphHierarchyModel model, int nextRankValue)
          Performs median minimisation over one rank.
 void setFineTuning(boolean fineTuning)
           
 void setInterRankCellSpacing(double interRankCellSpacing)
           
 void setIntraCellSpacing(double intraCellSpacing)
           
 void setLimitX(double limitX)
           
 void setLoggerLevel(Level level)
          Sets the logging level of this class
 void setOrientation(int orientation)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

layout

protected mxHierarchicalLayout layout
Reference to the enclosing layout algorithm


intraCellSpacing

protected double intraCellSpacing
The minimum buffer between cells on the same rank


interRankCellSpacing

protected double interRankCellSpacing
The minimum distance between cells on adjacent ranks


parallelEdgeSpacing

protected double parallelEdgeSpacing
The distance between each parallel edge on each ranks for long edges


maxIterations

protected int maxIterations
The number of heuristic iterations to run


orientation

protected int orientation
The position of the root ( start ) node(s) relative to the rest of the laid out graph


initialX

protected double initialX
The minimum x position node placement starts at


limitX

protected double limitX
The maximum x value this positioning lays up to


currentXDelta

protected double currentXDelta
The sum of x-displacements for the current iteration


widestRank

protected int widestRank
The rank that has the widest x position


widestRankValue

protected double widestRankValue
The X-coordinate of the edge of the widest rank


rankWidths

protected double[] rankWidths
The width of all the ranks


rankY

protected double[] rankY
The Y-coordinate of all the ranks


fineTuning

protected boolean fineTuning
Whether or not to perform local optimisations and iterate multiple times through the algorithm


disableEdgeStyle

protected boolean disableEdgeStyle
Specifies if the STYLE_NOEDGESTYLE flag should be set on edges that are modified by the result. Default is true.


nextLayerConnectedCache

protected mxGraphAbstractHierarchyCell[][] nextLayerConnectedCache
A store of connections to the layer above for speed


previousLayerConnectedCache

protected mxGraphAbstractHierarchyCell[][] previousLayerConnectedCache
A store of connections to the layer below for speed

Constructor Detail

mxCoordinateAssignment

public mxCoordinateAssignment(mxHierarchicalLayout layout,
                              double intraCellSpacing,
                              double interRankCellSpacing,
                              int orientation,
                              double initialX,
                              double parallelEdgeSpacing)
Creates a coordinate assignment.

Parameters:
intraCellSpacing - the minimum buffer between cells on the same rank
interRankCellSpacing - the minimum distance between cells on adjacent ranks
orientation - the position of the root node(s) relative to the graph
initialX - the leftmost coordinate node placement starts at
Method Detail

execute

public void execute(Object parent)
A basic horizontal coordinate assignment algorithm

Specified by:
execute in interface mxHierarchicalLayoutStage

rankMedianPosition

protected void rankMedianPosition(int rankValue,
                                  mxGraphHierarchyModel model,
                                  int nextRankValue)
Performs median minimisation over one rank.

Parameters:
rankValue - the layer number of this rank
model - an internal model of the hierarchical layout
nextRankValue - the layer number whose connected cels are to be laid out relative to

rankCoordinates

protected void rankCoordinates(int rankValue,
                               mxGraph graph,
                               mxGraphHierarchyModel model)
Sets up the layout in an initial positioning. All the first cells in each rank are moved to the left and the rest of the rank inserted as close together as their size and buffering permits. This method works on just the specified rank.

Parameters:
rankValue - the current rank being processed
graph - the facade describing the input graph
model - an internal model of the hierarchical layout

calculateWidestRank

protected void calculateWidestRank(mxGraph graph,
                                   mxGraphHierarchyModel model)
Calculates the width rank in the hierarchy. Also set the y value of each rank whilst performing the calculation

Parameters:
graph - the facade describing the input graph
model - an internal model of the hierarchical layout

getInterRankCellSpacing

public double getInterRankCellSpacing()
Returns:
Returns the interRankCellSpacing.

setInterRankCellSpacing

public void setInterRankCellSpacing(double interRankCellSpacing)
Parameters:
interRankCellSpacing - The interRankCellSpacing to set.

getIntraCellSpacing

public double getIntraCellSpacing()
Returns:
Returns the intraCellSpacing.

setIntraCellSpacing

public void setIntraCellSpacing(double intraCellSpacing)
Parameters:
intraCellSpacing - The intraCellSpacing to set.

getOrientation

public int getOrientation()
Returns:
Returns the orientation.

setOrientation

public void setOrientation(int orientation)
Parameters:
orientation - The orientation to set.

getLimitX

public double getLimitX()
Returns:
Returns the limitX.

setLimitX

public void setLimitX(double limitX)
Parameters:
limitX - The limitX to set.

isFineTuning

public boolean isFineTuning()
Returns:
Returns the fineTuning.

setFineTuning

public void setFineTuning(boolean fineTuning)
Parameters:
fineTuning - The fineTuning to set.

setLoggerLevel

public void setLoggerLevel(Level level)
Sets the logging level of this class

Parameters:
level - the logging level to set

JGraph X 1.3.0.0


Copyright (c) 2008 Gaudenz Alder. All rights reserved.