APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing.tree

public Class VariableHeightLayoutCache

extends AbstractLayoutCache
Class Inheritance
Annotations
@SuppressWarnings:serial
Imports
javax.swing.event.TreeModelEvent, java.awt.Rectangle, java.beans.BeanProperty, java.util.Enumeration, .Hashtable, .NoSuchElementException, .Stack, .Vector, sun.swing.SwingUtilities2

Note

This will become more open in a future release.

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.

Authors
Rob Davis, Ray Ryan, Scott Violet

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
VariableHeightLayoutCache.TreeStateNode

TreeStateNode is used to keep track of each of the nodes that have been expanded.

private class
VariableHeightLayoutCache.VisibleTreeStateNodeEnumeration

An enumerator to iterate through visible nodes.

Field Summary

Modifier and TypeField and Description
private Rectangle
boundsBuffer

Used in getting sizes for nodes to avoid creating a new Rectangle every time a size is needed.

private VariableHeightLayoutCache.TreeStateNode
root

The root node of the internal cache of nodes that have been shown.

private Stack<Stack<TreePath>>
tempStacks

A stack of stacks.

private Hashtable<TreePath, VariableHeightLayoutCache.TreeStateNode>
treePathMapping

Maps from TreePath to a TreeStateNode.

private boolean
updateNodeSizes

This is set to true if one of the entries has an invalid size.

private Vector<Object>
visibleNodes

The array of nodes that are currently visible, in the order they are displayed.

Inherited from javax.swing.tree.AbstractLayoutCache:
nodeDimensionsrootVisiblerowHeighttreeModeltreeSelectionModel

Constructor Summary

AccessConstructor and Description
public
VariableHeightLayoutCache()

Constructs a VariableHeightLayoutCache.

Method Summary

Modifier and TypeMethod and Description
private void
addMapping(VariableHeightLayoutCache.TreeStateNode node)

Adds a mapping for node.

private VariableHeightLayoutCache.TreeStateNode
createNodeAt(VariableHeightLayoutCache.TreeStateNode parent, int childIndex)

Creates a new node to represent the node at childIndex in parents children.

private VariableHeightLayoutCache.TreeStateNode
createNodeForValue(Object value)

Responsible for creating a TreeStateNode that will be used to track display information about value.

private void
ensurePathIsExpanded(TreePath aPath, boolean expandLast)

Ensures that all the path components in path are expanded, accept for the last component which will only be expanded if expandLast is true.

public Rectangle

Returns:

the bounds of the enclosing rectangle or null if the node could not be ascertained
getBounds
(TreePath
the path to be drawn
path
,
Rectangle
the bounds of the enclosing rectangle
placeIn
)

Implements abstract javax.swing.tree.AbstractLayoutCache.getBounds.

Returns the Rectangle enclosing the label portion into which the item identified by path will be drawn.

private Rectangle
getBounds(int row, Rectangle placeIn)

Returns the bounds for row, row by reference in placeIn.

public boolean

Returns:

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

Implements abstract javax.swing.tree.AbstractLayoutCache.getExpandedState.

Returns true if the path is expanded, and visible.

private VariableHeightLayoutCache.TreeStateNode
getMapping(TreePath path)

Returns the node previously added for path.

private int
getMaxNodeWidth()

Returns the maximum node width.

private VariableHeightLayoutCache.TreeStateNode
getNode(int row)

Returns the AbstractTreeUI.VisibleNode displayed at the given row

private VariableHeightLayoutCache.TreeStateNode
getNodeForPath(TreePath path, boolean onlyIfVisible, boolean shouldCreate)

Returns the TreeStateNode identified by path.

public TreePath

Returns:

the path to the node that is closest to x, y
getPathClosestTo
(int
the x-coordinate
x
,
int
the y-coordinate
y
)

Implements abstract javax.swing.tree.AbstractLayoutCache.getPathClosestTo.

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

public TreePath

Returns:

the path for row, or null if row is not visible
getPathForRow
(int
the location of interest
row
)

