Class ConfigTreeRenderer

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

public class ConfigTreeRenderer extends DefaultTreeCellRenderer
Implements a config tree renderer that fixes some AWT-Graphics problems in conjunction with the clipping. It seems that the AWT-Graphics ignores the clipping bounds for some primitive operations. Clipping is done if the operations are performed on the Graphics2D level.
Author:
Thomas Morgner
See Also:
  • Constructor Details

    • ConfigTreeRenderer

      public ConfigTreeRenderer()
      DefaultConstructor.
  • Method Details

    • getTreeCellRendererComponent

      public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, 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
      Overrides:
      getTreeCellRendererComponent in class DefaultTreeCellRenderer
      Parameters:
      tree - the tree that renders the node.
      value - the tree node
      sel - whether the node is selected.
      expanded - whether the node is expanded
      leaf - whether the node is a leaf
      row - the row number of the node in the tree.
      hasFocus - whether the node has the input focus
      Returns:
      the renderer component.
    • paint

      public void paint(Graphics g)
      Paints the value. The background is filled based on selected. The TreeCellRenderer or Swing or something else has a bug inside so that the clipping of the graphics is not done correctly. If a rectangle is painted with Graphics.fillRect(int, int, int, int) the graphics is totally messed up.
      Overrides:
      paint in class DefaultTreeCellRenderer
      Parameters:
      g - the graphics.