All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.basic.BasicTreeUI

java.lang.Object
   |
   +----com.sun.java.swing.plaf.ComponentUI
           |
           +----com.sun.java.swing.plaf.TreeUI
                   |
                   +----com.sun.java.swing.basic.AbstractTreeUI
                           |
                           +----com.sun.java.swing.basic.BasicTreeUI

public class BasicTreeUI
extends AbstractTreeUI
implements CellEditorListener, FocusListener, KeyListener, MouseListener, PropertyChangeListener

Variable Index

 o cellEditor
Editor for the tree.
 o collapsedIcon
 o componentListener
Used for large models, listens for moved/resized events and updates the validCachedPreferredSize bit accordingly.
 o cPreferredSize
Size needed to completely display all the nodes.
 o createdCellEditor
Set to true if editor renderer that is currently in the tree was created by this instance.
 o createdRenderer
Set to true if the renderer that is currently in the tree was created by this instance.
 o currentCellRenderer
Renderer that is being used to do the actual cell drawing.
 o editingComponent
When editing, this will be the Component that is doing the actual editing.
 o editingPath
Path that is being edited.
 o expandedIcon
 o HALF_SIZE
 o hashColor
Color used to draw hash marks.
 o isKeyDown
Set to true while keyPressed is active.
 o lastSelectedRow
Index of the row that was last selected.
 o leftChildIndent
Distance between left margin and where verical dashes will be drawn.
 o preferredMinSize
Minimum preferred size.
 o rendererPane
Used to paint the TreeCellRenderer.
 o repeatKeyAction
Key code that is being generated for.
 o rightChildIndent
Distance to add to leftChildIndent to determine where cell contents will be drawn.
 o SIZE
 o stopEditingInCompleteEditing
Set to false when editing and shouldSelectCell() returns true meaning the node should be selected before editing, used in completeEditing.
 o totalChildIndent
Total distance that will be indented.
 o tree
Component that we're going to be drawing into.
 o validCachedPreferredSize
Is the preferredSize valid?

Constructor Index

 o BasicTreeUI()

Method Index

 o cancelEditing()
Cancels the current editing session.
 o 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.
 o completeEditing(boolean, boolean, boolean)
Stops the editing session.
 o createExpandedNodeForValue(Object, int)
Creates a new instance of BasicLargeTreeModelNode.
 o createLargeTreeModelNodeForValue(Object, int)
Creates an instance of BasicLargeTreeModelNode.
 o createNodeForValue(Object, int)
Creates an instance of BasicVisibleTreeNode.
 o createUI(JComponent)
 o drawCentered(Component, Graphics, Icon, int, int)
 o drawDashedHorizontalLine(Graphics, int, int, int)
 o drawDashedVerticalLine(Graphics, int, int, int)
 o editingCanceled(ChangeEvent)
Stops the editing session by messaging cancelEditing(false).
 o editingStopped(ChangeEvent)
Stops the editing session by messaging stopCellEditing(false).
 o ensureRowsAreVisible(int, int)
Ensures that the rows identified by beginRow through endRow are visible.
 o focusGained(FocusEvent)
Invoked when focus is activated on the tree we're in, redraws the lead row.
 o focusLost(FocusEvent)
Invoked when focus is activated on the tree we're in, redraws the lead row.
 o getCellRenderer()
Return currentCellRenderer, which will either be the trees renderer, or defaultCellRenderer, which ever wasn't null.
 o getCollapsedIcon()
 o getDefaultCellEditor()
Creates a default cell editor.
 o getDefaultCellRenderer()
Returns the default cell renderer that is used to do the stamping of each node.
 o getEditingPath()
Returns the path to the element that is being edited.
 o getExpandedIcon()
 o getHashColor()
 o getLargeBoundsOf(LargeTreeModelNode, int, Object)
Returns the rectangle needed to draw the passed in row.
 o getLargeBoundsOf(LargeTreeModelNode, int, Object, Component, Rectangle[])
Returns the rectangle needed to draw the passed in row.
 o getLeftChildIndent()
 o 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.
 o getMinimumSize(JComponent)