Implements abstract javax.swing.tree.AbstractLayoutCache.getPathForRow.

Returns the path for row.

public int

Returns:

the preferred height
getPreferredHeight
()

Overrides javax.swing.tree.AbstractLayoutCache.getPreferredHeight.

Returns the preferred height.

public int
getPreferredWidth(Rectangle
the region being queried
bounds
)

Overrides javax.swing.tree.AbstractLayoutCache.getPreferredWidth.

Returns the preferred width and height for the region in visibleRegion.

private int
getRowContainingYLocation(int location)

Returns the index of the row containing location.

public int

Returns:

the number of visible rows
getRowCount
()

Implements abstract javax.swing.tree.AbstractLayoutCache.getRowCount.

Returns the number of visible rows.

public int

Returns:

the row where the last item in path is visible
getRowForPath
(TreePath
the TreePath of interest
path
)

Implements abstract javax.swing.tree.AbstractLayoutCache.getRowForPath.

Returns the row where the last item identified in path is visible.

public int

Returns:

the number of visible children for path
getVisibleChildCount
(TreePath path)

Implements abstract javax.swing.tree.AbstractLayoutCache.getVisibleChildCount.

Returns the number of visible children for path.

public Enumeration<TreePath>

Returns:

an Enumerator that increments over the visible paths
getVisiblePathsFrom
(TreePath
the location in the TreePath to start
path
)

Implements abstract javax.swing.tree.AbstractLayoutCache.getVisiblePathsFrom.

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

public void
invalidatePathBounds(TreePath
the TreePath which is now invalid
path
)

Implements abstract javax.swing.tree.AbstractLayoutCache.invalidatePathBounds.

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

public void
invalidateSizes()

Implements abstract javax.swing.tree.AbstractLayoutCache.invalidateSizes.

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

public boolean

Returns:

true if the value identified by path is currently expanded
isExpanded
(TreePath path)

Implements abstract javax.swing.tree.AbstractLayoutCache.isExpanded.

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

private void
rebuild(boolean clearSelection)

Completely rebuild the tree, all expanded state, and node caches are removed.

private void
removeMapping(VariableHeightLayoutCache.TreeStateNode node)

Removes the mapping for a previously added node.

public void
setExpandedState(TreePath
the TreePath of interest
path
,
boolean
true if the path should be expanded, otherwise false
isExpanded
)

Implements abstract javax.swing.tree.AbstractLayoutCache.setExpandedState.

Marks the path path expanded state to isExpanded.

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

Overrides javax.swing.tree.AbstractLayoutCache.setModel.

Sets the TreeModel that will provide the data.

public void
setNodeDimensions(AbstractLayoutCache.NodeDimensions
the renderer
nd
)

Overrides javax.swing.tree.AbstractLayoutCache.setNodeDimensions.

Sets the renderer that is responsible for drawing nodes in the tree.

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

Overrides javax.swing.tree.AbstractLayoutCache.setRootVisible.

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

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

Overrides javax.swing.tree.AbstractLayoutCache.setRowHeight.

Sets the height of each cell.

public void
treeNodesChanged(TreeModelEvent
the TreeModelEvent of interest
e
)

Implements abstract javax.swing.tree.AbstractLayoutCache.treeNodesChanged.

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

public void
treeNodesInserted(TreeModelEvent
the TreeModelEvent of interest
e
)

Implements abstract javax.swing.tree.AbstractLayoutCache.treeNodesInserted.

Invoked after nodes have been inserted into the tree.

public void
treeNodesRemoved(TreeModelEvent
the TreeModelEvent of interest
e
)

Implements abstract javax.swing.tree.AbstractLayoutCache.treeNodesRemoved.

Invoked after nodes have been removed from the tree.

public void
treeStructureChanged(TreeModelEvent
the TreeModelEvent of interest
e
)

Implements abstract javax.swing.tree.AbstractLayoutCache.treeStructureChanged.

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

private void
updateNodeSizes(boolean updateAll)

Resets the y origin of all the visible nodes as well as messaging all the visible nodes to updatePreferredSize().

