Class ColorHighlighter

java.lang.Object
org.jdesktop.swingx.decorator.AbstractHighlighter
org.jdesktop.swingx.decorator.ColorHighlighter
All Implemented Interfaces:
Highlighter
Direct Known Subclasses:
HighlighterFactory.UIColorHighlighter, ResetDTCRColorHighlighter, ShadingColorHighlighter

public class ColorHighlighter extends AbstractHighlighter
A Highlighter to modify component colors.

As of SwingX 1.6.1, ColorHighlighter now blends non-opaque colors. This will have little effect on previous users, who were likely to be using fully-opaque colors. If you are, however, supplying a non-opaque color and need it to be considered opaque, use PaintUtils.removeAlpha(Color).

  • Field Details

    • background

      private Color background
    • foreground

      private Color foreground
    • selectedBackground

      private Color selectedBackground
    • selectedForeground

      private Color selectedForeground
  • Constructor Details

    • ColorHighlighter

      public ColorHighlighter()
      Instantiates a ColorHighlighter with null colors and default HighlightPredicate.
    • ColorHighlighter

      public ColorHighlighter(HighlightPredicate predicate)
      Instantiates a ColorHighlighter with null colors and uses the specified HighlightPredicate.
      Parameters:
      predicate - the HighlightPredicate to use.
    • ColorHighlighter

      public ColorHighlighter(Color cellBackground, Color cellForeground)
      Constructs a ColorHighlighter with the specified background and foreground colors and null section colors. Uses the default predicate.
      Parameters:
      cellBackground - background color for unselected cell state
      cellForeground - foreground color for unselected cell state
    • ColorHighlighter

      public ColorHighlighter(HighlightPredicate predicate, Color cellBackground, Color cellForeground)
      Constructs a ColorHighlighter with the specified unselected colors and HighlightPredicate. Initializes selected colors to null.
      Parameters:
      predicate - the HighlightPredicate to use.
      cellBackground - background color for unselected cell state
      cellForeground - foreground color for unselected cell state
    • ColorHighlighter

      public ColorHighlighter(Color cellBackground, Color cellForeground, Color selectedBackground, Color selectedForeground)
      Constructs a ColorHighlighter with the specified background and foreground colors for unselected and selected cells. Uses the default HighlightPredicate.
      Parameters:
      cellBackground - background color for unselected cell state
      cellForeground - foreground color for unselected cell state
      selectedBackground - background color for selected cell state
      selectedForeground - foreground color for selected cell state
    • ColorHighlighter

      public ColorHighlighter(HighlightPredicate predicate, Color cellBackground, Color cellForeground, Color selectedBackground, Color selectedForeground)
      Constructs a ColorHighlighter with the specified colors and HighlightPredicate.
      Parameters:
      predicate - the HighlightPredicate to use.
      cellBackground - background color for unselected cell state
      cellForeground - foreground color for unselected cell state
      selectedBackground - background color for selected cell state
      selectedForeground - foreground color for selected cell state
  • Method Details

    • doHighlight

      protected Component doHighlight(Component renderer, ComponentAdapter adapter)
      Apply the highlights.
      Specified by:
      doHighlight in class AbstractHighlighter
      Parameters:
      renderer - the cell renderer component that is to be decorated
      adapter - the ComponentAdapter for this decorate operation
      See Also:
    • applyBackground

      protected void applyBackground(Component renderer, ComponentAdapter adapter)
      Applies a suitable background for the renderer component within the specified adapter.

      This implementation applies its background or selectedBackground color (depending on the adapter's selected state) if != null. Otherwise it does nothing.

      Parameters:
      renderer - the cell renderer component that is to be decorated
      adapter - the ComponentAdapter for this decorate operation
    • applyForeground

      protected void applyForeground(Component renderer, ComponentAdapter adapter)
      Applies a suitable foreground for the renderer component within the specified adapter.

      This implementation applies its foreground or selectedfForeground color (depending on the adapter's selected state) if != null. Otherwise it does nothing.

      Parameters:
      renderer - the cell renderer component that is to be decorated
      adapter - the ComponentAdapter for this decorate operation
    • getBackground

      public Color getBackground()
      Returns the background color of this ColorHighlighter.
      Returns:
      the background color of this ColorHighlighter, or null, if no background color has been set
    • setBackground

      public void setBackground(Color color)
      Sets the background color of this ColorHighlighter and notifies registered ChangeListeners.
      Parameters:
      color - the background color of this Highlighter, or null, to clear any existing background color
    • getForeground

      public Color getForeground()
      Returns the foreground color of this ColorHighlighter.
      Returns:
      the foreground color of this ColorHighlighter, or null, if no foreground color has been set
    • setForeground

      public void setForeground(Color color)
      Sets the foreground color of this ColorHighlighter and notifies registered ChangeListeners.
      Parameters:
      color - the foreground color of this ColorHighlighter, or null, to clear any existing foreground color
    • getSelectedBackground

      public Color getSelectedBackground()
      Returns the selected background color of this ColorHighlighter.
      Returns:
      the selected background color of this ColorHighlighter, or null, if no selected background color has been set
    • setSelectedBackground

      public void setSelectedBackground(Color color)
      Sets the selected background color of this ColorHighlighter and notifies registered ChangeListeners.
      Parameters:
      color - the selected background color of this ColorHighlighter, or null, to clear any existing selected background color
    • getSelectedForeground

      public Color getSelectedForeground()
      Returns the selected foreground color of this ColorHighlighter.
      Returns:
      the selected foreground color of this ColorHighlighter, or null, if no selected foreground color has been set
    • setSelectedForeground

      public void setSelectedForeground(Color color)
      Sets the selected foreground color of this ColorHighlighter and notifies registered ChangeListeners.
      Parameters:
      color - the selected foreground color of this ColorHighlighter, or null, to clear any existing selected foreground color