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.BasicTreeUIA UI delegate that paints a
JTreeas 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
SourceListwith 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 theTextProviderwill be queried for the node text. - If no implementation of
TextProvideris 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 theIconProviderwill 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 voidcompleteUIInstall()protected javax.swing.tree.AbstractLayoutCache.NodeDimensionscreateNodeDimensions()java.awt.FontgetCategoryFont()SourceListColorSchemegetColorScheme()Gets theSourceListColorSchemethat thisSourceListTreeUIuses to paint.java.awt.FontgetItemFont()java.awt.FontgetItemSelectedFont()java.awt.RectanglegetPathBounds(javax.swing.JTree tree, javax.swing.tree.TreePath path)protected voidinstallKeyboardActions()protected voidinstallListeners()voidpaint(java.awt.Graphics g, javax.swing.JComponent c)protected voidpaintExpandControl(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 voidpaintHorizontalLine(java.awt.Graphics g, javax.swing.JComponent c, int y, int left, int right)protected voidpaintVerticalPartOfLeg(java.awt.Graphics g, java.awt.Rectangle clipBounds, java.awt.Insets insets, javax.swing.tree.TreePath path)protected voidselectPathForEvent(javax.swing.tree.TreePath path, java.awt.event.MouseEvent event)voidsetCategoryFont(java.awt.Font categoryFont)voidsetColorScheme(SourceListColorScheme colorScheme)Sets theSourceListColorSchemethat thisSourceListTreeUIuses to paint.voidsetItemFont(java.awt.Font itemFont)voidsetItemSelectedFont(java.awt.Font itemSelectedFont)protected voidsetModel(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:
completeUIInstallin 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:
installListenersin classjavax.swing.plaf.basic.BasicTreeUI
-
installKeyboardActions
protected void installKeyboardActions()
- Overrides:
installKeyboardActionsin classjavax.swing.plaf.basic.BasicTreeUI
-
setModel
protected void setModel(javax.swing.tree.TreeModel model)
- Overrides:
setModelin classjavax.swing.plaf.basic.BasicTreeUI
-
getColorScheme
public SourceListColorScheme getColorScheme()
Gets theSourceListColorSchemethat thisSourceListTreeUIuses to paint.- Returns:
- the
SourceListColorSchemethat thisSourceListuses to paint.
-
setColorScheme
public void setColorScheme(SourceListColorScheme colorScheme)
Sets theSourceListColorSchemethat thisSourceListTreeUIuses to paint.- Parameters:
colorScheme- theSourceListColorSchemethat thisSourceListuses 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:
paintExpandControlin classjavax.swing.plaf.basic.BasicTreeUI
-
createNodeDimensions
protected javax.swing.tree.AbstractLayoutCache.NodeDimensions createNodeDimensions()
- Overrides:
createNodeDimensionsin classjavax.swing.plaf.basic.BasicTreeUI
-
getPathBounds
public java.awt.Rectangle getPathBounds(javax.swing.JTree tree, javax.swing.tree.TreePath path)- Overrides:
getPathBoundsin classjavax.swing.plaf.basic.BasicTreeUI
-
paint
public void paint(java.awt.Graphics g, javax.swing.JComponent c)- Overrides:
paintin classjavax.swing.plaf.basic.BasicTreeUI
-
paintHorizontalLine
protected void paintHorizontalLine(java.awt.Graphics g, javax.swing.JComponent c, int y, int left, int right)- Overrides:
paintHorizontalLinein 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:
paintVerticalPartOfLegin classjavax.swing.plaf.basic.BasicTreeUI
-
selectPathForEvent
protected void selectPathForEvent(javax.swing.tree.TreePath path, java.awt.event.MouseEvent event)- Overrides:
selectPathForEventin classjavax.swing.plaf.basic.BasicTreeUI
-
-