public class BinaryTreeLayout
extends java.lang.Object
implements java.awt.LayoutManager2
getLines()
is
undefined in such case. There is also no strict checking of loops or
components that have been added multiple times without being removed. In this
case, too, the behaviour is undefined.
The constraints which this layout manager will accept are strings defining
the node in which this component is located. These constraint strings can
contain any character, but only the characters 'l' and 'r' are taken into
account. The root of the tree should be given the constraint "". In the logic
of these constraint strings, this means that no branches have been taken. The
direct left child of any node should be given the string formed by taking the
parent's constraint string and adding 'l'. The same is true for the direct
right child, in which case 'r' has to be added to the parent's constraint
string.
Finally, this class also includes a way of drawing the lines that connect the
nodes of the tree. See getLines()
for more information on how to do
this.Constructor and Description |
---|
BinaryTreeLayout() |
Modifier and Type | Method and Description |
---|---|
void |
addLayoutComponent(java.awt.Component comp,
java.lang.Object arg1) |
void |
addLayoutComponent(java.lang.String name,
java.awt.Component comp) |
float |
getLayoutAlignmentX(java.awt.Container target) |
float |
getLayoutAlignmentY(java.awt.Container target) |
java.util.List<Line> |
getLines()
Generate and return the lines that make up the relations of this tree.
|
int |
getSpacingX()
Return the amount of space that is left between any two components on the
X-axis.
|
int |
getSpacingY()
Return the amount of space that is left between any two components on the
Y-axis.
|
void |
invalidateLayout(java.awt.Container target) |
void |
layoutContainer(java.awt.Container parent) |
java.awt.Dimension |
maximumLayoutSize(java.awt.Container target) |
java.awt.Dimension |
minimumLayoutSize(java.awt.Container parent) |
java.awt.Dimension |
preferredLayoutSize(java.awt.Container parent) |
void |
removeLayoutComponent(java.awt.Component comp) |
void |
setSpacingX(int spacingX)
Set the amount of space that is left between any two components on the
X-axis to the given value.
|
void |
setSpacingY(int spacingY)
Set the amount of space that is left between any two components on the
Y-axis to the given value.
|
public void addLayoutComponent(java.awt.Component comp, java.lang.Object arg1)
addLayoutComponent
in interface java.awt.LayoutManager2
public void addLayoutComponent(java.lang.String name, java.awt.Component comp)
addLayoutComponent
in interface java.awt.LayoutManager
public float getLayoutAlignmentX(java.awt.Container target)
getLayoutAlignmentX
in interface java.awt.LayoutManager2
public float getLayoutAlignmentY(java.awt.Container target)
getLayoutAlignmentY
in interface java.awt.LayoutManager2
public java.util.List<Line> getLines()
public int getSpacingX()
public int getSpacingY()
public void invalidateLayout(java.awt.Container target)
invalidateLayout
in interface java.awt.LayoutManager2
public void layoutContainer(java.awt.Container parent)
layoutContainer
in interface java.awt.LayoutManager
public java.awt.Dimension maximumLayoutSize(java.awt.Container target)
maximumLayoutSize
in interface java.awt.LayoutManager2
public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
minimumLayoutSize
in interface java.awt.LayoutManager
public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
preferredLayoutSize
in interface java.awt.LayoutManager
public void removeLayoutComponent(java.awt.Component comp)
removeLayoutComponent
in interface java.awt.LayoutManager
public void setSpacingX(int spacingX)
public void setSpacingY(int spacingY)