SalesPoint Framework v3.0

util.swing
Class TableSorter

java.lang.Object
  |
  +--javax.swing.table.AbstractTableModel
        |
        +--util.swing.AbstractTableModel
              |
              +--util.swing.TableMap
                    |
                    +--util.swing.TableSorter

public class TableSorter
extends TableMap

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. Habe diese Implementation mit geringen ?nderungen in dieses Package ?bernommen.

Version:
1.5 12/17/97
Author:
Philip Milne, Thomas Medack
See Also:
Serialized Form

Fields inherited from class util.swing.TableMap
model
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
TableSorter()
          Konstruktor.
TableSorter(AbstractTableModel model)
          Konstruktor.
 
Method Summary
 void addMouseListenerToHeaderInTable(JTable table, Object[] ao)
          F?gt einen Mouselistener hinzu.
 void checkModel()
          Hilfsmethode.
 int compare(int row1, int row2)
          Vergleich.
 int compareRowsByColumn(int row1, int row2, int column)
          Vergleicht Spalten von bestimmten Zeilen.
 Object getRecord(int row)
          Wrapper - getRecord
 Object getValueAt(int aRow, int aColumn)
          Wrapper - getValueAt
 void reallocateIndexes()
          Hilfsmethode.
 void setModel(AbstractTableModel model)
          Setzt das Model.
 void setValueAt(Object aValue, int aRow, int aColumn)
          Wrapper - setValueAt
 void shuttlesort(int[] from, int[] to, int low, int high)
          Revolution?re Sortiermethode.
 void sort(Object sender)
          Sortiermethode.
 void sortByColumn(int column)
          Sortiert eine Spalte.
 void sortByColumn(int column, boolean ascending)
          Sortiert eine Spalte.
 void swap(int i, int j)
          Hilfmethode.
 void tableChanged(TableModelEvent e)
          Wrapper - tableChanged
 
Methods inherited from class util.swing.TableMap
getColumnClass, getColumnCount, getColumnName, getModel, getRowCount, isCellEditable
 
Methods inherited from class util.swing.AbstractTableModel
getEntryDescriptor, orderByColumn, reOrderBy
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableSorter

public TableSorter()
Konstruktor.

TableSorter

public TableSorter(AbstractTableModel model)
Konstruktor.
Parameters:
model - das eingeschachtelte Model.
Method Detail

setModel

public void setModel(AbstractTableModel model)
Setzt das Model.
Parameters:
model - das Model.
Overrides:
setModel in class TableMap

compareRowsByColumn

public int compareRowsByColumn(int row1,
                               int row2,
                               int column)
Vergleicht Spalten von bestimmten Zeilen.
Parameters:
row1 - Zeile 1.
row2 - Zeile 2.
column - die Spalte.
Returns:
Vergleichswert.

compare

public int compare(int row1,
                   int row2)
Vergleich.
Parameters:
row1 - Zeile 1.
row2 - Zeile 2.
Returns:
Vergleichswert.

reallocateIndexes

public void reallocateIndexes()
Hilfsmethode.

tableChanged

public void tableChanged(TableModelEvent e)
Wrapper - tableChanged
Parameters:
e - das Event.
Overrides:
tableChanged in class TableMap

checkModel

public void checkModel()
Hilfsmethode.

sort

public void sort(Object sender)
Sortiermethode.
Parameters:
sender - ein Objekt.

shuttlesort

public void shuttlesort(int[] from,
                        int[] to,
                        int low,
                        int high)
Revolution?re Sortiermethode.
Parameters:
from - ?
to - ?
low - ?
high - ?

swap

public void swap(int i,
                 int j)
Hilfmethode.
Parameters:
i - ?
j - ?

getValueAt

public Object getValueAt(int aRow,
                         int aColumn)
Wrapper - getValueAt
Parameters:
aRow - die Zeile.
aColumn - die Spalte.
Returns:
der Wert.
Overrides:
getValueAt in class TableMap

getRecord

public Object getRecord(int row)
Wrapper - getRecord
Parameters:
row - die Zeile
Returns:
das Object
Overrides:
getRecord in class TableMap

setValueAt

public void setValueAt(Object aValue,
                       int aRow,
                       int aColumn)
Wrapper - setValueAt
Parameters:
aValue - der Wert.
aRow - die Zeile.
aColumn - die Spalte.
Overrides:
setValueAt in class TableMap

sortByColumn

public void sortByColumn(int column)
Sortiert eine Spalte.
Parameters:
column - die Spalte.

sortByColumn

public void sortByColumn(int column,
                         boolean ascending)
Sortiert eine Spalte. Aufsteigend oder absteigend.
Parameters:
column - die Spalte.
ascending - auf oder absteigend.

addMouseListenerToHeaderInTable

public void addMouseListenerToHeaderInTable(JTable table,
                                            Object[] ao)
F?gt einen Mouselistener hinzu.
Parameters:
table - die Tabelle, an die der Listener angeh?ngt werden soll.

SalesPoint Framework v3.0