com.jgraph.layout.hierarchical

Class JGraphCoordinateAssignment

public class JGraphCoordinateAssignment extends Object implements JGraphHierarchicalLayoutStep

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 classJGraphCoordinateAssignment.AreaSpatialCache
Utility class that stores a collection of vertices and edge points within a certain area.
protected classJGraphCoordinateAssignment.WeightedCellSorter
A utility class used to track cells whilst sorting occurs on the weighted sum of their connected edges.
Field Summary
protected booleancompactLayout
Whether or not to pull together sections of layout into empty space
protected doublecurrentXDelta
The sum of x-displacements for the current iteration
protected booleanfineTuning
Whether or not to perform local optimisations and iterate multiple times through the algorithm
protected doubleinitialX
The minimum x position node placement starts at
protected doubleinterRankCellSpacing
The minimum distance between cells on adjacent ranks
protected doubleintraCellSpacing
The minimum buffer between cells on the same rank
protected doublelimitX
The maximum x value this positioning lays up to
protected intmaxIterations
The number of heuristic iterations to run
protected JGraphAbstractHierarchyCell[][]nextLayerConnectedCache
A store of connections to the layer above for speed
protected intorientation
The position of the root ( start ) node(s) relative to the rest of the laid out graph
protected doubleparallelEdgeSpacing
The distance between each parallel edge on each ranks for long edges
protected JGraphAbstractHierarchyCell[][]previousLayerConnectedCache
A store of connections to the layer below for speed
protected double[]rankWidths
The width of all the ranks
protected double[]rankY
protected intwidestRank
The rank that has the widest x position
protected doublewidestRankValue
The X-coordinate of the edge of the widest rank
Constructor Summary
JGraphCoordinateAssignment(double intraCellSpacing, double interRankCellSpacing, int orientation, boolean compactLayout, double initialX, double parallelEdgeSpacing)
Creates a JGraphCoordinateAssignment
Method Summary
protected voidcalculateWidestRank(JGraphFacade facade, JGraphHierarchyModel model)
Calculates the width rank in the hierarchy.
doublegetInterRankCellSpacing()
doublegetIntraCellSpacing()
doublegetLimitX()
intgetOrientation()
booleanisCompactLayout()
booleanisFineTuning()
protected voidrankCoordinates(int rankValue, JGraphFacade facade, JGraphHierarchyModel model)
Sets up the layout in an initial positioning.
protected voidrankMedianPosition(int rankValue, JGraphHierarchyModel model, int nextRankValue)
Performs median minimisation over one rank.
JGraphHierarchyModelrun(JGraphFacade facade, JGraphHierarchyModel model)
A basic horizontal coordinate assignment algorithm
voidsetCompactLayout(boolean compactLayout)
voidsetFineTuning(boolean fineTuning)
voidsetInterRankCellSpacing(double interRankCellSpacing)
voidsetIntraCellSpacing(double intraCellSpacing)
voidsetLimitX(double limitX)
voidsetLoggerLevel(Level level)
Sets the logging level of this class
voidsetOrientation(int orientation)

Field Detail

compactLayout

protected boolean compactLayout
Whether or not to pull together sections of layout into empty space

currentXDelta

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

fineTuning

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

initialX

protected double initialX
The minimum x position node placement starts at

interRankCellSpacing

protected double interRankCellSpacing
The minimum distance between cells on adjacent ranks

intraCellSpacing

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

limitX

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

maxIterations

protected int maxIterations
The number of heuristic iterations to run

nextLayerConnectedCache

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

orientation

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

parallelEdgeSpacing

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

previousLayerConnectedCache

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

rankWidths

protected double[] rankWidths
The width of all the ranks

rankY

protected double[] rankY

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

Constructor Detail

JGraphCoordinateAssignment

public JGraphCoordinateAssignment(double intraCellSpacing, double interRankCellSpacing, int orientation, boolean compactLayout, double initialX, double parallelEdgeSpacing)
Creates a JGraphCoordinateAssignment

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

calculateWidestRank

protected void calculateWidestRank(JGraphFacade facade, JGraphHierarchyModel model)
Calculates the width rank in the hierarchy. Also set the y value of each rank whilst performing the calculation

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

getInterRankCellSpacing

public double getInterRankCellSpacing()

Returns: Returns the interRankCellSpacing.

getIntraCellSpacing

public double getIntraCellSpacing()

Returns: Returns the intraCellSpacing.

getLimitX

public double getLimitX()

Returns: Returns the limitX.

getOrientation

public int getOrientation()

Returns: Returns the orientation.

isCompactLayout

public boolean isCompactLayout()

Returns: Returns the compactLayout.

isFineTuning

public boolean isFineTuning()

Returns: Returns the fineTuning.

rankCoordinates

protected void rankCoordinates(int rankValue, JGraphFacade facade, JGraphHierarchyModel 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 facade the facade describing the input graph model an internal model of the hierarchical layout

rankMedianPosition

protected void rankMedianPosition(int rankValue, JGraphHierarchyModel 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

run

public JGraphHierarchyModel run(JGraphFacade facade, JGraphHierarchyModel model)
A basic horizontal coordinate assignment algorithm

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

Returns: the updated hierarchy model

setCompactLayout

public void setCompactLayout(boolean compactLayout)

Parameters: compactLayout The compactLayout to set.

setFineTuning

public void setFineTuning(boolean fineTuning)

Parameters: fineTuning The fineTuning to set.

setInterRankCellSpacing

public void setInterRankCellSpacing(double interRankCellSpacing)

Parameters: interRankCellSpacing The interRankCellSpacing to set.

setIntraCellSpacing

public void setIntraCellSpacing(double intraCellSpacing)

Parameters: intraCellSpacing The intraCellSpacing to set.

setLimitX

public void setLimitX(double limitX)

Parameters: limitX The limitX to set.

setLoggerLevel

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

Parameters: level the logging level to set

setOrientation

public void setOrientation(int orientation)

Parameters: orientation The orientation to set.

Copyright (C) 2001-2009 JGraph Ltd. All rights reserved.