Class mxGraphHierarchyModel
- java.lang.Object
-
- com.mxgraph.layout.hierarchical.model.mxGraphHierarchyModel
-
public class mxGraphHierarchyModel extends java.lang.Object
Internal model of a hierarchical graph. This model stores nodes and edges equivalent to the real graph nodes and edges, but also stores the rank of the cells, the order within the ranks and the new candidate locations of cells. The internal model also reverses edge direction were appropriate , ignores self-loop and groups parallels together under one edge object.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
mxGraphHierarchyModel.CellVisitor
Defines the interface that visitors use to perform operations upon the graph information during depth first search (dfs) or other tree-traversal strategies implemented by subclassers.
-
Field Summary
Fields Modifier and Type Field Description protected int
dfsCount
Count of the number of times the ancestor dfs has been usedprotected java.util.Map<java.lang.Object,mxGraphHierarchyEdge>
edgeMapper
Map from graph edges to internal model edgesint
maxRank
Stores the largest rank number allocatedjava.lang.Object
parent
The parent cell whose children are being laid outjava.util.Map<java.lang.Integer,mxGraphHierarchyRank>
ranks
Mapping from rank number to actual rankjava.util.List<java.lang.Object>
roots
Store of roots of this hierarchy model, these are real graph cells, not internal cellsprotected java.util.Map<java.lang.Object,mxGraphHierarchyNode>
vertexMapper
Map from graph vertices to internal model nodes
-
Constructor Summary
Constructors Constructor Description mxGraphHierarchyModel(mxHierarchicalLayout layout, java.lang.Object[] vertices, java.util.List<java.lang.Object> roots, java.lang.Object parent)
Creates an internal ordered graph model using the vertices passed in.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
createInternalCells(mxHierarchicalLayout layout, java.lang.Object[] vertices, mxGraphHierarchyNode[] internalVertices)
Creates all edges in the internal modelvoid
dfs(mxGraphHierarchyNode parent, mxGraphHierarchyNode root, mxGraphHierarchyEdge connectingEdge, mxGraphHierarchyModel.CellVisitor visitor, java.util.Set<mxGraphHierarchyNode> seen, int layer)
Performs a depth first search on the internal hierarchy modelvoid
dfs(mxGraphHierarchyNode parent, mxGraphHierarchyNode root, mxGraphHierarchyEdge connectingEdge, mxGraphHierarchyModel.CellVisitor visitor, java.util.Set<mxGraphHierarchyNode> seen, int[] ancestors, int childHash, int layer)
Performs a depth first search on the internal hierarchy model.void
fixRanks()
Fixes the layer assignments to the values stored in the nodes.int
getDfsCount()
java.util.Map<java.lang.Object,mxGraphHierarchyEdge>
getEdgeMapper()
java.util.Map<java.lang.Object,mxGraphHierarchyNode>
getVertexMapper()
void
initialRank()
Basic determination of minimum layer ranking by working from from sources or sinks and working through each node in the relevant edge direction.void
setDfsCount(int dfsCount)
void
setEdgeMapper(java.util.Map<java.lang.Object,mxGraphHierarchyEdge> edgeMapper)
void
setVertexMapper(java.util.Map<java.lang.Object,mxGraphHierarchyNode> vertexMapping)
void
visit(mxGraphHierarchyModel.CellVisitor visitor, mxGraphHierarchyNode[] dfsRoots, boolean trackAncestors, java.util.Set<mxGraphHierarchyNode> seenNodes)
A depth first search through the internal hierarchy model
-
-
-
Field Detail
-
maxRank
public int maxRank
Stores the largest rank number allocated
-
vertexMapper
protected java.util.Map<java.lang.Object,mxGraphHierarchyNode> vertexMapper
Map from graph vertices to internal model nodes
-
edgeMapper
protected java.util.Map<java.lang.Object,mxGraphHierarchyEdge> edgeMapper
Map from graph edges to internal model edges
-
ranks
public java.util.Map<java.lang.Integer,mxGraphHierarchyRank> ranks
Mapping from rank number to actual rank
-
roots
public java.util.List<java.lang.Object> roots
Store of roots of this hierarchy model, these are real graph cells, not internal cells
-
parent
public java.lang.Object parent
The parent cell whose children are being laid out
-
dfsCount
protected int dfsCount
Count of the number of times the ancestor dfs has been used
-
-
Constructor Detail
-
mxGraphHierarchyModel
public mxGraphHierarchyModel(mxHierarchicalLayout layout, java.lang.Object[] vertices, java.util.List<java.lang.Object> roots, java.lang.Object parent)
Creates an internal ordered graph model using the vertices passed in. If there are any, leftward edge need to be inverted in the internal model- Parameters:
layout
- the enclosing layout objectvertices
- the vertices for this hierarchy
-
-
Method Detail
-
createInternalCells
protected void createInternalCells(mxHierarchicalLayout layout, java.lang.Object[] vertices, mxGraphHierarchyNode[] internalVertices)
Creates all edges in the internal model- Parameters:
layout
- reference to the layout algorithmvertices
- the vertices whom are to have an internal representation createdinternalVertices
- the blank internal vertices to have their information filled in using the real vertices
-
initialRank
public void initialRank()
Basic determination of minimum layer ranking by working from from sources or sinks and working through each node in the relevant edge direction. Starting at the sinks is basically a longest path layering algorithm.
-
fixRanks
public void fixRanks()
Fixes the layer assignments to the values stored in the nodes. Also needs to create dummy nodes for edges that cross layers.
-
visit
public void visit(mxGraphHierarchyModel.CellVisitor visitor, mxGraphHierarchyNode[] dfsRoots, boolean trackAncestors, java.util.Set<mxGraphHierarchyNode> seenNodes)
A depth first search through the internal hierarchy model- Parameters:
visitor
- the visitor pattern to be called for each nodetrackAncestors
- whether or not the search is to keep track all nodes directly above this one in the search path
-
dfs
public void dfs(mxGraphHierarchyNode parent, mxGraphHierarchyNode root, mxGraphHierarchyEdge connectingEdge, mxGraphHierarchyModel.CellVisitor visitor, java.util.Set<mxGraphHierarchyNode> seen, int layer)
Performs a depth first search on the internal hierarchy model- Parameters:
parent
- the parent internal node of the current internal noderoot
- the current internal nodeconnectingEdge
- the internal edge connecting the internal node and the parent internal node, if anyvisitor
- the visitor pattern to be called for each nodeseen
- a set of all nodes seen by this dfs a set of all of the ancestor node of the current nodelayer
- the layer on the dfs tree ( not the same as the model ranks )
-
dfs
public void dfs(mxGraphHierarchyNode parent, mxGraphHierarchyNode root, mxGraphHierarchyEdge connectingEdge, mxGraphHierarchyModel.CellVisitor visitor, java.util.Set<mxGraphHierarchyNode> seen, int[] ancestors, int childHash, int layer)
Performs a depth first search on the internal hierarchy model. This dfs extends the default version by keeping track of cells ancestors, but it should be only used when necessary because of it can be computationally intensive for deep searches.- Parameters:
parent
- the parent internal node of the current internal noderoot
- the current internal nodeconnectingEdge
- the internal edge connecting the internal node and the parent internal node, if anyvisitor
- the visitor pattern to be called for each nodeseen
- a set of all nodes seen by this dfsancestors
- the parent hash codechildHash
- the new hash code for this nodelayer
- the layer on the dfs tree ( not the same as the model ranks )
-
getVertexMapper
public java.util.Map<java.lang.Object,mxGraphHierarchyNode> getVertexMapper()
- Returns:
- Returns the vertexMapping.
-
setVertexMapper
public void setVertexMapper(java.util.Map<java.lang.Object,mxGraphHierarchyNode> vertexMapping)
- Parameters:
vertexMapping
- The vertexMapping to set.
-
getEdgeMapper
public java.util.Map<java.lang.Object,mxGraphHierarchyEdge> getEdgeMapper()
- Returns:
- Returns the edgeMapper.
-
setEdgeMapper
public void setEdgeMapper(java.util.Map<java.lang.Object,mxGraphHierarchyEdge> edgeMapper)
- Parameters:
edgeMapper
- The edgeMapper to set.
-
getDfsCount
public int getDfsCount()
- Returns:
- Returns the dfsCount.
-
setDfsCount
public void setDfsCount(int dfsCount)
- Parameters:
dfsCount
- The dfsCount to set.
-
-