All Packages Class Hierarchy This Package Previous Next Index
Class com.sun.java.swing.basic.AbstractTreeUI
java.lang.Object
|
+----com.sun.java.swing.basic.AbstractTreeUI
- public abstract class AbstractTreeUI
- extends Object
- implements TreeModelListener, RowMapper, TreeSelectionListener
-
EMPTY_SIZE
-
-
rootVisible
- Is the root being displayed?
-
rowHeight
- Height to use for each row.
-
showsRootHandles
- true if there should be handles at the top level.
-
treeCacheRoot
- The root node of the internal cache of nodes that have been shown.
-
treeModel
- The model that is currently being compressed.
-
treeSelectionModel
- Used to determine if a node is selected.
-
updateNodeSizes
- When messaged to paint() if this is true updateNodeSizes()
will be messaged before painting to relayout the location and
sizes of the nodes.
-
visibleNodes
- The array of nodes that are currently visible, in the order they
are displayed.
-
AbstractTreeUI()
-
-
addSelectionPath(JTreePath)
- Adds the path identified by path to the current selection.
-
addSelectionPaths(JTreePath[])
- Adds each path in paths to the current selection.
-
addSelectionRow(int)
- Adds the path at row to the current selection.
-
addSelectionRows(int[])
- Adds the paths at each of the rows in rows to the current selection.
-
collapsePath(JTreePath)
- Insures that the last item identified in path is collapsed and
visible.
-
collapseRow(int)
- Insures that the item identified by row is collapsed.
-
createNodeAt(AbstractTreeUI. VisibleTreeNode, int)
- Creates a new node to represent the node at childIndex in
parents children.
-
createNodeForValue(Object)
- Responsible for creating a VisibleTreeNode that will be used
to track display information about value.
-
ensurePathIsAbstract(JTreePath, AbstractTreeUI. VisibleTreeNode)
- Returns an AbstractTreePath for path.
-
ensurePathIsExpanded(JTreePath, boolean)
- Returns the VisibleTreeNode instances that are used to
represent the user values in path, as well as insuring
that all the nodes are visible.
-
expandPath(JTreePath)
- Ensures that the last item identified in path is expanded and
visible.
-
expandRow(int)
- Insures that the item identified by row is expanded.
-
getClosestPathForLocation(int, int)
- Returns the path to the node that is closest to x,y.
-
getClosestRowForLocation(int, int)
- Returns the row to the node that is closest to x,y.
-
getMaxNodeWidth()
- Returns the maximum node width.
-
getMaxSelectionRow()
- Gets the last selected row.
-
getMinSelectionRow()
- Gets the first selected row.
-
getModel()
- Returns the TreeModel that is being displayed for.
-
getNode(int)
- Returns the AbstractTreeUI.VisibleNode displayed at the given row
-
getNodeForPath(Object[], boolean, boolean)
- Returns the VisibleTreeNode that represents the last item in
path.
-
getNodeForTreePath(JTreePath, boolean, boolean)
- Returns the VisibleTreeNode identified by path.
-
getNodesForPath(Object[], boolean, boolean)
- Returns the VisibleTreeNodes that represent
path.
-
getNodesForTreePath(JTreePath, boolean, boolean)
- Returns the path of VisibleTreeNode's to reach the path identified
in path.
-
getPathBounds(JTreePath)
- Returns the Rectangle enclosing the label portion that the
last item in path will be drawn into.
-
getPathForRow(int)
- Returns the path for passed in row.
-
getRowBounds(int)
- Returns the Rectangle enclosing the label portion that the
item identified by row will be drawn into.
-
getRowContainingYLocation(int)
- Returns the index of the row containing location.
-
getRowCount()
- Returns the number of visible rows.
-
getRowForPath(JTreePath)
- Returns the row that the last item identified in path is visible
at.
-
getRowHeight()
- Returns the height of each row.
-
getSelectionModel()
-
-
getSelectionPath()
- Returns the path to the first selected value, or null if
nothing is currently selected.
-
getSelectionPaths()
- Returns the path of the selected values, or null if nothing is
current selected.
-
getSelectionRows()
- Returns all of the currently selected rows.
-
getShowsRootHandles()
- Returns true if handles for the root nodes are displayed.
-
getSizeOfNode(AbstractTreeUI. VisibleTreeNode)
- Subclassers must implement this to return the size of node.
-
getValue(int)
- Returns the data model object displayed at the given row
-
getXOriginOfNode(AbstractTreeUI. VisibleTreeNode)
- Subclassers must implement this method, should return the x
origin of where the particular node is goin to drawn at.
-
getYOriginOfRow(int)
- Returns the y origin of row.
-
isAbstractTreePath(JTreePath, boolean, boolean)
- Returns true if path is an instance of AbstractTreePath
and was created by this instance (updating it if it is out of date).
-
isCollapsed(int)
- Returns true if the value identified by row is currently collapsed.
-
isCollapsed(JTreePath)
- Returns true if the value identified by path is currently collapsed,
this will return false if any of the values in path are currently
not being displayed.
-
isExpanded(int)
- Returns true if the value identified by row is currently expanded.
-
isExpanded(JTreePath)
- Returns true if the value identified by path is currently expanded,
this will return false if any of the values in path are currently
not being displayed.
-
isFixedRowHeight()
- Returns true if the height of each row is a fixed size.
-
isPathSelected(JTreePath)
- Returns true if item identified by path is currently selected.
-
isRootVisible()
- Returns true if root is currently visible.
-
isRowSelected(int)
- Returns true if the row identitifed by row is selected.
-
isSelectedIndex(int)
-
-
isVisible(JTreePath)
- Returns true if all the parents of path are currently expanded.
-
makeVisible(JTreePath)
- Ensures that all of the parents of path are currently expanded.
-
nodeWasCollapsed(AbstractTreeUI. VisibleTreeNode)
- Messaged from the VisibleTreeNode after it has collapsed.
-
nodeWasExpanded(AbstractTreeUI. VisibleTreeNode)
- Messaged from the VisibleTreeNode after it has been expanded.
-
rebuild()
- Sent to completely rebuild the visible tree.
-
setModel(TreeModel)
- Sets the model the data is going to come from.
-
setRootVisible(boolean)
- Sets whether or not the root node of the model is to be displayed.
-
setRowHeight(int)
- Sets the height of each to be rowHeight.
-
setSelectedPath(JTreePath, boolean)
-
Adds the value identified by path to the current selection if
addToSelection is true, otherwise sets the selection to path.
-
setSelectedRow(int, boolean)
- If addToSelection is true the path at row is added to the current
selection, otherwise the selection is set to the path at row.
-
setSelectionModel(TreeSelectionModel)
-
-
setSelectionPath(JTreePath)
-
Sets to selection to the value identified by path.
-
setSelectionPaths(JTreePath[])
-
Sets the selection to paths.
-
setSelectionRow(int)
- The current selection is set to the path for the item at row.
-
setSelectionRows(int[])
- The selection is set to the paths for the items at each of the rows
in rows.
-
setShowsRootHandles(boolean)
- Sets whether or not the root handles are to be displayed.
-
treeNodesChanged(TreeModelEvent)
- Invoked after nodes in the tree have changed in some way.
-
treeNodesInserted(TreeModelEvent)
- Invoked after nodes have been inserted into the tree.
-
treeNodesRemoved(TreeModelEvent)
- Invoked after nodes have been removed from the tree.
-
treeStructureChanged(TreeModelEvent)
- Invoked after the tree has drastically changed structure.
-
updateNodeSizes(boolean)
- Resets the y origin of all the visible nodes as well as messaging
all the visible nodes to updatePreferredSize().
-
updateYLocationsFrom(int)
- Updates the y locations of all of the visible nodes after
location.
-
valueChanged(TreeSelectionEvent)
-
-
visibleNodes()
- Returns an enumeration of AbstractTreeUI.VisibleTreeNode.
-
visibleNodesChanged()
- Messaged when the visible nodes have changed (eg when a
node is expanded, when nodes are removed from the model...).
treeModel
protected TreeModel treeModel
- The model that is currently being compressed.
rootVisible
protected boolean rootVisible
- Is the root being displayed?
treeCacheRoot
protected AbstractTreeUI. VisibleTreeNode treeCacheRoot
- 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.
visibleNodes
protected Vector visibleNodes
- The array of nodes that are currently visible, in the order they
are displayed.
updateNodeSizes
protected boolean updateNodeSizes
- When messaged to paint() if this is true updateNodeSizes()
will be messaged before painting to relayout the location and
sizes of the nodes.
rowHeight
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.
showsRootHandles
protected boolean showsRootHandles
- true if there should be handles at the top level. If the root
isn't visible it is highly recommended to make this true.
treeSelectionModel
protected TreeSelectionModel treeSelectionModel
- Used to determine if a node is selected.
EMPTY_SIZE
public static final Dimension EMPTY_SIZE
AbstractTreeUI
public AbstractTreeUI()
setModel
public void setModel(TreeModel newModel)
- Sets the model the data is going to come from. Will message
rebuild if the new model is different from the current model.
getModel
public TreeModel getModel()
- Returns the TreeModel that is being displayed for.
setRootVisible
public void setRootVisible(boolean rootVisible)
- Sets whether or not the root node of the model is to be displayed.
isRootVisible
public boolean isRootVisible()
- Returns true if root is currently visible.
setShowsRootHandles
public void setShowsRootHandles(boolean newValue)
- Sets whether or not the root handles are to be displayed.
getShowsRootHandles
public boolean getShowsRootHandles()
- Returns true if handles for the root nodes are displayed.
setRowHeight
public void setRowHeight(int rowHeight)
- Sets the height of each to be rowHeight. If rowHeight
is less than or equal to zero the current cell renderer will
be queried for each rows height.
getRowHeight
public int getRowHeight()
- Returns the height of each row. If returned value is less than
or equal to 0 the height for each row is determined by the
renderer.
isFixedRowHeight
public boolean isFixedRowHeight()
- Returns true if the height of each row is a fixed size.
getXOriginOfNode
public abstract int getXOriginOfNode(AbstractTreeUI. VisibleTreeNode node)
- Subclassers must implement this method, should return the x
origin of where the particular node is goin to drawn at.
getSizeOfNode
public abstract Dimension getSizeOfNode(AbstractTreeUI. VisibleTreeNode node)
- Subclassers must implement this to return the size of node.
visibleNodesChanged
public abstract void visibleNodesChanged()
- Messaged when the visible nodes have changed (eg when a
node is expanded, when nodes are removed from the model...).
nodeWasExpanded
protected abstract void nodeWasExpanded(AbstractTreeUI. VisibleTreeNode node)
- Messaged from the VisibleTreeNode after it has been expanded.
nodeWasCollapsed
protected abstract void nodeWasCollapsed(AbstractTreeUI. VisibleTreeNode node)
- Messaged from the VisibleTreeNode after it has collapsed.
isAbstractTreePath
protected boolean isAbstractTreePath(JTreePath path,
boolean onlyIfVisible,
boolean shouldCreate)
- Returns true if path is an instance of AbstractTreePath
and was created by this instance (updating it if it is out of date).
Otherwise false is returned.
getNodeForTreePath
protected AbstractTreeUI. VisibleTreeNode getNodeForTreePath(JTreePath path,
boolean onlyIfVisible,
boolean shouldCreate)
- Returns the VisibleTreeNode identified by path. This mirrors
the behavior of getNodeForPath, but tries to take advantage of
path if it is an instance of AbstractTreePath.
getNodesForTreePath
protected AbstractTreeUI. VisibleTreeNode[] getNodesForTreePath(JTreePath path,
boolean onlyIfVisible,
boolean shouldCreate)
- Returns the path of VisibleTreeNode's to reach the path identified
in path. This mirrors the behavior of getNodesForPath, but tries
to take advantage of path if it is an instance of AbstractTreePath.
ensurePathIsAbstract
protected JTreePath ensurePathIsAbstract(JTreePath path,
AbstractTreeUI. VisibleTreeNode node)
- Returns an AbstractTreePath for path. If path is already an
instance of AbstractTreePath, it is returned, otherwise an
instance of AbstractTreePath is created.
getNodeForPath
public AbstractTreeUI. VisibleTreeNode getNodeForPath(Object path[],
boolean onlyIfVisible,
boolean shouldCreate)
- Returns the VisibleTreeNode that represents the last item in
path. If onlyIfVisibile is true and any of the nodes in
path are not currently visible, null will be returned.
shouldCreate is passed into getLoadedChildren, a
true value will load the nodes if they have not already been
loaded.
getNodesForPath
public AbstractTreeUI. VisibleTreeNode[] getNodesForPath(Object path[],
boolean onlyIfVisible,
boolean shouldCreate)
- Returns the VisibleTreeNodes that represent
path. If onlyIfVisibile is true and any of the nodes in
path are not currently visible, null will be returned.
shouldCreate is passed into getLoadedChildren, a
true value will load the nodes if they have not already been
loaded.
updateYLocationsFrom
protected void updateYLocationsFrom(int location)
- Updates the y locations of all of the visible nodes after
location.
treeNodesChanged
public synchronized void treeNodesChanged(TreeModelEvent e)
- Invoked after nodes in the tree have changed in some way. All of
the nodes are siblings. The nodes have not changed locations in
the tree or altered their children arrays, but other attributes
have changed and may affect the nodes' presentation.
createNodeAt
protected AbstractTreeUI. VisibleTreeNode createNodeAt(AbstractTreeUI. VisibleTreeNode 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 succesful
in creating the new VisibleTreeNode, it is returned, otherwise
null is returned.
treeNodesInserted
public synchronized void treeNodesInserted(TreeModelEvent e)
- Invoked after nodes have been inserted into the tree.
treeNodesRemoved
public synchronized 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.
treeStructureChanged
public synchronized void treeStructureChanged(TreeModelEvent e)
- Invoked after the tree has drastically changed structure. The event
will identify the root of the subtree that has changed. The
behavior of this is to recreate the last node that is identified
by the path in the passed in event. If the node was previously
expanded it will be expanded when recreated, but none of its
children will be expanded. 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.
rebuild
public void rebuild()
- Sent to completely rebuild the visible tree. All nodes are collapsed.
updateNodeSizes
public 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
automaticly adjusts the locations.
updateAll determines if updatePreferredSize() is call on all nodes
or just those that don't have a valid size.
getYOriginOfRow
public int getYOriginOfRow(int row)
- Returns the y origin of row.
getRowContainingYLocation
public 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.
ensurePathIsExpanded
protected AbstractTreeUI. VisibleTreeNode[] ensurePathIsExpanded(JTreePath path,
boolean expandLast)
- Returns the VisibleTreeNode instances that are used to
represent the user values in path, as well as insuring
that all the nodes are visible. If any component of the path is
not valid, null will be returned.
setSelectedPath
public void setSelectedPath(JTreePath path,
boolean addToSelection)
- Adds the value identified by path to the current selection if
addToSelection is true, otherwise sets the selection to path.
If any component of path is not currently visible it will be
made visible.
setSelectionPath
public void setSelectionPath(JTreePath path)
- Sets to selection to the value identified by path. If any
component of path is not currently visible it will be made visible.
setSelectionPaths
public void setSelectionPaths(JTreePath paths[])
- Sets the selection to paths. If any component in any of the
paths is not currently visible it will be made visible.
setSelectedRow
public void setSelectedRow(int row,
boolean addToSelection)
- If addToSelection is true the path at row is added to the current
selection, otherwise the selection is set to the path at row.
setSelectionRow
public void setSelectionRow(int row)
- The current selection is set to the path for the item at row.
setSelectionRows
public void setSelectionRows(int rows[])
- The selection is set to the paths for the items at each of the rows
in rows.
addSelectionPath
public void addSelectionPath(JTreePath path)
- Adds the path identified by path to the current selection. If
any component of path isn't visible, it will be made visible.
addSelectionPaths
public void addSelectionPaths(JTreePath paths[])
- Adds each path in paths to the current selection. If
any component of any of the paths isn't visible, it will be
made visible.
addSelectionRow
public void addSelectionRow(int row)
- Adds the path at row to the current selection.
addSelectionRows
public void addSelectionRows(int rows[])
- Adds the paths at each of the rows in rows to the current selection.
getSelectionPath
public JTreePath getSelectionPath()
- Returns the path to the first selected value, or null if
nothing is currently selected.
getSelectionPaths
public JTreePath[] getSelectionPaths()
- Returns the path of the selected values, or null if nothing is
current selected.
getSelectionRows
public int[] getSelectionRows()
- Returns all of the currently selected rows.
getMinSelectionRow
public int getMinSelectionRow()
- Gets the first selected row.
getMaxSelectionRow
public int getMaxSelectionRow()
- Gets the last selected row.
isPathSelected
public boolean isPathSelected(JTreePath path)
- Returns true if item identified by path is currently selected.
isRowSelected
public boolean isRowSelected(int row)
- Returns true if the row identitifed by row is selected.
isExpanded
public boolean isExpanded(JTreePath path)
- Returns true if the value identified by path is currently expanded,
this will return false if any of the values in path are currently
not being displayed.
isExpanded
public boolean isExpanded(int row)
- Returns true if the value identified by row is currently expanded.
isCollapsed
public boolean isCollapsed(JTreePath path)
- Returns true if the value identified by path is currently collapsed,
this will return false if any of the values in path are currently
not being displayed.
isCollapsed
public boolean isCollapsed(int row)
- Returns true if the value identified by row is currently collapsed.
makeVisible
public void makeVisible(JTreePath path)
- Ensures that all of the parents of path are currently expanded.
To make sure it is truyly visible, you may wish to call
scrollPathToVisible, which will try and scroll the path to be
visibile if the JTree is in a scroller.
isVisible
public boolean isVisible(JTreePath path)
- Returns true if all the parents of path are currently expanded.
getRowCount
public int getRowCount()
- Returns the number of visible rows.
getPathBounds
public Rectangle getPathBounds(JTreePath path)
- Returns the Rectangle enclosing the label portion that the
last item in path will be drawn into. Will return null if
any component in path is currently valid.
getRowBounds
public Rectangle getRowBounds(int row)
- Returns the Rectangle enclosing the label portion that the
item identified by row will be drawn into.
getPathForRow
public JTreePath getPathForRow(int row)
- Returns the path for passed in row. If row is not visible
null is returned.
getRowForPath
public int getRowForPath(JTreePath 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.
expandPath
public void expandPath(JTreePath path)
- Ensures that the last item identified in path is expanded and
visible.
expandRow
public void expandRow(int row)
- Insures that the item identified by row is expanded.
collapsePath
public void collapsePath(JTreePath path)
- Insures that the last item identified in path is collapsed and
visible.
collapseRow
public void collapseRow(int row)
- Insures that the item identified by row is collapsed.
getClosestPathForLocation
public JTreePath getClosestPathForLocation(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.
getClosestRowForLocation
public int getClosestRowForLocation(int x,
int y)
- Returns the row to the node that is closest to x,y. If
there is nothing currently visible this will return -1, otherwise
it'll always return a valid row. If you need to test if the
returned object is exactly at x, y you should get the bounds for
the returned row and test x, y against that.
getValue
public Object getValue(int row)
- Returns the data model object displayed at the given row
getNode
public AbstractTreeUI. VisibleTreeNode getNode(int row)
- Returns the AbstractTreeUI.VisibleNode displayed at the given row
visibleNodes
public Enumeration visibleNodes()
- Returns an enumeration of AbstractTreeUI.VisibleTreeNode. There is one
element per visible row, and this enumerates through the rows from top
to bottom.
getMaxNodeWidth
public int getMaxNodeWidth()
- Returns the maximum node width. This will repeatedly call
getXOrigin() on this as well as getPreferredSize() on each node
to determine the size.
setSelectionModel
public void setSelectionModel(TreeSelectionModel newLSM)
getSelectionModel
public TreeSelectionModel getSelectionModel()
isSelectedIndex
public boolean isSelectedIndex(int row)
valueChanged
public void valueChanged(TreeSelectionEvent e)
createNodeForValue
protected AbstractTreeUI. VisibleTreeNode createNodeForValue(Object value)
- Responsible for creating a VisibleTreeNode that will be used
to track display information about value.
All Packages Class Hierarchy This Package Previous Next Index