Returns the minimum size for this component.
 o getPreferredMinSize()
Returns the minimum preferred size.
 o getPreferredSize(JComponent)
Returns the preferred size to properly display the tree, this is a cover method for getPreferredSize(c, false).
 o getPreferredSize(JComponent, boolean)
Returns the preferred size to represent the tree in c.
 o getRightChildIndent()
 o getSizeOfNode(VisibleTreeNode, int)
Messages the tree to configure the cell, and returns the the size of the component.
 o 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.
 o installUI(JComponent)
 o isEditing()
Returns true if the tree is being edited.
 o keyPressed(KeyEvent)
 o keyReleased(KeyEvent)
 o keyTyped(KeyEvent)
 o mouseClicked(MouseEvent)
Invoked when the mouse has been clicked on a component.
 o mouseEntered(MouseEvent)
Invoked when the mouse enters a component.
 o mouseExited(MouseEvent)
Invoked when the mouse exits a component.
 o mousePressed(MouseEvent)
Invoked when a mouse button has been pressed on a component.
 o mouseReleased(MouseEvent)
Invoked when a mouse button has been released on a component.
 o paint(Graphics, JComponent)
 o pathWasCollapsed(TreePath)
Messaged from the VisibleTreeNode after it has collapsed.
 o pathWasExpanded(TreePath)
Messaged from the VisibleTreeNode after it has been expanded.
 o propertyChange(PropertyChangeEvent)
Based on the value has changed will message the appropriate method.
 o rebuild()
Stops editing and messags super.
 o repaintNode(BasicLargeTreeModelNode)
Repaints the particular node by getting its bounds.
 o repaintNode(VisibleTreeNode)
Repaints the particular node by getting its bounds.
 o 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).
 o scrollRowToVisible(int)
Scrolls the item identified by row to be visible.
 o setCollapsedIcon(Icon)
 o setExpandedIcon(Icon)
 o setHashColor(Color)
 o setLargeModel(boolean)
Updates the componentListener, if necessary.
 o setLeftChildIndent(int)
 o setModel(TreeModel)
Stops editing and messages super.
 o setPreferredMinSize(Dimension)
Sets the preferred minimum size.
 o setRightChildIndent(int)
 o setSelectionModel(TreeSelectionModel)
Stops editing, messags super and becomes a listener on the model.
 o setupKeyboard()
Registers for keyboard events to manipulate the current selection.
 o 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.

 o startEditingAtPath(TreePath)
Selects the last item in path and tries to edit it.
 o stopEditing()
Stops the current editing session, returns true if the tree is current editing and the editor returns true from stopCellEditing().
 o uninstallUI(JComponent)
 o unsetKeyboard()
Unregisters for keyboard events that were previously registered for in setupKeyboard.
 o 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.

 o updateCellEditor()
Updates the cellEditor based on the editability of the JTree that we're contained in.
 o updateNodeSizes(boolean)
Resets the y origin of all the visible nodes as well as messaging all the visible nodes to updatePreferredSize().
 o updateRenderer()
Messaged from the tree we're in when the renderer has changed.
 o valueChanged(TreeSelectionEvent)
Messaged when the selection changes in the tree we're displaying for.
 o visibleNodesChanged()
Messaged whenever nodes are added/removed from the visible list, or the height/width of a node changes.

Variables

 o collapsedIcon
 protected transient Icon collapsedIcon
 o expandedIcon
 protected transient Icon expandedIcon
 o hashColor
 protected Color hashColor
Color used to draw hash marks. If null no hash marks will be drawn.

 o leftChildIndent
 protected int leftChildIndent
Distance between left margin and where verical dashes will be drawn.

 o rightChildIndent
 protected int rightChildIndent
Distance to add to leftChildIndent to determine where cell contents will be drawn.

 o totalChildIndent
 protected int totalChildIndent
Total distance that will be indented. The sum of leftChildIndent and rightChildIndent.

 o preferredMinSize
 protected Dimension preferredMinSize
Minimum preferred size.

 o lastSelectedRow
 protected int lastSelectedRow
Index of the row that was last selected.

 o tree
 protected JTree tree
Component that we're going to be drawing into.

 o currentCellRenderer
 protected transient TreeCellRenderer currentCellRenderer
Renderer that is being used to do the actual cell drawing.

 o createdRenderer
 protected boolean createdRenderer
Set to true if the renderer that is currently in the tree was created by this instance.

 o cellEditor
 protected transient TreeCellEditor cellEditor
Editor for the tree.

 o createdCellEditor
 protected boolean createdCellEditor
Set to true if editor renderer that is currently in the tree was created by this instance.

 o editingComponent
 protected Component editingComponent
When editing, this will be the Component that is doing the actual editing.

 o editingPath
 protected TreePath editingPath
Path that is being edited.

 o repeatKeyAction
 protected Action repeatKeyAction
Key code that is being generated for.

 o isKeyDown
 protected boolean isKeyDown
Set to true while keyPressed is active.

 o stopEditingInCompleteEditing
 protected boolean stopEditingInCompleteEditing
Set to false when editing and shouldSelectCell() returns true meaning the node should be selected before editing, used in completeEditing.

 o rendererPane
 protected CellRendererPane rendererPane
Used to paint the TreeCellRenderer.

 o cPreferredSize
 protected Dimension cPreferredSize
Size needed to completely display all the nodes.

 o validCachedPreferredSize
 protected boolean validCachedPreferredSize
Is the preferredSize valid?

 o componentListener
 protected transient ComponentAdapter componentListener
Used for large models, listens for moved/resized events and updates the validCachedPreferredSize bit accordingly.

 o HALF_SIZE
 protected static final int HALF_SIZE
 o SIZE
 protected static final int SIZE

Constructors

 o BasicTreeUI
 public BasicTreeUI()

Methods

 o createUI
 public static ComponentUI createUI(JComponent x)
 o setLeftChildIndent
 public void setLeftChildIndent(int newAmount)
 o getLeftChildIndent
 public int getLeftChildIndent()
 o setRightChildIndent
 public void setRightChildIndent(int newAmount)
 o getRightChildIndent
 public int getRightChildIndent()
 o setExpandedIcon
 public void setExpandedIcon(Icon newG)
 o getExpandedIcon
 public Icon getExpandedIcon()
 o setCollapsedIcon
 public void setCollapsedIcon(Icon newG)
 o getCollapsedIcon
 public Icon getCollapsedIcon()
 o setHashColor
 public void setHashColor(Color newColor)
 o getHashColor
 public Color getHashColor()
 o setLargeModel
 public void setLargeModel(boolean largeModel)
Updates the componentListener, if necessary.

Overrides:
setLargeModel in class AbstractTreeUI
 o installUI
 public void installUI(JComponent c)
Overrides:
installUI in class ComponentUI
 o uninstallUI
 public void uninstallUI(JComponent c)
Overrides:
uninstallUI in class ComponentUI
 o 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.

 o setupKeyboard
 protected void setupKeyboard()
Registers for keyboard events to manipulate the current selection.

 o unsetKeyboard
 protected void unsetKeyboard()
Unregisters for keyboard events that were previously registered for in setupKeyboard.

 o 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.

 o updateRenderer
 protected void updateRenderer()
Messaged from the tree we're in when the renderer has changed. Updates the size if necessary.

 o 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.

 o 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
 o getDefaultCellEditor
 protected TreeCellEditor getDefaultCellEditor()
Creates a default cell editor.

 o getDefaultCellRenderer
 public TreeCellRenderer getDefaultCellRenderer()
Returns the default cell renderer that is used to do the stamping of each node.

 o 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
 o 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
 o 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
 o 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].

 o 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.

 o 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
 o pathWasExpanded
 protected void pathWasExpanded(TreePath path)
Messaged from the VisibleTreeNode after it has been expanded.

Overrides:
pathWasExpanded in class AbstractTreeUI
 o pathWasCollapsed
 protected void pathWasCollapsed(TreePath path)
Messaged from the VisibleTreeNode after it has collapsed.

Overrides:
pathWasCollapsed in class AbstractTreeUI
 o ensureRowsAreVisible
 public void ensureRowsAreVisible(int beginRow,
                                  int endRow)
