Class RadianceDefaultTreeCellRenderer

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLabel
org.pushingpixels.radiance.theming.api.renderer.RadianceDefaultTreeCellRenderer
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants, TreeCellRenderer, FilteredIconAwareRenderer

public class RadianceDefaultTreeCellRenderer extends JLabel implements TreeCellRenderer, FilteredIconAwareRenderer
Default renderer for tree cells. Note that this does not extend DefaultTreeCellRenderer as other default renderers since that class overrides Component.setBackground(Color) and prevents the pass-through of UIResource colors that Radiance sets for odd-even row striping.
See Also:
  • Field Details

    • tree

      private JTree tree
      Last tree the renderer was painted in.
    • selected

      protected boolean selected
      Is the value currently selected.
    • hasFocus

      protected boolean hasFocus
      True if has focus.
    • activeContributions

      private Map<ComponentState,Float> activeContributions
  • Constructor Details

    • RadianceDefaultTreeCellRenderer

      public RadianceDefaultTreeCellRenderer()
      Returns a new instance of RadianceDefaultTreeCellRenderer. Alignment is set to start aligned. Icons and text color are determined from the UIManager.
  • Method Details

    • getDefaultOpenIcon

      private Icon getDefaultOpenIcon()
      Returns the default icon that is used to represent non-leaf nodes that are expanded.
      Returns:
      The default icon for non-leaf expanded nodes.
    • getDefaultClosedIcon

      private Icon getDefaultClosedIcon()
      Returns the default icon that is used to represent non-leaf nodes that are not expanded.
      Returns:
      The default icon for non-leaf non-expanded nodes.
    • getDefaultLeafIcon

      private Icon getDefaultLeafIcon()
      Returns the default icon that is used to represent leaf nodes.
      Returns:
      The default icon for leaf nodes.
    • setFont

      public void setFont(Font font)
      Subclassed to map FontUIResources to null. If font is null, or a FontUIResource, this has the effect of letting the font of the JTree show through. On the other hand, if font is non-null, and not a FontUIResource, the font becomes font.
      Overrides:
      setFont in class JComponent
    • getFont

      public Font getFont()
      Gets the font of this component.
      Specified by:
      getFont in interface MenuContainer
      Overrides:
      getFont in class Component
      Returns:
      this component's font; if a font has not been set for this component, the font of its parent is returned
    • getTreeCellRendererComponent

      public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
      Configures the renderer based on the passed in components. The value is set from messaging the tree with convertValueToText, which ultimately invokes toString on value. The foreground color is set based on the selection and the icon is set based on on leaf and expanded.
      Specified by:
      getTreeCellRendererComponent in interface TreeCellRenderer
    • getActiveContributions

      public Map<ComponentState,Float> getActiveContributions()
      Specified by:
      getActiveContributions in interface FilteredIconAwareRenderer
    • getColorSchemeForState

      private RadianceColorScheme getColorSchemeForState(JTree tree, RadianceTreeUI ui, ComponentState activeState)
    • getPreferredSize

      public Dimension getPreferredSize()
      Overrides JComponent.getPreferredSize to return slightly wider preferred size value.
      Overrides:
      getPreferredSize in class JComponent
    • validate

      public void validate()
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      validate in class Container
    • invalidate

      public void invalidate()
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      invalidate in class Container
    • revalidate

      public void revalidate()
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      revalidate in class JComponent
    • repaint

      public void repaint(long tm, int x, int y, int width, int height)
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      repaint in class JComponent
    • repaint

      public void repaint(Rectangle r)
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      repaint in class JComponent
    • repaint

      public void repaint()
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      repaint in class Component
    • firePropertyChange

      protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      firePropertyChange in class Component
    • firePropertyChange

      public void firePropertyChange(String propertyName, byte oldValue, byte newValue)
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      firePropertyChange in class Component
    • firePropertyChange

      public void firePropertyChange(String propertyName, char oldValue, char newValue)
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      firePropertyChange in class JComponent
    • firePropertyChange

      public void firePropertyChange(String propertyName, short oldValue, short newValue)
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      firePropertyChange in class Component
    • firePropertyChange

      public void firePropertyChange(String propertyName, int oldValue, int newValue)
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      firePropertyChange in class JComponent
    • firePropertyChange

      public void firePropertyChange(String propertyName, long oldValue, long newValue)
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      firePropertyChange in class Component
    • firePropertyChange

      public void firePropertyChange(String propertyName, float oldValue, float newValue)
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      firePropertyChange in class Component
    • firePropertyChange

      public void firePropertyChange(String propertyName, double oldValue, double newValue)
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      firePropertyChange in class Component
    • firePropertyChange

      public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      firePropertyChange in class JComponent
    • paint

      public final void paint(Graphics g)
      Overrides:
      paint in class JComponent
    • paintComponent

      protected final void paintComponent(Graphics g)
      Overrides:
      paintComponent in class JComponent