Class DefaultTreeCellRenderer

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

public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
Port of DefaultTreeCellRenderer. Extends JLabel so its peer is the SJLabel surrogate (a real Vaadin Component), satisfying the D_jtree_renderer_registry bridge's "return a Component-shaped emulator" requirement — exactly DefaultTableCellRenderer's shape (D_jtable_type_ports).

getTreeCellRendererComponent routes the value through tree.convertValueToText(...) — the JDK-overridable formatting hook — and picks the leaf / open / closed Icon for the JLabel icon slot (D_icon_rendering Path 1: ImageIcon renders through the surrogate's Vaadin-Image bridge). Icons default to null: the JDK defaults come from UIManager / L&F, which is dropped per R_match_swing_errors sub-bucket (b), so a fresh renderer shows text only until the app installs its own icons.

Selection / focus colour chrome (setBackgroundSelectionColor et al.) stores and round-trips; only the rendered effect is declined, because the Vaadin theme owns a Grid's row-selection styling and an inline-CSS shadow would not reach the rendered snapshot anyway. Keeping the values is R_decline_effect_only: the effect is droppable, the state never was. JDK's DefaultTreeCellRenderer also overrides the paint/validate family as performance no-ops; our paint pipeline doesn't run (R_layouts_close_enough), so those overrides are omitted rather than replicated.

See Also:
  • Field Details

    • leafIcon

      protected Icon leafIcon
    • openIcon

      protected Icon openIcon
    • closedIcon

      protected Icon closedIcon
    • textSelectionColor

      protected Color textSelectionColor
    • textNonSelectionColor

      protected Color textNonSelectionColor
    • backgroundSelectionColor

      protected Color backgroundSelectionColor
    • backgroundNonSelectionColor

      protected Color backgroundNonSelectionColor
    • borderSelectionColor

      protected Color borderSelectionColor
    • selected

      protected boolean selected
    • hasFocus

      protected boolean hasFocus
  • Constructor Details

    • DefaultTreeCellRenderer

      public DefaultTreeCellRenderer()
  • Method Details

    • setLeafIcon

      public void setLeafIcon(Icon newIcon)
      Icon shown for leaf nodes. null (the default) renders no icon.
    • getLeafIcon

      public Icon getLeafIcon()
    • setOpenIcon

      public void setOpenIcon(Icon newIcon)
      Icon shown for expanded non-leaf nodes. null renders no icon.
    • getOpenIcon

      public Icon getOpenIcon()
    • setClosedIcon

      public void setClosedIcon(Icon newIcon)
      Icon shown for collapsed non-leaf nodes. null renders no icon.
    • getClosedIcon

      public Icon getClosedIcon()
    • getDefaultLeafIcon

      public Icon getDefaultLeafIcon()
      JDK sources these from UIManager; L&F dispatch is dropped per R_match_swing_errors sub-bucket (b), so the "default" icons are honestly null.
    • getDefaultOpenIcon

      public Icon getDefaultOpenIcon()
    • getDefaultClosedIcon

      public Icon getDefaultClosedIcon()
    • setTextSelectionColor

      public void setTextSelectionColor(Color newColor)
      Store the colour selected text paints in. The value round-trips; the rendered effect is declined, since a Grid's selection chrome is the theme's ([D_theme_is_lookandfeel](../../../../../../emulators/decisions.md#D_theme_is_lookandfeel)).

      null is stored as null and read back as null — the JDK keeps no fallback here, unlike JTabbedPane's per-tab colours.

    • getTextSelectionColor

      public Color getTextSelectionColor()
    • setTextNonSelectionColor

      public void setTextNonSelectionColor(Color newColor)
      See Also:
    • getTextNonSelectionColor

      public Color getTextNonSelectionColor()
    • setBackgroundSelectionColor

      public void setBackgroundSelectionColor(Color newColor)
      See Also:
    • getBackgroundSelectionColor

      public Color getBackgroundSelectionColor()
    • setBackgroundNonSelectionColor

      public void setBackgroundNonSelectionColor(Color newColor)
      See Also:
    • getBackgroundNonSelectionColor

      public Color getBackgroundNonSelectionColor()
    • setBorderSelectionColor

      public void setBorderSelectionColor(Color newColor)
      See Also:
    • getBorderSelectionColor

      public Color getBorderSelectionColor()
    • getTreeCellRendererComponent

      public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
      Description copied from interface: TreeCellRenderer
      Build the rendering component for value.
      Specified by:
      getTreeCellRendererComponent in interface TreeCellRenderer
      Parameters:
      tree - the rendering host — the emulator JTree in emulator flow, null from pure-surrogate contexts.
      value - the node to render. null is valid.
      selected - whether the node is currently selected.
      expanded - whether the node is currently expanded.
      leaf - whether the node is a leaf per the model.
      row - the node's visible-row index, or -1 when the node isn't currently displayed.
      hasFocus - always false from the D_jtree_renderer_registry bridge — Vaadin TreeGrid has no per-cell focus signal at render time (R_vaadin_first sub-bucket (c)).