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..
| Modifier and Type | Class and Description |
|---|---|
| private class | VariableHeightLayoutCache.
TreeStateNode is used to keep track of each of the nodes that have been expanded. |
| private class | VariableHeightLayoutCache.
An enumerator to iterate through visible nodes. |
| Modifier and Type | Field 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. | root
The root node of the internal cache of nodes that have been shown. |
| private Stack | tempStacks
A stack of stacks. |
| private Hashtable | treePathMapping
Maps from |
| private boolean | updateNodeSizes
This is set to true if one of the entries has an invalid size. |
| private Vector | visibleNodes
The array of nodes that are currently visible, in the order they are displayed. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private VariableHeightLayoutCache. | createNodeAt(VariableHeightLayoutCache.
Creates a new node to represent the node at childIndex in parents children. |
| private VariableHeightLayoutCache. | 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 ornull
if the node could not be ascertainedthe path to be drawn path, Rectangle the bounds of the enclosing rectangle placeIn)Implements abstract javax. Returns the |
| private Rectangle | |
| public boolean | Returns: true if the path is expanded and visible, otherwise falseImplements abstract javax. Returns true if the path is expanded, and visible. |
| private VariableHeightLayoutCache. | |
| private int | |
| private VariableHeightLayoutCache. | |
| private VariableHeightLayoutCache. | 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, ythe x-coordinate x, int the y-coordinate y)Implements abstract javax. Returns the path to the node that is closest to x,y. |
| public TreePath | Returns: the path forrow, or null
if row is not visiblethe location of interest row)Implements abstract javax. Returns the path for |
| public int | Returns: the preferred heightOverrides javax. Returns the preferred height. |
| public int | getPreferredWidth(Rectangle
the region being queried bounds)Overrides javax. Returns the preferred width and height for the region in
|
| private int | |
| public int | Returns: the number of visible rowsImplements abstract javax. Returns the number of visible rows. |
| public int | Returns: the row where the last item in path is visiblethe path)TreePath of interestImplements abstract javax. Returns the row where the last item identified in path is visible. |
| public int | Returns: the number of visible children forpathImplements abstract javax. Returns the number of visible children for |
| public Enumeration | Returns: anEnumerator that increments over the visible
pathsthe location in the path)TreePath to startImplements abstract javax. Returns an |
| public void | invalidatePathBounds(TreePath
the path)TreePath which is now invalidImplements abstract javax. Instructs the |
| public void | invalidateSizes()
Implements abstract javax. Informs the |
| public boolean | Returns: true if the value identified bypath is
currently expandedImplements abstract javax. Returns true if the value identified by |
| private void | rebuild(boolean clearSelection)
Completely rebuild the tree, all expanded state, and node caches are removed. |
| private void | removeMapping(VariableHeightLayoutCache.
Removes the mapping for a previously added node. |
| public void | setExpandedState(TreePath
the path, boolean TreePath of interesttrue if the path should be expanded, otherwise false isExpanded)Implements abstract javax. Marks the path |
| public void | setModel(TreeModel
the newModel)TreeModel that is to provide the dataOverrides javax. Sets the |
| public void | setNodeDimensions(AbstractLayoutCache.
the renderer ndOverrides javax. 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. Determines whether or not the root node from
the |
| public void | setRowHeight(int
the height of each cell, in pixels rowHeight)Overrides javax. Sets the height of each cell. |
| public void | treeNodesChanged(TreeModelEvent
the e)TreeModelEvent of interestImplements abstract javax. Invoked after a node (or a set of siblings) has changed in some way. |
| public void | treeNodesInserted(TreeModelEvent
the e)TreeModelEvent of interestImplements abstract javax. Invoked after nodes have been inserted into the tree. |
| public void | treeNodesRemoved(TreeModelEvent
the e)TreeModelEvent of interestImplements abstract javax. Invoked after nodes have been removed from the tree. |
| public void | treeStructureChanged(TreeModelEvent
the e)TreeModelEvent of interestImplements abstract javax. 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 |
| boundsBuffer | back to summary |
|---|---|
| private Rectangle boundsBuffer Used in getting sizes for nodes to avoid creating a new Rectangle every time a size is needed. | |
| root | back to summary |
|---|---|
| private VariableHeightLayoutCache. 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. | |
| tempStacks | back to summary |
|---|---|
| private Stack<Stack<TreePath>> tempStacks A stack of stacks. | |
| treePathMapping | back to summary |
|---|---|
| private Hashtable<TreePath, VariableHeightLayoutCache. Maps from | |
| updateNodeSizes | back to summary |
|---|---|
| private boolean updateNodeSizes This is set to true if one of the entries has an invalid size. | |
| visibleNodes | back to summary |
|---|---|
| private Vector<Object> visibleNodes The array of nodes that are currently visible, in the order they are displayed. | |
| VariableHeightLayoutCache | back to summary |
|---|---|
| public VariableHeightLayoutCache() Constructs a | |
| addMapping | back to summary |
|---|---|
| private void addMapping(VariableHeightLayoutCache. Adds a mapping for node. | |
| createNodeAt | back to summary |
|---|---|
| private VariableHeightLayoutCache. 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. | |
| createNodeForValue | back to summary |
|---|---|
| private VariableHeightLayoutCache. Responsible for creating a TreeStateNode that will be used to track display information about value. | |
| ensurePathIsExpanded | back 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. | |
| getBounds | back to summary |
|---|---|
| public Rectangle getBounds(TreePath path, Rectangle placeIn) Implements abstract javax. Returns the | |
| getBounds | back to summary |
|---|---|
| private Rectangle getBounds(int row, Rectangle placeIn) Returns the bounds for row, | |
| getExpandedState | back to summary |
|---|---|
| public boolean getExpandedState(TreePath path) Implements abstract javax. Returns true if the path is expanded, and visible.
| |
| getMapping | back to summary |
|---|---|
| private VariableHeightLayoutCache. Returns the node previously added for | |
| getMaxNodeWidth | back to summary |
|---|---|
| private int getMaxNodeWidth() Returns the maximum node width. | |
| getNode | back to summary |
|---|---|
| private VariableHeightLayoutCache. Returns the AbstractTreeUI.VisibleNode displayed at the given row | |
| getNodeForPath | back to summary |
|---|---|
| private VariableHeightLayoutCache. 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. | |
| getPathClosestTo | back to summary |
|---|---|
| public TreePath getPathClosestTo(int x, int y) Implements abstract javax. Returns the path to the node that is closest to x,y. If
there is nothing currently visible this will return
| |
| getPathForRow | back to summary |
|---|---|
| public TreePath getPathForRow(int row) Implements abstract javax. Returns the path for
| |
| getPreferredHeight | back to summary |
|---|---|
| public int getPreferredHeight() Overrides javax. Returns the preferred height.
| |
| getPreferredWidth | back to summary |
|---|---|
| public int getPreferredWidth(Rectangle bounds) Overrides javax. Returns the preferred width and height for the region in
| |
| getRowContainingYLocation | back 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. | |
| getRowCount | back to summary |
|---|---|
| public int getRowCount() Implements abstract javax. Returns the number of visible rows.
| |
| getRowForPath | back to summary |
|---|---|
| public int getRowForPath(TreePath path) Implements abstract javax. 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.
| |
| getVisibleChildCount | back to summary |
|---|---|
| public int getVisibleChildCount(TreePath path) Implements abstract javax. Returns the number of visible children for
| |
| getVisiblePathsFrom | back to summary |
|---|---|
| public Enumeration Implements abstract javax. Returns an
| |
| invalidatePathBounds | back to summary |
|---|---|
| public void invalidatePathBounds(TreePath path) Implements abstract javax. Instructs the
| |
| invalidateSizes | back to summary |
|---|---|
| public void invalidateSizes() Implements abstract javax. Informs the | |
| isExpanded | back to summary |
|---|---|
| public boolean isExpanded(TreePath path) Implements abstract javax. Returns true if the value identified by
| |
| rebuild | back 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. | |
| removeMapping | back to summary |
|---|---|
| private void removeMapping(VariableHeightLayoutCache. Removes the mapping for a previously added node. | |
| setExpandedState | back to summary |
|---|---|
| public void setExpandedState(TreePath path, boolean isExpanded) Implements abstract javax. Marks the path
| |
| setModel | back to summary |
|---|---|
| public void setModel(TreeModel newModel) Overrides javax. Sets the
| |
| setNodeDimensions | back to summary |
|---|---|
| public void setNodeDimensions(AbstractLayoutCache. Overrides javax. Sets the renderer that is responsible for drawing nodes in the tree.
| |
| setRootVisible | back to summary |
|---|---|
| public void setRootVisible(boolean rootVisible) Overrides javax. Determines whether or not the root node from
the
| |
| setRowHeight | back to summary |
|---|---|
| public void setRowHeight(int rowHeight) Overrides javax. 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.
| |
| treeNodesChanged | back to summary |
|---|---|
| public void treeNodesChanged(TreeModelEvent e) Implements abstract javax. 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.
| |
| treeNodesInserted | back to summary |
|---|---|
| public void treeNodesInserted(TreeModelEvent e) Implements abstract javax. Invoked after nodes have been inserted into the tree.
| |
| treeNodesRemoved | back to summary |
|---|---|
| public void treeNodesRemoved(TreeModelEvent e) Implements abstract javax. 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.
| |
| treeStructureChanged | back to summary |
|---|---|
| public void treeStructureChanged(TreeModelEvent e) Implements abstract javax. Invoked after the tree has drastically changed structure from a
given node down. If the path returned by
| |
| updateNodeSizes | back 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. | |
| updateYLocationsFrom | back to summary |
|---|---|
| private void updateYLocationsFrom(int location) Updates the y locations of all of the visible nodes after location. | |
| visibleNodesChanged | back to summary |
|---|---|
| private void visibleNodesChanged() | |
| Modifier and Type | Field 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. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Enumeration | children()
Overrides javax. Implements javax. Returns the children of the receiver. |
| public void | |
| protected void | |
| protected void | |
| protected void | |
| public void | |
| protected void | |
| protected void | |
| public VariableHeightLayoutCache. | |
| protected Enumeration | |
| public int | |
| public Rectangle | |
| public int | |
| public int | |
| public int | |
| public TreePath | |
| public Object | |
| public int | getVisibleChildCount()
Returns the number of visible children, that is the number of children that are expanded, or leafs. |
| public int | |
| public int | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | isLeaf()
Overrides javax. Implements javax. Returns true if the receiver is a leaf. |
| public boolean | |
| public void | |
| protected void | |
| public void | remove(int childIndex)
Overrides javax. Implements javax. Messaged when this node is removed from its parent, this messages
|
| protected void | |
| protected void | |
| public void | setParent(MutableTreeNode parent)
Overrides javax. Implements javax. Messaged when this node is added somewhere, resets the path and adds a mapping from path to this node. |
| public void | setUserObject(Object o)
Overrides javax. Implements javax. Messaged to set the user object. |
| protected void | |
| protected void | |
| public void | |
| protected void | updatePreferredSize()
Updates the receivers preferredSize by invoking
|
| 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. |
| expanded | back to summary |
|---|---|
| protected boolean expanded Is this node currently expanded? | |
| hasBeenExpanded | back to summary |
|---|---|
| protected boolean hasBeenExpanded Has this node been expanded at least once? | |
| path | back to summary |
|---|---|
| protected TreePath path Path of this node. | |
| preferredHeight | back to summary |
|---|---|
| protected int preferredHeight | |
| preferredWidth | back to summary |
|---|---|
| protected int preferredWidth Preferred size needed to draw the user object. | |
| xOrigin | back to summary |
|---|---|
| protected int xOrigin X location that the user object will be drawn at. | |
| yOrigin | back to summary |
|---|---|
| protected int yOrigin Y location that the user object will be drawn at. | |
| TreeStateNode | back to summary |
|---|---|
| public TreeStateNode(Object value) | |
| children | back to summary |
|---|---|
| public Enumeration Overrides javax. Implements javax. Returns the children of the receiver. If the receiver is not currently expanded, this will return an empty enumeration.
| |
| collapse | back to summary |
|---|---|
| public void collapse() Collapses the receiver. | |
| collapse | back to summary |
|---|---|
| protected void collapse(boolean adjustTree) Collapses this node in the tree. If adjustTree is true the tree and selection are updated accordingly. | |
| deepMarkSizeInvalid | back to summary |
|---|---|
| protected void deepMarkSizeInvalid() Marks the receivers size, and all its descendants sizes, as invalid. | |
| didAdjustTree | back to summary |
|---|---|
| protected void didAdjustTree() Messaged from expand and collapse. This is meant for subclassers that may wish to do something interesting with this. | |
| expand | back to summary |
|---|---|
| public void expand() Expands the receiver. | |
| expand | back 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. | |
| expandParentAndReceiver | back to summary |
|---|---|
| protected void expandParentAndReceiver() Invokes | |
| getLastVisibleNode | back to summary |
|---|---|
| public VariableHeightLayoutCache. Returns the last visible node that is a child of this instance. | |
| getLoadedChildren | back to summary |
|---|---|
| protected Enumeration Returns the children of the receiver. If the children haven't
been loaded from the model and
| |
| getModelChildCount | back 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. | |
| getNodeBounds | back to summary |
|---|---|
| public Rectangle getNodeBounds(Rectangle placeIn) Returns the location and size of this node. | |
| getPreferredHeight | back to summary |
|---|---|
| public int getPreferredHeight() Returns the preferred height of the receiver. | |
| getPreferredWidth | back to summary |
|---|---|
| public int getPreferredWidth() Returns the preferred width of the receiver. | |
| getRow | back to summary |
|---|---|
| public int getRow() Returns the row of the receiver. | |
| getTreePath | back to summary |
|---|---|
| public TreePath getTreePath() Returns a TreePath instance for this node. | |
| getValue | back to summary |
|---|---|
| public Object getValue() Returns the value the receiver is representing. This is a cover for getUserObject. | |
| getVisibleChildCount | back to summary |
|---|---|
| public int getVisibleChildCount() Returns the number of visible children, that is the number of children that are expanded, or leafs. | |
| getXOrigin | back to summary |
|---|---|
public int getXOrigin()
| |
| getYOrigin | back to summary |
|---|---|
| public int getYOrigin() Returns the y origin the user object will be drawn at. | |
| hasBeenExpanded | back to summary |
|---|---|
| public boolean hasBeenExpanded() Returns true if this node has been expanded at least once. | |
| hasValidSize | back to summary |
|---|---|
| public boolean hasValidSize() Returns true if this node has a valid size. | |
| isExpanded | back to summary |
|---|---|
| public boolean isExpanded() Returns true if the receiver has been expanded. | |
| isLeaf | back to summary |
|---|---|
| public boolean isLeaf() Overrides javax. Implements javax. Returns true if the receiver is a leaf. | |
| isVisible | back to summary |
|---|---|
| public boolean isVisible() Returns true if the receiver is currently visible. | |
| makeVisible | back to summary |
|---|---|
| public void makeVisible() Makes the receiver visible, but invoking
| |
| markSizeInvalid | back to summary |
|---|---|
| protected void markSizeInvalid() Marks the receivers size as invalid. Next time the size, location is asked for it will be obtained. | |
| remove | back to summary |
|---|---|
| public void remove(int childIndex) Overrides javax. Implements javax. Messaged when this node is removed from its parent, this messages
| |
| removeFromMapping | back to summary |
|---|---|
| protected void removeFromMapping() Removes the receiver, and all its children, from the mapping table. | |
| resetChildrenPaths | back to summary |
|---|---|
| protected void resetChildrenPaths(TreePath parentPath) Recreates the receivers path, and all its children's paths. | |
| setParent | back to summary |
|---|---|
| public void setParent(MutableTreeNode parent) Overrides javax. Implements javax. Messaged when this node is added somewhere, resets the path and adds a mapping from path to this node. | |
| setUserObject | back to summary |
|---|---|
| public void setUserObject(Object o) Overrides javax. Implements javax. Messaged to set the user object. This resets the path. | |
| setYOrigin | back to summary |
|---|---|
| protected void setYOrigin(int newYOrigin) Sets y origin the user object will be drawn at to newYOrigin. | |
| shiftYOriginBy | back to summary |
|---|---|
| protected void shiftYOriginBy(int offset) Shifts the y origin by | |
| toggleExpanded | back to summary |
|---|---|
| public void toggleExpanded() Toggles the receiver between expanded and collapsed. | |
| updatePreferredSize | back to summary |
|---|---|
| protected void updatePreferredSize() Updates the receivers preferredSize by invoking
| |
| updatePreferredSize | back 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. | |
| Modifier and Type | Field and Description |
|---|---|
| protected int | childCount
Number of children in parent. |
| protected int | nextIndex
Index of next child. |
| protected VariableHeightLayoutCache. | parent
Parent whose children are being enumerated. |
| Access | Constructor and Description |
|---|---|
| protected | |
| protected |
| Modifier and Type | Method 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.Implements java. Tests if this enumeration contains more elements. |
| public TreePath | Returns: next visible TreePath.Implements java. Returns the next element of this enumeration if this enumeration object has at least one more element to provide. |
| protected boolean | updateNextIndex()
Updates |
| protected void | updateNextObject()
Determines the next object by invoking |
| childCount | back to summary |
|---|---|
| protected int childCount Number of children in parent. | |
| nextIndex | back to summary |
|---|---|
| protected int nextIndex Index of next child. An index of -1 signifies parent should be visibled next. | |
| parent | back to summary |
|---|---|
| protected VariableHeightLayoutCache. Parent whose children are being enumerated. | |
| VisibleTreeStateNodeEnumeration | back to summary |
|---|---|
| protected VisibleTreeStateNodeEnumeration(VariableHeightLayoutCache. | |
| VisibleTreeStateNodeEnumeration | back to summary |
|---|---|
| protected VisibleTreeStateNodeEnumeration(VariableHeightLayoutCache. | |
| findNextValidParent | back 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. | |
| hasMoreElements | back to summary |
|---|---|
| public boolean hasMoreElements() Implements java. Doc from java. Tests if this enumeration contains more elements.
| |
| nextElement | back to summary |
|---|---|
| public TreePath nextElement() Implements java. Doc from java. Returns the next element of this enumeration if this enumeration object has at least one more element to provide.
| |
| updateNextIndex | back to summary |
|---|---|
| protected boolean updateNextIndex() Updates | |
| updateNextObject | back to summary |
|---|---|
| protected void updateNextObject() Determines the next object by invoking | |