private void
updateYLocationsFrom(int location)

Updates the y locations of all of the visible nodes after location.

private void
Inherited from javax.swing.tree.AbstractLayoutCache:
getModelgetNodeDimensionsgetNodeDimensionsgetRowHeightgetRowsForPathsgetSelectionModelisFixedRowHeightisRootVisiblesetSelectionModel

Field Detail

boundsBufferback to summary
private Rectangle boundsBuffer

Used in getting sizes for nodes to avoid creating a new Rectangle every time a size is needed.

rootback to summary
private VariableHeightLayoutCache.TreeStateNode root

The root node of the internal cache of nodes that have been shown. If the treeModel is vending a network rather than a true tree, there may be one cached node for each path to a modeled node.

tempStacksback to summary
private Stack<Stack<TreePath>> tempStacks

A stack of stacks.

treePathMappingback to summary
private Hashtable<TreePath, VariableHeightLayoutCache.TreeStateNode> treePathMapping

Maps from TreePath to a TreeStateNode.

updateNodeSizesback to summary
private boolean updateNodeSizes

This is set to true if one of the entries has an invalid size.

visibleNodesback to summary
private Vector<Object> visibleNodes

The array of nodes that are currently visible, in the order they are displayed.

Constructor Detail

VariableHeightLayoutCacheback to summary
public VariableHeightLayoutCache()

Constructs a VariableHeightLayoutCache.

Method Detail

addMappingback to summary
private void addMapping(VariableHeightLayoutCache.TreeStateNode node)

Adds a mapping for node.

createNodeAtback to summary
private VariableHeightLayoutCache.TreeStateNode createNodeAt(VariableHeightLayoutCache.TreeStateNode parent, int childIndex)

Creates a new node to represent the node at childIndex in parents children. This should be called if the node doesn't already exist and parent has been expanded at least once. The newly created node will be made visible if parent is currently expanded. This does not update the position of any cells, nor update the selection if it needs to be. If successful in creating the new TreeStateNode, it is returned, otherwise null is returned.

createNodeForValueback to summary
private VariableHeightLayoutCache.TreeStateNode createNodeForValue(Object value)

Responsible for creating a TreeStateNode that will be used to track display information about value.

ensurePathIsExpandedback to summary
private void ensurePathIsExpanded(TreePath aPath, boolean expandLast)

Ensures that all the path components in path are expanded, accept for the last component which will only be expanded if expandLast is true. Returns true if successful in finding the path.

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

Implements abstract javax.swing.tree.AbstractLayoutCache.getBounds.

Returns the Rectangle enclosing the label portion into which the item identified by path will be drawn.

Parameters
path:TreePath

the path to be drawn

placeIn:Rectangle

the bounds of the enclosing rectangle

Returns:Rectangle

the bounds of the enclosing rectangle or null if the node could not be ascertained

getBoundsback to summary
private Rectangle getBounds(int row, Rectangle placeIn)

Returns the bounds for row, row by reference in placeIn. If placeIn is null a new Rectangle will be created and returned.

getExpandedStateback to summary
public boolean getExpandedState(TreePath path)

Implements abstract javax.swing.tree.AbstractLayoutCache.getExpandedState.

Returns true if the path is expanded, and visible.

Returns:boolean

true if the path is expanded and visible, otherwise false

getMappingback to summary
private VariableHeightLayoutCache.TreeStateNode getMapping(TreePath path)

Returns the node previously added for path. This may return null, if you to create a node use getNodeForPath.

getMaxNodeWidthback to summary
private int getMaxNodeWidth()

Returns the maximum node width.

getNodeback to summary
private VariableHeightLayoutCache.TreeStateNode getNode(int row)

Returns the AbstractTreeUI.VisibleNode displayed at the given row

getNodeForPathback to summary
private VariableHeightLayoutCache.TreeStateNode getNodeForPath(TreePath path, boolean onlyIfVisible, boolean shouldCreate)

Returns the TreeStateNode identified by path. This mirrors the behavior of getNodeForPath, but tries to take advantage of path if it is an instance of AbstractTreePath.

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

