Top Description Inners Fields Constructors Methods
javax.swing.tree

public abstract Class AbstractLayoutCache

extends Object
implements RowMapper
Class Inheritance
All Implemented Interfaces
javax.swing.tree.RowMapper
Known Direct Subclasses
javax.swing.tree.FixedHeightLayoutCache, javax.swing.tree.VariableHeightLayoutCache
Annotations
@SuppressWarnings:serial
Imports
javax.swing.event.TreeModelEvent, java.awt.Rectangle, java.beans.BeanProperty, java.util.Enumeration

Warning

Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Author
Scott Violet

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
AbstractLayoutCache.NodeDimensions

Used by AbstractLayoutCache to determine the size and x origin of a particular node.

Field Summary

Modifier and TypeField and Description
protected AbstractLayoutCache.NodeDimensions
nodeDimensions

Object responsible for getting the size of a node.

protected boolean
rootVisible

True if the root node is displayed, false if its children are the highest visible nodes.

protected int
rowHeight

Height to use for each row.

protected TreeModel
treeModel

Model providing information.

protected TreeSelectionModel
treeSelectionModel

Selection model.

Constructor Summary

AccessConstructor and Description
protected
AbstractLayoutCache()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
public abstract Rectangle

Returns:

a Rectangle object specifying the space to be used
getBounds
(TreePath
a TreePath specifying a node
path
,
Rectangle
a Rectangle object giving the available space
placeIn
)

Returns a rectangle giving the bounds needed to draw path.

public abstract boolean

Returns:

true if the path is expanded and visible, false otherwise
getExpandedState
(TreePath
the path being queried
path
)

Returns true if the path is expanded, and visible.

public TreeModel

Returns:

the TreeModel that is providing the data
getModel
()

Returns the TreeModel that is providing the data.

public AbstractLayoutCache.NodeDimensions

Returns:

the NodeDimensions object
getNodeDimensions
()

Returns the object that renders nodes in the tree, and which is responsible for calculating the dimensions of individual nodes.

protected Rectangle

Returns:

a Rectangle containing the node dimensions, or null if node has no dimension
getNodeDimensions
(Object
the value to be represented
value
,
int
row being queried
row
,
int
the depth of the row
depth
,
boolean
true if row is expanded, false otherwise
expanded
,
Rectangle
a Rectangle containing the size needed to represent value
placeIn
)

Returns, by reference in placeIn, the size needed to represent value.

public abstract TreePath

Returns:

the TreePath closest to the specified point
getPathClosestTo
(int
the horizontal component of the desired location
x
,
int
the vertical component of the desired location
y
)

Returns the path to the node that is closest to x,y.

public abstract TreePath

Returns:

the TreePath for the given row
getPathForRow
(int
the row being queried
row
)

Returns the path for passed in row.

public int

Returns:

the preferred height
getPreferredHeight
()

Returns the preferred height.

public int

Returns:

the preferred width for the passed in region
getPreferredWidth
(Rectangle
the region being queried
bounds
)

Returns the preferred width for the passed in region.

public abstract int

Returns:

the number of rows being displayed
getRowCount
()

Number of rows being displayed.

public abstract int

Returns:

the row where the last item in path is visible or -1 if any elements in path aren't currently visible
getRowForPath
(TreePath
the TreePath being queried
path
)

Returns the row that the last item identified in path is visible at.

public int

Returns:

the height of each row
getRowHeight
()

Returns the height of each row.

public int[]

Returns:

an array of the same length that is passed in containing the rows that each corresponding where each TreePath is displayed; if paths is null, null is returned
getRowsForPaths
(TreePath[]
the array of TreePaths being queried
paths
)

Implements javax.swing.tree.RowMapper.getRowsForPaths.

Returns the rows that the TreePath instances in path are being displayed at.

public TreeSelectionModel

Returns:

the treeSelectionModel
getSelectionModel
()

Returns the model used to maintain the selection.

public abstract int

Returns:

the number of visible children for the specified path
getVisibleChildCount
(TreePath
the path being queried
path
)

Returns the number of visible children for row.

public abstract Enumeration<TreePath>

Returns:

the Enumerator starting at the desired location
getVisiblePathsFrom
(TreePath
the starting location for the enumeration
path
)

Returns an Enumerator that increments over the visible paths starting at the passed in location.

public abstract void
invalidatePathBounds(TreePath
the path being updated
path
)

Instructs the LayoutCache that the bounds for path are invalid, and need to be updated.

public abstract void
invalidateSizes()

