Quaqua 7.4.2 2011-07-05

ch.randelshofer.quaqua
Class QuaquaTreeUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by javax.swing.plaf.TreeUI
          extended by javax.swing.plaf.basic.BasicTreeUI
              extended by ch.randelshofer.quaqua.QuaquaTreeUI

public class QuaquaTreeUI
extends javax.swing.plaf.basic.BasicTreeUI

QuaquaTreeUI. XXX - Without copying a substantial amount of code from BasicTreeUI, we can't implement the proper selection behavior for a JTree.

Version:
$Id: QuaquaTreeUI.java 374 2011-02-11 11:41:10Z wrandelshofer $
Author:
Werner Randelshofer

Nested Class Summary
 class QuaquaTreeUI.FocusHandler
          This inner class is marked "public" due to a compiler bug.
 class QuaquaTreeUI.TreeCancelEditingAction
          ActionListener that invokes cancelEditing when action performed.
 class QuaquaTreeUI.TreeHomeAction
          TreeHomeAction is used to handle end/home actions.
 class QuaquaTreeUI.TreeIncrementAction
          TreeIncrementAction is used to handle up/down actions.
 class QuaquaTreeUI.TreePageAction
          TreePageAction handles page up and page down events.
 class QuaquaTreeUI.TreeToggleAction
          For the first selected row expandedness will be toggled.
 class QuaquaTreeUI.TreeTraverseAction
          TreeTraverseAction is the action used for left/right keys.
 
Nested classes/interfaces inherited from class javax.swing.plaf.basic.BasicTreeUI
javax.swing.plaf.basic.BasicTreeUI.CellEditorHandler, javax.swing.plaf.basic.BasicTreeUI.ComponentHandler, javax.swing.plaf.basic.BasicTreeUI.KeyHandler, javax.swing.plaf.basic.BasicTreeUI.MouseHandler, javax.swing.plaf.basic.BasicTreeUI.MouseInputHandler, javax.swing.plaf.basic.BasicTreeUI.NodeDimensionsHandler, javax.swing.plaf.basic.BasicTreeUI.PropertyChangeHandler, javax.swing.plaf.basic.BasicTreeUI.SelectionModelPropertyChangeHandler, javax.swing.plaf.basic.BasicTreeUI.TreeExpansionHandler, javax.swing.plaf.basic.BasicTreeUI.TreeModelHandler, javax.swing.plaf.basic.BasicTreeUI.TreeSelectionHandler
 
Field Summary
 
Fields inherited from class javax.swing.plaf.basic.BasicTreeUI
cellEditor, collapsedIcon, createdCellEditor, createdRenderer, currentCellRenderer, depthOffset, drawingCache, editingComponent, editingPath, editingRow, editorHasDifferentSize, expandedIcon, largeModel, lastSelectedRow, leftChildIndent, nodeDimensions, preferredMinSize, preferredSize, rendererPane, rightChildIndent, stopEditingInCompleteEditing, totalChildIndent, tree, treeModel, treeSelectionModel, treeState, validCachedPreferredSize
 
Constructor Summary
QuaquaTreeUI()
          Creates a new instance.
 
Method Summary
protected  javax.swing.event.CellEditorListener createCellEditorListener()
          Creates a listener to handle events from the current editor.
protected  javax.swing.tree.TreeCellEditor createDefaultCellEditor()
          Creates a default cell editor.
protected  javax.swing.tree.TreeCellRenderer createDefaultCellRenderer()
          Returns the default cell renderer that is used to do the stamping of each node.
protected  java.awt.event.FocusListener createFocusListener()
          Creates the focus listener for handling keyboard navigation in the JTable.
protected  java.awt.event.KeyListener createKeyListener()
          Creates the listener reponsible for getting key events from the tree.
protected  java.awt.event.MouseListener createMouseListener()
           
protected  java.beans.PropertyChangeListener createPropertyChangeListener()
          Creates a listener that is responsible that updates the UI based on how the tree changes.
protected  java.beans.PropertyChangeListener createSelectionModelPropertyChangeListener()
          Creates the listener responsible for getting property change events from the selection model.
protected  javax.swing.event.TreeExpansionListener createTreeExpansionListener()
          Creates and returns the object responsible for updating the treestate when nodes expanded state changes.