Implements abstract javax.swing.tree.AbstractLayoutCache.getPathClosestTo.

Returns the path to the node that is closest to x,y. If there is nothing currently visible this will return null, otherwise it will 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 x-coordinate

y:int

the y-coordinate

Returns:TreePath

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

getPathForRowback to summary
public TreePath getPathForRow(int row)

Implements abstract javax.swing.tree.AbstractLayoutCache.getPathForRow.

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

Parameters
row:int

the location of interest

Returns:TreePath

the path for row, or null if row is not visible

getPreferredHeightback to summary
public int getPreferredHeight()

Overrides javax.swing.tree.AbstractLayoutCache.getPreferredHeight.

Returns the preferred height.

Returns:int

the preferred height

getPreferredWidthback to summary
public int getPreferredWidth(Rectangle bounds)

Overrides javax.swing.tree.AbstractLayoutCache.getPreferredWidth.

Returns the preferred width and height for the region in visibleRegion.

Parameters
bounds:Rectangle

the region being queried

getRowContainingYLocationback to summary
private int getRowContainingYLocation(int location)

Returns the index of the row containing location. If there are no rows, -1 is returned. If location is beyond the last row index, the last row index is returned.

getRowCountback to summary
public int getRowCount()

Implements abstract javax.swing.tree.AbstractLayoutCache.getRowCount.

Returns the number of visible rows.

Returns:int

the number of visible rows

getRowForPathback to summary
public int getRowForPath(TreePath path)

Implements abstract javax.swing.tree.AbstractLayoutCache.getRowForPath.

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

Parameters
path:TreePath

the TreePath of interest

Returns:int

the row where the last item in path is visible

getVisibleChildCountback to summary
public int getVisibleChildCount(TreePath path)

Implements abstract javax.swing.tree.AbstractLayoutCache.getVisibleChildCount.

Returns the number of visible children for path.

Returns:int

the number of visible children for path

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

Implements abstract javax.swing.tree.AbstractLayoutCache.getVisiblePathsFrom.

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.

Parameters
path:TreePath

the location in the TreePath to start

Returns:Enumeration<TreePath>

an Enumerator that increments over the visible paths

invalidatePathBoundsback to summary
public void invalidatePathBounds(TreePath path)

Implements abstract javax.swing.tree.AbstractLayoutCache.invalidatePathBounds.

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

Parameters
path:TreePath

the TreePath which is now invalid

invalidateSizesback to summary
public void invalidateSizes()

Implements abstract javax.swing.tree.AbstractLayoutCache.invalidateSizes.

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

isExpandedback to summary
public boolean isExpanded(TreePath path)

Implements abstract javax.swing.tree.AbstractLayoutCache.isExpanded.

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

Returns:boolean

true if the value identified by path is currently expanded

rebuildback to summary
private void rebuild(boolean clearSelection)

Completely rebuild the tree, all expanded state, and node caches are removed. All nodes are collapsed, except the root.

removeMappingback to summary
private void removeMapping(VariableHeightLayoutCache.TreeStateNode node)

Removes the mapping for a previously added node.

setExpandedStateback to summary
public void setExpandedState(TreePath path, boolean isExpanded)

Implements abstract javax.swing.tree.AbstractLayoutCache.setExpandedState.

Marks the path path expanded state to isExpanded.

Parameters
path:TreePath

the TreePath of interest

isExpanded:boolean

true if the path should be expanded, otherwise false

setModelback to summary
public void setModel(TreeModel newModel)

Overrides javax.swing.tree.AbstractLayoutCache.setModel.

Sets the TreeModel that will provide the data.

Parameters
newModel:TreeModel

the TreeModel that is to provide the data

Annotations
@BeanProperty
description:The TreeModel that will provide the data.
setNodeDimensionsback to summary
public void setNodeDimensions(AbstractLayoutCache.NodeDimensions nd)

Overrides javax.swing.tree.AbstractLayoutCache.setNodeDimensions.

