The nodes with their final layout can be retrieved through
getNodeBounds().
| Modifier and Type | Class and Description |
|---|---|
| public static class | |
| private class | TreeLayout.
The algorithm calculates the position starting with the root at 0. |
| Modifier and Type | Field and Description |
|---|---|
| private final Map | |
| private double | |
| private double | |
| private double | |
| private double | |
| private final Map | |
| private final Configuration | |
| private final Map | |
| private Map | |
| private final NodeExtentProvider | |
| private final Map | |
| private final Map | |
| private final Map | |
| private final Map | |
| private final List | |
| private final Map | |
| private final TreeForTreeLayout | |
| private final boolean |
| Access | Constructor and Description |
|---|---|
| public | TreeLayout(TreeForTreeLayout<TreeNode>
[default: false] when true, identity ("==") is used instead of
equality ("equals(...)") when checking nodes. Within a tree
each node must only exist once (using this check). useIdentity)Creates a TreeLayout for a given tree. |
| public | TreeLayout(TreeForTreeLayout<TreeNode> tree, NodeExtentProvider<TreeNode> nodeExtentProvider, Configuration<TreeNode> configuration)
|
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private TreeNode | Returns: the greatest distinct ancestor of vIMinus and its right neighbor v
|
| private TreeNode | Returns: the (possibly changes) defaultAncestor[nullable] the left sibling v, if there is any leftSibling, TreeNode the parent of v parentOfV)In difference to the original algorithm we also pass in the leftSibling and the parent of v. Why adding the parameter 'parent of v' (parentOfV) ? |
| private void | |
| public void | |
| private void | dumpTree(PrintStream output, TreeNode node, int indent, TreeLayout.
|
| public void | dumpTree(PrintStream
[default: new DumpConfiguration()] dumpConfigurationPrints a dump of the tree to the given printStream, using the node's "toString" method. |
| public void | |
| private void | |
| private void | firstWalk(TreeNode v, TreeNode
[nullable] the left sibling v, if there is any leftSibling)In difference to the original algorithm we also pass in the leftSibling
(see |
| private TreeNode | |
| public Rectangle2D | |
| private double | |
| public Configuration | Returns: the Configuration used by thisTreeLayoutReturns the Configuration used by this |
| private double | Returns: the distance between node v and wThe distance of two nodes is the distance of the centers of both noded. |
| private int | |
| public int | |
| private double | |
| public Map | Returns: maps each node of the tree to its bounds (position and size).Returns the layout of the tree nodes by mapping each node of the tree to its bounds (position and size). |
| public NodeExtentProvider | |
| private double | |
| private double | getNodeSize(TreeNode treeNode)
When the level changes in Y-axis (i.e. root location Top or Bottom) the width of a node is its size, otherwise the node's height is its size. |
| private double | getNodeThickness(TreeNode treeNode)
When the level changes in Y-axis (i.e. root location Top or Bottom) the height of a node is its thickness, otherwise the node's width is its thickness. |
| private double | |
| private int | |
| private double | |
| private double | |
| public double | Returns: the size of the level [level >= 0 && level < levelCount]Returns the size of a level. |
| private TreeNode | |
| public TreeForTreeLayout | |
| private double | |
| private boolean | |
| private void | |
| private TreeNode | |
| private TreeNode | |
| private void | secondWalk(TreeNode v, double m, int level, double levelStart)
In difference to the original algorithm we also pass in extra level information. |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void |
| ancestor | back to summary |
|---|---|
| private final Map<TreeNode, TreeNode> ancestor | |
| boundsBottom | back to summary |
|---|---|
| private double boundsBottom | |
| boundsLeft | back to summary |
|---|---|
| private double boundsLeft | |
| boundsRight | back to summary |
|---|---|
| private double boundsRight | |
| boundsTop | back to summary |
|---|---|
| private double boundsTop | |
| change | back to summary |
|---|---|
| private final Map<TreeNode, Double> change | |
| configuration | back to summary |
|---|---|
| private final Configuration<TreeNode> configuration | |
| mod | back to summary |
|---|---|
| private final Map<TreeNode, Double> mod | |
| nodeBounds | back to summary |
|---|---|
| private Map<TreeNode, Rectangle2D. | |
| nodeExtentProvider | back to summary |
|---|---|
| private final NodeExtentProvider<TreeNode> nodeExtentProvider | |
| number | back to summary |
|---|---|
| private final Map<TreeNode, Integer> number | |
| positions | back to summary |
|---|---|
| private final Map<TreeNode, Point2D> positions | |
| prelim | back to summary |
|---|---|
| private final Map<TreeNode, Double> prelim | |
| shift | back to summary |
|---|---|
| private final Map<TreeNode, Double> shift | |
| sizeOfLevel | back to summary |
|---|---|
| private final List<Double> sizeOfLevel | |
| thread | back to summary |
|---|---|
| private final Map<TreeNode, TreeNode> thread | |
| tree | back to summary |
|---|---|
| private final TreeForTreeLayout<TreeNode> tree | |
| useIdentity | back to summary |
|---|---|
| private final boolean useIdentity | |
| TreeLayout | back to summary |
|---|---|
| public TreeLayout(TreeForTreeLayout<TreeNode> tree, NodeExtentProvider<TreeNode> nodeExtentProvider, Configuration<TreeNode> configuration, boolean useIdentity) Creates a TreeLayout for a given tree.
In addition to the tree the
| |
| TreeLayout | back to summary |
|---|---|
| public TreeLayout(TreeForTreeLayout<TreeNode> tree, NodeExtentProvider<TreeNode> nodeExtentProvider, Configuration<TreeNode> configuration) | |
| addUniqueNodes | back to summary |
|---|---|
| private void addUniqueNodes(Map<TreeNode, TreeNode> nodes, TreeNode newNode) | |
| ancestor | back to summary |
|---|---|
private TreeNode ancestor(TreeNode vIMinus, TreeNode v, TreeNode parentOfV, TreeNode defaultAncestor)
| |
| apportion | back to summary |
|---|---|
| private TreeNode apportion(TreeNode v, TreeNode defaultAncestor, TreeNode leftSibling, TreeNode parentOfV) In difference to the original algorithm we also pass in the leftSibling and the parent of v. Why adding the parameter 'parent of v' (parentOfV) ? In this method we need access to the parent of v. Not every tree implementation may support efficient (i.e. constant time) access to it. On the other hand the (only) caller of this method can provide this information with only constant extra time. Also we need access to the "left most sibling" of v. Not every tree implementation may support efficient (i.e. constant time) access to it. On the other hand the "left most sibling" of v is also the "first child" of the parent of v. The first child of a parent node we can get in constant time. As we got the parent of v we can so also get the "left most sibling" of v in constant time. Why adding the parameter 'leftSibling' ? In this method we need access to the "left sibling" of v. Not every tree implementation may support efficient (i.e. constant time) access to it. However it is easy for the caller of this method to provide this information with only constant extra time.
In addition these extra parameters avoid the need for
| |
| calcSizeOfLevels | back to summary |
|---|---|
| private void calcSizeOfLevels(TreeNode node, int level) | |
| checkTree | back to summary |
|---|---|
| public void checkTree() Check if the tree is a "valid" tree. Typically you will use this method during development when you get an unexpected layout from your trees. The following checks are performed:
| |
| dumpTree | back to summary |
|---|---|
| private void dumpTree(PrintStream output, TreeNode node, int indent, TreeLayout. | |
| dumpTree | back to summary |
|---|---|
| public void dumpTree(PrintStream printStream, TreeLayout. Prints a dump of the tree to the given printStream, using the node's "toString" method.
| |
| dumpTree | back to summary |
|---|---|
| public void dumpTree(PrintStream printStream) | |
| executeShifts | back to summary |
|---|---|
private void executeShifts(TreeNode v)
| |
| firstWalk | back to summary |
|---|---|
| private void firstWalk(TreeNode v, TreeNode leftSibling) In difference to the original algorithm we also pass in the leftSibling
(see
| |
| getAncestor | back to summary |
|---|---|
| private TreeNode getAncestor(TreeNode node) | |
| getBounds | back to summary |
|---|---|
| public Rectangle2D getBounds() Returns the bounds of the tree layout. The bounds of a TreeLayout is the smallest rectangle containing the bounds of all nodes in the layout. It always starts at (0,0).
| |
| getChange | back to summary |
|---|---|
| private double getChange(TreeNode node) | |
| getConfiguration | back to summary |
|---|---|
| public Configuration Returns the Configuration used by this
| |
| getDistance | back to summary |
|---|---|
| private double getDistance(TreeNode v, TreeNode w) The distance of two nodes is the distance of the centers of both noded. I.e. the distance includes the gap between the nodes and half of the sizes of the nodes.
| |
| getLevelChangeSign | back to summary |
|---|---|
| private int getLevelChangeSign() | |
| getLevelCount | back to summary |
|---|---|
| public int getLevelCount() Returns the number of levels of the tree.
| |
| getMod | back to summary |
|---|---|
| private double getMod(TreeNode node) | |
| getNodeBounds | back to summary |
|---|---|
| public Map Returns the layout of the tree nodes by mapping each node of the tree to its bounds (position and size). For each rectangle x and y will be >= 0. At least one rectangle will have an x == 0 and at least one rectangle will have an y == 0.
| |
| getNodeExtentProvider | back to summary |
|---|---|
| public NodeExtentProvider Returns the
| |
| getNodeHeight | back to summary |
|---|---|
| private double getNodeHeight(TreeNode node) | |
| getNodeSize | back to summary |
|---|---|
| private double getNodeSize(TreeNode treeNode) When the level changes in Y-axis (i.e. root location Top or Bottom) the width of a node is its size, otherwise the node's height is its size. The size of a node is used when calculating the distance between two nodes. | |
| getNodeThickness | back to summary |
|---|---|
| private double getNodeThickness(TreeNode treeNode) When the level changes in Y-axis (i.e. root location Top or Bottom) the height of a node is its thickness, otherwise the node's width is its thickness. The thickness of a node is used when calculating the locations of the levels. | |
| getNodeWidth | back to summary |
|---|---|
| private double getNodeWidth(TreeNode node) | |
| getNumber | back to summary |
|---|---|
private int getNumber(TreeNode node, TreeNode parentNode)
| |
| getPrelim | back to summary |
|---|---|
| private double getPrelim(TreeNode node) | |
| getShift | back to summary |
|---|---|
| private double getShift(TreeNode node) | |
| getSizeOfLevel | back to summary |
|---|---|
| public double getSizeOfLevel(int level) Returns the size of a level. When the root is located at the top or bottom the size of a level is the maximal height of the nodes of that level. When the root is located at the left or right the size of a level is the maximal width of the nodes of that level.
| |
| getThread | back to summary |
|---|---|
| private TreeNode getThread(TreeNode node) | |
| getTree | back to summary |
|---|---|
| public TreeForTreeLayout Returns the Tree the layout is created for.
| |
| getWidthOrHeightOfNode | back to summary |
|---|---|
| private double getWidthOrHeightOfNode(TreeNode treeNode, boolean returnWidth) | |
| isLevelChangeInYAxis | back to summary |
|---|---|
| private boolean isLevelChangeInYAxis() | |
| moveSubtree | back to summary |
|---|---|
| private void moveSubtree(TreeNode wMinus, TreeNode wPlus, TreeNode parent, double shift) | |
| nextLeft | back to summary |
|---|---|
| private TreeNode nextLeft(TreeNode v) | |
| nextRight | back to summary |
|---|---|
| private TreeNode nextRight(TreeNode v) | |
| secondWalk | back to summary |
|---|---|
| private void secondWalk(TreeNode v, double m, int level, double levelStart) In difference to the original algorithm we also pass in extra level information. | |
| setAncestor | back to summary |
|---|---|
| private void setAncestor(TreeNode node, TreeNode ancestor) | |
| setChange | back to summary |
|---|---|
| private void setChange(TreeNode node, double d) | |
| setMod | back to summary |
|---|---|
| private void setMod(TreeNode node, double d) | |
| setPrelim | back to summary |
|---|---|
| private void setPrelim(TreeNode node, double d) | |
| setShift | back to summary |
|---|---|
| private void setShift(TreeNode node, double d) | |
| setThread | back to summary |
|---|---|
| private void setThread(TreeNode node, TreeNode thread) | |
| updateBounds | back to summary |
|---|---|
| private void updateBounds(TreeNode node, double centerX, double centerY) | |
| Modifier and Type | Field and Description |
|---|---|
| public final boolean | includeNodeSize
When true the dump also includes the size of each node, otherwise not. |
| public final boolean | includeObjectToString
When true, the text as returned by |
| public final String | indent
The text used to indent the output per level. |
| Access | Constructor and Description |
|---|---|
| public | DumpConfiguration(String
[default: " "] indent, boolean [default: false] includeNodeSize, boolean [default: false] includePointer)
|
| public |
| includeNodeSize | back to summary |
|---|---|
| public final boolean includeNodeSize When true the dump also includes the size of each node, otherwise not. | |
| includeObjectToString | back to summary |
|---|---|
| public final boolean includeObjectToString When true, the text as returned by | |
| indent | back to summary |
|---|---|
| public final String indent The text used to indent the output per level. | |
| DumpConfiguration | back to summary |
|---|---|
public DumpConfiguration(String indent, boolean includeNodeSize, boolean includePointer)
| |
| DumpConfiguration | back to summary |
|---|---|
| public DumpConfiguration() | |
NormalizedPosition will normalize the position (given relative to
the root position), taking the current bounds into account. This way the
left most node bounds will start at x = 0, the top most node bounds at y
= 0.
| Modifier and Type | Field and Description |
|---|---|
| private double | |
| private double |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public double | getX()
Implements abstract java. Point2D in
double precision.
|
| public double | getY()
Implements abstract java. Point2D in
double precision.
|
| public void | setLocation(double
the new X coordinate of this x_relativeToRoot, double Point2Dthe new Y coordinate of this y_relativeToRoot)Point2DImplements abstract java. Point2D to the
specified double coordinates.
|
| x_relativeToRoot | back to summary |
|---|---|
| private double x_relativeToRoot | |
| y_relativeToRoot | back to summary |
|---|---|
| private double y_relativeToRoot | |
| NormalizedPosition | back to summary |
|---|---|
| public NormalizedPosition(double x_relativeToRoot, double y_relativeToRoot) | |
| getX | back to summary |
|---|---|
| public double getX() Implements abstract java. Doc from java. Returns the X coordinate of this
| |
| getY | back to summary |
|---|---|
| public double getY() Implements abstract java. Doc from java. Returns the Y coordinate of this
| |
| setLocation | back to summary |
|---|---|
| public void setLocation(double x_relativeToRoot, double y_relativeToRoot) Implements abstract java. Doc from java. Sets the location of this
| |