Class UITreeLayout
public class UITreeLayout extends UILayoutManager
{
// Constructors
public UITreeLayout();
public UITreeLayout(int indent);
public UITreeLayout(int indent, int vgap);
// Methods
public Dimension adjustLayoutSize(IUIContainer parent,
Dimension oldParentSize, IUIComponent comp,
Dimension oldSize, Dimension newSize);
public void drawLine(FxGraphics g, int x1, int y1, int x2,
int y2);
public Dimension getMinimumSize(IUIContainer target);
public Dimension getPreferredSize(IUIContainer target);
public boolean isHeightRelative();
public boolean isOverlapping();
public boolean isWidthRelative();
public void layout(IUIContainer target, Rectangle bounds);
public void paintContainer(IUIContainer target, FxGraphics g);
}
This class implements a layout manager for tree nodes. UITreeLayout handles the drawing of the lines that connect a tree node to its children. UITree typically uses UITreeLayout for its default layout manager.
By default, UISystem defines UITreeLayout at the TREE_LAYOUT index.
UILayoutManager
|
+--UITreeLayout
public UITreeLayout();
Creates a tree layout manager.
Remarks:
By default, the vertical spacing between all components is 2 pixels. A tree node's child components will be laid out with an indent of 16 pixels.
public UITreeLayout(int indent);
Creates a tree layout manager with the specified indent.
Parameter | Description |
indent
| The indent (in pixels) used when laying out child components.
|
Remarks:
By default, the vertical spacing between all components is 2 pixels.
public UITreeLayout(int indent, int vgap);
Creates a tree layout manager with the specified indent and vertical gap.
Parameter | Description |
indent
| The indent (in pixels) used when laying out child components.
|
vgap
| The vertical spacing (in pixels) between components.
|
public Dimension adjustLayoutSize(IUIContainer parent,
Dimension oldParentSize, IUIComponent comp, Dimension oldSize,
Dimension newSize);
Called to adjust the layout size of the specified component in the specified container.
Return Value:
Returns a Dimension object containing the new preferred size of the container.
Parameter | Description |
parent
| The container of the component.
|
oldParentSize
| The previous layout size of the container.
|
comp
| The component being sized.
|
oldSize
| The previous layout size of the component.
|
newSize
| The new layout size of the component.
|
Overrides:
adjustLayoutSize(IUIContainer,Dimension,IUIComponent,Dimension,Dimension) in UILayoutManager.
public void drawLine(FxGraphics g, int x1, int y1, int x2, int y2);
Draws a line from one point to another.
Return Value:
No return value.
Parameter | Description |
g
| The graphics context.
|
x1
| The x coordinate of the line's starting point.
|
y1
| The y coordinate of the line's starting point.
|
x2
| The x coordinate of the line's ending point.
|
y2
| The y coordinate of the line's ending point.
|
Remarks:
This method is called by paintContainer to draw the lines that connect a tree node to its children.
public Dimension getMinimumSize(IUIContainer target);
Determines the minimum dimensions (in pixels) needed to lay out the child components in the specified container.
Return Value:
Returns a Dimension object containing the minimum layout size.
Parameter | Description |
target
| The container of the components.
|
Remarks:
The height of the returned Dimension object is the sum of the minimum heights of each item displayed by the tree node and all its children, plus the vertical gaps between each item. The Dimension object's width is the largest of the minimum widths of the items (including the indent).
Overrides:
getMinimumSize(IUIContainer) in UILayoutManager.
See Also: getPreferredSize
public Dimension getPreferredSize(IUIContainer target);
Determines the preferred dimensions (in pixels) for laying out the child components in the specified container.
Return Value:
Returns a Dimension object containing the preferred layout size.
Parameter | Description |
target
| The container of the components.
|
Remarks:
The height of the returned Dimension object is the sum of the preferred heights of each item displayed by the tree node and all its children, plus the vertical gaps between each item. The Dimension object's width is the largest of the preferred widths of the items (including the indent).
Overrides:
getPreferredSize(IUIContainer) in UILayoutManager.
See Also: getMinimumSize
public boolean isHeightRelative();
This method simply returns false, indicating that the UITreeLayout does not lay out its components based on the height of the container.
Return Value:
Returns false.
Overrides:
isHeightRelative() in UILayoutManager.
See Also: isWidthRelative
public boolean isOverlapping();
This method simply returns false, indicating that the UITreeLayout lays out its components such that they never overlap.
Return Value:
Returns false.
Overrides:
isOverlapping() in UILayoutManager.
public boolean isWidthRelative();
This method simply returns false, indicating that the UITreeLayout does not lay out its components based on the width of the container.
Return Value:
Returns false.
Overrides:
isWidthRelative() in UILayoutManager.
See Also: isHeightRelative
public void layout(IUIContainer target, Rectangle bounds);
Lays out the components in the specified container.
Return Value:
No return value.
Parameter | Description |
target
| The container being laid out.
|
bounds
| The bounding rectangle in which to lay out the components.
|
Remarks:
The height and width of each component is based on the component's respective preferred height and width. The vertical gap (defined when the layout manager was created) is used for vertical spacing between each component.
For each tree node's expand button, layoutContainer determines where the attaching line must be drawn from the node to its parent, based on the node's getAttachRect method and the layout manager's defined indent. The paintContainer method is then invoked to draw all connecting lines between a node and its children.
Overrides:
layout(IUIContainer,Rectangle) in UILayoutManager.
public void paintContainer(IUIContainer target, FxGraphics g);
Draws the container.
Return Value:
No return value.
Parameter | Description |
target
| The container.
|
g
| The graphics context of the container.
|
Remarks:
This method is automatically invoked during a call to the container's paint method. If the tree node is expanded, paintContainer calls drawLine to connect the node to its children.
Overrides:
paintContainer(IUIContainer,FxGraphics) in UILayoutManager.