Sets the renderer that is responsible for drawing nodes in the tree.

Parameters
nd:AbstractLayoutCache.NodeDimensions

the renderer

setRootVisibleback to summary
public void setRootVisible(boolean rootVisible)

Overrides javax.swing.tree.AbstractLayoutCache.setRootVisible.

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)

Overrides javax.swing.tree.AbstractLayoutCache.setRowHeight.

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.
treeNodesChangedback to summary
public void treeNodesChanged(TreeModelEvent e)

Implements abstract javax.swing.tree.AbstractLayoutCache.treeNodesChanged.

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 of interest

treeNodesInsertedback to summary
public void treeNodesInserted(TreeModelEvent e)

Implements abstract javax.swing.tree.AbstractLayoutCache.treeNodesInserted.

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 of interest

treeNodesRemovedback to summary
public void treeNodesRemoved(TreeModelEvent e)

Implements abstract javax.swing.tree.AbstractLayoutCache.treeNodesRemoved.

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 of interest

treeStructureChangedback to summary
public void treeStructureChanged(TreeModelEvent e)

Implements abstract javax.swing.tree.AbstractLayoutCache.treeStructureChanged.

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 of interest

updateNodeSizesback to summary
private void updateNodeSizes(boolean updateAll)

Resets the y origin of all the visible nodes as well as messaging all the visible nodes to updatePreferredSize(). You should not normally have to call this. Expanding and contracting the nodes automatically adjusts the locations. updateAll determines if updatePreferredSize() is call on all nodes or just those that don't have a valid size.

updateYLocationsFromback to summary
private void updateYLocationsFrom(int location)

Updates the y locations of all of the visible nodes after location.

visibleNodesChangedback to summary
private void visibleNodesChanged()
javax.swing.tree back to summary

private Class VariableHeightLayoutCache.TreeStateNode

extends DefaultMutableTreeNode
Class Inheritance

TreeStateNode is used to keep track of each of the nodes that have been expanded. This will also cache the preferred size of the value it represents.

Field Summary

Modifier and TypeField and Description
protected boolean
expanded

Is this node currently expanded?

protected boolean
hasBeenExpanded

Has this node been expanded at least once?

protected TreePath
path

Path of this node.

protected int
protected int
preferredWidth

Preferred size needed to draw the user object.

protected int
xOrigin

X location that the user object will be drawn at.

protected int
yOrigin

Y location that the user object will be drawn at.

Inherited from javax.swing.tree.DefaultMutableTreeNode:
allowsChildrenchildrenEMPTY_ENUMERATIONparentuserObject

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Enumeration<TreeNode>
children()

Overrides javax.swing.tree.DefaultMutableTreeNode.children.

Implements javax.swing.tree.TreeNode.children.

Returns the children of the receiver.

public void
collapse()

Collapses the receiver.

protected void
collapse(boolean adjustTree)

Collapses this node in the tree.

protected void
deepMarkSizeInvalid()

Marks the receivers size, and all its descendants sizes, as invalid.

protected void
didAdjustTree()

Messaged from expand and collapse.

public void
expand()

Expands the receiver.

protected void
expand(boolean adjustTree)

Expands this node in the tree.

protected void
expandParentAndReceiver()

Invokes expandParentAndReceiver on the parent, and expands the receiver.

public VariableHeightLayoutCache.TreeStateNode
getLastVisibleNode()

Returns the last visible node that is a child of this instance.

protected Enumeration<TreeNode>
getLoadedChildren(boolean createIfNeeded)

Returns the children of the receiver.

public int
getModelChildCount()

Returns the number of children this will have.

public Rectangle
getNodeBounds(Rectangle placeIn)

Returns the location and size of this node.

public int
getPreferredHeight()

Returns the preferred height of the receiver.

public int
getPreferredWidth()

Returns the preferred width of the receiver.

public int
getRow()

Returns the row of the receiver.

public TreePath
getTreePath()

Returns a TreePath instance for this node.

public Object
getValue()

Returns the value the receiver is representing.

public int
getVisibleChildCount()

