Class JGraphAbstractTreeLayout
java.lang.Object
com.jgraph.layout.tree.JGraphAbstractTreeLayout
- All Implemented Interfaces:
JGraphLayout
- Direct Known Subclasses:
JGraphCompactTreeLayout, JGraphTreeLayout
An implementation of a basic tree layout. The layout is created using the
internal
TreeNode structure with appropriate interfaces to the
actual graph model. The layout can be configured by orientation, the
alignment of the nodes per level, the minimum distance between-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classAn ADT representing a node in a tree structure.Nested classes/interfaces inherited from interface JGraphLayout
JGraphLayout.Stoppable -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected JGraphFacadeThe facade that describes the graph to be acted uponprotected doublelevelDistance is the distance between the lowest point of any vertex on one level to the highest point of any vertex on the next level down.protected double[]The lowest point for each tree levelprotected doublenodeDistance is the minimum distance between any two vertices on the same level.protected MapStores the mapping between internal tree nodes and graph cellsprotected Point2DKeeps track of the old origin so that the new layout can be aligned to itprotected intorientation indicates where, relative to the rest of the tree, the root node is placed.protected booleanIndicates whether or not to space out multiple trees so that no overlapping occurs between each treeprotected booleanWhether or not to apply a standard routing algorithm to the edgesprotected doubleKeeps track of the coordinate that each tree fills space up to.protected doubleIfpositionMultipleTreesistruethis value is the minimum distance between each overlapping tree structure after they are separatedprotected double[]The highest point for each tree levelFields inherited from interface JGraphLayout
VERSION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubledoubleintbooleandoublebooleanvoidrun(JGraphFacade graph) The API method used to exercise the layout upon the facade description and produce a separate description of the vertex position and edge routing changes made.voidsetLevelDistance(double distance) voidsetNodeDistance(int distance) voidsetOrientation(int orientation) SwingConstants.NORTH SwingConstants.EAST SwingConstants.SOUTH SwingConstants.WEST are valid inputs to this methodvoidsetPositionMultipleTrees(boolean positionMultipleTrees) voidsetRouteTreeEdges(boolean routeTreeEdges) voidsetTreeDistance(int treeDistance)
-
Field Details
-
nodes
Stores the mapping between internal tree nodes and graph cells -
orientation
protected int orientationorientation indicates where, relative to the rest of the tree, the root node is placed. Default is SwingConstants.NORTH (1), other valid values are SwingConstants.SOUTH (5), SwingConstants.EAST (3) and SwingConstants.WEST (7). NORTH means the root is at the top and the children below, WEST means the root is on the left and the children to the right, and so on. -
levelDistance
protected double levelDistancelevelDistance is the distance between the lowest point of any vertex on one level to the highest point of any vertex on the next level down. -
nodeDistance
protected double nodeDistancenodeDistance is the minimum distance between any two vertices on the same level. Levels closer to the root tend to be spaced a lot further apart than this. -
positionMultipleTrees
protected boolean positionMultipleTreesIndicates whether or not to space out multiple trees so that no overlapping occurs between each tree -
treeDistance
protected double treeDistanceIfpositionMultipleTreesistruethis value is the minimum distance between each overlapping tree structure after they are separated -
treeBoundary
protected double treeBoundaryKeeps track of the coordinate that each tree fills space up to. This value refers to either axis, depending on the orientation of the tree. This is used when there are multiple trees to ensure the correct minimum separation distance between each one. -
oldOrigin
Keeps track of the old origin so that the new layout can be aligned to it -
graph
The facade that describes the graph to be acted upon -
routeTreeEdges
protected boolean routeTreeEdgesWhether or not to apply a standard routing algorithm to the edges -
lowerLevelValues
protected double[] lowerLevelValuesThe lowest point for each tree level -
upperLevelValues
protected double[] upperLevelValuesThe highest point for each tree level
-
-
Constructor Details
-
JGraphAbstractTreeLayout
public JGraphAbstractTreeLayout()
-
-
Method Details
-
run
The API method used to exercise the layout upon the facade description and produce a separate description of the vertex position and edge routing changes made. It first builds a representation of the tree using the inner tree class by doing a depth first search of the graph from the root. It then lays out the graph using the obtained data- Specified by:
runin interfaceJGraphLayout- Parameters:
graph- the facade describing the graph and its configuration
-
setOrientation
public void setOrientation(int orientation) SwingConstants.NORTH SwingConstants.EAST SwingConstants.SOUTH SwingConstants.WEST are valid inputs to this method- Parameters:
orientation-
-
setLevelDistance
public void setLevelDistance(double distance) - Parameters:
distance- new level distance
-
setNodeDistance
public void setNodeDistance(int distance) - Parameters:
distance- new node distance
-
getLevelDistance
public double getLevelDistance()- Returns:
- Returns the levelDistance.
-
getNodeDistance
public double getNodeDistance()- Returns:
- Returns the nodeDistance.
-
getOrientation
public int getOrientation()- Returns:
- Returns the orientation.
-
isPositionMultipleTrees
public boolean isPositionMultipleTrees()- Returns:
- Returns the positionMultipleTrees.
-
setPositionMultipleTrees
public void setPositionMultipleTrees(boolean positionMultipleTrees) - Parameters:
positionMultipleTrees- The positionMultipleTrees to set.
-
getTreeDistance
public double getTreeDistance()- Returns:
- Returns the treeDistance.
-
setTreeDistance
public void setTreeDistance(int treeDistance) - Parameters:
treeDistance- The treeDistance to set.
-
getRouteTreeEdges
public boolean getRouteTreeEdges()- Returns:
- Returns the routeTreeEdges.
-
setRouteTreeEdges
public void setRouteTreeEdges(boolean routeTreeEdges) - Parameters:
routeTreeEdges- The routeTreeEdges to set.
-