Class JRendererLabel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants, IconAware, PainterAware

public class JRendererLabel extends JLabel implements PainterAware, IconAware
A JLabel optimized for usage in renderers and with a minimal background painter support.

Note: the painter support will be switched to painter_work as soon it enters main. The reasoning for the performance-overrides is copied from core:

The standard JLabel component was not designed to be used this way and we want to avoid triggering a revalidate each time the cell is drawn. This would greatly decrease performance because the revalidate message would be passed up the hierarchy of the container to determine whether any other components would be affected. As the renderer is only parented for the lifetime of a painting operation we similarly want to avoid the overhead associated with walking the hierarchy for painting operations. So this class overrides the validate, invalidate, revalidate, repaint, and firePropertyChange methods to be no-ops and override the isOpaque method solely to improve performance. If you write your own renderer component, please keep this performance consideration in mind.

Author:
Jeanette Winzenburg
See Also:
  • Field Details

    • painter

      protected Painter painter
      Painter
  • Constructor Details

    • JRendererLabel

      public JRendererLabel()
  • Method Details

    • setPainter

      public void setPainter(Painter painter)
      TODO maven-javadoc-plugin 3.3.2 needs a doc here
      Specified by:
      setPainter in interface PainterAware
      Parameters:
      painter - Painter
    • getPainter

      public Painter getPainter()
      Specified by:
      getPainter in interface PainterAware
      Returns:
      Painter
    • paintComponent

      protected void paintComponent(Graphics g)

      Overridden to inject Painter's painting.

      TODO: cleanup logic - see JRendererCheckBox.

      Overrides:
      paintComponent in class JComponent
    • paintComponentWithPainter

      protected void paintComponentWithPainter(Graphics2D g)
      PRE: painter != null, isOpaque()
      Parameters:
      g - Graphics2D
    • setToolTipText

      public void setToolTipText(String text)

      Overridden to not automatically de/register itself from/to the ToolTipManager. As rendering component it is not considered to be active in any way, so the manager must not listen.

      Overrides:
      setToolTipText in class JComponent
    • invalidate

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

      public void validate()
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      validate 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
      Since:
      1.5
    • 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, boolean oldValue, boolean newValue)
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      firePropertyChange in class JComponent