org.opensourcephysics.display
Class SortDecorator

java.lang.Object
  extended by org.opensourcephysics.display.SortDecorator
All Implemented Interfaces:
java.util.EventListener, javax.swing.event.TableModelListener, javax.swing.table.TableModel

public class SortDecorator
extends java.lang.Object
implements javax.swing.table.TableModel, javax.swing.event.TableModelListener

Sorts table column based on their numeric values if the table's values are numeric. Otherwise sorts using toString.

Version:
1.0
Author:
W. Christian

Constructor Summary
SortDecorator(javax.swing.table.TableModel model)
          Constructor SortDecorator
 
Method Summary
 void addTableModelListener(javax.swing.event.TableModelListener l)
           
 int compare(int i, int j, int column)
           
 java.lang.Class<?> getColumnClass(int columnIndex)
           
 int getColumnCount()
           
 java.lang.String getColumnName(int columnIndex)
           
 int getRowCount()
           
 java.lang.Object getValueAt(int row, int column)
           
 boolean isCellEditable(int rowIndex, int columnIndex)
           
 void removeTableModelListener(javax.swing.event.TableModelListener l)
           
 void setValueAt(java.lang.Object aValue, int row, int column)
           
 void sort(int column)
           
 void swap(int i, int j)
           
 void tableChanged(javax.swing.event.TableModelEvent e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortDecorator

public SortDecorator(javax.swing.table.TableModel model)
Constructor SortDecorator

Parameters:
model -
Method Detail

getValueAt

public java.lang.Object getValueAt(int row,
                                   int column)
Specified by:
getValueAt in interface javax.swing.table.TableModel

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int row,
                       int column)
Specified by:
setValueAt in interface javax.swing.table.TableModel

tableChanged

public void tableChanged(javax.swing.event.TableModelEvent e)
Specified by:
tableChanged in interface javax.swing.event.TableModelListener

sort

public void sort(int column)

swap

public void swap(int i,
                 int j)

compare

public int compare(int i,
                   int j,
                   int column)

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface javax.swing.table.TableModel

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface javax.swing.table.TableModel

getColumnName

public java.lang.String getColumnName(int columnIndex)
Specified by:
getColumnName in interface javax.swing.table.TableModel

getColumnClass

public java.lang.Class<?> getColumnClass(int columnIndex)
Specified by:
getColumnClass in interface javax.swing.table.TableModel

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Specified by:
isCellEditable in interface javax.swing.table.TableModel

addTableModelListener

public void addTableModelListener(javax.swing.event.TableModelListener l)
Specified by:
addTableModelListener in interface javax.swing.table.TableModel

removeTableModelListener

public void removeTableModelListener(javax.swing.event.TableModelListener l)
Specified by:
removeTableModelListener in interface javax.swing.table.TableModel