protected  javax.swing.event.TreeModelListener createTreeModelListener()
          Returns a listener that can update the tree when the model changes.
protected  javax.swing.event.TreeSelectionListener createTreeSelectionListener()
          Creates the listener that updates the display based on selection change methods.
static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
           
protected  int getRowX(int row, int depth)
          Returns the location, along the x-axis, to render a particular row at.
protected  boolean getShowsRootHandles()
           
protected  void installDefaults()
           
protected  void installKeyboardActions()
           
protected  boolean isMultiSelectEvent(java.awt.event.MouseEvent event)
          Returning true signifies a mouse event on the node should select from the anchor point.
protected  boolean isToggleEvent(java.awt.event.MouseEvent event)
           
protected  boolean isToggleSelectionEvent(java.awt.event.MouseEvent event)
          Returning true signifies a mouse event on the node should toggle the selection of only the row under mouse.
 void paint(java.awt.Graphics gr, javax.swing.JComponent c)
           
protected  void paintExpandControl(java.awt.Graphics g, java.awt.Rectangle clipBounds, java.awt.Insets insets, java.awt.Rectangle bounds, javax.swing.tree.TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)
          Paints the expand (toggle) part of a row.
protected  void paintHorizontalLine(java.awt.Graphics g, javax.swing.JComponent c, int y, int left, int right)
          Paints a horizontal line.
protected  void paintHorizontalPartOfLeg(java.awt.Graphics g, java.awt.Rectangle clipBounds, java.awt.Insets insets, java.awt.Rectangle bounds, javax.swing.tree.TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)
          Paints the horizontal part of the leg.
protected  void paintRow(java.awt.Graphics g, java.awt.Rectangle clipBounds, java.awt.Insets insets, java.awt.Rectangle bounds, javax.swing.tree.TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf, boolean isEnabled, boolean isFocused, boolean isActive)
          Paints the renderer part of a row.
protected  void paintVerticalLine(java.awt.Graphics g, javax.swing.JComponent c, int x, int top, int bottom)
          Paints a vertical line.
protected  void paintVerticalPartOfLeg(java.awt.Graphics g, java.awt.Rectangle clipBounds, java.awt.Insets insets, javax.swing.tree.TreePath path)
          Paints the vertical part of the leg.
protected  void prepareForUIInstall()
          Invoked after the tree instance variable has been set, but before any defaults/listeners have been installed.
protected  void setShowsRootHandles(boolean newValue)
          Determines whether the node handles are to be displayed.
protected  void uninstallListeners()
           
 
Methods inherited from class javax.swing.plaf.basic.BasicTreeUI
cancelEditing, checkForClickInExpandControl, completeEditing, completeEditing, completeUIInstall, completeUIUninstall, configureLayoutCache, createCellRendererPane, createComponentListener, createLayoutCache, createNodeDimensions, drawCentered, drawDashedHorizontalLine, drawDashedVerticalLine, ensureRowsAreVisible, getBaseline, getBaselineResizeBehavior, getCellEditor, getCellRenderer, getClosestPathForLocation, getCollapsedIcon, getEditingPath, getExpandedIcon, getHashColor, getHorizontalLegBuffer, getLastChildPath, getLeftChildIndent, getMaximumSize, getMinimumSize, getModel, getPathBounds, getPathForRow, getPreferredMinSize, getPreferredSize, getPreferredSize, getRightChildIndent, getRowCount, getRowForPath, getRowHeight, getSelectionModel, getVerticalLegBuffer, handleExpandControlClick, installComponents, installListeners, installUI, isEditable, isEditing, isLargeModel, isLeaf, isLocationInExpandControl, isRootVisible, paintRow, pathWasCollapsed, pathWasExpanded, prepareForUIUninstall, selectPathForEvent, setCellEditor, setCellRenderer, setCollapsedIcon, setEditable, setExpandedIcon, setHashColor, setLargeModel, setLeftChildIndent, setModel, setPreferredMinSize, setRightChildIndent, setRootVisible, setRowHeight, setSelectionModel, shouldPaintExpandControl, startEditing, startEditingAtPath, stopEditing, toggleExpandState, uninstallComponents, uninstallDefaults, uninstallKeyboardActions, uninstallUI, updateCachedPreferredSize, updateCellEditor, updateDepthOffset, updateExpandedDescendants, updateLayoutCacheExpandedNodes, updateRenderer, updateSize
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuaquaTreeUI

