org.jdesktop.swingx.decorator
Class Filter

java.lang.Object
  extended by org.jdesktop.swingx.decorator.Filter
Direct Known Subclasses:
FilterPipeline.IdentityFilter, PatternFilter, Sorter

public abstract class Filter
extends java.lang.Object

A Filter is used to filter the data presented in a data-aware component such as a JXList or a JXTable. Filtering involves interposing one or more filters in a FilterPipeline between a data model and a view to change the apparent order and/or number of records in the data model.

Author:
Ramesh Gupta
See Also:
FilterPipeline, JXTable

Constructor Summary
Filter()
          Constructs a new filter for the first column of a data model.
Filter(int column)
          Constructs a new filter for the specified column of a data model in absolute model coordinates.
 
Method Summary
 int convertRowIndexToModel(int row)
          Convert row index from view coordinates to model coordinates accounting for the presence of sorters and filters.
 int convertRowIndexToView(int row)
          Convert row index from model coordinates to view coordinates accounting for the presence of sorters and filters.
 int getColumnIndex()
          Returns the model index of the column that this filter has been bound to.
 java.lang.String getColumnName()
           
abstract  int getSize()
          Returns the number of records that remain in this filter's output ("view") after the input records have been filtered.
 java.lang.String getStringAt(int row, int column)
          Returns the string representation at the specified row and column.
 java.lang.Object getValueAt(int row, int column)
          Returns the value at the specified row and column.
 boolean isCellEditable(int row, int column)
          Returns editability of the cell identified by the specified row and column index.
 void refresh()
          Refreshes the internal state of the filter, performs the filter operation and regenerates row mappings from the previous filter.
 void setColumnIndex(int modelColumn)
          TODO: PENDING: not tested!
 void setValueAt(java.lang.Object aValue, int row, int column)
          Sets the specified value as the new value for the cell identified by the specified row and column index.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Filter

public Filter()
Constructs a new filter for the first column of a data model.


Filter

public Filter(int column)
Constructs a new filter for the specified column of a data model in absolute model coordinates.

Parameters:
column - column index in absolute model coordinates
Method Detail

refresh

public void refresh()
Refreshes the internal state of the filter, performs the filter operation and regenerates row mappings from the previous filter. If this filter is bound to a filter pipeline (as most filters are), it also triggers a filterChanged notification.


getColumnIndex

public int getColumnIndex()
Returns the model index of the column that this filter has been bound to.

Returns:
the column index in absolute model coordinates

setColumnIndex

public void setColumnIndex(int modelColumn)
TODO: PENDING: not tested!

Parameters:
modelColumn - column index in absolute model coordinates

getColumnName

public java.lang.String getColumnName()

convertRowIndexToModel

public int convertRowIndexToModel(int row)
Convert row index from view coordinates to model coordinates accounting for the presence of sorters and filters. PRE: 0 <= row < getSize()

Parameters:
row - the row index in this filter's output ("view") coordinates
Returns:
row index in absolute model coordinates

convertRowIndexToView

public int convertRowIndexToView(int row)
Convert row index from model coordinates to view coordinates accounting for the presence of sorters and filters.

Parameters:
row - row index in model coordinates
Returns:
row index in this filter's "view" coordinates

getValueAt

public java.lang.Object getValueAt(int row,
                                   int column)
Returns the value at the specified row and column. The column index is in absolute column coordinates. PRE: 0 <= row < getSize()

Parameters:
row - the row index in this filter's output ("view") coordinates
column - column index in absolute model coordinates
Returns:
the value at the specified row and column

getStringAt

public java.lang.String getStringAt(int row,
                                    int column)
Returns the string representation at the specified row and column. The column index is in absolute column coordinates. PRE: 0 <= row < getSize()

Parameters:
row - the row index in this filter's output ("view") coordinates
column - column index in model coordinates
Returns:
the string representation of the cell at the specified row and column.

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int row,
                       int column)
Sets the specified value as the new value for the cell identified by the specified row and column index. The column index is in absolute column coordinates. PRE: 0 <= row < getSize()

Parameters:
aValue - new value for the specified cell
row - the row index in this filter's output ("view") coordinates
column - the column index in absolute model coordinates

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Returns editability of the cell identified by the specified row and column index. The column index is in absolute column coordinates. PRE: 0 <= row < getSize()

Parameters:
row - the row index in this filter's output ("view") coordinates
column - column index in model coordinates
Returns:
true if the cell at the specified row/col is editable

getSize

public abstract int getSize()
Returns the number of records that remain in this filter's output ("view") after the input records have been filtered.

Returns:
the number of records that remain in this filter's output ("view") after the input records have been filtered