Informs the TreeState that it needs to recalculate all the sizes it is referencing.

public abstract boolean

Returns:

whether TreePath is expanded
isExpanded
(TreePath
TreePath to check
path
)

Returns true if the value identified by row is currently expanded.

protected boolean

Returns:

whether the height of each row is a fixed size
isFixedRowHeight
()

Returns true if the height of each row is a fixed size.

public boolean

Returns:

true if the root node of the tree is displayed
isRootVisible
()

Returns true if the root node of the tree is displayed.

public abstract void
setExpandedState(TreePath
the path being expanded or collapsed
path
,
boolean
true if the path should be expanded, false otherwise
isExpanded
)

Marks the path path expanded state to isExpanded.

public void
setModel(TreeModel
the TreeModel that is to provide the data
newModel
)

Sets the TreeModel that will provide the data.

public void
setNodeDimensions(AbstractLayoutCache.NodeDimensions
a NodeDimensions object
nd
)

Sets the renderer that is responsible for drawing nodes in the tree and which is therefore responsible for calculating the dimensions of individual nodes.

public void
setRootVisible(boolean
true if the root node of the tree is to be displayed
rootVisible
)

Determines whether or not the root node from the TreeModel is visible.

public void
setRowHeight(int
the height of each cell, in pixels
rowHeight
)

Sets the height of each cell.

public void
setSelectionModel(TreeSelectionModel
the new TreeSelectionModel
newLSM
)

Sets the TreeSelectionModel used to manage the selection to new LSM.

public abstract void
treeNodesChanged(TreeModelEvent
the TreeModelEvent
e
)

Invoked after a node (or a set of siblings) has changed in some way.

public abstract void
treeNodesInserted(TreeModelEvent
the TreeModelEvent
e
)

Invoked after nodes have been inserted into the tree.

public abstract void
treeNodesRemoved(TreeModelEvent
the TreeModelEvent
e
)

Invoked after nodes have been removed from the tree.

public abstract void
treeStructureChanged(TreeModelEvent
the TreeModelEvent
e
)

Invoked after the tree has drastically changed structure from a given node down.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nodeDimensionsback to summary
protected AbstractLayoutCache.NodeDimensions nodeDimensions

Object responsible for getting the size of a node.

rootVisibleback to summary
protected boolean rootVisible

True if the root node is displayed, false if its children are the highest visible nodes.

rowHeightback to summary
protected int rowHeight

Height to use for each row. If this is <= 0 the renderer will be used to determine the height for each row.

treeModelback to summary
protected TreeModel treeModel

Model providing information.

treeSelectionModelback to summary
protected TreeSelectionModel treeSelectionModel

Selection model.

Constructor Detail

AbstractLayoutCacheback to summary
protected AbstractLayoutCache()

Constructor for subclasses to call.

Method Detail

getBoundsback to summary
public abstract Rectangle getBounds(TreePath path, Rectangle placeIn)

Returns a rectangle giving the bounds needed to draw path.

Parameters
path:TreePath

a TreePath specifying a node

placeIn:Rectangle

a Rectangle object giving the available space

Returns:Rectangle

a Rectangle object specifying the space to be used

getExpandedStateback to summary
public abstract boolean getExpandedState(TreePath path)

Returns true if the path is expanded, and visible.

Parameters
path:TreePath

the path being queried

Returns:boolean

true if the path is expanded and visible, false otherwise

getModelback to summary
public TreeModel getModel()

Returns the TreeModel that is providing the data.

Returns:TreeModel

the TreeModel that is providing the data

getNodeDimensionsback to summary
public AbstractLayoutCache.NodeDimensions getNodeDimensions()

Returns the object that renders nodes in the tree, and which is responsible for calculating the dimensions of individual nodes.

Returns:AbstractLayoutCache.NodeDimensions

the NodeDimensions object

getNodeDimensionsback to summary
protected Rectangle getNodeDimensions(Object value, int row, int depth, boolean expanded, Rectangle placeIn)

Returns, by reference in placeIn, the size needed to represent value. If inPlace is null, a newly created Rectangle should be returned, otherwise the value should be placed in inPlace and returned. This will return null if there is no renderer.

Parameters
value:Object

the value to be represented

row:int

row being queried

depth:int

the depth of the row

expanded:boolean

true if row is expanded, false otherwise

placeIn:Rectangle

a Rectangle containing the size needed to represent value

Returns:Rectangle

a Rectangle containing the node dimensions, or null if node has no dimension

