Class ColorHighlighter
- All Implemented Interfaces:
Highlighter
- Direct Known Subclasses:
HighlighterFactory.UIColorHighlighter
,ResetDTCRColorHighlighter
,ShadingColorHighlighter
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.
Users can select the pre-SwingX-1.6.1 behavior which replaces colors instead
of blending, by using the legacy property methods. These methods were added
and immediately deprecated. They exist to provide a bridge to the old
behavior, but are not recommended. If you are supplying a non-opaque color
and need it to be considered opaque, use ColorUtil.removeAlpha(Color)
.
- Author:
- Jeanette Winzenburg, Karl Schaefer
-
Field Summary
Fields inherited from class org.jdesktop.swingx.decorator.AbstractHighlighter
listenerList
-
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a ColorHighlighter with null colors and default HighlightPredicate.ColorHighlighter
(Color cellBackground, Color cellForeground) Constructs aColorHighlighter
with the specified background and foreground colors and null section colors.ColorHighlighter
(Color cellBackground, Color cellForeground, Color selectedBackground, Color selectedForeground) Constructs aColorHighlighter
with the specified background and foreground colors for unselected and selected cells.ColorHighlighter
(HighlightPredicate predicate) Instantiates a ColorHighlighter with null colors and uses the specified HighlightPredicate.ColorHighlighter
(HighlightPredicate predicate, Color cellBackground, Color cellForeground) Constructs aColorHighlighter
with the specified unselected colors and HighlightPredicate.ColorHighlighter
(HighlightPredicate predicate, Color cellBackground, Color cellForeground, Color selectedBackground, Color selectedForeground) Constructs aColorHighlighter
with the specified colors and HighlightPredicate. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
applyBackground
(Component renderer, ComponentAdapter adapter) Applies a suitable background for the renderer component within the specified adapter.protected void
applyForeground
(Component renderer, ComponentAdapter adapter) Applies a suitable foreground for the renderer component within the specified adapter.protected Component
doHighlight
(Component renderer, ComponentAdapter adapter) Apply the highlights.Returns the background color of thisColorHighlighter
.Returns the foreground color of thisColorHighlighter
.Returns the selected background color of thisColorHighlighter
.Returns the selected foreground color of thisColorHighlighter
.boolean
isLegacy()
Deprecated.(pre-1.6.1) see class doc, on how to workaroundvoid
setBackground
(Color color) Sets the background color of thisColorHighlighter
and notifies registered ChangeListeners.void
setForeground
(Color color) Sets the foreground color of thisColorHighlighter
and notifies registered ChangeListeners.void
setLegacy
(boolean legacy) Deprecated.(pre-1.6.1) see class doc, on how to workaroundvoid
setSelectedBackground
(Color color) Sets the selected background color of thisColorHighlighter
and notifies registered ChangeListeners.void
setSelectedForeground
(Color color) Sets the selected foreground color of thisColorHighlighter
and notifies registered ChangeListeners.Methods inherited from class org.jdesktop.swingx.decorator.AbstractHighlighter
addChangeListener, areEqual, canHighlight, fireStateChanged, getChangeListeners, getHighlightPredicate, highlight, removeChangeListener, setHighlightPredicate
-
Constructor Details
-
ColorHighlighter
public ColorHighlighter()Instantiates a ColorHighlighter with null colors and default HighlightPredicate. -
ColorHighlighter
Instantiates a ColorHighlighter with null colors and uses the specified HighlightPredicate.- Parameters:
predicate
- the HighlightPredicate to use.
-
ColorHighlighter
Constructs aColorHighlighter
with the specified background and foreground colors and null section colors. Uses the default predicate.- Parameters:
cellBackground
- background color for unselected cell statecellForeground
- foreground color for unselected cell state
-
ColorHighlighter
Constructs aColorHighlighter
with the specified unselected colors and HighlightPredicate. Initializes selected colors to null.- Parameters:
predicate
- the HighlightPredicate to use.cellBackground
- background color for unselected cell statecellForeground
- foreground color for unselected cell state
-
ColorHighlighter
public ColorHighlighter(Color cellBackground, Color cellForeground, Color selectedBackground, Color selectedForeground) Constructs aColorHighlighter
with the specified background and foreground colors for unselected and selected cells. Uses the default HighlightPredicate.- Parameters:
cellBackground
- background color for unselected cell statecellForeground
- foreground color for unselected cell stateselectedBackground
- background color for selected cell stateselectedForeground
- foreground color for selected cell state
-
ColorHighlighter
public ColorHighlighter(HighlightPredicate predicate, Color cellBackground, Color cellForeground, Color selectedBackground, Color selectedForeground) Constructs aColorHighlighter
with the specified colors and HighlightPredicate.- Parameters:
predicate
- the HighlightPredicate to use.cellBackground
- background color for unselected cell statecellForeground
- foreground color for unselected cell stateselectedBackground
- background color for selected cell stateselectedForeground
- foreground color for selected cell state
-
-
Method Details
-
doHighlight
Apply the highlights.- Specified by:
doHighlight
in classAbstractHighlighter
- Parameters:
renderer
- the cell renderer component that is to be decoratedadapter
- the ComponentAdapter for this decorate operation- See Also:
-
applyBackground
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 decoratedadapter
- the ComponentAdapter for this decorate operation
-
applyForeground
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 decoratedadapter
- the ComponentAdapter for this decorate operation
-
getBackground
Returns the background color of thisColorHighlighter
.- Returns:
- the background color of this
ColorHighlighter
, or null, if no background color has been set
-
setBackground
Sets the background color of thisColorHighlighter
and notifies registered ChangeListeners.- Parameters:
color
- the background color of thisHighlighter
, or null, to clear any existing background color
-
getForeground
Returns the foreground color of thisColorHighlighter
.- Returns:
- the foreground color of this
ColorHighlighter
, or null, if no foreground color has been set
-
setForeground
Sets the foreground color of thisColorHighlighter
and notifies registered ChangeListeners.- Parameters:
color
- the foreground color of thisColorHighlighter
, or null, to clear any existing foreground color
-
getSelectedBackground
Returns the selected background color of thisColorHighlighter
.- Returns:
- the selected background color of this
ColorHighlighter
, or null, if no selected background color has been set
-
setSelectedBackground
Sets the selected background color of thisColorHighlighter
and notifies registered ChangeListeners.- Parameters:
color
- the selected background color of thisColorHighlighter
, or null, to clear any existing selected background color
-
getSelectedForeground
Returns the selected foreground color of thisColorHighlighter
.- Returns:
- the selected foreground color of this
ColorHighlighter
, or null, if no selected foreground color has been set
-
setSelectedForeground
Sets the selected foreground color of thisColorHighlighter
and notifies registered ChangeListeners.- Parameters:
color
- the selected foreground color of thisColorHighlighter
, or null, to clear any existing selected foreground color
-
isLegacy
Deprecated.(pre-1.6.1) see class doc, on how to workaround- Returns:
- legacy mode
-
setLegacy
Deprecated.(pre-1.6.1) see class doc, on how to workaround- Parameters:
legacy
- set legacy mode
-