Package org.jdesktop.swingx.decorator
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,
ColorHighlighternow 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, usePaintUtils.removeAlpha(Color).
-
-
Field Summary
Fields Modifier and Type Field Description private java.awt.Colorbackgroundprivate java.awt.Colorforegroundprivate java.awt.ColorselectedBackgroundprivate java.awt.ColorselectedForeground-
Fields inherited from class org.jdesktop.swingx.decorator.AbstractHighlighter
listenerList
-
-
Constructor Summary
Constructors Constructor Description ColorHighlighter()Instantiates a ColorHighlighter with null colors and default HighlightPredicate.ColorHighlighter(java.awt.Color cellBackground, java.awt.Color cellForeground)Constructs aColorHighlighterwith the specified background and foreground colors and null section colors.ColorHighlighter(java.awt.Color cellBackground, java.awt.Color cellForeground, java.awt.Color selectedBackground, java.awt.Color selectedForeground)Constructs aColorHighlighterwith 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, java.awt.Color cellBackground, java.awt.Color cellForeground)Constructs aColorHighlighterwith the specified unselected colors and HighlightPredicate.ColorHighlighter(HighlightPredicate predicate, java.awt.Color cellBackground, java.awt.Color cellForeground, java.awt.Color selectedBackground, java.awt.Color selectedForeground)Constructs aColorHighlighterwith the specified colors and HighlightPredicate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidapplyBackground(java.awt.Component renderer, ComponentAdapter adapter)Applies a suitable background for the renderer component within the specified adapter.protected voidapplyForeground(java.awt.Component renderer, ComponentAdapter adapter)Applies a suitable foreground for the renderer component within the specified adapter.protected java.awt.ComponentdoHighlight(java.awt.Component renderer, ComponentAdapter adapter)Apply the highlights.java.awt.ColorgetBackground()Returns the background color of thisColorHighlighter.java.awt.ColorgetForeground()Returns the foreground color of thisColorHighlighter.java.awt.ColorgetSelectedBackground()Returns the selected background color of thisColorHighlighter.java.awt.ColorgetSelectedForeground()Returns the selected foreground color of thisColorHighlighter.voidsetBackground(java.awt.Color color)Sets the background color of thisColorHighlighterand notifies registered ChangeListeners.voidsetForeground(java.awt.Color color)Sets the foreground color of thisColorHighlighterand notifies registered ChangeListeners.voidsetSelectedBackground(java.awt.Color color)Sets the selected background color of thisColorHighlighterand notifies registered ChangeListeners.voidsetSelectedForeground(java.awt.Color color)Sets the selected foreground color of thisColorHighlighterand notifies registered ChangeListeners.-
Methods inherited from class org.jdesktop.swingx.decorator.AbstractHighlighter
addChangeListener, areEqual, canHighlight, fireStateChanged, getChangeListeners, getHighlightPredicate, highlight, removeChangeListener, setHighlightPredicate
-
-
-
-
Constructor Detail
-
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(java.awt.Color cellBackground, java.awt.Color cellForeground)Constructs aColorHighlighterwith 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
public ColorHighlighter(HighlightPredicate predicate, java.awt.Color cellBackground, java.awt.Color cellForeground)
Constructs aColorHighlighterwith 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(java.awt.Color cellBackground, java.awt.Color cellForeground, java.awt.Color selectedBackground, java.awt.Color selectedForeground)Constructs aColorHighlighterwith 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, java.awt.Color cellBackground, java.awt.Color cellForeground, java.awt.Color selectedBackground, java.awt.Color selectedForeground)
Constructs aColorHighlighterwith 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 Detail
-
doHighlight
protected java.awt.Component doHighlight(java.awt.Component renderer, ComponentAdapter adapter)Apply the highlights.- Specified by:
doHighlightin classAbstractHighlighter- Parameters:
renderer- the cell renderer component that is to be decoratedadapter- the ComponentAdapter for this decorate operation- See Also:
AbstractHighlighter.highlight(Component, ComponentAdapter)
-
applyBackground
protected void applyBackground(java.awt.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 decoratedadapter- the ComponentAdapter for this decorate operation
-
applyForeground
protected void applyForeground(java.awt.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 decoratedadapter- the ComponentAdapter for this decorate operation
-
getBackground
public java.awt.Color getBackground()
Returns the background color of thisColorHighlighter.- Returns:
- the background color of this
ColorHighlighter, or null, if no background color has been set
-
setBackground
public void setBackground(java.awt.Color color)
Sets the background color of thisColorHighlighterand notifies registered ChangeListeners.- Parameters:
color- the background color of thisHighlighter, or null, to clear any existing background color
-
getForeground
public java.awt.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
public void setForeground(java.awt.Color color)
Sets the foreground color of thisColorHighlighterand notifies registered ChangeListeners.- Parameters:
color- the foreground color of thisColorHighlighter, or null, to clear any existing foreground color
-
getSelectedBackground
public java.awt.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
public void setSelectedBackground(java.awt.Color color)
Sets the selected background color of thisColorHighlighterand notifies registered ChangeListeners.- Parameters:
color- the selected background color of thisColorHighlighter, or null, to clear any existing selected background color
-
getSelectedForeground
public java.awt.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
public void setSelectedForeground(java.awt.Color color)
Sets the selected foreground color of thisColorHighlighterand notifies registered ChangeListeners.- Parameters:
color- the selected foreground color of thisColorHighlighter, or null, to clear any existing selected foreground color
-
-