com.rubecula.spreadsheet
Class TableModel

java.lang.Object
  |
  +--javax.swing.table.AbstractTableModel
        |
        +--com.rubecula.spreadsheet.TableModel
All Implemented Interfaces:
Auditable, Identifiable, java.io.Serializable, javax.swing.table.TableModel

public class TableModel
extends javax.swing.table.AbstractTableModel
implements Auditable

Class to provide the underlying model for the spreadsheet application.

Version:
$Revision: 1.5 $
Author:
Robin Hillyard
See Also:
Serialized Form

Field Summary
(package private)  java.lang.Object[][] _Cells
           
(package private)  java.lang.String[] _ColumnNames
           
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
TableModel()
          Construct a new spreadsheet model.
 
Method Summary
 java.lang.String audit()
          Method to return a detailed (unlabeled) string from an object for debugging purposes.
 void audit(java.io.PrintStream out, java.lang.String label)
          Method to output detailed string from an object for debugging purposes.
 java.lang.String audit(java.lang.String label)
          Method to return a detailed string from an arithmetical object for debugging purposes.
(package private)  java.lang.String auditCell(int row, int col)
           
 java.util.Iterator getCells()
           
static java.lang.String GetColName(int col)
          Get a name for this column in the form of a letter or sequence of letters.
 int getColumnCount()
           
 java.lang.String getColumnName(int col)
           
 java.lang.String getIdentifier()
          Method to get the specific identifier for an object.
static PresentationFactoryInterface GetPresentationFactory()
           
 int getRowCount()
           
static java.lang.String GetRowName(int row)
          Get a name for this row in the form of a number.
 java.lang.Object getValueAt(int row, int col)
           
 boolean isCellEditable(int row, int col)
          Don't need to implement this method unless your table's editable.
 boolean isDirty()
           
 void makeCell(Presentable value, int row, int col)
           
 void makeCell(Presentable value, int row, int col, java.lang.String name)
           
 void makeCell(Presentation persentation, int row, int col)
           
 void makeCell(Presentation presentation, int row, int col, java.lang.String name)
           
 void makeCell(QuantityCell cell, int row, int col)
           
 void makeCell(java.lang.String value, int row, int col)
           
 void makeCell(java.lang.String formula, int row, int col, java.lang.String name)
           
(package private)  void open(java.io.InputStream stream)
          Method to populate a the current spreadsheet by loading the properties file referenced by stream.
 void removeAttribute(java.lang.String attr, int row, int col)
          Method to unset an attribute for this cell.
(package private)  void save(java.io.OutputStream stream)
          Method to store the current spreadsheet by creating a properties file referenced by stream.
 void setAttribute(java.lang.String attr, java.lang.String value, int row, int col)
          Method to set/reset an attribute for this cell.
 void setDirty(boolean dirty)
           
 void setDirtyAll()
           
 void setValueAt(java.lang.Object value, int row, int col)
          Don't need to implement this method unless your table's data can change.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_ColumnNames

final java.lang.String[] _ColumnNames

_Cells

java.lang.Object[][] _Cells
Constructor Detail

TableModel

public TableModel()
Construct a new spreadsheet model.

Method Detail

open

void open(java.io.InputStream stream)
Method to populate a the current spreadsheet by loading the properties file referenced by stream. If stream is null, then the current spreadsheet remains unchanged.

Parameters:
stream - a properties file (or null). See http://java.sun.com/j2se/1.4/docs/api/java/util/Properties.html#load

save

void save(java.io.OutputStream stream)
Method to store the current spreadsheet by creating a properties file referenced by stream.

Parameters:
stream - a properties file. See http://java.sun.com/j2se/1.4/docs/api/java/util/Properties.html#load

makeCell

public void makeCell(QuantityCell cell,
                     int row,
                     int col)
Parameters:
cell - a QuantityCell which is to be stored in the specified cell.
row - the spreadsheet row counting from 1 up.
col - the spreadsheet column counting from 1 up.

makeCell

public void makeCell(Presentable value,
                     int row,
                     int col,
                     java.lang.String name)
Parameters:
value - a presentable instance which is the (fixed) value for this new cell.
name - The name of the new cell.
row - the spreadsheet row counting from 1 up.
col - the spreadsheet column counting from 1 up.

makeCell

