public class ColorHighlighter extends AbstractHighlighter
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)
.
Modifier and Type | Field and Description |
---|---|
private Color |
background |
private Color |
foreground |
private Color |
selectedBackground |
private Color |
selectedForeground |
listenerList
Constructor and Description |
---|
ColorHighlighter()
Instantiates a ColorHighlighter with null colors and default
HighlightPredicate.
|
ColorHighlighter(Color cellBackground,
Color cellForeground)
Constructs a
ColorHighlighter with the specified
background and foreground colors and null section colors. |
ColorHighlighter(Color cellBackground,
Color cellForeground,
Color selectedBackground,
Color selectedForeground)
Constructs a
ColorHighlighter 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 a
ColorHighlighter with the specified
unselected colors and HighlightPredicate. |
ColorHighlighter(HighlightPredicate predicate,
Color cellBackground,
Color cellForeground,
Color selectedBackground,
Color selectedForeground)
Constructs a
ColorHighlighter with the specified colors
and HighlightPredicate. |
Modifier and Type | Method and Description |
---|---|
protected 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.
|
Color |
getBackground()
Returns the background color of this
ColorHighlighter . |
Color |
getForeground()
Returns the foreground color of this
ColorHighlighter . |
Color |
getSelectedBackground()
Returns the selected background color of this
ColorHighlighter . |
Color |
getSelectedForeground()
Returns the selected foreground color of this
ColorHighlighter . |
void |
setBackground(Color color)
Sets the background color of this
ColorHighlighter and
notifies registered ChangeListeners. |
void |
setForeground(Color color)
Sets the foreground color of this
ColorHighlighter and notifies
registered ChangeListeners. |
void |
setSelectedBackground(Color color)
Sets the selected background color of this
ColorHighlighter
and notifies registered ChangeListeners. |
void |
setSelectedForeground(Color color)
Sets the selected foreground color of this
ColorHighlighter and
notifies registered ChangeListeners. |
addChangeListener, areEqual, canHighlight, fireStateChanged, getChangeListeners, getHighlightPredicate, highlight, removeChangeListener, setHighlightPredicate
private Color background
private Color foreground
private Color selectedBackground
private Color selectedForeground
public ColorHighlighter()
public ColorHighlighter(HighlightPredicate predicate)
predicate
- the HighlightPredicate to use.public ColorHighlighter(Color cellBackground, Color cellForeground)
ColorHighlighter
with the specified
background and foreground colors and null section colors. Uses
the default predicate.cellBackground
- background color for unselected cell statecellForeground
- foreground color for unselected cell statepublic ColorHighlighter(HighlightPredicate predicate, Color cellBackground, Color cellForeground)
ColorHighlighter
with the specified
unselected colors and HighlightPredicate.
Initializes selected colors to null.predicate
- the HighlightPredicate to use.cellBackground
- background color for unselected cell statecellForeground
- foreground color for unselected cell statepublic ColorHighlighter(Color cellBackground, Color cellForeground, Color selectedBackground, Color selectedForeground)
ColorHighlighter
with the specified
background and foreground colors for unselected and selected cells.
Uses the default HighlightPredicate.cellBackground
- background color for unselected cell statecellForeground
- foreground color for unselected cell stateselectedBackground
- background color for selected cell stateselectedForeground
- foreground color for selected cell statepublic ColorHighlighter(HighlightPredicate predicate, Color cellBackground, Color cellForeground, Color selectedBackground, Color selectedForeground)
ColorHighlighter
with the specified colors
and HighlightPredicate.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 stateprotected Component doHighlight(Component renderer, ComponentAdapter adapter)
doHighlight
in class AbstractHighlighter
renderer
- the cell renderer component that is to be decoratedadapter
- the ComponentAdapter for this decorate operationAbstractHighlighter.highlight(Component, ComponentAdapter)
protected void applyBackground(Component renderer, ComponentAdapter adapter)
This implementation applies its background or selectedBackground color (depending on the adapter's selected state) if != null. Otherwise it does nothing.
renderer
- the cell renderer component that is to be decoratedadapter
- the ComponentAdapter for this decorate operationprotected void applyForeground(Component renderer, ComponentAdapter adapter)
This implementation applies its foreground or selectedfForeground color (depending on the adapter's selected state) if != null. Otherwise it does nothing.
renderer
- the cell renderer component that is to be decoratedadapter
- the ComponentAdapter for this decorate operationpublic Color getBackground()
ColorHighlighter
.ColorHighlighter
,
or null, if no background color has been setpublic void setBackground(Color color)
ColorHighlighter
and
notifies registered ChangeListeners.color
- the background color of this Highlighter
,
or null, to clear any existing background colorpublic Color getForeground()
ColorHighlighter
.ColorHighlighter
,
or null, if no foreground color has been setpublic void setForeground(Color color)
ColorHighlighter
and notifies
registered ChangeListeners.color
- the foreground color of this ColorHighlighter
,
or null, to clear any existing foreground colorpublic Color getSelectedBackground()
ColorHighlighter
.ColorHighlighter
,
or null, if no selected background color has been setpublic void setSelectedBackground(Color color)
ColorHighlighter
and notifies registered ChangeListeners.color
- the selected background color of this ColorHighlighter
,
or null, to clear any existing selected background colorpublic Color getSelectedForeground()
ColorHighlighter
.ColorHighlighter
,
or null, if no selected foreground color has been setpublic void setSelectedForeground(Color color)
ColorHighlighter
and
notifies registered ChangeListeners.color
- the selected foreground color of this ColorHighlighter
,
or null, to clear any existing selected foreground colorWebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses