Package weka.gui.arffviewer
Class ArffTableModel
- java.lang.Object
-
- weka.gui.arffviewer.ArffTableModel
-
-
Constructor Summary
Constructors Constructor Description ArffTableModel(java.lang.String filename)
initializes the object and loads the given fileArffTableModel(Instances data)
initializes the model with the given data
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTableModelListener(javax.swing.event.TableModelListener l)
adds a listener to the list that is notified each time a change to data model occursvoid
addUndoPoint()
adds an undo point to the undo history, if the undo support is enabledvoid
attributeAsClassAt(int columnIndex)
sets the attribute at the given col index as the new class attribute, i.e.boolean
canUndo()
returns whether an undo is possible, i.e.void
clearUndo()
removes the undo historyvoid
deleteAttributeAt(int columnIndex)
deletes the attribute at the given col index.void
deleteAttributeAt(int columnIndex, boolean notify)
deletes the attribute at the given col indexvoid
deleteAttributes(int[] columnIndices)
deletes the attributes at the given indicesvoid
deleteInstanceAt(int rowIndex)
deletes the instance at the given indexvoid
deleteInstanceAt(int rowIndex, boolean notify)
deletes the instance at the given indexvoid
deleteInstances(int[] rowIndices)
deletes the instances at the given positionsAttribute
getAttributeAt(int columnIndex)
returns the attribute at the given index, can be NULL if not an attribute columnint
getAttributeColumn(java.lang.String name)
returns the column of the given attribute name, -1 if not foundjava.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 modeljava.lang.String
getColumnName(int columnIndex)
returns the name of the column at columnIndexInstances
getInstances()
returns the datadouble
getInstancesValueAt(int rowIndex, int columnIndex)
returns the double value of the underlying Instances object at the given position, -1 if out of boundsint
getRowCount()
returns the number of rows in the modelint
getType(int columnIndex)
returns the TYPE of the attribute at the given positionint
getType(int rowIndex, int columnIndex)
returns the TYPE of the attribute at the given positionjava.lang.Object
getValueAt(int rowIndex, int columnIndex)
returns the value for the cell at columnindex and rowIndexboolean
isCellEditable(int rowIndex, int columnIndex)
returns true if the cell at rowindex and columnindexis editableboolean
isMissingAt(int rowIndex, int columnIndex)
checks whether the value at the given position is missingboolean
isNotificationEnabled()
returns whether the notification of changes is enabledboolean
isReadOnly()
returns whether the model is read-onlyboolean
isUndoEnabled()
returns whether undo support is enabledvoid
notifyListener(javax.swing.event.TableModelEvent e)
notfies all listener of the change of the modelvoid
removeTableModelListener(javax.swing.event.TableModelListener l)
removes a listener from the list that is notified each time a change to the data model occursvoid
renameAttributeAt(int columnIndex, java.lang.String newName)
renames the attribute at the given col indexvoid
setInstances(Instances data)
sets the datavoid
setNotificationEnabled(boolean enabled)
sets whether the notification of changes is enabledvoid
setReadOnly(boolean value)
sets whether the model is read-onlyvoid
setUndoEnabled(boolean enabled)
sets whether undo support is enabledvoid
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 attributevoid
undo()
undoes the last action
-
-
-
Constructor Detail
-
ArffTableModel
public ArffTableModel(java.lang.String filename)
initializes the object and loads the given file- Parameters:
filename
- the file to load
-
ArffTableModel
public ArffTableModel(Instances data)
initializes the model with the given data- Parameters:
data
- the data to use
-
-
Method Detail
-
isNotificationEnabled
public boolean isNotificationEnabled()
returns whether the notification of changes is enabled- Returns:
- true if notification of changes is enabled
-
setNotificationEnabled
public void setNotificationEnabled(boolean enabled)
sets whether the notification of changes is enabled- Parameters:
enabled
- enables/disables the notification
-
isUndoEnabled
public boolean isUndoEnabled()
returns whether undo support is enabled- Specified by:
isUndoEnabled
in interfaceUndoable
- Returns:
- true if undo support is enabled
-
setUndoEnabled
public void setUndoEnabled(boolean enabled)
sets whether undo support is enabled- Specified by:
setUndoEnabled
in interfaceUndoable
- Parameters:
enabled
- whether to enable/disable undo support
-
isReadOnly
public boolean isReadOnly()
returns whether the model is read-only- Returns:
- true if model is read-only
-
setReadOnly
public void setReadOnly(boolean value)
sets whether the model is read-only- Parameters:
value
- if true the model is set to read-only
-
setInstances
public void setInstances(Instances data)
sets the data- Parameters:
data
- the data to use
-
getInstances
public Instances getInstances()
returns the data- Returns:
- the current data
-
getAttributeAt
public Attribute getAttributeAt(int columnIndex)
returns the attribute at the given index, can be NULL if not an attribute column- Parameters:
columnIndex
- the index of the column- Returns:
- the attribute at the position
-
getType
public int getType(int columnIndex)
returns the TYPE of the attribute at the given position- Parameters:
columnIndex
- the index of the column- Returns:
- the attribute type
-
getType
public int getType(int rowIndex, int columnIndex)
returns the TYPE of the attribute at the given position- Parameters:
rowIndex
- the index of the rowcolumnIndex
- the index of the column- Returns:
- the attribute type
-
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 deletenotify
- whether to notify the listeners
-
deleteAttributes
public void deleteAttributes(int[] columnIndices)
deletes the attributes at the given indices- Parameters:
columnIndices
- the column indices
-
renameAttributeAt
public void renameAttributeAt(int columnIndex, java.lang.String newName)
renames the attribute at the given col index- Parameters:
columnIndex
- the index of the columnnewName
- the new name of the attribute
-
attributeAsClassAt
public void attributeAsClassAt(int columnIndex)
sets the attribute at the given col index as the new class attribute, i.e. it moves it to the end of the attributes- Parameters:
columnIndex
- the index of the column
-
deleteInstanceAt
public void deleteInstanceAt(int rowIndex)
deletes the instance at the given index- Parameters:
rowIndex
- the index of the row
-
deleteInstanceAt
public void deleteInstanceAt(int rowIndex, boolean notify)
deletes the instance at the given index- Parameters:
rowIndex
- the index of the rownotify
- whether to notify the listeners
-
deleteInstances
public void deleteInstances(int[] rowIndices)
deletes the instances at the given positions- Parameters:
rowIndices
- the indices to delete
-
sortInstances
public void sortInstances(int columnIndex)
sorts the instances via the given attribute- Parameters:
columnIndex
- the index of the column
-
getAttributeColumn
public int getAttributeColumn(java.lang.String name)
returns the column of the given attribute name, -1 if not found- Parameters:
name
- the name of the attribute- Returns:
- the column index or -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 interfacejavax.swing.table.TableModel
- Parameters:
columnIndex
- the column index- Returns:
- the class of the column
-
getColumnCount
public int getColumnCount()
returns the number of columns in the model- Specified by:
getColumnCount
in interfacejavax.swing.table.TableModel
- Returns:
- the number of columns
-
getColumnName
public java.lang.String getColumnName(int columnIndex)
returns the name of the column at columnIndex- Specified by:
getColumnName
in interfacejavax.swing.table.TableModel
- Parameters:
columnIndex
- the index of the column- Returns:
- the name of the column
-
getRowCount
public int getRowCount()
returns the number of rows in the model- Specified by:
getRowCount
in interfacejavax.swing.table.TableModel
- Returns:
- the number of rows
-
isMissingAt
public boolean isMissingAt(int rowIndex, int columnIndex)
checks whether the value at the given position is missing- Parameters:
rowIndex
- the row indexcolumnIndex
- the column index- Returns:
- true if the value at the position is missing
-
getInstancesValueAt
public double getInstancesValueAt(int rowIndex, int columnIndex)
returns the double value of the underlying Instances object at the given position, -1 if out of bounds- Parameters:
rowIndex
- the row indexcolumnIndex
- the column index- Returns:
- the underlying value in the Instances object
-
getValueAt
public java.lang.Object getValueAt(int rowIndex, int columnIndex)
returns the value for the cell at columnindex and rowIndex- Specified by:
getValueAt
in interfacejavax.swing.table.TableModel
- Parameters:
rowIndex
- the row indexcolumnIndex
- the column index- Returns:
- the value at the position
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex)
returns true if the cell at rowindex and columnindexis editable- Specified by:
isCellEditable
in interfacejavax.swing.table.TableModel
- Parameters:
rowIndex
- the index of the rowcolumnIndex
- the index of the column- Returns:
- true if the cell is editable
-
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 interfacejavax.swing.table.TableModel
- Parameters:
aValue
- the new valuerowIndex
- the row indexcolumnIndex
- the column index
-
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- Parameters:
aValue
- the new valuerowIndex
- the row indexcolumnIndex
- the column indexnotify
- whether to notify the listeners
-
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 interfacejavax.swing.table.TableModel
- Parameters:
l
- the listener to add
-
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 interfacejavax.swing.table.TableModel
- Parameters:
l
- the listener to remove
-
notifyListener
public void notifyListener(javax.swing.event.TableModelEvent e)
notfies all listener of the change of the model- Parameters:
e
- the event to send to the listeners
-
clearUndo
public void clearUndo()
removes the undo history
-
canUndo
public boolean canUndo()
returns whether an undo is possible, i.e. whether there are any undo points saved so far
-
addUndoPoint
public void addUndoPoint()
adds an undo point to the undo history, if the undo support is enabled- Specified by:
addUndoPoint
in interfaceUndoable
- See Also:
isUndoEnabled()
,setUndoEnabled(boolean)
-
-