Returns the number of visible children, that is the number of children that are expanded, or leafs.

public int
getXOrigin()

Returns: x location to draw node at.

public int
getYOrigin()

Returns the y origin the user object will be drawn at.

public boolean
hasBeenExpanded()

Returns true if this node has been expanded at least once.

public boolean
hasValidSize()

Returns true if this node has a valid size.

public boolean
isExpanded()

Returns true if the receiver has been expanded.

public boolean
isLeaf()

Overrides javax.swing.tree.DefaultMutableTreeNode.isLeaf.

Implements javax.swing.tree.TreeNode.isLeaf.

Returns true if the receiver is a leaf.

public boolean
isVisible()

Returns true if the receiver is currently visible.

public void
makeVisible()

Makes the receiver visible, but invoking expandParentAndReceiver on the superclass.

protected void
markSizeInvalid()

Marks the receivers size as invalid.

public void
remove(int childIndex)

Overrides javax.swing.tree.DefaultMutableTreeNode.remove.

Implements javax.swing.tree.MutableTreeNode.remove.

Messaged when this node is removed from its parent, this messages removedFromMapping to remove all the children.

protected void
removeFromMapping()

Removes the receiver, and all its children, from the mapping table.

protected void
resetChildrenPaths(TreePath parentPath)

Recreates the receivers path, and all its children's paths.

public void
setParent(MutableTreeNode parent)

Overrides javax.swing.tree.DefaultMutableTreeNode.setParent.

Implements javax.swing.tree.MutableTreeNode.setParent.

Messaged when this node is added somewhere, resets the path and adds a mapping from path to this node.

public void
protected void
setYOrigin(int newYOrigin)

Sets y origin the user object will be drawn at to newYOrigin.

protected void
shiftYOriginBy(int offset)

Shifts the y origin by offset.

public void
toggleExpanded()

Toggles the receiver between expanded and collapsed.

protected void
updatePreferredSize()

Updates the receivers preferredSize by invoking updatePreferredSize with an argument of -1.

protected void
updatePreferredSize(int index)

Updates the preferred size by asking the current renderer for the Dimension needed to draw the user object this instance represents.

Inherited from javax.swing.tree.DefaultMutableTreeNode:
addbreadthFirstEnumerationclonedepthFirstEnumerationgetAllowsChildrengetChildAftergetChildAtgetChildBeforegetChildCountgetDepthgetFirstChildgetFirstLeafgetIndexgetLastChildgetLastLeafgetLeafCountgetLevelgetNextLeafgetNextNodegetNextSiblinggetParentgetPathgetPathToRootgetPreviousLeafgetPreviousNodegetPreviousSiblinggetRootgetSharedAncestorgetSiblingCountgetUserObjectgetUserObjectPathinsertisNodeAncestorisNodeChildisNodeDescendantisNodeRelatedisNodeSiblingisRootpathFromAncestorEnumerationpostorderEnumerationpreorderEnumerationremoveremoveAllChildrenremoveFromParentsetAllowsChildrentoString

Field Detail

expandedback to summary
protected boolean expanded

Is this node currently expanded?

hasBeenExpandedback to summary
protected boolean hasBeenExpanded

Has this node been expanded at least once?

pathback to summary
protected TreePath path

Path of this node.

preferredHeightback to summary
protected int preferredHeight
preferredWidthback to summary
protected int preferredWidth

Preferred size needed to draw the user object.

xOriginback to summary
protected int xOrigin

X location that the user object will be drawn at.

yOriginback to summary
protected int yOrigin

Y location that the user object will be drawn at.

Constructor Detail

TreeStateNodeback to summary
public TreeStateNode(Object value)

Method Detail

childrenback to summary
public Enumeration<TreeNode> children()

Overrides javax.swing.tree.DefaultMutableTreeNode.children.

Implements javax.swing.tree.TreeNode.children.

Returns the children of the receiver. If the receiver is not currently expanded, this will return an empty enumeration.

Annotations
@Override
collapseback to summary
public void collapse()

Collapses the receiver.

