weka.gui.arffviewer
Class ArffTableSorter

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by weka.gui.TableMap
          extended by weka.gui.TableSorter
              extended by weka.gui.arffviewer.ArffTableSorter
All Implemented Interfaces:
java.io.Serializable, java.util.EventListener, javax.swing.event.TableModelListener, javax.swing.table.TableModel, Undoable

public class ArffTableSorter
extends TableSorter
implements Undoable

A sorter for the ARFF-Viewer - necessary because of the custom CellRenderer.

Version:
$Revision: 1.1.2.2 $
Author:
FracPete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form

Constructor Summary
ArffTableSorter(Instances data)
          initializes the sorter w/o a model, but uses the given data to create a model from that
ArffTableSorter(java.lang.String filename)
          initializes the sorter w/o a model, but loads the given file and creates from that a model
ArffTableSorter(javax.swing.table.TableModel model)
          initializes the sorter with the given model
 
Method Summary
 void addTableModelListener(javax.swing.event.TableModelListener l)
          adds a listener to the list that is notified each time a change to data model occurs
 void addUndoPoint()
          adds an undo point to the undo history
 boolean canUndo()
          returns whether an undo is possible, i.e.
 void clearUndo()
          removes the undo history
 void deleteAttributeAt(int columnIndex)
          deletes the attribute at the given col index
 void deleteAttributes(int[] columnIndices)
          deletes the attributes at the given indices
 void deleteInstanceAt(int rowIndex)
          deletes the instance at the given index
 void deleteInstances(int[] rowIndices)
          deletes the instances at the given positions
 Attribute getAttributeAt(int columnIndex)
          returns the attribute at the given index, can be NULL if not an attribute column
 int getAttributeColumn(java.lang.String name)
          returns the column of the given attribute name, -1 if not found
 Instances getInstances()
          returns the data
 java.lang.Object getModelValueAt(int rowIndex, int columnIndex)
          returns the value at the given position
 int getType(int columnIndex)
          returns the TYPE of the attribute at the given position
 int getType(int rowIndex, int columnIndex)
          returns the TYPE of the attribute at the given position
 boolean isMissingAt(int rowIndex, int columnIndex)
          checks whether the value at the given position is missing
 boolean isNotificationEnabled()
          returns whether the notification of changes is enabled
 boolean isUndoEnabled()
          returns whether undo support is enabled
 void notifyListener(javax.swing.event.TableModelEvent e)
          notfies all listener of the change of the model
 void removeTableModelListener(javax.swing.event.TableModelListener l)
          removes a listener from the list that is notified each time a change to the data model occurs
 void renameAttributeAt(int columnIndex, java.lang.String newName)
          renames the attribute at the given col index
 void setInstances(Instances data)
          sets the data
 void setNotificationEnabled(boolean enabled)
          sets whether the notification of changes is enabled
 void setUndoEnabled(boolean enabled)
          sets whether undo support is enabled
 void sortInstances(int columnIndex)
          sorts the instances via the given attribute
 void undo()
          undoes the last action
 
Methods inherited from class weka.gui.TableSorter
addMouseListenerToHeaderInTable, checkModel, compare, compareRowsByColumn, getValueAt, n2sort, reallocateIndexes, setModel, setValueAt, shuttlesort, sort, sortByColumn, sortByColumn, swap, tableChanged
 
Methods inherited from class weka.gui.TableMap
getColumnClass, getColumnCount, getColumnName, getModel, getRowCount, isCellEditable
 
Methods inherited from class javax.swing.table.AbstractTableModel
findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArffTableSorter

public ArffTableSorter(java.lang.String filename)
initializes the sorter w/o a model, but loads the given file and creates from that a model


ArffTableSorter

public ArffTableSorter(Instances data)
initializes the sorter w/o a model, but uses the given data to create a model from that


ArffTableSorter

public ArffTableSorter(javax.swing.table.TableModel model)
initializes the sorter with the given model

Method Detail

isNotificationEnabled

public boolean isNotificationEnabled()
returns whether the notification of changes is enabled


setNotificationEnabled

public void setNotificationEnabled(boolean enabled)
sets whether the notification of changes is enabled


isUndoEnabled

public boolean isUndoEnabled()
returns whether undo support is enabled

Specified by:
isUndoEnabled in interface Undoable

setUndoEnabled

public void setUndoEnabled(boolean enabled)
sets whether undo support is enabled

Specified by:
setUndoEnabled in interface Undoable

getModelValueAt

public java.lang.Object getModelValueAt(int rowIndex,
                                        int columnIndex)
returns the value at the given position

Overrides:
getModelValueAt in class TableSorter

getType

public int getType(int columnIndex)
returns the TYPE of the attribute at the given position


getType

public int getType(int rowIndex,
                   int columnIndex)
returns the TYPE of the attribute at the given position


deleteAttributeAt

public void deleteAttributeAt(int columnIndex)
deletes the attribute at the given col index


deleteAttributes

public void deleteAttributes(int[] columnIndices)
deletes the attributes at the given indices


renameAttributeAt

public void renameAttributeAt(int columnIndex,
                              java.lang.String newName)
renames the attribute at the given col index


deleteInstanceAt

public void deleteInstanceAt(int rowIndex)
deletes the instance at the given index


deleteInstances

public void deleteInstances(int[] rowIndices)
deletes the instances at the given positions


sortInstances

public void sortInstances(int columnIndex)
sorts the instances via the given attribute


getAttributeColumn

public int getAttributeColumn(java.lang.String name)
returns the column of the given attribute name, -1 if not found


isMissingAt

public boolean isMissingAt(int rowIndex,
                           int columnIndex)
checks whether the value at the given position is missing


setInstances

public void setInstances(Instances data)
sets the data


getInstances

public Instances getInstances()
returns the data


getAttributeAt

public Attribute getAttributeAt(int columnIndex)
returns the attribute at the given index, can be NULL if not an attribute column


addTableModelListener

public void addTableModelListener(javax.swing.event.TableModelListener l)
adds a listener to the list that is notified each time a change to data model occurs

Specified by:
addTableModelListener in interface javax.swing.table.TableModel
Overrides:
addTableModelListener in class javax.swing.table.AbstractTableModel

removeTableModelListener

public void removeTableModelListener(javax.swing.event.TableModelListener l)
removes a listener from the list that is notified each time a change to the data model occurs

Specified by:
removeTableModelListener in interface javax.swing.table.TableModel
Overrides:
removeTableModelListener in class javax.swing.table.AbstractTableModel

notifyListener

public void notifyListener(javax.swing.event.TableModelEvent e)
notfies all listener of the change of the model


clearUndo

public void clearUndo()
removes the undo history

Specified by:
clearUndo in interface Undoable

canUndo

public boolean canUndo()
returns whether an undo is possible, i.e. whether there are any undo points saved so far

Specified by:
canUndo in interface Undoable
Returns:
returns TRUE if there is an undo possible

undo

public void undo()
undoes the last action

Specified by:
undo in interface Undoable

addUndoPoint

public void addUndoPoint()
adds an undo point to the undo history

Specified by:
addUndoPoint in interface Undoable