edu.iastate.metnet.model
Class TableSorter
java.lang.Object
javax.swing.table.AbstractTableModel
edu.iastate.metnet.model.TableMap
edu.iastate.metnet.model.TableSorter
- All Implemented Interfaces:
- java.io.Serializable, java.util.EventListener, javax.swing.event.TableModelListener, javax.swing.table.TableModel
public class TableSorter
- extends TableMap
- See Also:
- Serialized Form
| Fields inherited from class edu.iastate.metnet.model.TableMap |
model |
| Fields inherited from class javax.swing.table.AbstractTableModel |
listenerList |
|
Method Summary |
void |
addMouseListenerToHeaderInTable(javax.swing.JTable table)
There is no-where else to put this. |
void |
checkModel()
|
int |
compare(int row1,
int row2)
|
int |
compareRowsByColumn(int row1,
int row2,
int column)
|
int |
getTrueRow(int rowIndex)
get the underline model's row |
java.lang.Object |
getValueAt(int aRow,
int aColumn)
|
void |
n2sort()
|
void |
reallocateIndexes()
|
void |
setModel(javax.swing.table.TableModel model)
|
void |
setValueAt(java.lang.Object aValue,
int aRow,
int aColumn)
|
void |
shuttlesort(int[] from,
int[] to,
int low,
int high)
This is a home-grown implementation which we have not had time to research - it may perform
poorly in some circumstances. |
void |
sort(java.lang.Object sender)
|
void |
sortByColumn(int column)
|
void |
sortByColumn(int column,
boolean ascending)
|
void |
swap(int i,
int j)
|
void |
tableChanged(javax.swing.event.TableModelEvent e)
|
| 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 |
logger
static org.apache.log4j.Logger logger
indexes
int[] indexes
sortingColumns
java.util.Vector sortingColumns
ascending
boolean ascending
compares
int compares
TableSorter
public TableSorter()
TableSorter
public TableSorter(javax.swing.table.TableModel model)
setModel
public void setModel(javax.swing.table.TableModel model)
- Overrides:
setModel in class TableMap
compareRowsByColumn
public int compareRowsByColumn(int row1,
int row2,
int column)
compare
public int compare(int row1,
int row2)
reallocateIndexes
public void reallocateIndexes()
tableChanged
public void tableChanged(javax.swing.event.TableModelEvent e)
- Specified by:
tableChanged in interface javax.swing.event.TableModelListener- Overrides:
tableChanged in class TableMap
checkModel
public void checkModel()
sort
public void sort(java.lang.Object sender)
n2sort
public void n2sort()
shuttlesort
public void shuttlesort(int[] from,
int[] to,
int low,
int high)
- This is a home-grown implementation which we have not had time to research - it may perform
poorly in some circumstances. It requires twice the space of an in-place algorithm and makes
NlogN assigments shuttling the values between the two arrays. The number of compares appears
to vary between N-1 and NlogN depending on the initial order but the main reason for using
it here is that, unlike qsort, it is stable.
swap
public void swap(int i,
int j)
getValueAt
public java.lang.Object getValueAt(int aRow,
int aColumn)
- Specified by:
getValueAt in interface javax.swing.table.TableModel- Overrides:
getValueAt in class TableMap
getTrueRow
public int getTrueRow(int rowIndex)
- get the underline model's row
setValueAt
public void setValueAt(java.lang.Object aValue,
int aRow,
int aColumn)
- Specified by:
setValueAt in interface javax.swing.table.TableModel- Overrides:
setValueAt in class TableMap
sortByColumn
public void sortByColumn(int column)
sortByColumn
public void sortByColumn(int column,
boolean ascending)
addMouseListenerToHeaderInTable
public void addMouseListenerToHeaderInTable(javax.swing.JTable table)
- There is no-where else to put this. Add a mouse listener to the Table to trigger a table
sort when a column heading is clicked in the JTable.