Class mxCoordinateAssignment
- java.lang.Object
-
- com.mxgraph.layout.hierarchical.stage.mxCoordinateAssignment
-
- All Implemented Interfaces:
mxHierarchicalLayoutStage
public class mxCoordinateAssignment extends java.lang.Object implements mxHierarchicalLayoutStage
Sets the horizontal locations of node and edge dummy nodes on each layer. Uses median down and up weighings as well as heuristics to straighten edges as far as possible.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classmxCoordinateAssignment.AreaSpatialCacheUtility class that stores a collection of vertices and edge points within a certain area.protected classmxCoordinateAssignment.WeightedCellSorterA utility class used to track cells whilst sorting occurs on the weighted sum of their connected edges.
-
Field Summary
Fields Modifier and Type Field Description protected intchannelBufferThe size of the vertical buffer in the center of inter-rank channels where edge control points should not be placedprotected doublecurrentXDeltaThe sum of x-displacements for the current iterationprotected booleandisableEdgeStyleSpecifies if the STYLE_NOEDGESTYLE flag should be set on edges that are modified by the result.protected com.mxgraph.layout.hierarchical.stage.mxCoordinateAssignment.HierarchicalEdgeStyleedgeStyleThe style to apply between cell layers to edge segmentsprotected booleanfineTuningWhether or not to perform local optimisations and iterate multiple times through the algorithmprotected intgroupPaddingPadding added to resized parentsprotected doubleinitialXThe minimum x position node placement starts atprotected doubleinterRankCellSpacingThe minimum distance between cells on adjacent ranksprotected doubleintraCellSpacingThe minimum buffer between cells on the same rankprotected java.util.Map<mxGraphHierarchyEdge,double[]>jettyPositionsMap of internal edges and (x,y) pair of positions of the start and end jetty for that edge where it connects to the source and target vertices.protected mxHierarchicalLayoutlayoutReference to the enclosing layout algorithmprotected doublelimitXThe maximum x value this positioning lays up toprotected intmaxIterationsThe number of heuristic iterations to runprotected intminEdgeJettyThe minimum distance for an edge jetty from a vertexprotected mxGraphAbstractHierarchyCell[][]nextLayerConnectedCacheA store of connections to the layer above for speedprotected intorientationThe position of the root ( start ) node(s) relative to the rest of the laid out graphprotected doubleparallelEdgeSpacingThe distance between each parallel edge on each ranks for long edgesprotected intprefHozEdgeSepThe preferred horizontal distance between edges exiting a vertexprotected intprefVertEdgeOffThe preferred vertical offset between edges exiting a vertexprotected mxGraphAbstractHierarchyCell[][]previousLayerConnectedCacheA store of connections to the layer below for speedprotected double[]rankBottomYInternal cache of bottom-most value of Y for each rankprotected double[]rankTopYInternal cache of top-most values of Y for each rankprotected double[]rankWidthsThe width of all the ranksprotected double[]rankYThe Y-coordinate of all the ranksprotected doublevertexConnectionBufferThe buffer on either side of a vertex where edges must not connect.protected intwidestRankThe rank that has the widest x positionprotected doublewidestRankValueThe X-coordinate of the edge of the widest rank
-
Constructor Summary
Constructors Constructor Description mxCoordinateAssignment(mxHierarchicalLayout layout, double intraCellSpacing, double interRankCellSpacing, int orientation, double initialX, double parallelEdgeSpacing)Creates a coordinate assignment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidadjustParents(java.util.Set<java.lang.Object> parentsChanged)Adjust parent cells whose child geometries have changed.protected voidcalculateWidestRank(mxGraph graph, mxGraphHierarchyModel model)Calculates the width rank in the hierarchy.voidexecute(java.lang.Object parent)A basic horizontal coordinate assignment algorithmdoublegetInterRankCellSpacing()doublegetIntraCellSpacing()doublegetLimitX()intgetOrientation()booleanisFineTuning()protected voidlocalEdgeProcessing(mxGraphHierarchyModel model)Separates the x position of edges as they connect to verticesprotected voidminPath(mxGraphHierarchyModel model)Straightens out chains of virtual nodes where possiblevoidprintStatus()Utility method to display the x co-ordsprotected voidprocessReversedEdge(mxGraphHierarchyEdge edge, java.lang.Object realEdge)Hook to add additional processingprotected voidrankCoordinates(int rankValue, mxGraph graph, mxGraphHierarchyModel model)Sets up the layout in an initial positioning.protected voidrankMedianPosition(int rankValue, mxGraphHierarchyModel model, int nextRankValue)Performs median minimisation over one rank.protected booleanrepositionValid(mxGraphHierarchyModel model, mxGraphAbstractHierarchyCell cell, int rank, double position)Determines whether or not a node may be moved to the specified x position on the specified rankprotected voidsetCellLocations(mxGraph graph, mxGraphHierarchyModel model)Sets the cell locations in the facade to those stored after this layout processing step has completed.protected voidsetEdgePosition(mxGraphAbstractHierarchyCell cell)Fixes the control pointsvoidsetFineTuning(boolean fineTuning)voidsetInterRankCellSpacing(double interRankCellSpacing)voidsetIntraCellSpacing(double intraCellSpacing)voidsetLimitX(double limitX)voidsetOrientation(int orientation)protected voidsetVertexLocation(mxGraphAbstractHierarchyCell cell)Fixes the position of the specified vertex
-
-
-
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
-
vertexConnectionBuffer
protected double vertexConnectionBuffer
The buffer on either side of a vertex where edges must not connect.
-
maxIterations
protected int maxIterations
The number of heuristic iterations to run
-
prefHozEdgeSep
protected int prefHozEdgeSep
The preferred horizontal distance between edges exiting a vertex
-
prefVertEdgeOff
protected int prefVertEdgeOff
The preferred vertical offset between edges exiting a vertex
-
minEdgeJetty
protected int minEdgeJetty
The minimum distance for an edge jetty from a vertex
-
channelBuffer
protected int channelBuffer
The size of the vertical buffer in the center of inter-rank channels where edge control points should not be placed
-
jettyPositions
protected java.util.Map<mxGraphHierarchyEdge,double[]> jettyPositions
Map of internal edges and (x,y) pair of positions of the start and end jetty for that edge where it connects to the source and target vertices. Note this should technically be a WeakHashMap, but since JS does not have an equivalent, housekeeping must be performed before using. i.e. check all edges are still in the model and clear the values. Note that the y co-ord is the offset of the jetty, not the absolute point
-
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
-
rankTopY
protected double[] rankTopY
Internal cache of top-most values of Y for each rank
-
rankBottomY
protected double[] rankBottomY
Internal cache of bottom-most value of Y for each rank
-
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.
-
edgeStyle
protected com.mxgraph.layout.hierarchical.stage.mxCoordinateAssignment.HierarchicalEdgeStyle edgeStyle
The style to apply between cell layers to edge segments
-
nextLayerConnectedCache
protected mxGraphAbstractHierarchyCell[][] nextLayerConnectedCache
A store of connections to the layer above for speed
-
groupPadding
protected int groupPadding
Padding added to resized parents
-
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 rankinterRankCellSpacing- the minimum distance between cells on adjacent ranksorientation- the position of the root node(s) relative to the graphinitialX- the leftmost coordinate node placement starts at
-
-
Method Detail
-
printStatus
public void printStatus()
Utility method to display the x co-ords
-
execute
public void execute(java.lang.Object parent)
A basic horizontal coordinate assignment algorithm- Specified by:
executein interfacemxHierarchicalLayoutStage
-
rankMedianPosition
protected void rankMedianPosition(int rankValue, mxGraphHierarchyModel model, int nextRankValue)Performs median minimisation over one rank.- Parameters:
rankValue- the layer number of this rankmodel- an internal model of the hierarchical layoutnextRankValue- 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 processedgraph- the facade describing the input graphmodel- 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 graphmodel- an internal model of the hierarchical layout
-
minPath
protected void minPath(mxGraphHierarchyModel model)
Straightens out chains of virtual nodes where possible- Parameters:
model- an internal model of the hierarchical layout
-
repositionValid
protected boolean repositionValid(mxGraphHierarchyModel model, mxGraphAbstractHierarchyCell cell, int rank, double position)
Determines whether or not a node may be moved to the specified x position on the specified rank- Parameters:
model- the layout modelcell- the cell being analysedrank- the layer of the cellposition- the x position being sought- Returns:
- whether or not the virtual node can be moved to this position
-
setCellLocations
protected void setCellLocations(mxGraph graph, mxGraphHierarchyModel model)
Sets the cell locations in the facade to those stored after this layout processing step has completed.- Parameters:
graph- the facade describing the input graphmodel- an internal model of the hierarchical layout
-
adjustParents
protected void adjustParents(java.util.Set<java.lang.Object> parentsChanged)
Adjust parent cells whose child geometries have changed. The default implementation adjusts the group to just fit around the children with a padding.
-
localEdgeProcessing
protected void localEdgeProcessing(mxGraphHierarchyModel model)
Separates the x position of edges as they connect to vertices- Parameters:
model- an internal model of the hierarchical layout
-
setEdgePosition
protected void setEdgePosition(mxGraphAbstractHierarchyCell cell)
Fixes the control points- Parameters:
cell-
-
setVertexLocation
protected void setVertexLocation(mxGraphAbstractHierarchyCell cell)
Fixes the position of the specified vertex- Parameters:
cell- the vertex to position
-
processReversedEdge
protected void processReversedEdge(mxGraphHierarchyEdge edge, java.lang.Object realEdge)
Hook to add additional processing- Parameters:
edge- The hierarchical model edgerealEdge- The real edge in the graph
-
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.
-
-