public class DataTableModel extends DefaultTableModel implements weka.core.Undoable
Modifier and Type | Field and Description |
---|---|
protected Hashtable<String,String> |
m_Cache
for caching long relational and string values that get processed for
display.
|
protected weka.core.Instances |
m_Data
the data
|
protected boolean |
m_IgnoreChanges
whether to ignore changes, i.e.
|
protected HashSet<TableModelListener> |
m_Listeners
the listeners
|
protected boolean |
m_NotificationEnabled
whether notfication is enabled
|
protected boolean |
m_ReadOnly
whether the table is read-only
|
protected boolean |
m_ShowAttributeIndex
whether to display the attribute index in the table header.
|
protected boolean |
m_UndoEnabled
whether undo is active
|
protected Vector<File> |
m_UndoList
the undo list (contains temp.
|
columnIdentifiers, dataVector
listenerList
Constructor and Description |
---|
DataTableModel(weka.core.Instances data)
initializes the model with the given data
|
DataTableModel(String filename,
weka.core.converters.AbstractFileLoader... loaders)
initializes the object and loads the given file
|
Modifier and Type | Method and Description |
---|---|
void |
addTableModelListener(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
|
void |
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 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
|
weka.core.Attribute |
getAttributeAt(int columnIndex)
returns the attribute at the given index, can be NULL if not an attribute
column
|
int |
getAttributeColumn(String name)
returns the column of the given attribute name, -1 if not found
|
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
|
String |
getColumnName(int columnIndex)
returns the name of the column at columnIndex
|
weka.core.Instances |
getInstances()
returns the data
|
double |
getInstancesValueAt(int rowIndex,
int columnIndex)
returns the double value of the underlying Instances object at the given
position, -1 if out of bounds
|
int |
getRowCount()
returns the number of rows in the model
|
boolean |
getShowAttributeIndex()
Returns whether to display the attribute index in the header.
|
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
|
Object |
getValueAt(int rowIndex,
int columnIndex)
returns the value for the cell at columnindex and rowIndex
|
void |
insertInstance(int index) |
void |
insertInstance(int index,
boolean notify) |
boolean |
isCellEditable(int rowIndex,
int columnIndex)
returns true if the cell at rowindex and columnindexis editable
|
protected boolean |
isClassIndex(int columnIndex)
checks whether the column represents the class or not
|
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 |
isReadOnly()
returns whether the model is read-only
|
boolean |
isUndoEnabled()
returns whether undo support is enabled
|
protected void |
loadFile(String filename,
weka.core.converters.AbstractFileLoader... loaders)
loads the specified ARFF file
|
void |
notifyListener(TableModelEvent e)
notfies all listener of the change of the model
|
void |
removeTableModelListener(TableModelListener l)
removes a listener from the list that is notified each time a change to the
data model occurs
|
void |
renameAttributeAt(int columnIndex,
String newName)
renames the attribute at the given col index
|
void |
setInstances(weka.core.Instances data)
sets the data
|
void |
setNotificationEnabled(boolean enabled)
sets whether the notification of changes is enabled
|
void |
setReadOnly(boolean value)
sets whether the model is read-only
|
void |
setShowAttributeIndex(boolean value)
Sets whether to display the attribute index in the header.
|
void |
setUndoEnabled(boolean enabled)
sets whether undo support is enabled
|
void |
setValueAt(Object aValue,
int rowIndex,
int columnIndex)
sets the value in the cell at columnIndex and rowIndex to aValue.
|
void |
setValueAt(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 |
sortInstances(int columnIndex,
boolean ascending)
sorts the instances via the given attribute
|
void |
undo()
undoes the last action
|
addColumn, addColumn, addColumn, addRow, addRow, convertToVector, convertToVector, getDataVector, insertRow, insertRow, moveRow, newDataAvailable, newRowsAdded, removeRow, rowsRemoved, setColumnCount, setColumnIdentifiers, setColumnIdentifiers, setDataVector, setDataVector, setNumRows, setRowCount
findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners
protected HashSet<TableModelListener> m_Listeners
protected weka.core.Instances m_Data
protected boolean m_NotificationEnabled
protected boolean m_UndoEnabled
protected boolean m_IgnoreChanges
protected boolean m_ReadOnly
protected boolean m_ShowAttributeIndex
public DataTableModel(String filename, weka.core.converters.AbstractFileLoader... loaders)
filename
- the file to loadloaders
- optional varargs for a loader to usepublic DataTableModel(weka.core.Instances data)
data
- the data to usepublic boolean isNotificationEnabled()
public void setNotificationEnabled(boolean enabled)
enabled
- enables/disables the notificationpublic boolean isUndoEnabled()
isUndoEnabled
in interface weka.core.Undoable
public void setUndoEnabled(boolean enabled)
setUndoEnabled
in interface weka.core.Undoable
enabled
- whether to enable/disable undo supportpublic boolean isReadOnly()
public void setReadOnly(boolean value)
value
- if true the model is set to read-onlyprotected void loadFile(String filename, weka.core.converters.AbstractFileLoader... loaders)
filename
- the file to loadloaders
- optional varargs for a loader to usepublic void setInstances(weka.core.Instances data)
data
- the data to usepublic weka.core.Instances getInstances()
public weka.core.Attribute getAttributeAt(int columnIndex)
columnIndex
- the index of the columnpublic int getType(int columnIndex)
columnIndex
- the index of the columnpublic int getType(int rowIndex, int columnIndex)
rowIndex
- the index of the rowcolumnIndex
- the index of the columnpublic void deleteAttributeAt(int columnIndex)
columnIndex
- the index of the attribute to deletepublic void deleteAttributeAt(int columnIndex, boolean notify)
columnIndex
- the index of the attribute to deletenotify
- whether to notify the listenerspublic void deleteAttributes(int[] columnIndices)
columnIndices
- the column indicespublic void renameAttributeAt(int columnIndex, String newName)
columnIndex
- the index of the columnnewName
- the new name of the attributepublic void attributeAsClassAt(int columnIndex)
columnIndex
- the index of the columnpublic void deleteInstanceAt(int rowIndex)
rowIndex
- the index of the rowpublic void deleteInstanceAt(int rowIndex, boolean notify)
rowIndex
- the index of the rownotify
- whether to notify the listenerspublic void insertInstance(int index)
public void insertInstance(int index, boolean notify)
public void deleteInstances(int[] rowIndices)
rowIndices
- the indices to deletepublic void sortInstances(int columnIndex)
columnIndex
- the index of the columnpublic void sortInstances(int columnIndex, boolean ascending)
columnIndex
- the index of the columnascending
- ascending if true, otherwise descendingpublic int getAttributeColumn(String name)
name
- the name of the attributepublic Class<?> getColumnClass(int columnIndex)
getColumnClass
in interface TableModel
getColumnClass
in class AbstractTableModel
columnIndex
- the column indexpublic int getColumnCount()
getColumnCount
in interface TableModel
getColumnCount
in class DefaultTableModel
protected boolean isClassIndex(int columnIndex)
columnIndex
- the index of the columnpublic String getColumnName(int columnIndex)
getColumnName
in interface TableModel
getColumnName
in class DefaultTableModel
columnIndex
- the index of the columnpublic int getRowCount()
getRowCount
in interface TableModel
getRowCount
in class DefaultTableModel
public boolean isMissingAt(int rowIndex, int columnIndex)
rowIndex
- the row indexcolumnIndex
- the column indexpublic double getInstancesValueAt(int rowIndex, int columnIndex)
rowIndex
- the row indexcolumnIndex
- the column indexpublic Object getValueAt(int rowIndex, int columnIndex)
getValueAt
in interface TableModel
getValueAt
in class DefaultTableModel
rowIndex
- the row indexcolumnIndex
- the column indexpublic boolean isCellEditable(int rowIndex, int columnIndex)
isCellEditable
in interface TableModel
isCellEditable
in class DefaultTableModel
rowIndex
- the index of the rowcolumnIndex
- the index of the columnpublic void setValueAt(Object aValue, int rowIndex, int columnIndex)
setValueAt
in interface TableModel
setValueAt
in class DefaultTableModel
aValue
- the new valuerowIndex
- the row indexcolumnIndex
- the column indexpublic void setValueAt(Object aValue, int rowIndex, int columnIndex, boolean notify)
aValue
- the new valuerowIndex
- the row indexcolumnIndex
- the column indexnotify
- whether to notify the listenerspublic void addTableModelListener(TableModelListener l)
addTableModelListener
in interface TableModel
addTableModelListener
in class AbstractTableModel
l
- the listener to addpublic void removeTableModelListener(TableModelListener l)
removeTableModelListener
in interface TableModel
removeTableModelListener
in class AbstractTableModel
l
- the listener to removepublic void notifyListener(TableModelEvent e)
e
- the event to send to the listenerspublic void clearUndo()
clearUndo
in interface weka.core.Undoable
public boolean canUndo()
canUndo
in interface weka.core.Undoable
public void undo()
undo
in interface weka.core.Undoable
public void addUndoPoint()
addUndoPoint
in interface weka.core.Undoable
isUndoEnabled()
,
setUndoEnabled(boolean)
public void setShowAttributeIndex(boolean value)
value
- if true then the attribute indices are displayed in the table
headerpublic boolean getShowAttributeIndex()
Copyright © 2017. All Rights Reserved.