getPathClosestToback to summary
public abstract TreePath getPathClosestTo(int x, int y)

Returns the path to the node that is closest to x,y. If there is nothing currently visible this will return null, otherwise it'll always return a valid path. If you need to test if the returned object is exactly at x, y you should get the bounds for the returned path and test x, y against that.

Parameters
x:int

the horizontal component of the desired location

y:int

the vertical component of the desired location

Returns:TreePath

the TreePath closest to the specified point

getPathForRowback to summary
public abstract TreePath getPathForRow(int row)

Returns the path for passed in row. If row is not visible null is returned.

Parameters
row:int

the row being queried

Returns:TreePath

the TreePath for the given row

getPreferredHeightback to summary
public int getPreferredHeight()

Returns the preferred height.

Returns:int

the preferred height

getPreferredWidthback to summary
public int getPreferredWidth(Rectangle bounds)

Returns the preferred width for the passed in region. The region is defined by the path closest to (bounds.x, bounds.y) and ends at bounds.height + bounds.y. If bounds is null, the preferred width for all the nodes will be returned (and this may be a VERY expensive computation).

Parameters
bounds:Rectangle

the region being queried

Returns:int

the preferred width for the passed in region

getRowCountback to summary
public abstract int getRowCount()

Number of rows being displayed.

Returns:int

the number of rows being displayed

getRowForPathback to summary
public abstract int getRowForPath(TreePath path)

Returns the row that the last item identified in path is visible at. Will return -1 if any of the elements in path are not currently visible.

Parameters
path:TreePath

the TreePath being queried

Returns:int

the row where the last item in path is visible or -1 if any elements in path aren't currently visible

getRowHeightback to summary
public int getRowHeight()

Returns the height of each row. If the returned value is less than or equal to 0 the height for each row is determined by the renderer.

Returns:int

the height of each row

getRowsForPathsback to summary
public int[] getRowsForPaths(TreePath[] paths)

Implements javax.swing.tree.RowMapper.getRowsForPaths.

Returns the rows that the TreePath instances in path are being displayed at. This method should return an array of the same length as that passed in, and if one of the TreePaths in path is not valid its entry in the array should be set to -1.

Parameters
paths:TreePath[]

the array of TreePaths being queried

Returns:int[]

an array of the same length that is passed in containing the rows that each corresponding where each TreePath is displayed; if paths is null, null is returned

getSelectionModelback to summary
public TreeSelectionModel getSelectionModel()

Returns the model used to maintain the selection.

Returns:TreeSelectionModel

the treeSelectionModel

getVisibleChildCountback to summary
public abstract int getVisibleChildCount(TreePath path)

Returns the number of visible children for row.

Parameters
path:TreePath

the path being queried

Returns:int

the number of visible children for the specified path

getVisiblePathsFromback to summary
public abstract Enumeration<TreePath> getVisiblePathsFrom(TreePath path)

Returns an Enumerator that increments over the visible paths starting at the passed in location. The ordering of the enumeration is based on how the paths are displayed. The first element of the returned enumeration will be path, unless it isn't visible, in which case null will be returned.

Parameters
path:TreePath

the starting location for the enumeration

Returns:Enumeration<TreePath>

the Enumerator starting at the desired location

invalidatePathBoundsback to summary
public abstract void invalidatePathBounds(TreePath path)

Instructs the LayoutCache that the bounds for path are invalid, and need to be updated.

Parameters
path:TreePath

the path being updated

invalidateSizesback to summary
public abstract void invalidateSizes()

Informs the TreeState that it needs to recalculate all the sizes it is referencing.

isExpandedback to summary
public abstract boolean isExpanded(TreePath path)

Returns true if the value identified by row is currently expanded.

Parameters
path:TreePath

TreePath to check

Returns:boolean

whether TreePath is expanded

isFixedRowHeightback to summary
protected boolean isFixedRowHeight()

Returns true if the height of each row is a fixed size.

Returns:boolean

whether the height of each row is a fixed size

isRootVisibleback to summary
public boolean isRootVisible()

Returns true if the root node of the tree is displayed.

Returns:boolean

true if the root node of the tree is displayed

See Also
rootVisible
setExpandedStateback to summary
public abstract void setExpandedState(TreePath path, boolean isExpanded)

Marks the path path expanded state to isExpanded.

Parameters
path:TreePath

the path being expanded or collapsed

isExpanded:boolean

true if the path should be expanded, false otherwise

setModelback to summary
public void setModel(TreeModel newModel)

Sets the TreeModel that will provide the data.

