Documentation of 'org.statcato.spreadsheet.SpreadsheetModel' Java class
SpreadsheetModel
org.statcato.spreadsheet

Class SpreadsheetModel

  • All Implemented Interfaces:
    java.io.Serializable, java.util.EventListener, javax.swing.event.TableModelListener, javax.swing.table.TableModel


    public class SpreadsheetModel
    extends javax.swing.table.AbstractTableModel
    implements javax.swing.event.TableModelListener
    A table model for Spreadsheet.

    The table data is represented by vectors of vectors of Cell. The first row of the table contains the column/variable names. The row and column numbers of table Cells are not guaranteed to be accurate. Their correctness is ensured when a row/column is retrieved.

    Since:
    1.0
    See Also:
    Spreadsheet, Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      SpreadsheetModel(Statcato app)
      Constructor given the parent frame.
      SpreadsheetModel(Statcato app, int rows, int columns)
      Constructor given the parent frame, number of rows, and number of columns.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void clearCell(int row, int col)
      Clears the contents in the cell at the specified row and column.
      void deleteCell(int row, int column)
      Deletes the cell at the specified row and column.
      void deleteCells(int minRow, int maxRow, int minCol, int maxCol)
      Deletes the cells within the specified range.
      void deleteColumn(int column)
      Deletes the entire column at the specified column number.
      void deleteRow(int row)
      Deletes the entire row at the specified row number.
      java.util.Vector getAllColumnNumbers()
      Gets all the column numbers.
      java.util.Vector<Cell> getColumn(int col)
      Returns the vector of cells in the given column number.
      java.lang.Class getColumnClass(int c) 
      int getColumnCount() 
      static java.lang.String getColumnLabel(int column)
      Returns the column label for the given column number.
      java.lang.String getColumnName(int col)
      Returns the column name at the given column.
      int getColumnNumber(java.lang.String label)
      Returns the column number embedded in the given column label.
      java.util.Vector getColumnsWithData()
      Returns the column number of columns that contain data.
      java.lang.String getCommaSeparatedValues()
      Returns the table data as a string of comma-separated values.
      int getLastNonEmptyColumn()
      Returns the column number of the last column with data.
      int getLastNonEmptyColumn(int row)
      returns the column number of the last non-empty column in the given row.
      int getLastNonEmptyRow()
      Returns the row number of the last non-empty row.
      java.util.Vector<Cell> getRow(int row)
      Returns the vector of cells in the given row number.
      int getRowCount() 
      int getRowNumber(java.lang.String label)
      Returns the row number from the given row label.
      java.lang.String getTabDelimitedValues()
      Returns the table data as a string of tab-dlimited values.
      java.lang.Object getValueAt(int row, int col) 
      java.lang.String getVariableName(int col)
      Returns the variable name at the given column.
      static boolean hasData(java.lang.Object cell)
      Returns true if and only if the given cell has data.
      void insertCell(int row, int col)
      Inserts a blank cell at the specified row and column.
      void insertColumn(int col)
      Inserts a blank column at the specified column number.
      void insertRow(int row)
      Inserts a blank row at the specified row number.
      boolean isCellEditable(int row, int col) 
      void printDebugData()
      Prints debug data.
      void setCellColumn(int column, java.util.Vector<Cell> data)
      Sets the contents of the given column to the given cell vector.
      void setColumn(int column, java.util.Vector<java.lang.String> data)
      Sets the contents of the given column to the given data vector.
      void setData(java.util.Vector<java.util.Vector<java.lang.String>> data)
      Sets the underlying table structure to the given data matrix.
      void setRow(int row, java.util.Vector<java.lang.String> data)
      Sets the contents of the given row to the given data vector.
      void setStringValueAt(java.lang.String value, int row, int col)
      Set the string value at the specified row and column.
      void setValueAt(java.lang.Object value, int row, int col)
      Sets the value at the given row and column to the given value.
      void tableChanged(javax.swing.event.TableModelEvent e) 
      • Methods inherited from class javax.swing.table.AbstractTableModel

        addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SpreadsheetModel

        public SpreadsheetModel(Statcato app)
        Constructor given the parent frame.
        Parameters:
        app - parent frame
      • SpreadsheetModel

        public SpreadsheetModel(Statcato app,
                                int rows,
                                int columns)
        Constructor given the parent frame, number of rows, and number of columns.
        Parameters:
        app - parent frame
        rows - number of rows
        columns - number of columns
    • Method Detail

      • getColumn

        public java.util.Vector<Cell> getColumn(int col)
        Returns the vector of cells in the given column number.
        Parameters:
        col - column number
        Returns:
        vector of cells in the given column
      • getRow

        public java.util.Vector<Cell> getRow(int row)
        Returns the vector of cells in the given row number.
        Parameters:
        row - row number
        Returns:
        vector of cells in the given row
      • getColumnLabel

        public static java.lang.String getColumnLabel(int column)
        Returns the column label for the given column number.
        Parameters:
        column - number
        Returns:
        column label
      • getColumnNumber

        public int getColumnNumber(java.lang.String label)
        Returns the column number embedded in the given column label.
        Parameters:
        label - column label
        Returns:
        column number
      • getRowNumber

        public int getRowNumber(java.lang.String label)
        Returns the row number from the given row label.
        Parameters:
        label - row label
        Returns:
        row number
      • getLastNonEmptyRow

        public int getLastNonEmptyRow()
        Returns the row number of the last non-empty row.
        Returns:
        row number
      • getLastNonEmptyColumn

        public int getLastNonEmptyColumn(int row)
        returns the column number of the last non-empty column in the given row.
        Parameters:
        row - number in which the last non-empty column is found
        Returns:
        column number
      • getLastNonEmptyColumn

        public int getLastNonEmptyColumn()
        Returns the column number of the last column with data.
        Returns:
        column number
      • tableChanged

        public void tableChanged(javax.swing.event.TableModelEvent e)
        Specified by:
        tableChanged in interface javax.swing.event.TableModelListener
      • getColumnCount

        public int getColumnCount()
        Specified by:
        getColumnCount in interface javax.swing.table.TableModel
      • getRowCount

        public int getRowCount()
        Specified by:
        getRowCount in interface javax.swing.table.TableModel
      • getColumnName

        public java.lang.String getColumnName(int col)
        Returns the column name at the given column.
        Specified by:
        getColumnName in interface javax.swing.table.TableModel
        Overrides:
        getColumnName in class javax.swing.table.AbstractTableModel
        Parameters:
        col - column number
        Returns:
        column name
      • getVariableName

        public java.lang.String getVariableName(int col)
        Returns the variable name at the given column.
        Parameters:
        col - column number
        Returns:
        variable name
      • getValueAt

        public java.lang.Object getValueAt(int row,
                                           int col)
        Specified by:
        getValueAt in interface javax.swing.table.TableModel
      • getColumnClass

        public java.lang.Class getColumnClass(int c)
        Specified by:
        getColumnClass in interface javax.swing.table.TableModel
        Overrides:
        getColumnClass in class javax.swing.table.AbstractTableModel
      • isCellEditable

        public boolean isCellEditable(int row,
                                      int col)
        Specified by:
        isCellEditable in interface javax.swing.table.TableModel
        Overrides:
        isCellEditable in class javax.swing.table.AbstractTableModel
      • getColumnsWithData

        public java.util.Vector getColumnsWithData()
        Returns the column number of columns that contain data.
        Returns:
        vector of Integers representing column numbers
      • getAllColumnNumbers

        public java.util.Vector getAllColumnNumbers()
        Gets all the column numbers.
        Returns:
        a vector of integers (column numbers)
      • hasData

        public static boolean hasData(java.lang.Object cell)
        Returns true if and only if the given cell has data. A cell has data if its content is not an empty string.
        Parameters:
        cell - cell object to check if it contains data
        Returns:
        true iff the given cell has data
      • setValueAt

        public void setValueAt(java.lang.Object value,
                               int row,
                               int col)
        Sets the value at the given row and column to the given value. If the target row is the variable row, checks if the given variable name already exists.
        Specified by:
        setValueAt in interface javax.swing.table.TableModel
        Overrides:
        setValueAt in class javax.swing.table.AbstractTableModel
        Parameters:
        value - Object to set
        row - row number
        col - column number
      • setStringValueAt

        public void setStringValueAt(java.lang.String value,
                                     int row,
                                     int col)
        Set the string value at the specified row and column.
        Parameters:
        value - string value
        row - row
        col - column
      • setColumn

        public void setColumn(int column,
                              java.util.Vector<java.lang.String> data)
        Sets the contents of the given column to the given data vector.
        Parameters:
        column - column number
        data - vector of strings
      • setCellColumn

        public void setCellColumn(int column,
                                  java.util.Vector<Cell> data)
        Sets the contents of the given column to the given cell vector.
        Parameters:
        column - column number
        data - vector of cells
      • setRow

        public void setRow(int row,
                           java.util.Vector<java.lang.String> data)
        Sets the contents of the given row to the given data vector.
        Parameters:
        row - row number
        data - vector of strings
      • setData

        public void setData(java.util.Vector<java.util.Vector<java.lang.String>> data)
        Sets the underlying table structure to the given data matrix.
        Parameters:
        data - vector of vectors of strings
      • getTabDelimitedValues

        public java.lang.String getTabDelimitedValues()
        Returns the table data as a string of tab-dlimited values.
        Returns:
        string containing table data values separated by tab
      • getCommaSeparatedValues

        public java.lang.String getCommaSeparatedValues()
        Returns the table data as a string of comma-separated values.
        Returns:
        string containing table data values separated by comma
      • clearCell

        public void clearCell(int row,
                              int col)
        Clears the contents in the cell at the specified row and column.
        Parameters:
        row - row number
        col - column number
      • deleteRow

        public void deleteRow(int row)
        Deletes the entire row at the specified row number. Shifts all rows below upward by one row.
        Parameters:
        row - row number
      • deleteColumn

        public void deleteColumn(int column)
        Deletes the entire column at the specified column number. Shifts all columns on the right to the left by one column.
        Parameters:
        column - column number
      • deleteCell

        public void deleteCell(int row,
                               int column)
        Deletes the cell at the specified row and column. Shifts data up to replace the removed cell.
        Parameters:
        row - row number
        column - column number
      • deleteCells

        public void deleteCells(int minRow,
                                int maxRow,
                                int minCol,
                                int maxCol)
        Deletes the cells within the specified range.
        Parameters:
        minRow - minimum row
        maxRow - maximum row
        minCol - minimum col
        maxCol - maximum col
      • insertRow

        public void insertRow(int row)
        Inserts a blank row at the specified row number.
        Parameters:
        row - row number
      • insertColumn

        public void insertColumn(int col)
        Inserts a blank column at the specified column number.
        Parameters:
        col - column number
      • insertCell

        public void insertCell(int row,
                               int col)
        Inserts a blank cell at the specified row and column.
        Parameters:
        row - row number
        col - column number
      • printDebugData

        public void printDebugData()
        Prints debug data.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.