collapseback to summary
protected void collapse(boolean adjustTree)

Collapses this node in the tree. If adjustTree is true the tree and selection are updated accordingly.

deepMarkSizeInvalidback to summary
protected void deepMarkSizeInvalid()

Marks the receivers size, and all its descendants sizes, as invalid.

didAdjustTreeback to summary
protected void didAdjustTree()

Messaged from expand and collapse. This is meant for subclassers that may wish to do something interesting with this.

expandback to summary
public void expand()

Expands the receiver.

expandback to summary
protected void expand(boolean adjustTree)

Expands this node in the tree. This will load the children from the treeModel if this node has not previously been expanded. If adjustTree is true the tree and selection are updated accordingly.

expandParentAndReceiverback to summary
protected void expandParentAndReceiver()

Invokes expandParentAndReceiver on the parent, and expands the receiver.

getLastVisibleNodeback to summary
public VariableHeightLayoutCache.TreeStateNode getLastVisibleNode()

Returns the last visible node that is a child of this instance.

getLoadedChildrenback to summary
protected Enumeration<TreeNode> getLoadedChildren(boolean createIfNeeded)

Returns the children of the receiver. If the children haven't been loaded from the model and createIfNeeded is true, the children are first loaded.

getModelChildCountback to summary
public int getModelChildCount()

Returns the number of children this will have. If the children have not yet been loaded, this messages the model.

getNodeBoundsback to summary
public Rectangle getNodeBounds(Rectangle placeIn)

Returns the location and size of this node.

getPreferredHeightback to summary
public int getPreferredHeight()

Returns the preferred height of the receiver.

getPreferredWidthback to summary
public int getPreferredWidth()

Returns the preferred width of the receiver.

getRowback to summary
public int getRow()

Returns the row of the receiver.

getTreePathback to summary
public TreePath getTreePath()

Returns a TreePath instance for this node.

getValueback to summary
public Object getValue()

Returns the value the receiver is representing. This is a cover for getUserObject.

getVisibleChildCountback to summary
public int getVisibleChildCount()

Returns the number of visible children, that is the number of children that are expanded, or leafs.

getXOriginback to summary
public int getXOrigin()
Returns:int

x location to draw node at.

getYOriginback to summary
public int getYOrigin()

Returns the y origin the user object will be drawn at.

hasBeenExpandedback to summary
public boolean hasBeenExpanded()

Returns true if this node has been expanded at least once.

hasValidSizeback to summary
public boolean hasValidSize()

Returns true if this node has a valid size.

isExpandedback to summary
public boolean isExpanded()

Returns true if the receiver has been expanded.

isLeafback to summary
public boolean isLeaf()

Overrides javax.swing.tree.DefaultMutableTreeNode.isLeaf.

Implements javax.swing.tree.TreeNode.isLeaf.

Returns true if the receiver is a leaf.

isVisibleback to summary
public boolean isVisible()

Returns true if the receiver is currently visible.

makeVisibleback to summary
public void makeVisible()

Makes the receiver visible, but invoking expandParentAndReceiver on the superclass.

markSizeInvalidback to summary
protected void markSizeInvalid()

Marks the receivers size as invalid. Next time the size, location is asked for it will be obtained.

removeback to summary
public void remove(int childIndex)

Overrides javax.swing.tree.DefaultMutableTreeNode.remove.

Implements javax.swing.tree.MutableTreeNode.remove.

Messaged when this node is removed from its parent, this messages removedFromMapping to remove all the children.

removeFromMappingback to summary
protected void removeFromMapping()

Removes the receiver, and all its children, from the mapping table.

resetChildrenPathsback to summary
protected void resetChildrenPaths(TreePath parentPath)

Recreates the receivers path, and all its children's paths.

setParentback to summary
public void setParent(MutableTreeNode parent)

Overrides javax.swing.tree.DefaultMutableTreeNode.setParent.

Implements javax.swing.tree.MutableTreeNode.setParent.

Messaged when this node is added somewhere, resets the path and adds a mapping from path to this node.

