Class ContextTreeCellRenderer

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants, TreeCellRenderer

public class ContextTreeCellRenderer extends DefaultTreeCellRenderer
A custom TreeCellRenderer for the context tree that provides specific icons and labels for different types of context nodes.

It prioritizes specialized icons provided by the nodes themselves (e.g., NetBeans project or file icons) and ensures that the node's display name is used instead of its toString() representation.

It also implements automatic icon fading (desaturation) and text graying for inactive nodes (e.g., disabled toolkits or pruned messages).

Author:
anahata
See Also:
  • Field Details

    • toolkitIcon

      private final Icon toolkitIcon
      Default icon for toolkits (authentic Java logo).
    • toolIcon

      private final Icon toolIcon
      Programmatic icon for individual tools.
    • toolsIcon

      private final Icon toolsIcon
      Refined programmatic icon for tool containers.
    • toolManagerIcon

      private final Icon toolManagerIcon
      Specialized icon for the ToolManager node.
    • messageIcon

      private final Icon messageIcon
      Default icon for individual messages.
    • partIcon

      private final Icon partIcon
      Default icon for individual message parts.
  • Constructor Details

    • ContextTreeCellRenderer

      public ContextTreeCellRenderer()
  • Method Details

    • getTreeCellRendererComponent

      public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus)
      Implementation details: 1. Sets the text to the node's name. 2. Inspects the node for a specialized icon, otherwise falls back to a default icon based on the node type. 3. If no specialized or type-specific icon is found, it preserves the default JTree folder/file icons. 4. Fades the icon and grays out the text if the node is inactive.
      Specified by:
      getTreeCellRendererComponent in interface TreeCellRenderer
      Overrides:
      getTreeCellRendererComponent in class DefaultTreeCellRenderer