|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--javax.swing.table.AbstractTableModel
|
+--javatools.swing.table.IndexedTableMap
|
+--javatools.swing.table.IndexedTableSorter
It seems a table, it is a table sorter for indexed tables. Based upon the sorter in the Java tutorial.
| Field Summary | |
protected boolean |
ascending
true: ascending order;
false: descending order. |
protected int |
compares
Contains the number of made comparisons. |
protected int[] |
indexes
The indexes to use for correct order. |
protected int |
lastSortedColumn
Contains the last sorted column to alternate ascending and descending order. |
protected boolean |
lastSortingDirection
Contains the last sorting direction, to alternate ascending and descending order. |
protected java.util.Vector |
sortingColumns
Contains the columns to use to sort. |
| Fields inherited from class javatools.swing.table.IndexedTableMap |
model |
| Fields inherited from class javax.swing.table.AbstractTableModel |
listenerList |
| Constructor Summary | |
IndexedTableSorter()
Creates new IndexedTableSorter |
|
IndexedTableSorter(IndexedTableModel model)
Creates a new IndexedTableSorter. |
|
| Method Summary | |
void |
addMouseListenerToHeaderInTable(javax.swing.JTable table)
Method used to add a mouse listener to catch click on table headers. |
void |
checkModel()
Checks if the model is OK. |
int |
compare(int row1,
int row2)
Compares two columns. |
int |
compareRowsByColumn(int row1,
int row2,
int column)
Compares two rows by a column. |
java.lang.Object |
getIndex(int row)
Returns the index. |
java.lang.Object |
getValueAt(int aRow,
int aColumn)
Returns the value in a certain position. |
void |
n2sort()
Sorts 2 items. |
void |
reallocateIndexes()
Initializes indexes. |
void |
removeRow(int row)
Removes a row. |
void |
setIndex(int row,
java.lang.Object index)
Sets an index. |
void |
setModel(IndexedTableModel model)
Sets the table model to sort. |
void |
setValueAt(java.lang.Object aValue,
int aRow,
int aColumn)
Sets a value in the table. |
void |
shuttlesort(int[] from,
int[] to,
int low,
int high)
Sorts using shuttlesort. |
void |
sort(java.lang.Object sender)
Sorts the table. |
void |
sortByColumn(int column)
Sorts the table by a column. |
void |
sortByColumn(int column,
boolean ascending)
Sorts the table by column. |
void |
swap(int i,
int j)
Swaps (logically) two rows. |
void |
tableChanged(javax.swing.event.TableModelEvent e)
Method that is called whenever the table changes. |
| Methods inherited from class javatools.swing.table.IndexedTableMap |
getColumnClass, getColumnCount, getColumnName, getModel, getRowCount, isCellEditable |
| Methods inherited from class javax.swing.table.AbstractTableModel |
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected int[] indexes
protected java.util.Vector sortingColumns
protected boolean ascending
true: ascending order;
false: descending order.
protected int compares
protected int lastSortedColumn
protected boolean lastSortingDirection
| Constructor Detail |
public IndexedTableSorter()
public IndexedTableSorter(IndexedTableModel model)
model - The base table model to use.| Method Detail |
public void setModel(IndexedTableModel model)
setModel in class IndexedTableMapmodel - The model.
public int compareRowsByColumn(int row1,
int row2,
int column)
row1 - The first row.row2 - The second row.column - The column to use as a criterion.
public int compare(int row1,
int row2)
row1 - The first row.row2 - The second row.
public void reallocateIndexes()
public void tableChanged(javax.swing.event.TableModelEvent e)
tableChanged in interface javax.swing.event.TableModelListenertableChanged in class IndexedTableMape - The event.public void checkModel()
public void sort(java.lang.Object sender)
sender - Ignored (what????).public void n2sort()
public void shuttlesort(int[] from,
int[] to,
int low,
int high)
from - The origin indexes.to - The destination indexes.low - The lower limit.high - The higher limit.
public void swap(int i,
int j)
i - The first index.j - The second index.
public java.lang.Object getValueAt(int aRow,
int aColumn)
getValueAt in interface javax.swing.table.TableModelgetValueAt in class IndexedTableMapaRow - The row index.aColumn - The column index.
public java.lang.Object getIndex(int row)
throws java.lang.ArrayIndexOutOfBoundsException
getIndex in class IndexedTableMaprow - The row index.
java.lang.ArrayIndexOutOfBoundsException - If row is not correct.
public void setValueAt(java.lang.Object aValue,
int aRow,
int aColumn)
setValueAt in interface javax.swing.table.TableModelsetValueAt in class IndexedTableMapaValue - The value.aRow - The row index.aColumn - The column index.
public void setIndex(int row,
java.lang.Object index)
throws java.lang.ArrayIndexOutOfBoundsException
setIndex in class IndexedTableMaprow - The row index.index - The index.
java.lang.ArrayIndexOutOfBoundsException - If row is not correct.public void removeRow(int row)
row - The row index.public void sortByColumn(int column)
column - The column to sort by.
public void sortByColumn(int column,
boolean ascending)
column - The column to use.ascending - true: ascending order;
false: descending order.public void addMouseListenerToHeaderInTable(javax.swing.JTable table)
table - The table.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||