|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.table.AbstractTableModel | +--suncertify.swingClient.swingTable.TableMap | +--suncertify.swingClient.swingTable.TableSorter
A sorter for TableModels. The sorter has a model (conforming to TableModel) and itself implements TableModel. TableSorter does not store or copy the data in the TableModel, instead it maintains an array of integers which it keeps the same size as the number of rows in its model. When the model changes it notifies the sorter that something has changed eg. "rowsAdded" so that its internal array of integers can be reallocated. As requests are made of the sorter (like getValueAt(row, col) it redirects them to its model via the mapping array. That way the TableSorter appears to hold another copy of the table with the rows in a different order. The sorting algorthm used is stable which means that it does not move around rows when its comparison function returns 0 to denote that they are equivalent.
Fields inherited from class suncertify.swingClient.swingTable.TableMap |
model |
Fields inherited from class javax.swing.table.AbstractTableModel |
listenerList |
Constructor Summary | |
TableSorter()
The class constructor with no argument. |
|
TableSorter(javax.swing.table.TableModel model)
The class constructor with a single argument. |
Method Summary | |
void |
addMouseListenerToHeaderInTable(javax.swing.JTable table)
Add a mouse listener to the Table to trigger a table sort when a column heading is clicked in the JTable. |
void |
checkModel()
Validate the table model. |
int |
compare(int row1,
int row2)
The compare method. |
int |
compareRowsByColumn(int row1,
int row2,
int column)
Sort the values in the table on a row by row basis on the columns. |
java.lang.Object |
getValueAt(int aRow,
int aColumn)
get cell value |
void |
n2sort()
The sorting method. |
void |
reallocateIndexes()
The method to reallocate the indexes. |
void |
setModel(javax.swing.table.TableModel model)
The method to set the model of a table. |
void |
setValueAt(java.lang.Object aValue,
int aRow,
int aColumn)
set cell value |
void |
shuttlesort(int[] from,
int[] to,
int low,
int high)
use the shuttle sort algorithm to sort. |
void |
sort(java.lang.Object sender)
Method to sort the table. |
void |
sortByColumn(int column)
sort by the chosen column |
void |
sortByColumn(int column,
boolean ascending)
sort by the chosen column |
void |
swap(int i,
int j)
swap indexes. |
void |
tableChanged(javax.swing.event.TableModelEvent e)
called when the underlying table changes. |
Methods inherited from class suncertify.swingClient.swingTable.TableMap |
getColumnClass,
getColumnCount,
getColumnName,
getModel,
getRowCount,
isCellEditable |
Methods inherited from class javax.swing.table.AbstractTableModel |
addTableModelListener,
findColumn,
fireTableCellUpdated,
fireTableChanged,
fireTableDataChanged,
fireTableRowsDeleted,
fireTableRowsInserted,
fireTableRowsUpdated,
fireTableStructureChanged,
removeTableModelListener |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public TableSorter()
public TableSorter(javax.swing.table.TableModel model)
Method Detail |
public void setModel(javax.swing.table.TableModel model)
public int compareRowsByColumn(int row1, int row2, int column)
public int compare(int row1, int row2)
public void reallocateIndexes()
public void tableChanged(javax.swing.event.TableModelEvent e)
public void checkModel()
public void sort(java.lang.Object sender)
public void n2sort()
public void shuttlesort(int[] from, int[] to, int low, int high)
public void swap(int i, int j)
public java.lang.Object getValueAt(int aRow, int aColumn)
public void setValueAt(java.lang.Object aValue, int aRow, int aColumn)
public void sortByColumn(int column)
public void sortByColumn(int column, boolean ascending)
public void addMouseListenerToHeaderInTable(javax.swing.JTable table)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |