Class 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 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:

    1. 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.
    2. 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:
    1. 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 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
    • 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 the SourceListColorScheme that this SourceListTreeUI 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 the SourceListColorScheme that this SourceListTreeUI 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
      • 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

      • SourceListTreeUI

        public SourceListTreeUI()
    • Method Detail

      • completeUIInstall

        protected void completeUIInstall()
        Overrides:
        completeUIInstall in class javax.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 class javax.swing.plaf.basic.BasicTreeUI
      • installKeyboardActions

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

        protected void setModel​(javax.swing.tree.TreeModel model)
        Overrides:
        setModel 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)
        Overrides:
        paintExpandControl in class javax.swing.plaf.basic.BasicTreeUI
      • createNodeDimensions

        protected javax.swing.tree.AbstractLayoutCache.NodeDimensions createNodeDimensions()
        Overrides:
        createNodeDimensions in class javax.swing.plaf.basic.BasicTreeUI
      • getPathBounds

        public java.awt.Rectangle getPathBounds​(javax.swing.JTree tree,
                                                javax.swing.tree.TreePath path)
        Overrides:
        getPathBounds in class javax.swing.plaf.basic.BasicTreeUI
      • paint

        public void paint​(java.awt.Graphics g,
                          javax.swing.JComponent c)
        Overrides:
        paint 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)
        Overrides:
        paintHorizontalLine 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)
        Overrides:
        paintVerticalPartOfLeg in class javax.swing.plaf.basic.BasicTreeUI
      • selectPathForEvent

        protected void selectPathForEvent​(javax.swing.tree.TreePath path,
                                          java.awt.event.MouseEvent event)
        Overrides:
        selectPathForEvent in class javax.swing.plaf.basic.BasicTreeUI