Parameters
newModel:TreeModel

the TreeModel that is to provide the data

setNodeDimensionsback to summary
public void setNodeDimensions(AbstractLayoutCache.NodeDimensions nd)

Sets the renderer that is responsible for drawing nodes in the tree and which is therefore responsible for calculating the dimensions of individual nodes.

Parameters
nd:AbstractLayoutCache.NodeDimensions

a NodeDimensions object

setRootVisibleback to summary
public void setRootVisible(boolean rootVisible)

Determines whether or not the root node from the TreeModel is visible.

Parameters
rootVisible:boolean

true if the root node of the tree is to be displayed

Annotations
@BeanProperty
description:Whether or not the root node from the TreeModel is visible.
See Also
rootVisible
setRowHeightback to summary
public void setRowHeight(int rowHeight)

Sets the height of each cell. If the specified value is less than or equal to zero the current cell renderer is queried for each row's height.

Parameters
rowHeight:int

the height of each cell, in pixels

Annotations
@BeanProperty
description:The height of each cell.
setSelectionModelback to summary
public void setSelectionModel(TreeSelectionModel newLSM)

Sets the TreeSelectionModel used to manage the selection to new LSM.

Parameters
newLSM:TreeSelectionModel

the new TreeSelectionModel

treeNodesChangedback to summary
public abstract void treeNodesChanged(TreeModelEvent e)

Invoked after a node (or a set of siblings) has changed in some way. The node(s) have not changed locations in the tree or altered their children arrays, but other attributes have changed and may affect presentation. Example: the name of a file has changed, but it is in the same location in the file system.

e.path() returns the path the parent of the changed node(s).

e.childIndices() returns the index(es) of the changed node(s).

Parameters
e:TreeModelEvent

the TreeModelEvent

treeNodesInsertedback to summary
public abstract void treeNodesInserted(TreeModelEvent e)

Invoked after nodes have been inserted into the tree.

e.path() returns the parent of the new nodes

e.childIndices() returns the indices of the new nodes in ascending order.

Parameters
e:TreeModelEvent

the TreeModelEvent

treeNodesRemovedback to summary
public abstract void treeNodesRemoved(TreeModelEvent e)

Invoked after nodes have been removed from the tree. Note that if a subtree is removed from the tree, this method may only be invoked once for the root of the removed subtree, not once for each individual set of siblings removed.

e.path() returns the former parent of the deleted nodes.

e.childIndices() returns the indices the nodes had before they were deleted in ascending order.

Parameters
e:TreeModelEvent

the TreeModelEvent

treeStructureChangedback to summary
public abstract void treeStructureChanged(TreeModelEvent e)

Invoked after the tree has drastically changed structure from a given node down. If the path returned by e.getPath() is of length one and the first element does not identify the current root node the first element should become the new root of the tree.

e.path() holds the path to the node.

e.childIndices() returns null.

Parameters
e:TreeModelEvent

the TreeModelEvent

javax.swing.tree back to summary

public abstract Class AbstractLayoutCache.NodeDimensions

extends Object
Class Inheritance
Known Direct Subclasses
javax.swing.plaf.basic.BasicTreeUI.NodeDimensionsHandler

Used by AbstractLayoutCache to determine the size and x origin of a particular node.

Constructor Summary

AccessConstructor and Description
protected
NodeDimensions()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
public abstract Rectangle

Returns:

a Rectangle containing the node dimensions, or null if node has no dimension
getNodeDimensions
(Object
the value to be represented
value
,
int
row being queried
row
,
int
the depth of the row
depth
,
boolean
true if row is expanded, false otherwise
expanded
,
Rectangle
a Rectangle containing the size needed to represent value
bounds
)

Returns, by reference in bounds, the size and x origin to place value at.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

NodeDimensionsback to summary
protected NodeDimensions()

Constructor for subclasses to call.

Method Detail

getNodeDimensionsback to summary
public abstract Rectangle getNodeDimensions(Object value, int row, int depth, boolean expanded, Rectangle bounds)

Returns, by reference in bounds, the size and x origin to place value at. The calling method is responsible for determining the Y location. If bounds is null, a newly created Rectangle should be returned, otherwise the value should be placed in bounds and returned.

Parameters
value:Object

the value to be represented

row:int

row being queried

depth:int

the depth of the row

expanded:boolean

true if row is expanded, false otherwise

bounds:Rectangle

a Rectangle containing the size needed to represent value

Returns:Rectangle

a Rectangle containing the node dimensions, or null if node has no dimension