All Packages Class Hierarchy This Package Previous Next Index
Class java.awt.swing.basic.BasicTreeUI
java.lang.Object
|
+----java.awt.swing.plaf.ComponentUI
|
+----java.awt.swing.plaf.TreeUI
|
+----java.awt.swing.basic.AbstractTreeUI
|
+----java.awt.swing.basic.BasicTreeUI
- public class BasicTreeUI
- extends AbstractTreeUI
- implements CellEditorListener, FocusListener, KeyListener, MouseListener, PropertyChangeListener
BasicTreeUI.BasicTreeMouseListener- BasicTreeMouseListener handles passing all mouse events,
including mouse motion events, until the mouse is released to
the destination it is constructed with.
BasicTreeUI.BasicTreeUIPaintInfo- BasicTreeUIPaintInfo is used during a painting session for largeModels.
BasicTreeUI.CollapsedIcon-
BasicTreeUI.ExpandedIcon-
cellEditor- Editor for the tree.
collapsedIcon-
componentListener- Used for large models, listens for moved/resized events and
updates the validCachedPreferredSize bit accordingly.
cPreferredSize- Size needed to completely display all the nodes.
createdCellEditor- Set to true if editor renderer that is currently in the tree was
created by this instance.
createdRenderer- Set to true if the renderer that is currently in the tree was
created by this instance.
currentCellRenderer- Renderer that is being used to do the actual cell drawing.
editingComponent- When editing, this will be the Component that is doing the actual
editing.
editingPath- Path that is being edited.
expandedIcon-
HALF_SIZE-
isKeyDown- Set to true while keyPressed is active.
lastSelectedRow- Index of the row that was last selected.
leftChildIndent- Distance between left margin and where verical dashes will be
drawn.
preferredMinSize- Minimum preferred size.
rendererPane- Used to paint the TreeCellRenderer.
repeatKeyAction- Key code that is being generated for.
rightChildIndent- Distance to add to leftChildIndent to determine where cell
contents will be drawn.
SIZE-
stopEditingInCompleteEditing- Set to false when editing and shouldSelectCell() returns true meaning
the node should be selected before editing, used in completeEditing.
totalChildIndent- Total distance that will be indented.
tree- Component that we're going to be drawing into.
validCachedPreferredSize- Is the preferredSize valid?
BasicTreeUI()
-
cancelEditing()
- Cancels the current editing session.
checkConsistency()
- Checks to insure that the all the sizes of the nodes are valid,
and if there isn't a valid node size, as determined by
updateNodeSizes in our superclass, than updateNodeSizes()
is messaged.
checkForClickInExpandControl(VisibleTreeNode, LargeTreeModelNode, int, int, int, int, int)
-
clickedInExpandControl(int, int, int, int)
-
completeEditing(boolean, boolean, boolean)
- Stops the editing session.
createExpandedNodeForValue(Object, int)
- Creates a new instance of BasicLargeTreeModelNode.
createLargeTreeModelNodeForValue(Object, int)
- Creates an instance of BasicLargeTreeModelNode.
createNodeForValue(Object, int)
- Creates an instance of BasicVisibleTreeNode.
createUI(JComponent)
-
drawCentered(Component, Graphics, Icon, int, int)
-
drawDashedHorizontalLine(Graphics, int, int, int)
-
drawDashedVerticalLine(Graphics, int, int, int)
-
drawHorizontalPartOfLeg(Graphics, JComponent, int, int, int, int, int, int)
-
drawLeg(Graphics, JComponent, VisibleTreeNode, VisibleTreeNode)
-
drawVerticalPartOfLeg(Graphics, JComponent, int, int, int, int, int, int)
-
editingCanceled(ChangeEvent)
- Stops the editing session by messaging cancelEditing(false).
editingStopped(ChangeEvent)
- Stops the editing session by messaging stopCellEditing(false).
ensureRowsAreVisible(int, int)
- Ensures that the rows identified by beginRow through endRow are
visible.
focusGained(FocusEvent)
- Invoked when focus is activated on the tree we're in, redraws the
lead row.
focusLost(FocusEvent)
- Invoked when focus is activated on the tree we're in, redraws the
lead row.
getCellRenderer()
- Return currentCellRenderer, which will either be the trees
renderer, or defaultCellRenderer, which ever wasn't null.
getCollapsedIcon()
-
getDefaultCellEditor()
- Creates a default cell editor.
getDefaultCellRenderer()
- Returns the default cell renderer that is used to do the
stamping of each node.
getEditingPath()
- Returns the path to the element that is being edited.
getExpandedIcon()
-
getHashColor()
-
getLargeBoundsOf(LargeTreeModelNode, int, Object)
- Returns the rectangle needed to draw the passed in row.
getLargeBoundsOf(LargeTreeModelNode, int, Object, Component, Rectangle[])
- Returns the rectangle needed to draw the passed in row.
getLeftChildIndent()
-
getMaximumSize(JComponent)
- Returns the maximum size for this component, which will be the
preferred size if the instance is currently in a JTree, or 0, 0.
getMinimumSize(JComponent)
- Returns the minimum size for this component.
getPreferredMinSize()
- Returns the minimum preferred size.
getPreferredSize(JComponent)
- Returns the preferred size to properly display the tree,
this is a cover method for getPreferredSize(c, false).
getPreferredSize(JComponent, boolean)
- Returns the preferred size to represent the tree in
c.
getRightChildIndent()
-
getSizeOfNode(VisibleTreeNode, int)
- Messages the tree to configure the cell, and returns the
the size of the component.
getXOriginOfNode(VisibleTreeNode)
- Returns the x origin of the given node, which is based on whether
or not we're showing handles and the visible level of the node
multiplied by the right and left indent factor.
handleExpandControlClick(VisibleTreeNode, LargeTreeModelNode, int, int)
-
installUI(JComponent)
-
isEditing()
- Returns true if the tree is being edited.
keyPressed(KeyEvent)
-
keyReleased(KeyEvent)
-
keyTyped(KeyEvent)
-
mouseClicked(MouseEvent)
- Invoked when the mouse has been clicked on a component.
mouseEntered(MouseEvent)
- Invoked when the mouse enters a component.
mouseExited(MouseEvent)
- Invoked when the mouse exits a component.
mousePressed(MouseEvent)
- Invoked when a mouse button has been pressed on a component.
mouseReleased(MouseEvent)
- Invoked when a mouse button has been released on a component.
paint(Graphics, JComponent)
-
paintExpandControl(Graphics, JComponent, VisibleTreeNode, VisibleTreeNode, int, int, int, int)
-
paintRow(Graphics, JComponent, VisibleTreeNode, VisibleTreeNode, int, int, int, int)
-
pathWasCollapsed(TreePath)
- Messaged from the VisibleTreeNode after it has collapsed.
pathWasExpanded(TreePath)
- Messaged from the VisibleTreeNode after it has been expanded.
propertyChange(PropertyChangeEvent)
- Based on the value has changed will message the appropriate
method.
rebuild()
- Stops editing and messags super.
repaintNode(BasicLargeTreeModelNode)
- Repaints the particular node by getting its bounds.
repaintNode(VisibleTreeNode)
- Repaints the particular node by getting its bounds.
scrollPathToVisible(TreePath)
- Makes sure all the path components in path are expanded (accept
for the last path component) and tries to scroll the resulting path
to be visible (the scrolling will only work if the JTree is
contained in a JScrollPane).
scrollRowToVisible(int)
- Scrolls the item identified by row to be visible.
setCollapsedIcon(Icon)
-
setExpandedIcon(Icon)
-
setHashColor(Color)
-
setLargeModel(boolean)
- Updates the componentListener, if necessary.
setLeftChildIndent(int)
-
setModel(TreeModel)
- Stops editing and messages super.
setPreferredMinSize(Dimension)
- Sets the preferred minimum size.
setRightChildIndent(int)
-
setSelectionModel(TreeSelectionModel)
- Stops editing, messags super and becomes a listener on the model.
setupKeyboard()
- Registers for keyboard events to manipulate the current selection.
shouldDrawLegToParent(VisibleTreeNode, VisibleTreeNode)
-
shouldPaintExpandControl(VisibleTreeNode, VisibleTreeNode)
-
startEditing(TreePath, MouseEvent)
- Will start editing for node if there is a cellEditor and
shouldSelectCell returns true.
This assumes that path is valid and visible.
startEditingAtPath(TreePath)
- Selects the last item in path and tries to edit it.
stopEditing()
- Stops the current editing session, returns true if the tree is
current editing and the editor returns true from stopCellEditing().
toggleExpandState(int)
-
uninstallUI(JComponent)
-
unsetKeyboard()
- Unregisters for keyboard events that were previously registered for
in setupKeyboard.
updateCachedPreferredSize()
- Updates the
cPreferredSize
instance variable,
which is returned from getPreferredSize()
.
If largeModel
is true, the width is determined
from only the visible rows, otherwise the width is determined
from getMaxNodeWidth
.
updateCellEditor()
- Updates the cellEditor based on the editability of the JTree that
we're contained in.
updateNodeSizes(boolean)
- Resets the y origin of all the visible nodes as well as messaging
all the visible nodes to updatePreferredSize().
updateRenderer()
- Messaged from the tree we're in when the renderer has changed.
valueChanged(TreeSelectionEvent)
- Messaged when the selection changes in the tree we're displaying
for.
visibleNodesChanged()
- Messaged whenever nodes are added/removed from the visible list,
or the height/width of a node changes.
collapsedIcon
protected transient Icon collapsedIcon
expandedIcon
protected transient Icon expandedIcon
leftChildIndent
protected int leftChildIndent
- Distance between left margin and where verical dashes will be
drawn.
rightChildIndent
protected int rightChildIndent
- Distance to add to leftChildIndent to determine where cell
contents will be drawn.
totalChildIndent
protected int totalChildIndent
- Total distance that will be indented. The sum of leftChildIndent
and rightChildIndent.
preferredMinSize
protected Dimension preferredMinSize
- Minimum preferred size.
lastSelectedRow
protected int lastSelectedRow
- Index of the row that was last selected.
tree
protected JTree tree
- Component that we're going to be drawing into.
currentCellRenderer
protected transient TreeCellRenderer currentCellRenderer
- Renderer that is being used to do the actual cell drawing.
createdRenderer
protected boolean createdRenderer
- Set to true if the renderer that is currently in the tree was
created by this instance.
cellEditor
protected transient TreeCellEditor cellEditor
- Editor for the tree.
createdCellEditor
protected boolean createdCellEditor
- Set to true if editor renderer that is currently in the tree was
created by this instance.
editingComponent
protected Component editingComponent
- When editing, this will be the Component that is doing the actual
editing.
editingPath
protected TreePath editingPath
- Path that is being edited.
repeatKeyAction
protected Action repeatKeyAction
- Key code that is being generated for.
isKeyDown
protected boolean isKeyDown
- Set to true while keyPressed is active.
stopEditingInCompleteEditing
protected boolean stopEditingInCompleteEditing
- Set to false when editing and shouldSelectCell() returns true meaning
the node should be selected before editing, used in completeEditing.
rendererPane
protected CellRendererPane rendererPane
- Used to paint the TreeCellRenderer.
cPreferredSize
protected Dimension cPreferredSize
- Size needed to completely display all the nodes.
validCachedPreferredSize
protected boolean validCachedPreferredSize
- Is the preferredSize valid?
componentListener
protected transient ComponentAdapter componentListener
- Used for large models, listens for moved/resized events and
updates the validCachedPreferredSize bit accordingly.
HALF_SIZE
protected static final int HALF_SIZE
SIZE
protected static final int SIZE
BasicTreeUI
public BasicTreeUI()
createUI
public static ComponentUI createUI(JComponent x)
getHashColor
protected Color getHashColor()
setHashColor
protected void setHashColor(Color color)
setLeftChildIndent
public void setLeftChildIndent(int newAmount)
getLeftChildIndent
public int getLeftChildIndent()
setRightChildIndent
public void setRightChildIndent(int newAmount)
getRightChildIndent
public int getRightChildIndent()
setExpandedIcon
public void setExpandedIcon(Icon newG)
getExpandedIcon
public Icon getExpandedIcon()
setCollapsedIcon
public void setCollapsedIcon(Icon newG)
getCollapsedIcon
public Icon getCollapsedIcon()
setLargeModel
public void setLargeModel(boolean largeModel)
- Updates the componentListener, if necessary.
- Overrides:
- setLargeModel in class AbstractTreeUI
installUI
public void installUI(JComponent c)
- Overrides:
- installUI in class ComponentUI
uninstallUI
public void uninstallUI(JComponent c)
- Overrides:
- uninstallUI in class ComponentUI
propertyChange
public void propertyChange(PropertyChangeEvent event)
- Based on the value has changed will message the appropriate
method. Which is one of treeRendererChanged, setModel,
setRootVisible, setShowsRootHandles, or setRowHeight.
setupKeyboard
protected void setupKeyboard()
- Registers for keyboard events to manipulate the current selection.
unsetKeyboard
protected void unsetKeyboard()
- Unregisters for keyboard events that were previously registered for
in setupKeyboard.
updateCellEditor
protected void updateCellEditor()
- Updates the cellEditor based on the editability of the JTree that
we're contained in. If the tree is editable but doesn't have a
cellEditor, a basic one will be used.
updateRenderer
protected void updateRenderer()
- Messaged from the tree we're in when the renderer has changed.
Updates the size if necessary.
checkConsistency
public boolean checkConsistency()
- Checks to insure that the all the sizes of the nodes are valid,
and if there isn't a valid node size, as determined by
updateNodeSizes in our superclass, than updateNodeSizes()
is messaged.
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().
- Overrides:
- updateNodeSizes in class AbstractTreeUI
getDefaultCellEditor
protected TreeCellEditor getDefaultCellEditor()
- Creates a default cell editor.
getDefaultCellRenderer
public TreeCellRenderer getDefaultCellRenderer()
- Returns the default cell renderer that is used to do the
stamping of each node.
getXOriginOfNode
public int getXOriginOfNode(VisibleTreeNode node)
- Returns the x origin of the given node, which is based on whether
or not we're showing handles and the visible level of the node
multiplied by the right and left indent factor.
- Overrides:
- getXOriginOfNode in class AbstractTreeUI
getSizeOfNode
public Dimension getSizeOfNode(VisibleTreeNode node,
int index)
- Messages the tree to configure the cell, and returns the
the size of the component.
- Overrides:
- getSizeOfNode in class AbstractTreeUI
getLargeBoundsOf
protected Rectangle getLargeBoundsOf(LargeTreeModelNode parent,
int row,
Object childUserObject)
- Returns the rectangle needed to draw the passed in row. This messages
getLargeBoundsOf(parent, row, childUserObject, null, null) for the
return value.
- Overrides:
- getLargeBoundsOf in class AbstractTreeUI
getLargeBoundsOf
protected Rectangle getLargeBoundsOf(LargeTreeModelNode parent,
int row,
Object childUserObject,
Component component,
Rectangle[] placeIn)
- Returns the rectangle needed to draw the passed in row. If Component
is non-null the size is taken from the component. If placeIn is
non-null the returned Rectangle will be placeIn[0].
updateCachedPreferredSize
protected void updateCachedPreferredSize()
- Updates the
cPreferredSize
instance variable,
which is returned from getPreferredSize()
.
If largeModel
is true, the width is determined
from only the visible rows, otherwise the width is determined
from getMaxNodeWidth
.
visibleNodesChanged
public void visibleNodesChanged()
- Messaged whenever nodes are added/removed from the visible list,
or the height/width of a node changes. This updates the size
of the JTree we're drawing for based on the dimension
returned from getPreferredSize.
- Overrides:
- visibleNodesChanged in class AbstractTreeUI
pathWasExpanded
protected void pathWasExpanded(TreePath path)
- Messaged from the VisibleTreeNode after it has been expanded.
- Overrides:
- pathWasExpanded in class AbstractTreeUI
pathWasCollapsed
protected void pathWasCollapsed(TreePath path)
- Messaged from the VisibleTreeNode after it has collapsed.
- Overrides:
- pathWasCollapsed in class AbstractTreeUI
ensureRowsAreVisible
public void ensureRowsAreVisible(int beginRow,
int endRow)
- Ensures that the rows identified by beginRow through endRow are
visible.
scrollPathToVisible
public void scrollPathToVisible(TreePath path)
- Makes sure all the path components in path are expanded (accept
for the last path component) and tries to scroll the resulting path
to be visible (the scrolling will only work if the JTree is
contained in a JScrollPane).
- Overrides:
- scrollPathToVisible in class TreeUI
scrollRowToVisible
public void scrollRowToVisible(int row)
- Scrolls the item identified by row to be visible. This will
only work if the JTree is contained in a JSrollPane.
- Overrides:
- scrollRowToVisible in class TreeUI
getCellRenderer
public TreeCellRenderer getCellRenderer()
- Return currentCellRenderer, which will either be the trees
renderer, or defaultCellRenderer, which ever wasn't null.
currentCellRenderer is set as part of checkConsistency().
createExpandedNodeForValue
protected LargeTreeModelNode createExpandedNodeForValue(Object value,
int childIndex)
- Creates a new instance of BasicLargeTreeModelNode.
paint
public void paint(Graphics g,
JComponent c)
- Overrides:
- paint in class ComponentUI
shouldDrawLegToParent
protected boolean shouldDrawLegToParent(VisibleTreeNode parentNode,
VisibleTreeNode childNode)
shouldPaintExpandControl
protected boolean shouldPaintExpandControl(VisibleTreeNode parentNode,
VisibleTreeNode childNode)
drawLeg
protected void drawLeg(Graphics g,
JComponent c,
VisibleTreeNode parentNode,
VisibleTreeNode childNode)
drawVerticalPartOfLeg
protected void drawVerticalPartOfLeg(Graphics g,
JComponent c,
int parentX,
int parentY,
int childX,
int childY,
int parentRowHeight,
int childRowHeight)
drawHorizontalPartOfLeg
protected void drawHorizontalPartOfLeg(Graphics g,
JComponent c,
int parentX,
int parentY,
int childX,
int childY,
int parentRowHeight,
int childRowHeight)
paintRow
protected void paintRow(Graphics g,
JComponent c,
VisibleTreeNode parentNode,
VisibleTreeNode childNode,
int childX,
int childY,
int childRowHeight,
int row)
paintExpandControl
protected void paintExpandControl(Graphics g,
JComponent c,
VisibleTreeNode parentNode,
VisibleTreeNode childNode,
int childX,
int childY,
int childRowHeight,
int row)
drawCentered
protected void drawCentered(Component c,
Graphics graphics,
Icon icon,
int x,
int y)
drawDashedHorizontalLine
protected void drawDashedHorizontalLine(Graphics g,
int y,
int x1,
int x2)
drawDashedVerticalLine
protected void drawDashedVerticalLine(Graphics g,
int x,
int y1,
int y2)
setPreferredMinSize
public void setPreferredMinSize(Dimension newSize)
- Sets the preferred minimum size.
getPreferredMinSize
public Dimension getPreferredMinSize()
- Returns the minimum preferred size.
getPreferredSize
public Dimension getPreferredSize(JComponent c)
- Returns the preferred size to properly display the tree,
this is a cover method for getPreferredSize(c, false).
- Overrides:
- getPreferredSize in class ComponentUI
getPreferredSize
public Dimension getPreferredSize(JComponent c,
boolean checkConsistancy)
- Returns the preferred size to represent the tree in
c. If checkConsistancy is true
checkConsistancy is messaged first.
getMinimumSize
public Dimension getMinimumSize(JComponent c)
- Returns the minimum size for this component. Which will be
the min preferred size or 0, 0.
- Overrides:
- getMinimumSize in class ComponentUI
getMaximumSize
public Dimension getMaximumSize(JComponent c)
- Returns the maximum size for this component, which will be the
preferred size if the instance is currently in a JTree, or 0, 0.
- Overrides:
- getMaximumSize in class ComponentUI
valueChanged
public void valueChanged(TreeSelectionEvent event)
- Messaged when the selection changes in the tree we're displaying
for. Stops editing, messages super and displays the changed paths.
- Overrides:
- valueChanged in class AbstractTreeUI
editingStopped
public void editingStopped(ChangeEvent e)
- Stops the editing session by messaging stopCellEditing(false).
editingCanceled
public void editingCanceled(ChangeEvent e)
- Stops the editing session by messaging cancelEditing(false).
isEditing
public boolean isEditing()
- Returns true if the tree is being edited. The item that is being
edited can be returned by getSelectionPath().
- Overrides:
- isEditing in class TreeUI
stopEditing
public boolean stopEditing()
- Stops the current editing session, returns true if the tree is
current editing and the editor returns true from stopCellEditing().
- Overrides:
- stopEditing in class TreeUI
cancelEditing
public void cancelEditing()
- Cancels the current editing session.
completeEditing
protected void completeEditing(boolean messageStop,
boolean messageCancel,
boolean messageTree)
- Stops the editing session. If messageStop is true the editor
is messaged with stopEditing, if messageCancel is true the
editor is messaged with cancelEditing. If messageTree is true
the treeModel is messaged with valueForPathChanged.
startEditingAtPath
public void startEditingAtPath(TreePath path)
- Selects the last item in path and tries to edit it. Editing will
fail if the CellEditor won't allow it for the selected item.
- Overrides:
- startEditingAtPath in class TreeUI
startEditing
protected boolean startEditing(TreePath path,
MouseEvent event)
- Will start editing for node if there is a cellEditor and
shouldSelectCell returns true.
This assumes that path is valid and visible.
getEditingPath
public TreePath getEditingPath()
- Returns the path to the element that is being edited.
- Overrides:
- getEditingPath in class TreeUI
mouseClicked
public void mouseClicked(MouseEvent e)
- Invoked when the mouse has been clicked on a component.
mousePressed
public void mousePressed(MouseEvent e)
- Invoked when a mouse button has been pressed on a component.
checkForClickInExpandControl
protected void checkForClickInExpandControl(VisibleTreeNode node,
LargeTreeModelNode eNode,
int childIndex,
int row,
int rowLevel,
int mouseX,
int mouseY)
clickedInExpandControl
protected boolean clickedInExpandControl(int row,
int rowLevel,
int mouseX,
int mouseY)
handleExpandControlClick
public void handleExpandControlClick(VisibleTreeNode node,
LargeTreeModelNode eNode,
int childIndex,
int row)
toggleExpandState
protected void toggleExpandState(int row)
mouseReleased
public void mouseReleased(MouseEvent e)
- Invoked when a mouse button has been released on a component.
mouseEntered
public void mouseEntered(MouseEvent e)
- Invoked when the mouse enters a component.
mouseExited
public void mouseExited(MouseEvent e)
- Invoked when the mouse exits a component.
focusGained
public void focusGained(FocusEvent e)
- Invoked when focus is activated on the tree we're in, redraws the
lead row.
focusLost
public void focusLost(FocusEvent e)
- Invoked when focus is activated on the tree we're in, redraws the
lead row.
keyPressed
public void keyPressed(KeyEvent e)
keyReleased
public void keyReleased(KeyEvent e)
keyTyped
public void keyTyped(KeyEvent e)
setModel
public void setModel(TreeModel newModel)
- Stops editing and messages super.
- Overrides:
- setModel in class AbstractTreeUI
rebuild
public void rebuild()
- Stops editing and messags super.
- Overrides:
- rebuild in class AbstractTreeUI
setSelectionModel
public void setSelectionModel(TreeSelectionModel newLSM)
- Stops editing, messags super and becomes a listener on the model.
- Overrides:
- setSelectionModel in class AbstractTreeUI
createNodeForValue
protected VisibleTreeNode createNodeForValue(Object value,
int index)
- Creates an instance of BasicVisibleTreeNode.
- Overrides:
- createNodeForValue in class AbstractTreeUI
createLargeTreeModelNodeForValue
protected LargeTreeModelNode createLargeTreeModelNodeForValue(Object value,
int childIndex)
- Creates an instance of BasicLargeTreeModelNode.
- Overrides:
- createLargeTreeModelNodeForValue in class AbstractTreeUI
repaintNode
protected void repaintNode(BasicLargeTreeModelNode node)
- Repaints the particular node by getting its bounds.
repaintNode
protected void repaintNode(VisibleTreeNode node)
- Repaints the particular node by getting its bounds.
All Packages Class Hierarchy This Package Previous Next Index
Submit a bug or feature