public QuaquaTreeUI()
Creates a new instance.

Method Detail

createUI

public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)

installDefaults

protected void installDefaults()
Overrides:
installDefaults in class javax.swing.plaf.basic.BasicTreeUI

installKeyboardActions

protected void installKeyboardActions()
Overrides:
installKeyboardActions in class javax.swing.plaf.basic.BasicTreeUI

prepareForUIInstall

protected void prepareForUIInstall()
Invoked after the tree instance variable has been set, but before any defaults/listeners have been installed.

Overrides:
prepareForUIInstall in class javax.swing.plaf.basic.BasicTreeUI

uninstallListeners

protected void uninstallListeners()
Overrides:
uninstallListeners in class javax.swing.plaf.basic.BasicTreeUI

createDefaultCellEditor

protected javax.swing.tree.TreeCellEditor createDefaultCellEditor()
Creates a default cell editor.

Overrides:
createDefaultCellEditor in class javax.swing.plaf.basic.BasicTreeUI

createDefaultCellRenderer

protected javax.swing.tree.TreeCellRenderer createDefaultCellRenderer()
Returns the default cell renderer that is used to do the stamping of each node.

Overrides:
createDefaultCellRenderer in class javax.swing.plaf.basic.BasicTreeUI

createKeyListener

protected java.awt.event.KeyListener createKeyListener()
Creates the listener reponsible for getting key events from the tree.

Overrides:
createKeyListener in class javax.swing.plaf.basic.BasicTreeUI

createSelectionModelPropertyChangeListener

protected java.beans.PropertyChangeListener createSelectionModelPropertyChangeListener()
Creates the listener responsible for getting property change events from the selection model.

Overrides:
createSelectionModelPropertyChangeListener in class javax.swing.plaf.basic.BasicTreeUI

createTreeSelectionListener

protected javax.swing.event.TreeSelectionListener createTreeSelectionListener()
Creates the listener that updates the display based on selection change methods.

Overrides:
createTreeSelectionListener in class javax.swing.plaf.basic.BasicTreeUI

createCellEditorListener

protected javax.swing.event.CellEditorListener createCellEditorListener()
Creates a listener to handle events from the current editor.

Overrides:
createCellEditorListener in class javax.swing.plaf.basic.BasicTreeUI

createTreeExpansionListener

protected javax.swing.event.TreeExpansionListener createTreeExpansionListener()
Creates and returns the object responsible for updating the treestate when nodes expanded state changes.

Overrides:
createTreeExpansionListener in class javax.swing.plaf.basic.BasicTreeUI

createPropertyChangeListener

protected java.beans.PropertyChangeListener createPropertyChangeListener()
Creates a listener that is responsible that updates the UI based on how the tree changes.

Overrides:
createPropertyChangeListener in class javax.swing.plaf.basic.BasicTreeUI

createTreeModelListener

protected javax.swing.event.TreeModelListener createTreeModelListener()
Returns a listener that can update the tree when the model changes.

Overrides:
createTreeModelListener in class javax.swing.plaf.basic.BasicTreeUI

isToggleSelectionEvent

protected boolean isToggleSelectionEvent(java.awt.event.MouseEvent event)
Returning true signifies a mouse event on the node should toggle the selection of only the row under mouse.

Overrides:
isToggleSelectionEvent in class javax.swing.plaf.basic.BasicTreeUI

isToggleEvent

protected boolean isToggleEvent(java.awt.event.MouseEvent event)
Overrides:
isToggleEvent in class javax.swing.plaf.basic.BasicTreeUI

isMultiSelectEvent

protected boolean isMultiSelectEvent(java.awt.event.MouseEvent event)
Returning true signifies a mouse event on the node should select from the anchor point.

Overrides:
isMultiSelectEvent in class javax.swing.plaf.basic.BasicTreeUI

setShowsRootHandles

protected void setShowsRootHandles(boolean newValue)
Determines whether the node handles are to be displayed. Regardless of what value you specify here, the Quaqua look and feel always shows the root handles.