Ensures that the rows identified by beginRow through endRow are visible.

 o 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
 o 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
 o 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().

 o createExpandedNodeForValue
 protected LargeTreeModelNode createExpandedNodeForValue(Object value,
                                                         int childIndex)
Creates a new instance of BasicLargeTreeModelNode.

 o paint
 public void paint(Graphics g,
                   JComponent c)
Overrides:
paint in class ComponentUI
 o drawCentered
 protected void drawCentered(Component c,
                             Graphics graphics,
                             Icon icon,
                             int x,
                             int y)
 o drawDashedHorizontalLine
 protected void drawDashedHorizontalLine(Graphics g,
                                         int y,
                                         int x1,
                                         int x2)
 o drawDashedVerticalLine
 protected void drawDashedVerticalLine(Graphics g,
                                       int x,
                                       int y1,
                                       int y2)
 o setPreferredMinSize
 public void setPreferredMinSize(Dimension newSize)
Sets the preferred minimum size.

 o getPreferredMinSize
 public Dimension getPreferredMinSize()
Returns the minimum preferred size.

 o 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
 o 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.

 o 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
 o 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
 o 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
 o editingStopped
 public void editingStopped(ChangeEvent e)
Stops the editing session by messaging stopCellEditing(false).

 o editingCanceled
 public void editingCanceled(ChangeEvent e)
Stops the editing session by messaging cancelEditing(false).

 o 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
 o 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
 o cancelEditing
 public void cancelEditing()
Cancels the current editing session.

 o 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.

 o 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
 o 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.

 o getEditingPath
 public TreePath getEditingPath()
Returns the path to the element that is being edited.

Overrides:
getEditingPath in class TreeUI
 o mouseClicked
 public void mouseClicked(MouseEvent e)
Invoked when the mouse has been clicked on a component.

 o mousePressed
 public void mousePressed(MouseEvent e)
Invoked when a mouse button has been pressed on a component.

 o mouseReleased
 public void mouseReleased(MouseEvent e)
Invoked when a mouse button has been released on a component.

 o mouseEntered
 public void mouseEntered(MouseEvent e)
Invoked when the mouse enters a component.

 o mouseExited
 public void mouseExited(MouseEvent e)
Invoked when the mouse exits a component.

 o focusGained
 public void focusGained(FocusEvent e)
Invoked when focus is activated on the tree we're in, redraws the lead row.

 o focusLost
 public void focusLost(FocusEvent e)
Invoked when focus is activated on the tree we're in, redraws the lead row.

 o keyPressed
 public void keyPressed(KeyEvent e)
 o keyReleased
 public void keyReleased(KeyEvent e)
 o keyTyped
 public void keyTyped(KeyEvent e)
 o setModel
 public void setModel(TreeModel newModel)
Stops editing and messages super.

Overrides:
setModel in class AbstractTreeUI
 o rebuild
 public void rebuild()
Stops editing and messags super.

Overrides:
rebuild in class AbstractTreeUI
 o setSelectionModel
 public void setSelectionModel(TreeSelectionModel newLSM)
Stops editing, messags super and becomes a listener on the model.

Overrides:
setSelectionModel in class AbstractTreeUI
 o createNodeForValue
 protected VisibleTreeNode createNodeForValue(Object value,
                                              int index)
Creates an instance of BasicVisibleTreeNode.

Overrides:
createNodeForValue in class AbstractTreeUI
 o createLargeTreeModelNodeForValue
 protected LargeTreeModelNode createLargeTreeModelNodeForValue(Object value,
                                                               int childIndex)
Creates an instance of BasicLargeTreeModelNode.

Overrides:
createLargeTreeModelNodeForValue in class AbstractTreeUI
 o repaintNode
 protected void repaintNode(BasicLargeTreeModelNode node)
Repaints the particular node by getting its bounds.

 o repaintNode
 protected void repaintNode(VisibleTreeNode node)
Repaints the particular node by getting its bounds.


All Packages  Class Hierarchy  This Package  Previous  Next  Index