weka.gui.arffviewer
Class ArffTableModel

java.lang.Object
  extended byweka.gui.arffviewer.ArffTableModel
All Implemented Interfaces:
javax.swing.table.TableModel, Undoable

public class ArffTableModel
extends java.lang.Object
implements javax.swing.table.TableModel, Undoable

The model for the Arff-Viewer.

Version:
$Revision: 1.1.2.1 $
Author:
FracPete (fracpete at waikato dot ac dot nz)

Constructor Summary
ArffTableModel(Instances data)
          initializes the model with the given data
ArffTableModel(java.lang.String filename)
          initializes the object and loads the given file
 
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, if the undo support is enabled
 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 deleteAttributeAt(int columnIndex, boolean notify)
          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 deleteInstanceAt(int rowIndex, boolean notify)
          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
 java.lang.Class getColumnClass(int columnIndex)
          returns the most specific superclass for all the cell values in the column (always String)
 int getColumnCount()
          returns the number of columns in the model
 java.lang.String getColumnName(int columnIndex)
          returns the name of the column at columnIndex
 Instances getInstances()
          returns the data
 int getRowCount()
          returns the number of rows in the model
 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
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
          returns the value for the cell at columnindex and rowIndex
 boolean isCellEditable(int rowIndex, int columnIndex)
          returns true if the cell at rowindex and columnindexis editable
 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 setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
          sets the value in the cell at columnIndex and rowIndex to aValue.
 void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex, boolean notify)
          sets the value in the cell at columnIndex and rowIndex to aValue.
 void sortInstances(int columnIndex)
          sorts the instances via the given attribute
 void undo()
          undoes the last action
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArffTableModel

public ArffTableModel(java.lang.String filename)
initializes the object and loads the given file


ArffTableModel

public ArffTableModel(Instances data)
initializes the model with the given data

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

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


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. notifies the listeners.

Parameters:
columnIndex - the index of the attribute to delete

deleteAttributeAt

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

Parameters:
columnIndex - the index of the attribute to delete
notify - whether to notify the listeners

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


deleteInstanceAt

public void deleteInstanceAt(int rowIndex,
                             boolean notify)
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


getColumnClass

public java.lang.Class getColumnClass(int columnIndex)
returns the most specific superclass for all the cell values in the column (always String)

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

getColumnCount

public int getColumnCount()
returns the number of columns in the model

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

getColumnName

public java.lang.String getColumnName(int columnIndex)
returns the name of the column at columnIndex

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

getRowCount

public int getRowCount()
returns the number of rows in the model

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

isMissingAt

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


getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
returns the value for the cell at columnindex and rowIndex

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

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
returns true if the cell at rowindex and columnindexis editable

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

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int rowIndex,
                       int columnIndex)
sets the value in the cell at columnIndex and rowIndex to aValue. but only the value and the value can be changed

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

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int rowIndex,
                       int columnIndex,
                       boolean notify)
sets the value in the cell at columnIndex and rowIndex to aValue. but only the value and the value can be changed


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

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

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, if the undo support is enabled

Specified by:
addUndoPoint in interface Undoable
See Also:
isUndoEnabled(), setUndoEnabled(boolean)