org.jcreme.swing.table.colormodel
Class LineTitlesColorModel

java.lang.Object
  extended byorg.jcreme.swing.table.colormodel.DefaultTableColorModel
      extended byorg.jcreme.swing.table.colormodel.LineTitlesColorModel
All Implemented Interfaces:
TableColorModel

public class LineTitlesColorModel
extends DefaultTableColorModel
implements TableColorModel

This class enables to give cycling colors to a Table. The cycle can have any length desired and can contain any number of colors. An obvious use of this ColorModel is to have a different color for every two or three lines to ease the reading of the Table. This ColorModel implementation acts on lines rather than on cells.

Version:
$Revision: 1.1 $
Author:
$Author: dbregeon $

Field Summary
 
Fields inherited from class org.jcreme.swing.table.colormodel.DefaultTableColorModel
MINIMUM_COLOR_DISTANCE
 
Constructor Summary
LineTitlesColorModel(java.awt.Color bgColor, java.awt.Color fgColor, java.awt.Color bgSelectedColor, java.awt.Color fgSelectedColor, int numberOfColumnsInTitle)
          Creates new LineTitlesColorModel
 
Method Summary
 java.awt.Color getBackgroundColor()
          Gives access to the color to apply to the background to mark title columns.
 java.awt.Color getBackgroundColor(int row, int column, boolean selected, java.awt.Component renderer)
          Gives access to the background color of a cell.
 java.awt.Color getBackgroundSelectedColor()
          Gives access to the color to apply to the background to mark title columns when the row is selected.
 java.awt.Color getForegroundColor()
          Gives access to the color to apply to the foreground to mark title columns.
 java.awt.Color getForegroundColor(int row, int column, boolean selected, java.awt.Component renderer)
          Gives access to the foreground color of a cell.
 java.awt.Color getForegroundSelectedColor()
          Gives access to the color to apply to the foreground to mark title columns when the row is selected.
 int getNumberOfColumnsInTitle()
          Gives access to the number of columns to include in the title.
 void setBackgroundColor(java.awt.Color bgColor)
          Enables to change the background color for title columns.
 void setBackgroundSelectedColor(java.awt.Color bgSelectedColor)
          This method enables to change the color used as background for selected cells.
 void setForegroundColor(java.awt.Color fgColor)
          Enables to change the foreground color for title columns.
 void setForegroundSelectedColor(java.awt.Color fgSelectedColor)
          This method enables to change the color used as foreground for selected cells.
 void setNumberOfColumnsInTitle(int titleSize)
          Enables to change the number of columns to be included as title.
 
Methods inherited from class org.jcreme.swing.table.colormodel.DefaultTableColorModel
addTableColorModelListener, ensureMinimumDistance, fireTableColorModelChanged, getDistance, getListeners, getTableModel, mixColors, removeTableColorModelListener, setTableModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jcreme.swing.table.TableColorModel
addTableColorModelListener, getListeners, getTableModel, removeTableColorModelListener, setTableModel
 

Constructor Detail

LineTitlesColorModel

public LineTitlesColorModel(java.awt.Color bgColor,
                            java.awt.Color fgColor,
                            java.awt.Color bgSelectedColor,
                            java.awt.Color fgSelectedColor,
                            int numberOfColumnsInTitle)
Creates new LineTitlesColorModel

Parameters:
bgColor - the backgroud colors of the cycle.
fgColor - the foreground colors of the cycle.
bgSelectedColor - the background color for selected rows.
fgSelectedColor - the foreground color for selected rows.
numberOfColumnsInTitle - the number of columns that are part of a line's title.
Method Detail

getBackgroundColor

public java.awt.Color getBackgroundColor(int row,
                                         int column,
                                         boolean selected,
                                         java.awt.Component renderer)
Gives access to the background color of a cell.

Specified by:
getBackgroundColor in interface TableColorModel
Overrides:
getBackgroundColor in class DefaultTableColorModel
Parameters:
row - the cell's row.
column - the cell's column.
selected - whether the cell is currently selected or not.
renderer - the renderer used to display the cell.
Returns:
the background color for the cell.

getForegroundColor

public java.awt.Color getForegroundColor(int row,
                                         int column,
                                         boolean selected,
                                         java.awt.Component renderer)
Gives access to the foreground color of a cell.

Specified by:
getForegroundColor in interface TableColorModel
Overrides:
getForegroundColor in class DefaultTableColorModel
Parameters:
row - the cell's row.
column - the cell's column.
selected - whether the cell is currently selected or not.
renderer - the renderer used to display the cell.
Returns:
the foreground color for the cell.

getForegroundColor

public java.awt.Color getForegroundColor()
Gives access to the color to apply to the foreground to mark title columns.

Returns:
the foreground color for the title columns.

getForegroundSelectedColor

public java.awt.Color getForegroundSelectedColor()
Gives access to the color to apply to the foreground to mark title columns when the row is selected.

Returns:
the foreground color for the title columns.

getBackgroundColor

public java.awt.Color getBackgroundColor()
Gives access to the color to apply to the background to mark title columns.

Returns:
the background color for the title columns.

getBackgroundSelectedColor

public java.awt.Color getBackgroundSelectedColor()
Gives access to the color to apply to the background to mark title columns when the row is selected.

Returns:
the background color for the title columns.

getNumberOfColumnsInTitle

public int getNumberOfColumnsInTitle()
Gives access to the number of columns to include in the title.

Returns:
the number of columns in the line title.

setNumberOfColumnsInTitle

public void setNumberOfColumnsInTitle(int titleSize)
Enables to change the number of columns to be included as title.

Parameters:
titleSize - the new number of columns to be included as titles.

setBackgroundColor

public void setBackgroundColor(java.awt.Color bgColor)
Enables to change the background color for title columns.

Parameters:
bgColor - the new background title color.

setForegroundColor

public void setForegroundColor(java.awt.Color fgColor)
Enables to change the foreground color for title columns.

Parameters:
fgColor - the new foreground title color.

setBackgroundSelectedColor

public void setBackgroundSelectedColor(java.awt.Color bgSelectedColor)
This method enables to change the color used as background for selected cells.

Parameters:
bgSelectedColor - the new background for selected cells.

setForegroundSelectedColor

public void setForegroundSelectedColor(java.awt.Color fgSelectedColor)
This method enables to change the color used as foreground for selected cells.

Parameters:
fgSelectedColor - the new foreground for selected cells.


Copyright 2006 null. All Rights Reserved.