Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
javax.swing.tree.AbstractLayoutCache
javax.swing.tree.VariableHeightLayoutCache
public class VariableHeightLayoutCache
extends AbstractLayoutCache
Nested Class Summary |
Nested classes/interfaces inherited from class javax.swing.tree.AbstractLayoutCache | |
AbstractLayoutCache.NodeDimensions |
Field Summary |
Fields inherited from class javax.swing.tree.AbstractLayoutCache | |
nodeDimensions , rootVisible , rowHeight , treeModel , treeSelectionModel |
Constructor Summary | |
|
Method Summary | |
Rectangle | |
boolean |
|
TreePath |
|
TreePath |
|
int |
|
int |
|
int |
|
int |
|
int |
|
Enumeration |
|
void |
|
void |
|
boolean |
|
void |
|
void | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public VariableHeightLayoutCache()
Creates the unitialised instance. Before using the class, the row height must be set with thesetRowHeight(int)
and the model must be set withsetModel(TreeModel)
. The node dimensions may not be set.
public Rectangle getBounds(TreePath path, Rectangle rect)
Get bounds for the given tree path.
- Overrides:
- getBounds in interface AbstractLayoutCache
- Parameters:
path
- the tree pathrect
- the rectangle that will be reused to return the result.
- Returns:
- Rectangle the bounds of the last line, defined by the given path.
public boolean getExpandedState(TreePath path)
Return the expansion state of the given tree path. The expansion state must be previously set with thesetExpandedState(TreePath,boolean)
- Overrides:
- getExpandedState in interface AbstractLayoutCache
- Parameters:
path
- the path being checked
- Returns:
- true if the last node of the path is expanded, false otherwise.
public TreePath getPathClosestTo(int x, int y)
Get the path, closest to the given point.
- Overrides:
- getPathClosestTo in interface AbstractLayoutCache
- Parameters:
x
- the point x coordinatey
- the point y coordinate
- Returns:
- the tree path, closest to the the given point
public TreePath getPathForRow(int row)
Get the path, the last element of that is displayed in the given row.
- Overrides:
- getPathForRow in interface AbstractLayoutCache
- Parameters:
row
- the row
- Returns:
- TreePath the path
public int getPreferredHeight()
Get the sum of heights for all rows.
- Overrides:
- getPreferredHeight in interface AbstractLayoutCache
public int getPreferredWidth(Rectangle value)
Get the maximal width.
- Overrides:
- getPreferredWidth in interface AbstractLayoutCache
public int getRowCount()
Get the total number of rows in the tree. Every displayed node occupies the single row. The root node row is included if the root node is set as visible (false by default).
- Overrides:
- getRowCount in interface AbstractLayoutCache
- Returns:
- int the number of the displayed rows.
public int getRowForPath(TreePath path)
Get the row, displaying the last node of the given path.
- Overrides:
- getRowForPath in interface AbstractLayoutCache
- Parameters:
path
- the path
- Returns:
- int the row number or -1 if the end of the path is not visible.
public int getVisibleChildCount(TreePath path)
Get the number of the visible childs for the given tree path. If the node is not expanded, 0 is returned. Otherwise, the number of children is obtained from the model as the number of children for the last path component.
- Overrides:
- getVisibleChildCount in interface AbstractLayoutCache
- Parameters:
path
- the tree path
- Returns:
- int the number of the visible childs (for row).
public EnumerationgetVisiblePathsFrom(TreePath parentPath)
Get the enumeration over all visible paths that start from the given parent path.
- Overrides:
- getVisiblePathsFrom in interface AbstractLayoutCache
- Parameters:
parentPath
- the parent path
- Returns:
- the enumeration over pathes
public void invalidatePathBounds(TreePath path)
Discard the bound information for the given path.
- Overrides:
- invalidatePathBounds in interface AbstractLayoutCache
- Parameters:
path
- the path, for that the bound information must be recomputed.
public void invalidateSizes()
Mark all cached information as invalid.
- Overrides:
- invalidateSizes in interface AbstractLayoutCache
public boolean isExpanded(TreePath path)
Get the expanded state for the given tree path.
- Overrides:
- isExpanded in interface AbstractLayoutCache
- Returns:
- true if the given path is expanded, false otherwise.
public void setExpandedState(TreePath path, boolean isExpanded)
Set the expanded state of the given path. The expansion states must be always updated when expanding and colapsing the tree nodes. Otherwise other methods will not work correctly after the nodes are collapsed or expanded.
- Overrides:
- setExpandedState in interface AbstractLayoutCache
- Parameters:
path
- the tree path, for that the state is being set.isExpanded
- the expanded state of the given path.
public void setModel(TreeModel newModel)
Set the tree model that will provide the data.
- Overrides:
- setModel in interface AbstractLayoutCache
public void setNodeDimensions(AbstractLayoutCache.NodeDimensions dim)
Sets the node dimensions and invalidates the cached layout.
- Overrides:
- setNodeDimensions in interface AbstractLayoutCache
- Parameters:
dim
- the dimensions to set
public void setRootVisible(boolean visible)
Inform the instance if the tree root node is visible. If this method is not called, it is assumed that the tree root node is not visible.
- Overrides:
- setRootVisible in interface AbstractLayoutCache
- Parameters:
visible
- true if the tree root node is visible, false otherwise.
public void setRowHeight(int height)
Sets the row height and marks the layout as invalid.
- Overrides:
- setRowHeight in interface AbstractLayoutCache
- Parameters:
height
- the row height to set
public void treeNodesChanged(TreeModelEvent event)
The listener method, called when the tree nodes are changed.
- Overrides:
- treeNodesChanged in interface AbstractLayoutCache
- Parameters:
event
- the change event
public void treeNodesInserted(TreeModelEvent event)
The listener method, called when the tree nodes are inserted.
- Overrides:
- treeNodesInserted in interface AbstractLayoutCache
- Parameters:
event
- the change event
public void treeNodesRemoved(TreeModelEvent event)
The listener method, called when the tree nodes are removed.
- Overrides:
- treeNodesRemoved in interface AbstractLayoutCache
- Parameters:
event
- the change event
public void treeStructureChanged(TreeModelEvent event)
Called when the tree structure has been changed.
- Overrides:
- treeStructureChanged in interface AbstractLayoutCache
- Parameters:
event
- the change event