org.jdesktop.swingx.decorator
Class AlternateRowHighlighter

java.lang.Object
  extended by org.jdesktop.swingx.decorator.Highlighter
      extended by org.jdesktop.swingx.decorator.AlternateRowHighlighter
Direct Known Subclasses:
AlternateRowHighlighter.UIAlternateRowHighlighter

public class AlternateRowHighlighter
extends Highlighter

AlternateRowHighlighter prepares a cell renderer to use different background colors for alternating rows in a data view.

Author:
Ramesh Gupta

Nested Class Summary
static class AlternateRowHighlighter.UIAlternateRowHighlighter
           
 
Nested classes/interfaces inherited from class org.jdesktop.swingx.decorator.Highlighter
Highlighter.UIHighlighter
 
Field Summary
static Highlighter beige
           
static Highlighter classicLinePrinter
           
static Highlighter floralWhite
           
static AlternateRowHighlighter genericGrey
           
static Highlighter linePrinter
           
static Highlighter quickSilver
           
 
Fields inherited from class org.jdesktop.swingx.decorator.Highlighter
changeEvent, immutable, ledgerBackground, listenerList, notePadBackground
 
Constructor Summary
AlternateRowHighlighter()
          Constructs a default AlternateRowHighlighter that prepares a cell renderer to paint a white background for odd rows and a silver (0xF0, 0xF0, 0xE0) background for even rows.
AlternateRowHighlighter(java.awt.Color oddRowBackground, java.awt.Color evenRowBackground, java.awt.Color foreground)
          Constructs an AlternateRowHighlighter that prepares a cell renderer to paint the specified background colors for odd and even and even rows.
AlternateRowHighlighter(java.awt.Color oddRowBackground, java.awt.Color evenRowBackground, java.awt.Color foreground, boolean immutable)
           
 
Method Summary
protected  java.awt.Color computeBackground(java.awt.Component renderer, ComponentAdapter adapter)
          Computes the background color for the current rendering context for the specified adapter.
protected  java.awt.Color computeSelectedBackground(java.awt.Color seed)
          Computes the selected background color.
protected  java.awt.Color computeSelectedForeground(java.awt.Color seed)
          Computes the selected foreground color.
 java.awt.Color getEvenRowBackground()
          Returns the background color for even rows, or null if the background color of the cell renderer should be left unchanged for even rows.
 java.awt.Color getOddRowBackground()
          Returns the background color for odd rows, or null if the background color of the cell renderer should be left unchanged for odd rows.
 void setEvenRowBackground(java.awt.Color color)
          Sets the background color for even rows to the specified color.
 void setOddRowBackground(java.awt.Color color)
          Sets the background color for odd rows to the specified color.
 
Methods inherited from class org.jdesktop.swingx.decorator.Highlighter
addChangeListener, applyBackground, applyFont, applyForeground, computeForeground, doHighlight, fireStateChanged, getBackground, getChangeListeners, getForeground, getSelectedBackground, getSelectedForeground, highlight, isImmutable, removeChangeListener, setBackground, setForeground, setSelectedBackground, setSelectedForeground
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

beige

public static final Highlighter beige

linePrinter

public static final Highlighter linePrinter

classicLinePrinter

public static final Highlighter classicLinePrinter

floralWhite

public static final Highlighter floralWhite

quickSilver

public static final Highlighter quickSilver

genericGrey

public static final AlternateRowHighlighter genericGrey
Constructor Detail

AlternateRowHighlighter

public AlternateRowHighlighter()
Constructs a default AlternateRowHighlighter that prepares a cell renderer to paint a white background for odd rows and a silver (0xF0, 0xF0, 0xE0) background for even rows.


AlternateRowHighlighter

public AlternateRowHighlighter(java.awt.Color oddRowBackground,
                               java.awt.Color evenRowBackground,
                               java.awt.Color foreground)
Constructs an AlternateRowHighlighter that prepares a cell renderer to paint the specified background colors for odd and even and even rows. A foreground color may also be specified. If null is specified for the foreground color, the foreground color for the renderer is unchanged. Otherwise, it is set to the specified foreground color for both odd and even rows.

Parameters:
oddRowBackground -
evenRowBackground -
foreground -

AlternateRowHighlighter

public AlternateRowHighlighter(java.awt.Color oddRowBackground,
                               java.awt.Color evenRowBackground,
                               java.awt.Color foreground,
                               boolean immutable)
Method Detail

getOddRowBackground

public java.awt.Color getOddRowBackground()
Returns the background color for odd rows, or null if the background color of the cell renderer should be left unchanged for odd rows.

Returns:
the background color for odd rows, or null if the background color of the cell renderer should be left unchanged for odd rows

setOddRowBackground

public void setOddRowBackground(java.awt.Color color)
Sets the background color for odd rows to the specified color. If null is specified, the background color for odd rows is left unchanged in the renderer

Parameters:
color - the background color for odd rows, or null if the background color of the cell renderer should be left unchanged for odd rows

getEvenRowBackground

public java.awt.Color getEvenRowBackground()
Returns the background color for even rows, or null if the background color of the cell renderer should be left unchanged for even rows.

Returns:
the background color for even rows, or null if the background color of the cell renderer should be left unchanged for even rows

setEvenRowBackground

public void setEvenRowBackground(java.awt.Color color)
Sets the background color for even rows to the specified color. If null is specified, the background color for even rows is left unchanged in the renderer.

Parameters:
color - the background color for even rows, or null if the background color of the cell renderer should be left unchanged for even rows

computeBackground

protected java.awt.Color computeBackground(java.awt.Component renderer,
                                           ComponentAdapter adapter)
Computes the background color for the current rendering context for the specified adapter. It first chooses the raw background color for the renderer depending on whether the row being rendered is odd or even. If the chosen background color is not null calls computeSelectedBackground passing in the chosen raw background color as the seed color, but only if the row being rendered is selected.

Overrides:
computeBackground in class Highlighter
Parameters:
renderer - the cell renderer component
adapter -
Returns:
the computed background color

computeSelectedBackground

protected java.awt.Color computeSelectedBackground(java.awt.Color seed)
Description copied from class: Highlighter
Computes the selected background color. If the selected background color of this Highlighter is not null, this method returns that color. Otherwise, it returns a Color.darker() version of the specified seed color.

Overrides:
computeSelectedBackground in class Highlighter
Parameters:
seed - initial background color; must cope with null!
Returns:
the background color for a selected cell

computeSelectedForeground

protected java.awt.Color computeSelectedForeground(java.awt.Color seed)
Description copied from class: Highlighter
Computes the selected foreground color. If the selected foreground color of this Highlighter is not null, this method returns that color. Otherwise, it returns Color.white, ignoring the specified seed color.

Overrides:
computeSelectedForeground in class Highlighter
Parameters:
seed - initial foreground color; must cope with null!
Returns:
the foreground color for a selected cell


Copyright © 2005 Sun Microsystems All Rights Reserved.