jAudioFeatureExtractor
Class SortingTableModelDecorator

java.lang.Object
  extended by jAudioFeatureExtractor.SortingTableModelDecorator
All Implemented Interfaces:
java.util.EventListener, javax.swing.event.TableModelListener, javax.swing.table.TableModel

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

Decorator model on top of normal feature selection model.

Author:
Daniel McEnnis

Constructor Summary
SortingTableModelDecorator(javax.swing.table.TableModel base)
          Creates a new model that decorates the underlying model with sorting capabilities
 
Method Summary
 void addTableModelListener(javax.swing.event.TableModelListener l)
          passed directly to underlying model
 java.lang.Class<?> getColumnClass(int columnIndex)
          passed directly to underlying model
 int getColumnCount()
          passed directly to underlying model
 java.lang.String getColumnName(int columnIndex)
          passed directly to underlying model
 int getRealPrefferedWidth(javax.swing.JTable t, int col)
          This method calculates a reasonable preffered width by calculating the width of both the header and each element of the table.
 int getRowCount()
          passed directly to underlying model
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
          passed to underlying model with a translated row index
 boolean isCellEditable(int rowIndex, int columnIndex)
          passed directly to underlying model
 void removeTableModelListener(javax.swing.event.TableModelListener l)
          passed directly to underlying model
 void resetIndeci()
          This method restores the indeci to their default encoding.
 void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
          passed to underlying model with a translated row index.
 void sort(int index)
          Sorts the rows using quicksort
 void tableChanged(javax.swing.event.TableModelEvent e)
          Method for handling generic changes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortingTableModelDecorator

public SortingTableModelDecorator(javax.swing.table.TableModel base)
Creates a new model that decorates the underlying model with sorting capabilities

Parameters:
base - Underlying model this model is built on top of.
Method Detail

tableChanged

public void tableChanged(javax.swing.event.TableModelEvent e)
Method for handling generic changes. Since these changes could involve creation or deletion of features from the table, a the table is completely reset to the default order.

Specified by:
tableChanged in interface javax.swing.event.TableModelListener

getRowCount

public int getRowCount()
passed directly to underlying model

Specified by:
getRowCount in interface javax.swing.table.TableModel

getColumnCount

public int getColumnCount()
passed directly to underlying model

Specified by:
getColumnCount in interface javax.swing.table.TableModel

getColumnName

public java.lang.String getColumnName(int columnIndex)
passed directly to underlying model

Specified by:
getColumnName in interface javax.swing.table.TableModel

getColumnClass

public java.lang.Class<?> getColumnClass(int columnIndex)
passed directly to underlying model

Specified by:
getColumnClass in interface javax.swing.table.TableModel

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
passed directly to underlying model

Specified by:
isCellEditable in interface javax.swing.table.TableModel

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
passed to underlying model with a translated row index

Specified by:
getValueAt in interface javax.swing.table.TableModel

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int rowIndex,
                       int columnIndex)
passed to underlying model with a translated row index.

Specified by:
setValueAt in interface javax.swing.table.TableModel

addTableModelListener

public void addTableModelListener(javax.swing.event.TableModelListener l)
passed directly to underlying model

Specified by:
addTableModelListener in interface javax.swing.table.TableModel

removeTableModelListener

public void removeTableModelListener(javax.swing.event.TableModelListener l)
passed directly to underlying model

Specified by:
removeTableModelListener in interface javax.swing.table.TableModel

sort

public void sort(int index)
Sorts the rows using quicksort

Parameters:
index - Which column is being sorted

resetIndeci

public void resetIndeci()
This method restores the indeci to their default encoding.


getRealPrefferedWidth

public int getRealPrefferedWidth(javax.swing.JTable t,
                                 int col)
This method calculates a reasonable preffered width by calculating the width of both the header and each element of the table.

Parameters:
t - link to the JTable associated with this model
col - which column's width is bein calcualted.
Returns:
Preferred width of the column.