com.explodingpixels.macwidgets.plaf
Class SourceListTreeUI
java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.TreeUI
javax.swing.plaf.basic.BasicTreeUI
com.explodingpixels.macwidgets.plaf.SourceListTreeUI
public class SourceListTreeUI
- extends BasicTreeUI
A UI delegate that paints a JTree as an Apple defined
Source List. While this UI delegate can be directly installed on existing JTrees, it is
recommended that you use the MacWidgetFactory.makeSourceList(javax.swing.JTree) method
in conjuction with MacWidgetFactory.createSourceListScrollPane(javax.swing.JComponent).
For the best development experience, it is recommended that you migrate your code to use the
SourceList with the SourceListModel, as this component abstracts away many of the
complexities of JTree.
Pictured below are the two different rendering styles of a Source List: focused and unfocused.
The corresponding JTree's focusable property drives this rendering style.
 |
 |
| Focusable SourceList |
Non-focusable SourceList |
Providing Category and Item text and icons
During the rendering process, each Category and Item node will be consulted for the text to be
displayed. The renderer determines the text based on these prioritized checks:
- If the node is an instance of
DefaultMutableTreeNode, and the
DefaultMutableTreeNode.getUserObject() is an instance of TextProvider, then
the TextProvider will be queried for the node text.
- If no implementation of
TextProvider is found, the standard
JTree.convertValueToText(Object, boolean, boolean, boolean, int, boolean) method will
be consulted.
Also, during rendering, each Item node will be consulted for an icon. Similarly to the above
mechanism for determining text, the render determines a nodes icon by the following check:
- If the node is an instance of
DefaultMutableTreeNode, and the
DefaultMutableTreeNode.getUserObject() is an instance of IconProvider, then
the IconProvider will be queried for the node icon.
| Nested classes/interfaces inherited from class javax.swing.plaf.basic.BasicTreeUI |
BasicTreeUI.CellEditorHandler, BasicTreeUI.ComponentHandler, BasicTreeUI.FocusHandler, BasicTreeUI.KeyHandler, BasicTreeUI.MouseHandler, BasicTreeUI.MouseInputHandler, BasicTreeUI.NodeDimensionsHandler, BasicTreeUI.PropertyChangeHandler, BasicTreeUI.SelectionModelPropertyChangeHandler, BasicTreeUI.TreeCancelEditingAction, BasicTreeUI.TreeExpansionHandler, BasicTreeUI.TreeHomeAction, BasicTreeUI.TreeIncrementAction, BasicTreeUI.TreeModelHandler, BasicTreeUI.TreePageAction, BasicTreeUI.TreeSelectionHandler, BasicTreeUI.TreeToggleAction, BasicTreeUI.TreeTraverseAction |
| 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 |
|
Method Summary |
protected void |
completeUIInstall()
|
protected AbstractLayoutCache.NodeDimensions |
createNodeDimensions()
|
Rectangle |
getPathBounds(JTree tree,
TreePath path)
|
protected void |
installKeyboardActions()
|
protected void |
installListeners()
|
void |
paint(Graphics g,
JComponent c)
|
protected void |
paintExpandControl(Graphics g,
Rectangle clipBounds,
Insets insets,
Rectangle bounds,
TreePath path,
int row,
boolean isExpanded,
boolean hasBeenExpanded,
boolean isLeaf)
|
protected void |
paintHorizontalLine(Graphics g,
JComponent c,
int y,
int left,
int right)
|
protected void |
paintVerticalPartOfLeg(Graphics g,
Rectangle clipBounds,
Insets insets,
TreePath path)
|
void |
setColorScheme(SourceListColorScheme colorScheme)
|
| Methods inherited from class javax.swing.plaf.basic.BasicTreeUI |
cancelEditing, checkForClickInExpandControl, completeEditing, completeEditing, completeUIUninstall, configureLayoutCache, createCellEditorListener, createCellRendererPane, createComponentListener, createDefaultCellEditor, createDefaultCellRenderer, createFocusListener, createKeyListener, createLayoutCache, createMouseListener, createPropertyChangeListener, createSelectionModelPropertyChangeListener, createTreeExpansionListener, createTreeModelListener, createTreeSelectionListener, createUI, drawCentered, drawDashedHorizontalLine, drawDashedVerticalLine, ensureRowsAreVisible, getCellEditor, getCellRenderer, getClosestPathForLocation, getCollapsedIcon, getEditingPath, getExpandedIcon, getHashColor, getHorizontalLegBuffer, getLastChildPath, getLeftChildIndent, getMaximumSize, getMinimumSize, getModel, getPathForRow, getPreferredMinSize, getPreferredSize, getPreferredSize, getRightChildIndent, getRowCount, getRowForPath, getRowHeight, getRowX, getSelectionModel, getShowsRootHandles, getVerticalLegBuffer, handleExpandControlClick, installComponents, installDefaults, installUI, isEditable, isEditing, isLargeModel, isLeaf, isLocationInExpandControl, isMultiSelectEvent, isRootVisible, isToggleEvent, isToggleSelectionEvent, paintHorizontalPartOfLeg, paintRow, paintVerticalLine, pathWasCollapsed, pathWasExpanded, prepareForUIInstall, prepareForUIUninstall, selectPathForEvent, setCellEditor, setCellRenderer, setCollapsedIcon, setEditable, setExpandedIcon, setHashColor, setLargeModel, setLeftChildIndent, setModel, setPreferredMinSize, setRightChildIndent, setRootVisible, setRowHeight, setSelectionModel, setShowsRootHandles, shouldPaintExpandControl, startEditing, startEditingAtPath, stopEditing, toggleExpandState, uninstallComponents, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, uninstallUI, updateCachedPreferredSize, updateCellEditor, updateDepthOffset, updateExpandedDescendants, updateLayoutCacheExpandedNodes, updateRenderer, updateSize |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SourceListTreeUI
public SourceListTreeUI()
completeUIInstall
protected void completeUIInstall()
- Overrides:
completeUIInstall in class BasicTreeUI
installListeners
protected void installListeners()
- Overrides:
installListeners in class BasicTreeUI
installKeyboardActions
protected void installKeyboardActions()
- Overrides:
installKeyboardActions in class BasicTreeUI
setColorScheme
public void setColorScheme(SourceListColorScheme colorScheme)
paintExpandControl
protected void paintExpandControl(Graphics g,
Rectangle clipBounds,
Insets insets,
Rectangle bounds,
TreePath path,
int row,
boolean isExpanded,
boolean hasBeenExpanded,
boolean isLeaf)
- Overrides:
paintExpandControl in class BasicTreeUI
createNodeDimensions
protected AbstractLayoutCache.NodeDimensions createNodeDimensions()
- Overrides:
createNodeDimensions in class BasicTreeUI
getPathBounds
public Rectangle getPathBounds(JTree tree,
TreePath path)
- Overrides:
getPathBounds in class BasicTreeUI
paint
public void paint(Graphics g,
JComponent c)
- Overrides:
paint in class BasicTreeUI
paintHorizontalLine
protected void paintHorizontalLine(Graphics g,
JComponent c,
int y,
int left,
int right)
- Overrides:
paintHorizontalLine in class BasicTreeUI
paintVerticalPartOfLeg
protected void paintVerticalPartOfLeg(Graphics g,
Rectangle clipBounds,
Insets insets,
TreePath path)
- Overrides:
paintVerticalPartOfLeg in class BasicTreeUI