org.jcreme.swing.table.colormodel
Class AbstractValueIndexedTableColorModel

java.lang.Object
  extended byorg.jcreme.swing.table.colormodel.AbstractValueIndexedTableColorModel
All Implemented Interfaces:
TableColorModel
Direct Known Subclasses:
GeneralValueIndexedTableColorModel, ValueIndexedTableColorModel

public abstract class AbstractValueIndexedTableColorModel
extends java.lang.Object
implements TableColorModel

The purpose of this class is to have a specific background color for the lines that have a given reference column above a given Threshold value. (the value of a specified column is at a specified value).

Version:
$Revision: 1.3 $
Author:
$Author: dbregeon $

Constructor Summary
AbstractValueIndexedTableColorModel()
          Creates new ValueIndexedTableColorModel
 
Method Summary
 void addTableColorModelListener(TableColorModelListener l)
          Registers a new listener for the modifications of the color scheme.
 void fireTableColorModelChanged(TableColorModelEvent e)
          Fires a TableColorModelEvent telling registered listeners that the color scheme has changed.
 java.awt.Color getBackgroundColor()
           
 java.awt.Color getBackgroundColor(int row, int column, boolean selected, java.awt.Component renderer)
          Gets the current background color that the cell described by the params should have.
 java.awt.Color getForegroundColor()
           
 java.awt.Color getForegroundColor(int row, int column, boolean selected, java.awt.Component renderer)
          Gets the current foreground color that the cell described by the params should have.
 java.util.EventListener[] getListeners(java.lang.Class listenerType)
          Gets the list of the listeners registered for the modifications of the color scheme.
protected  int getReferenceColumn()
           
 java.awt.Color getSelectedBackgroundColor()
           
 java.awt.Color getSelectedForegroundColor()
           
 java.awt.Color getSelectedThresholdColor()
           
 javax.swing.table.TableModel getTableModel()
          Gives access to the TableModel colored by this TableColorModel.
 java.awt.Color getThresholdColor()
           
 void removeTableColorModelListener(TableColorModelListener l)
          Unregisters the given listener ffor the modifications of the color scheme.
 void setBackgroundColor(java.awt.Color backgroundColor)
           
 void setForegroundColor(java.awt.Color foregroundColor)
           
 void setReferenceColumn(int column)
          Sets the reference column whose value is monitored to determine the rows' states.
 void setSelectedBackgroundColor(java.awt.Color selectedBackgroundColor)
           
 void setSelectedForegroundColor(java.awt.Color selectedForegroundColor)
           
 void setSelectedThresholdColor(java.awt.Color selectedThresholdColor)
           
 void setTableModel(javax.swing.table.TableModel model)
          Sets the model that will be colored by this TableColorModel.
 void setThresholdColor(java.awt.Color thresholdColor)
           
protected abstract  boolean testThreshold(java.lang.Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractValueIndexedTableColorModel

public AbstractValueIndexedTableColorModel()
Creates new ValueIndexedTableColorModel

Method Detail

testThreshold

protected abstract boolean testThreshold(java.lang.Object value)

getReferenceColumn

protected int getReferenceColumn()

getTableModel

public javax.swing.table.TableModel getTableModel()
Description copied from interface: TableColorModel
Gives access to the TableModel colored by this TableColorModel.

Specified by:
getTableModel in interface TableColorModel
Returns:
the data colored by this model.

setReferenceColumn

public void setReferenceColumn(int column)
Sets the reference column whose value is monitored to determine the rows' states.

Parameters:
column - The index of the column to be used as a reference.

getBackgroundColor

public java.awt.Color getBackgroundColor(int row,
                                         int column,
                                         boolean selected,
                                         java.awt.Component renderer)
Gets the current background color that the cell described by the params should have.

Specified by:
getBackgroundColor in interface TableColorModel
Parameters:
row - The row index of the cell.
column - The column index of the cell.
selected - Boolean telling whether the cell is selected.
renderer - the renderer that renders the cell.
Returns:
the current background color that the cell described by the params should have.

getForegroundColor

public java.awt.Color getForegroundColor(int row,
                                         int column,
                                         boolean selected,
                                         java.awt.Component renderer)
Gets the current foreground color that the cell described by the params should have.

Specified by:
getForegroundColor in interface TableColorModel
Parameters:
row - The row index of the cell.
column - The column index of the cell.
selected - Boolean telling whether the cell is selected.
renderer - the renderer that renders the cell.
Returns:
the current foreground color that the cell described by the params should have.

addTableColorModelListener

public void addTableColorModelListener(TableColorModelListener l)
Registers a new listener for the modifications of the color scheme.

Specified by:
addTableColorModelListener in interface TableColorModel
Parameters:
l - The listener to be added to the list.

removeTableColorModelListener

public void removeTableColorModelListener(TableColorModelListener l)
Unregisters the given listener ffor the modifications of the color scheme.

Specified by:
removeTableColorModelListener in interface TableColorModel
Parameters:
l - The listener to be removed from the list.

fireTableColorModelChanged

public void fireTableColorModelChanged(TableColorModelEvent e)
Fires a TableColorModelEvent telling registered listeners that the color scheme has changed.

Parameters:
e - The event describing the changes.

getListeners

public java.util.EventListener[] getListeners(java.lang.Class listenerType)
Gets the list of the listeners registered for the modifications of the color scheme.

Specified by:
getListeners in interface TableColorModel
Parameters:
listenerType - The class of listeners to retrieve.
Returns:
The list of all listeners of the given type registered in the list.

setTableModel

public void setTableModel(javax.swing.table.TableModel model)
Description copied from interface: TableColorModel
Sets the model that will be colored by this TableColorModel.

Specified by:
setTableModel in interface TableColorModel
Parameters:
model - the data to be colored by this model.
See Also:
TableColorModel.setTableModel(javax.swing.table.TableModel)

getBackgroundColor

public java.awt.Color getBackgroundColor()
Returns:
Returns the backgroundColor.

setBackgroundColor

public void setBackgroundColor(java.awt.Color backgroundColor)
Parameters:
backgroundColor - The backgroundColor to set.

getForegroundColor

public java.awt.Color getForegroundColor()
Returns:
Returns the foregroundColor.

setForegroundColor

public void setForegroundColor(java.awt.Color foregroundColor)
Parameters:
foregroundColor - The foregroundColor to set.

getSelectedBackgroundColor

public java.awt.Color getSelectedBackgroundColor()
Returns:
Returns the selectedBackgroundColor.

setSelectedBackgroundColor

public void setSelectedBackgroundColor(java.awt.Color selectedBackgroundColor)
Parameters:
selectedBackgroundColor - The selectedBackgroundColor to set.

getSelectedForegroundColor

public java.awt.Color getSelectedForegroundColor()
Returns:
Returns the selectedForegroundColor.

setSelectedForegroundColor

public void setSelectedForegroundColor(java.awt.Color selectedForegroundColor)
Parameters:
selectedForegroundColor - The selectedForegroundColor to set.

getSelectedThresholdColor

public java.awt.Color getSelectedThresholdColor()
Returns:
Returns the selectedThresholdColor.

setSelectedThresholdColor

public void setSelectedThresholdColor(java.awt.Color selectedThresholdColor)
Parameters:
selectedThresholdColor - The selectedThresholdColor to set.

getThresholdColor

public java.awt.Color getThresholdColor()
Returns:
Returns the thresholdColor.

setThresholdColor

public void setThresholdColor(java.awt.Color thresholdColor)
Parameters:
thresholdColor - The thresholdColor to set.


Copyright 2006 null. All Rights Reserved.