public void makeCell(Presentation presentation,
                     int row,
                     int col,
                     java.lang.String name)
              throws PresentationException
Parameters:
presentation - a presentation instance representing the (fixed) value for this new cell.
name - The name of the new cell.
row - the spreadsheet row counting from 1 up.
col - the spreadsheet column counting from 1 up.
Throws:
PresentationException - a problem with parsing the presentation.

makeCell

public void makeCell(java.lang.String formula,
                     int row,
                     int col,
                     java.lang.String name)
Parameters:
formula - an expression defining the value of the new cell, possibly in terms of other cells, as well as (optionally) a set of attributes relating to this cell.
name - The name of the new cell.
row - the spreadsheet row counting from 1 up.
col - the spreadsheet column counting from 1 up.

makeCell

public void makeCell(Presentable value,
                     int row,
                     int col)
Parameters:
value - a presentatble object.
row - the spreadsheet row counting from 1 up.
col - the spreadsheet column counting from 1 up.

makeCell

public void makeCell(Presentation persentation,
                     int row,
                     int col)
              throws PresentationException
Parameters:
persentation - a presentation.
row - the spreadsheet row counting from 1 up.
col - the spreadsheet column counting from 1 up.
Throws:
PresentationException - if the persentation cannot be parsed.

makeCell

public void makeCell(java.lang.String value,
                     int row,
                     int col)
Parameters:
value - a string
row - the spreadsheet row counting from 1 up
col - the spreadsheet column counting from 1 up

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)
Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel

getValueAt

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

isCellEditable

public boolean isCellEditable(int row,
                              int col)
Don't need to implement this method unless your table's editable.

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel
Parameters:
row - the row starting with 0 at the top.
col - the columb starting with 0 at the left.
Returns:
true if the cell is editable.

setValueAt

public void setValueAt(java.lang.Object value,
                       int row,
                       int col)
Don't need to implement this method unless your table's data can change.

Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel
Parameters:
value - the Presentable value to show.
row - the row starting with 0 at the top.
col - the column starting with 0 at the left.

setAttribute

public void setAttribute(java.lang.String attr,
                         java.lang.String value,
                         int row,
                         int col)
Method to set/reset an attribute for this cell.

Parameters:
attr - the attribute name.
value - the attribute value.
row - the row to which the cell belongs (0 < row <= nrows)
col - the column to which the cell belongs (0 < col <= ncols)

removeAttribute

public void removeAttribute(java.lang.String attr,
                            int row,
                            int col)
Method to unset an attribute for this cell.

Parameters:
attr - the attribute name.
row - the row to which the cell belongs (0 < row <= nrows)
col - the column to which the cell belongs (0 < col <= ncols)

getCells

public java.util.Iterator getCells()

setDirtyAll

public void setDirtyAll()

getIdentifier

public java.lang.String getIdentifier()
Method to get the specific identifier for an object.

Specified by:
getIdentifier in interface Identifiable
Returns:
the identifier.

audit

public java.lang.String audit(java.lang.String label)
Method to return a detailed string from an arithmetical object for debugging purposes.

Specified by:
audit in interface Auditable
Parameters:
label - String: the label to associate with the data
Returns:
the detailed string.

audit

public java.lang.String audit()
Method to return a detailed (unlabeled) string from an object for debugging purposes.

Specified by:
audit in interface Auditable
Returns:
the detailed string.

audit

public void audit(java.io.PrintStream out,
                  java.lang.String label)
Method to output detailed string from an object for debugging purposes.

Specified by:
audit in interface Auditable
Parameters:
out - the output stream.
label - the label to attach to the output (may be null).

auditCell

java.lang.String auditCell(int row,
                           int col)

GetRowName

public static java.lang.String GetRowName(int row)
Get a name for this row in the form of a number.

Parameters:
row - row index between 1 and Nrows.
Returns:
A string of the form [0-9][0-9]...[0-9].

GetColName

public static java.lang.String GetColName(int col)
Get a name for this column in the form of a letter or sequence of letters.

Parameters:
col - column index between 1 and Ncols.
Returns:
A name of the form [A-Z][A-Z]...[A-Z]

setDirty

public void setDirty(boolean dirty)

isDirty

public boolean isDirty()

GetPresentationFactory

public static PresentationFactoryInterface GetPresentationFactory()