Class JXTree.DelegatingRenderer

  • All Implemented Interfaces:
    javax.swing.tree.TreeCellRenderer, RolloverRenderer
    Enclosing class:
    JXTree

    public class JXTree.DelegatingRenderer
    extends java.lang.Object
    implements javax.swing.tree.TreeCellRenderer, RolloverRenderer
    A decorator for the original TreeCellRenderer. Needed to hook highlighters after messaging the delegate.

    PENDING JW: formally implement UIDependent? PENDING JW: missing updateUI anyway (got lost when c&p from JXList ;-) PENDING JW: missing override of updateUI in xtree ...

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private javax.swing.Icon closedIcon  
      private javax.swing.tree.TreeCellRenderer delegate  
      private javax.swing.Icon leafIcon  
      private javax.swing.Icon openIcon  
    • Constructor Summary

      Constructors 
      Constructor Description
      DelegatingRenderer()
      Instantiates a DelegatingRenderer with tree's default renderer as delegate.
      DelegatingRenderer​(javax.swing.tree.TreeCellRenderer delegate)
      Instantiates a DelegatingRenderer with the given delegate.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void doClick()
      Same as AbstractButton.doClick().
      javax.swing.tree.TreeCellRenderer getDelegateRenderer()
      Returns the delegate.
      java.awt.Component getTreeCellRendererComponent​(javax.swing.JTree tree, java.lang.Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
      private void initIcons​(javax.swing.tree.DefaultTreeCellRenderer renderer)
      initially sets the icons to the defaults as given by a DefaultTreeCellRenderer.
      boolean isEnabled()  
      void setClosedIcon​(javax.swing.Icon closedIcon)  
      void setDelegateRenderer​(javax.swing.tree.TreeCellRenderer delegate)
      Sets the delegate.
      void setLeafIcon​(javax.swing.Icon leafIcon)  
      void setOpenIcon​(javax.swing.Icon openIcon)  
      private void updateIcons()
      tries to set the renderers icons.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • closedIcon

        private javax.swing.Icon closedIcon
      • openIcon

        private javax.swing.Icon openIcon
      • leafIcon

        private javax.swing.Icon leafIcon
      • delegate

        private javax.swing.tree.TreeCellRenderer delegate
    • Constructor Detail

      • DelegatingRenderer

        public DelegatingRenderer()
        Instantiates a DelegatingRenderer with tree's default renderer as delegate.
      • DelegatingRenderer

        public DelegatingRenderer​(javax.swing.tree.TreeCellRenderer delegate)
        Instantiates a DelegatingRenderer with the given delegate. If the delegate is null, the default is created via the list's factory method.
        Parameters:
        delegate - the delegate to use, if null the tree's default is created and used.
    • Method Detail

      • initIcons

        private void initIcons​(javax.swing.tree.DefaultTreeCellRenderer renderer)
        initially sets the icons to the defaults as given by a DefaultTreeCellRenderer.
        Parameters:
        renderer -
      • setDelegateRenderer

        public void setDelegateRenderer​(javax.swing.tree.TreeCellRenderer delegate)
        Sets the delegate. If the delegate is null, the default is created via the list's factory method. Updates the folder/leaf icons. THINK: how to update? always override with this.icons, only if renderer's icons are null, update this icons if they are not, update all if only one is != null.... ??
        Parameters:
        delegate - the delegate to use, if null the list's default is created and used.
      • updateIcons

        private void updateIcons()
        tries to set the renderers icons. Can succeed only if the delegate is a DefaultTreeCellRenderer. THINK: how to update? always override with this.icons, only if renderer's icons are null, update this icons if they are not, update all if only one is != null.... ??
      • setClosedIcon

        public void setClosedIcon​(javax.swing.Icon closedIcon)
      • setOpenIcon

        public void setOpenIcon​(javax.swing.Icon openIcon)
      • setLeafIcon

        public void setLeafIcon​(javax.swing.Icon leafIcon)
      • getDelegateRenderer

        public javax.swing.tree.TreeCellRenderer getDelegateRenderer()
        Returns the delegate.
        Returns:
        the delegate renderer used by this renderer, guaranteed to not-null.
      • getTreeCellRendererComponent

        public java.awt.Component getTreeCellRendererComponent​(javax.swing.JTree tree,
                                                               java.lang.Object value,
                                                               boolean selected,
                                                               boolean expanded,
                                                               boolean leaf,
                                                               int row,
                                                               boolean hasFocus)

        Overridden to apply the highlighters, if any, after calling the delegate. The decorators are not applied if the row is invalid.

        Specified by:
        getTreeCellRendererComponent in interface javax.swing.tree.TreeCellRenderer
      • isEnabled

        public boolean isEnabled()
        Specified by:
        isEnabled in interface RolloverRenderer
        Returns:
        true if rollover effects are on and clickable.
      • doClick

        public void doClick()
        Description copied from interface: RolloverRenderer
        Same as AbstractButton.doClick(). It's up to client code to prepare the renderer's component before calling this method.
        Specified by:
        doClick in interface RolloverRenderer