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 javax.swing.plaf.basic.BasicTreeUI
A UI delegate that paints a
JTree
as an Apple defined Source List. Consider using this UI delegate withMacWidgetFactory.createSourceListScrollPane(javax.swing.JComponent)
.For the best development experience, it is recommended that you migrate your code to use the
SourceList
with theSourceListModel
, as this component abstracts away many of the complexities ofJTree
.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 theDefaultMutableTreeNode.getUserObject()
is an instance ofTextProvider
, then theTextProvider
will be queried for the node text. - If no implementation of
TextProvider
is found, the standardJTree.convertValueToText(Object, boolean, boolean, boolean, int, boolean)
method will be consulted.
- If the node is an instance of
DefaultMutableTreeNode
, and theDefaultMutableTreeNode.getUserObject()
is an instance ofIconProvider
, then theIconProvider
will be queried for the node icon.
- If the node is an instance of
-
-
Nested Class Summary
-
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.FocusHandler, 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.TreeCancelEditingAction, javax.swing.plaf.basic.BasicTreeUI.TreeExpansionHandler, javax.swing.plaf.basic.BasicTreeUI.TreeHomeAction, javax.swing.plaf.basic.BasicTreeUI.TreeIncrementAction, javax.swing.plaf.basic.BasicTreeUI.TreeModelHandler, javax.swing.plaf.basic.BasicTreeUI.TreePageAction, javax.swing.plaf.basic.BasicTreeUI.TreeSelectionHandler, javax.swing.plaf.basic.BasicTreeUI.TreeToggleAction, javax.swing.plaf.basic.BasicTreeUI.TreeTraverseAction
-
-
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
Constructors Constructor Description SourceListTreeUI()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
completeUIInstall()
protected javax.swing.tree.AbstractLayoutCache.NodeDimensions
createNodeDimensions()
java.awt.Font
getCategoryFont()
SourceListColorScheme
getColorScheme()
Gets theSourceListColorScheme
that thisSourceListTreeUI
uses to paint.java.awt.Font
getItemFont()
java.awt.Font
getItemSelectedFont()
java.awt.Rectangle
getPathBounds(javax.swing.JTree tree, javax.swing.tree.TreePath path)
protected void
installKeyboardActions()
protected void
installListeners()
void
paint(java.awt.Graphics g, 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)
protected void
paintHorizontalLine(java.awt.Graphics g, javax.swing.JComponent c, int y, int left, int right)
protected void
paintVerticalPartOfLeg(java.awt.Graphics g, java.awt.Rectangle clipBounds, java.awt.Insets insets, javax.swing.tree.TreePath path)
protected void
selectPathForEvent(javax.swing.tree.TreePath path, java.awt.event.MouseEvent event)
void
setCategoryFont(java.awt.Font categoryFont)
void
setColorScheme(SourceListColorScheme colorScheme)
Sets theSourceListColorScheme
that thisSourceListTreeUI
uses to paint.void
setItemFont(java.awt.Font itemFont)
void
setItemSelectedFont(java.awt.Font itemSelectedFont)
protected void
setModel(javax.swing.tree.TreeModel model)
-
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, getBaseline, getBaselineResizeBehavior, getCellEditor, getCellRenderer, getClosestPathForLocation, getCollapsedIcon, getDropLineRect, getEditingPath, getExpandedIcon, getHashColor, getHorizontalLegBuffer, getLastChildPath, getLeadSelectionRow, getLeftChildIndent, getMaximumSize, getMinimumSize, getModel, getPathForRow, getPreferredMinSize, getPreferredSize, getPreferredSize, getRightChildIndent, getRowCount, getRowForPath, getRowHeight, getRowX, getSelectionModel, getShowsRootHandles, getVerticalLegBuffer, handleExpandControlClick, installComponents, installDefaults, installUI, isDropLine, isEditable, isEditing, isLargeModel, isLeaf, isLocationInExpandControl, isMultiSelectEvent, isRootVisible, isToggleEvent, isToggleSelectionEvent, paintDropLine, paintHorizontalPartOfLeg, paintRow, paintVerticalLine, pathWasCollapsed, pathWasExpanded, prepareForUIInstall, prepareForUIUninstall, setCellEditor, setCellRenderer, setCollapsedIcon, setEditable, setExpandedIcon, setHashColor, setLargeModel, setLeftChildIndent, setPreferredMinSize, setRightChildIndent, setRootVisible, setRowHeight, setSelectionModel, setShowsRootHandles, shouldPaintExpandControl, startEditing, startEditingAtPath, stopEditing, toggleExpandState, uninstallComponents, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, uninstallUI, updateCachedPreferredSize, updateCellEditor, updateDepthOffset, updateExpandedDescendants, updateLayoutCacheExpandedNodes, updateLeadSelectionRow, updateRenderer, updateSize
-
-
-
-
Method Detail
-
completeUIInstall
protected void completeUIInstall()
- Overrides:
completeUIInstall
in classjavax.swing.plaf.basic.BasicTreeUI
-
getCategoryFont
public java.awt.Font getCategoryFont()
-
setCategoryFont
public void setCategoryFont(java.awt.Font categoryFont)
-
getItemFont
public java.awt.Font getItemFont()
-
setItemFont
public void setItemFont(java.awt.Font itemFont)
-
getItemSelectedFont
public java.awt.Font getItemSelectedFont()
-
setItemSelectedFont
public void setItemSelectedFont(java.awt.Font itemSelectedFont)
-
installListeners
protected void installListeners()
- Overrides:
installListeners
in classjavax.swing.plaf.basic.BasicTreeUI
-
installKeyboardActions
protected void installKeyboardActions()
- Overrides:
installKeyboardActions
in classjavax.swing.plaf.basic.BasicTreeUI
-
setModel
protected void setModel(javax.swing.tree.TreeModel model)
- Overrides:
setModel
in classjavax.swing.plaf.basic.BasicTreeUI
-
getColorScheme
public SourceListColorScheme getColorScheme()
Gets theSourceListColorScheme
that thisSourceListTreeUI
uses to paint.- Returns:
- the
SourceListColorScheme
that thisSourceList
uses to paint.
-
setColorScheme
public void setColorScheme(SourceListColorScheme colorScheme)
Sets theSourceListColorScheme
that thisSourceListTreeUI
uses to paint.- Parameters:
colorScheme
- theSourceListColorScheme
that thisSourceList
uses to paint.
-
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)
- Overrides:
paintExpandControl
in classjavax.swing.plaf.basic.BasicTreeUI
-
createNodeDimensions
protected javax.swing.tree.AbstractLayoutCache.NodeDimensions createNodeDimensions()
- Overrides:
createNodeDimensions
in classjavax.swing.plaf.basic.BasicTreeUI
-
getPathBounds
public java.awt.Rectangle getPathBounds(javax.swing.JTree tree, javax.swing.tree.TreePath path)
- Overrides:
getPathBounds
in classjavax.swing.plaf.basic.BasicTreeUI
-
paint
public void paint(java.awt.Graphics g, javax.swing.JComponent c)
- Overrides:
paint
in classjavax.swing.plaf.basic.BasicTreeUI
-
paintHorizontalLine
protected void paintHorizontalLine(java.awt.Graphics g, javax.swing.JComponent c, int y, int left, int right)
- Overrides:
paintHorizontalLine
in classjavax.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)
- Overrides:
paintVerticalPartOfLeg
in classjavax.swing.plaf.basic.BasicTreeUI
-
selectPathForEvent
protected void selectPathForEvent(javax.swing.tree.TreePath path, java.awt.event.MouseEvent event)
- Overrides:
selectPathForEvent
in classjavax.swing.plaf.basic.BasicTreeUI
-
-