setUserObjectback to summary
public void setUserObject(Object o)

Overrides javax.swing.tree.DefaultMutableTreeNode.setUserObject.

Implements javax.swing.tree.MutableTreeNode.setUserObject.

Messaged to set the user object. This resets the path.

setYOriginback to summary
protected void setYOrigin(int newYOrigin)

Sets y origin the user object will be drawn at to newYOrigin.

shiftYOriginByback to summary
protected void shiftYOriginBy(int offset)

Shifts the y origin by offset.

toggleExpandedback to summary
public void toggleExpanded()

Toggles the receiver between expanded and collapsed.

updatePreferredSizeback to summary
protected void updatePreferredSize()

Updates the receivers preferredSize by invoking updatePreferredSize with an argument of -1.

updatePreferredSizeback to summary
protected void updatePreferredSize(int index)

Updates the preferred size by asking the current renderer for the Dimension needed to draw the user object this instance represents.

javax.swing.tree back to summary

private Class VariableHeightLayoutCache.VisibleTreeStateNodeEnumeration

extends Object
implements Enumeration<TreePath>
Class Inheritance
  • java.lang.Object
  • javax.swing.tree.VariableHeightLayoutCache.VisibleTreeStateNodeEnumeration
All Implemented Interfaces
java.util.Enumeration

An enumerator to iterate through visible nodes.

Field Summary

Modifier and TypeField and Description
protected int
childCount

Number of children in parent.

protected int
nextIndex

Index of next child.

protected VariableHeightLayoutCache.TreeStateNode
parent

Parent whose children are being enumerated.

Constructor Summary

AccessConstructor and Description
protected
protected

Method Summary

Modifier and TypeMethod and Description
protected boolean
findNextValidParent()

Finds the next valid parent, this should be called when nextIndex is beyond the number of children of the current parent.

public boolean

Returns:

true if more visible nodes.
hasMoreElements
()

Implements java.util.Enumeration.hasMoreElements.

Tests if this enumeration contains more elements.

public TreePath

Returns:

next visible TreePath.
nextElement
()

Implements java.util.Enumeration.nextElement.

Returns the next element of this enumeration if this enumeration object has at least one more element to provide.

protected boolean
updateNextIndex()

Updates nextIndex returning false if it is beyond the number of children of parent.

protected void
updateNextObject()

Determines the next object by invoking updateNextIndex and if not successful findNextValidParent.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

childCountback to summary
protected int childCount

Number of children in parent.

nextIndexback to summary
protected int nextIndex

Index of next child. An index of -1 signifies parent should be visibled next.

parentback to summary
protected VariableHeightLayoutCache.TreeStateNode parent

Parent whose children are being enumerated.

Constructor Detail

VisibleTreeStateNodeEnumerationback to summary
protected VisibleTreeStateNodeEnumeration(VariableHeightLayoutCache.TreeStateNode node)
VisibleTreeStateNodeEnumerationback to summary
protected VisibleTreeStateNodeEnumeration(VariableHeightLayoutCache.TreeStateNode parent, int startIndex)

Method Detail

findNextValidParentback to summary
protected boolean findNextValidParent()

Finds the next valid parent, this should be called when nextIndex is beyond the number of children of the current parent.

hasMoreElementsback to summary
public boolean hasMoreElements()

Implements java.util.Enumeration.hasMoreElements.

Doc from java.util.Enumeration.hasMoreElements.

Tests if this enumeration contains more elements.

Returns:boolean

true if more visible nodes.

nextElementback to summary
public TreePath nextElement()

Implements java.util.Enumeration.nextElement.

Doc from java.util.Enumeration.nextElement.

Returns the next element of this enumeration if this enumeration object has at least one more element to provide.

Returns:TreePath

next visible TreePath.

updateNextIndexback to summary
protected boolean updateNextIndex()

Updates nextIndex returning false if it is beyond the number of children of parent.

updateNextObjectback to summary
protected void updateNextObject()

Determines the next object by invoking updateNextIndex and if not successful findNextValidParent.