Overrides:
setShowsRootHandles in class javax.swing.plaf.basic.BasicTreeUI

getShowsRootHandles

protected boolean getShowsRootHandles()
Overrides:
getShowsRootHandles in class javax.swing.plaf.basic.BasicTreeUI

paintExpandControl

protected void paintExpandControl(java.awt.Graphics g,
                                  java.awt.Rectangle clipBounds,
                                  java.awt.Insets insets,
                                  java.awt.Rectangle bounds,
                                  javax.swing.tree.TreePath path,
                                  int row,
                                  boolean isExpanded,
                                  boolean hasBeenExpanded,
                                  boolean isLeaf)
Paints the expand (toggle) part of a row. The receiver should NOT modify clipBounds, or insets.

Overrides:
paintExpandControl in class javax.swing.plaf.basic.BasicTreeUI

getRowX

protected int getRowX(int row,
                      int depth)
Returns the location, along the x-axis, to render a particular row at. The return value does not include any Insets specified on the JTree. This does not check for the validity of the row or depth, it is assumed to be correct and will not throw an Exception if the row or depth doesn't match that of the tree.

Overrides:
getRowX in class javax.swing.plaf.basic.BasicTreeUI
Parameters:
row - Row to return x location for
depth - Depth of the row
Returns:
amount to indent the given row.
Since:
1.5

createFocusListener

protected java.awt.event.FocusListener createFocusListener()
Creates the focus listener for handling keyboard navigation in the JTable.

Overrides:
createFocusListener in class javax.swing.plaf.basic.BasicTreeUI

createMouseListener

protected java.awt.event.MouseListener createMouseListener()
Overrides:
createMouseListener in class javax.swing.plaf.basic.BasicTreeUI

paint

public void paint(java.awt.Graphics gr,
                  javax.swing.JComponent c)
Overrides:
paint in class javax.swing.plaf.basic.BasicTreeUI

paintVerticalPartOfLeg

protected void paintVerticalPartOfLeg(java.awt.Graphics g,
                                      java.awt.Rectangle clipBounds,
                                      java.awt.Insets insets,
                                      javax.swing.tree.TreePath path)
Paints the vertical part of the leg. The receiver should NOT modify clipBounds, insets.

Overrides:
paintVerticalPartOfLeg in class javax.swing.plaf.basic.BasicTreeUI

paintHorizontalPartOfLeg

protected void paintHorizontalPartOfLeg(java.awt.Graphics g,
                                        java.awt.Rectangle clipBounds,
                                        java.awt.Insets insets,
                                        java.awt.Rectangle bounds,
                                        javax.swing.tree.TreePath path,
                                        int row,
                                        boolean isExpanded,
                                        boolean hasBeenExpanded,
                                        boolean isLeaf)
Paints the horizontal part of the leg. The receiver should NOT modify clipBounds, or insets.

NOTE: parentRow can be -1 if the root is not visible.

Overrides:
paintHorizontalPartOfLeg in class javax.swing.plaf.basic.BasicTreeUI

paintVerticalLine

protected void paintVerticalLine(java.awt.Graphics g,
                                 javax.swing.JComponent c,
                                 int x,
                                 int top,
                                 int bottom)
Paints a vertical line.

Overrides:
paintVerticalLine in class javax.swing.plaf.basic.BasicTreeUI

paintHorizontalLine

protected void paintHorizontalLine(java.awt.Graphics g,
                                   javax.swing.JComponent c,
                                   int y,
                                   int left,
                                   int right)
Paints a horizontal line.

Overrides:
paintHorizontalLine in class javax.swing.plaf.basic.BasicTreeUI

paintRow

protected void paintRow(java.awt.Graphics g,
                        java.awt.Rectangle clipBounds,
                        java.awt.Insets insets,
                        java.awt.Rectangle bounds,
                        javax.swing.tree.TreePath path,
                        int row,
                        boolean isExpanded,
                        boolean hasBeenExpanded,
                        boolean isLeaf,
                        boolean isEnabled,
                        boolean isFocused,
                        boolean isActive)
Paints the renderer part of a row. The receiver should NOT modify clipBounds, or insets.


Copyright 2003-2007 (c) Werner Randelshofer.
All rights reserved.