Class SpreadSheetTableModel

    • Field Detail

      • m_Sheet

        protected SpreadSheet m_Sheet
        the underlying spreadsheet.
      • m_NumDecimals

        protected int m_NumDecimals
        the number of decimals to display.
      • m_CellRenderingCustomizer

        protected CellRenderingCustomizer m_CellRenderingCustomizer
        for customizing the cell rendering.
      • m_ShowFormulas

        protected boolean m_ShowFormulas
        whether to show formulas rather than the result.
      • m_ShowRowColumn

        protected boolean m_ShowRowColumn
        whether to show the row column as well.
      • m_UseSimpleHeader

        protected boolean m_UseSimpleHeader
        whether to use a simple header.
      • m_ReadOnly

        protected boolean m_ReadOnly
        whether the model is read-only (default).
      • m_Modified

        protected boolean m_Modified
        whether the model is modified.
      • m_ShowCellTypes

        protected boolean m_ShowCellTypes
        whether to show the types instead of the values.
    • Constructor Detail

      • SpreadSheetTableModel

        public SpreadSheetTableModel()
        Initializes the model with an empty spread sheet.
      • SpreadSheetTableModel

        public SpreadSheetTableModel​(SpreadSheet sheet)
        Initializes the model with the given spread sheet.
        Parameters:
        sheet - the spread sheet to display
      • SpreadSheetTableModel

        public SpreadSheetTableModel​(SpreadSheet sheet,
                                     int numDec)
        Initializes the model with the given spread sheet and number of decimals to display.
        Parameters:
        sheet - the spread sheet to display
        numDec - the number of decimals to display
    • Method Detail

      • setShowRowColumn

        public void setShowRowColumn​(boolean value)
        Whether to display the column with the row numbers.
        Parameters:
        value - true if to display column
      • getShowRowColumn

        public boolean getShowRowColumn()
        Returns whether the column with the row numbers is displayed.
        Returns:
        true if column displayed
      • setUseSimpleHeader

        public void setUseSimpleHeader​(boolean value)
        Whether to display a simple header or an HTML one with the column indices.
        Parameters:
        value - true if to display simple header
      • getUseSimpleHeader

        public boolean getUseSimpleHeader()
        Returns whether to display a simple header or an HTML one with the column indices.
        Returns:
        true if simple header displayed
      • setReadOnly

        public void setReadOnly​(boolean value)
        Sets whether the table model is read-only.
        Parameters:
        value - true if read-only
      • isReadOnly

        public boolean isReadOnly()
        Returns whether the table model is read-only.
        Returns:
        true if read-only
      • setModified

        public void setModified​(boolean value)
        Sets whether the table model has been modified.
        Parameters:
        value - true if modified
      • isModified

        public boolean isModified()
        Returns whether the table model has been modified.
        Returns:
        true if modified
      • setShowCellTypes

        public void setShowCellTypes​(boolean value)
        Sets whether to show the cell types rather than the cell values.
        Parameters:
        value - true if to show cell types
      • getShowCellTypes

        public boolean getShowCellTypes()
        Returns whether to show the cell types rather than the cell values.
        Returns:
        true if showing the cell types
      • getRowCount

        public int getRowCount()
        Returns the number of rows in the sheet.
        Specified by:
        getRowCount in interface TableModel
        Returns:
        the number of rows
      • getColumnCount

        public int getColumnCount()
        Returns the number of columns in the sheet.
        Specified by:
        getColumnCount in interface TableModel
        Returns:
        the number of columns
      • getColumnName

        public String getColumnName​(int columnIndex)
        Returns the name of the column at columnIndex. This is used to initialize the table's column header name. Note: this name does not need to be unique; two columns in a table can have the same name.
        Specified by:
        getColumnName in interface TableModel
        Overrides:
        getColumnName in class AbstractTableModel
        Parameters:
        columnIndex - the index of the column
        Returns:
        the name of the column
      • determineContentType

        protected Cell.ContentType determineContentType​(int columnIndex)
        Determines the content type of the specified column.
        Parameters:
        columnIndex - the index of the column to determine the type for
        Returns:
        the content type
      • getColumnClass

        public Class getColumnClass​(int columnIndex)
        Returns the most specific superclass for all the cell values in the column.
        Specified by:
        getColumnClass in interface TableModel
        Overrides:
        getColumnClass in class AbstractTableModel
        Parameters:
        columnIndex - the index of the column
        Returns:
        the class of the specified column
      • isCellEditable

        public boolean isCellEditable​(int rowIndex,
                                      int columnIndex)
        Returns true if the cell at rowIndex and columnIndex is editable. Otherwise, setValueAt on the cell will not change the value of that cell.
        Specified by:
        isCellEditable in interface TableModel
        Overrides:
        isCellEditable in class AbstractTableModel
        Parameters:
        rowIndex - the row whose value to be queried
        columnIndex - the column whose value to be queried
        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.
        Specified by:
        setValueAt in interface TableModel
        Overrides:
        setValueAt in class AbstractTableModel
        Parameters:
        aValue - the new value
        rowIndex - the row whose value is to be changed
        columnIndex - the column whose value is to be changed
      • getValueAt

        public Object getValueAt​(int rowIndex,
                                 int columnIndex)
        Returns the value for the cell at columnIndex and rowIndex.
        Specified by:
        getValueAt in interface TableModel
        Parameters:
        rowIndex - the row
        columnIndex - the column
        Returns:
        the value of the sepcified cell
      • getCellAt

        public Cell getCellAt​(int rowIndex,
                              int columnIndex)
        Returns the spread sheet cell at the specified location.
        Parameters:
        rowIndex - the current display row index
        columnIndex - the column index
        Returns:
        the cell or null if invalid coordinates
      • setNumDecimals

        public void setNumDecimals​(int value)
        Sets the number of decimals to display. Use -1 to display all.
        Parameters:
        value - the number of decimals
      • getNumDecimals

        public int getNumDecimals()
        Returns the currently set number of decimals. -1 if displaying all.
        Returns:
        the number of decimals
      • setCellRenderingCustomizer

        public void setCellRenderingCustomizer​(CellRenderingCustomizer value)
        Sets the customizer for cell rendering.
        Parameters:
        value - the customizer
      • getCellRenderingCustomizer

        public CellRenderingCustomizer getCellRenderingCustomizer()
        Returns the customizer for cell rendering.
        Returns:
        the customizer
      • setShowFormulas

        public void setShowFormulas​(boolean value)
        Sets whether to display the formulas or their calculated values.
        Parameters:
        value - true if to display the formulas rather than the calculated values
      • getShowFormulas

        public boolean getShowFormulas()
        Returns whether to display the formulas or their calculated values.
        Returns:
        true if to display the formulas rather than the calculated values
      • getComparisonColumnClass

        public Class getComparisonColumnClass​(int columnIndex)
        Returns the class type of the column that is used for comparisons.
        Specified by:
        getComparisonColumnClass in interface ComparableTableModel
        Parameters:
        columnIndex - the column to get the class for
        Returns:
        the class for the column
      • getComparisonValueAt

        public Object getComparisonValueAt​(int row,
                                           int column)
        Returns the field at the given position.
        Specified by:
        getComparisonValueAt in interface ComparableTableModel
        Parameters:
        row - the row
        column - the column (ignored, since only 1 column)
        Returns:
        the field
      • newModel

        public SpreadSheetTableModel newModel​(SpreadSheet sheet)
        Creates a new model with the same settings for the provided spreadsheet.
        Parameters:
        sheet - the spreadsheet to create a new model for
        Returns:
        the new model
      • getSheet

        public SpreadSheet getSheet()
        Returns the underlying spreadsheet.
        Returns:
        the spreadsheet
      • cleanUp

        public void cleanUp()
        Cleans up data structures, frees up memory.
        Specified by:
        cleanUp in interface CleanUpHandler