Class ArffTableModel

    • Constructor Detail

      • ArffTableModel

        public ArffTableModel​(String filename,
                              AbstractFileLoader... loaders)
        initializes the object and loads the given file
        Parameters:
        filename - the file to load
        loaders - optional varargs for a loader to use
      • 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 interface Undoable
        Returns:
        true if undo support is enabled
      • setUndoEnabled

        public void setUndoEnabled​(boolean enabled)
        sets whether undo support is enabled
        Specified by:
        setUndoEnabled in interface Undoable
        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
      • getAttributeIndex

        public int getAttributeIndex​(int columnIndex)
        Returns the attribute index for the given column index.
        Parameters:
        columnIndex - the column index
        Returns:
        the attribute index
      • isAttribute

        public boolean isAttribute​(int columnIndex)
        Check if given index is in range of column indices for attributes
        Parameters:
        columnIndex - the column index
        Returns:
        true if the column corresponds to attribute
      • 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 row
        columnIndex - 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 delete
        notify - 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,
                                      String newName)
        renames the attribute at the given col index
        Parameters:
        columnIndex - the index of the column
        newName - the new name of the attribute
      • setAttributeWeightAt

        public void setAttributeWeightAt​(int columnIndex,
                                         double weight)
        set the attribute weight at the given col index
        Parameters:
        columnIndex - the index of the column
        weight - the new weight 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 row
        notify - whether to notify the listeners
      • setInstanceWeight

        public void setInstanceWeight​(int index,
                                      double weight)
      • setInstanceWeight

        public void setInstanceWeight​(int index,
                                      double weight,
                                      boolean notify)
      • insertInstance

        public void insertInstance​(int index)
      • insertInstance

        public void insertInstance​(int index,
                                   boolean notify)
      • 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 (ascending)
        Parameters:
        columnIndex - the index of the column
      • sortInstances

        public void sortInstances​(int columnIndex,
                                  boolean ascending)
        sorts the instances via the given attribute
        Parameters:
        columnIndex - the index of the column
        ascending - ascending if true, otherwise descending
      • getAttributeColumn

        public int getAttributeColumn​(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 Class<?> getColumnClass​(int columnIndex)
        returns the most specific superclass for all the cell values in the column (always String)
        Specified by:
        getColumnClass in interface TableModel
        Overrides:
        getColumnClass in class AbstractTableModel
        Parameters:
        columnIndex - the column index
        Returns:
        the class of the column
      • getColumnName

        public String getColumnName​(int columnIndex)
        returns the name of the column at columnIndex
        Specified by:
        getColumnName in interface TableModel
        Overrides:
        getColumnName in class DefaultTableModel
        Parameters:
        columnIndex - the index of the column
        Returns:
        the name of the column
      • isMissingAt

        public boolean isMissingAt​(int rowIndex,
                                   int columnIndex)
        checks whether the value at the given position is missing
        Parameters:
        rowIndex - the row index
        columnIndex - 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 index
        columnIndex - the column index
        Returns:
        the underlying value in the Instances object
      • getValueAt

        public Object getValueAt​(int rowIndex,
                                 int columnIndex)
        returns the value for the cell at columnIndex and rowIndex
        Specified by:
        getValueAt in interface TableModel
        Overrides:
        getValueAt in class DefaultTableModel
        Parameters:
        rowIndex - the row index
        columnIndex - 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 interface TableModel
        Overrides:
        isCellEditable in class DefaultTableModel
        Parameters:
        rowIndex - the index of the row
        columnIndex - the index of the column
        Returns:
        true if the cell is editable
      • setValueAt

        public void setValueAt​(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 TableModel
        Overrides:
        setValueAt in class DefaultTableModel
        Parameters:
        aValue - the new value
        rowIndex - the row index
        columnIndex - the column index
      • setValueAt

        public void setValueAt​(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 value
        rowIndex - the row index
        columnIndex - the column index
        notify - whether to notify the listeners
      • notifyListener

        public void notifyListener​(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
        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
      • setShowAttributeIndex

        public void setShowAttributeIndex​(boolean value)
        Sets whether to display the attribute index in the header.
        Parameters:
        value - if true then the attribute indices are displayed in the table header
      • getShowAttributeIndex

        public boolean getShowAttributeIndex()
        Returns whether to display the attribute index in the header.
        Returns:
        true if the attribute indices are displayed in the table header