org.statcato.spreadsheet
Class Spreadsheet

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JTable
                  extended by org.statcato.spreadsheet.Spreadsheet
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.CellEditorListener, javax.swing.event.ListSelectionListener, javax.swing.event.RowSorterListener, javax.swing.event.TableColumnModelListener, javax.swing.event.TableModelListener, javax.swing.Scrollable, javax.swing.undo.StateEditable

public class Spreadsheet
extends javax.swing.JTable
implements javax.swing.undo.StateEditable

A spreadsheet represented by a table of Cells.

Since:
1.0
Version:
%I%, %G%
Author:
Margaret Yau
See Also:
Cell, SpreadsheetModel, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JTable
javax.swing.JTable.AccessibleJTable, javax.swing.JTable.DropLocation, javax.swing.JTable.PrintMode
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected static java.lang.String MODEL
           
protected static java.lang.String STATUS
           
protected  javax.swing.undo.UndoableEditSupport undoableEditSupport
           
 
Fields inherited from class javax.swing.JTable
AUTO_RESIZE_ALL_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_OFF, AUTO_RESIZE_SUBSEQUENT_COLUMNS, autoCreateColumnsFromModel, autoResizeMode, cellEditor, cellSelectionEnabled, columnModel, dataModel, defaultEditorsByColumnClass, defaultRenderersByColumnClass, editingColumn, editingRow, editorComp, gridColor, preferredViewportSize, rowHeight, rowMargin, rowSelectionAllowed, selectionBackground, selectionForeground, selectionModel, showHorizontalLines, showVerticalLines, tableHeader
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.undo.StateEditable
RCSID
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Spreadsheet(Statcato app)
          Constructor, given the parent frame.
Spreadsheet(Statcato app, int numRows, int numColumns)
          Constructor, given the parent frame, the number of rows, and the number of columns.
 
Method Summary
 void addUndoableEditListener(javax.swing.event.UndoableEditListener undoableEditListener)
           
 void clearAllCells()
          Clear the contents in all cells without moving surrouding cells.
 void clearSelectedCells()
          Clear the contents in the selected cells without moving surrouding cells.
 void closeFile()
          Closes the file associated with this spreadsheet, if any.
 int[] convertColumnLabelsToNumbers(java.lang.Object[] Labels)
          Converts the given array of Objects representing column labels to column numbers.
 void deleteSelectedCells()
          Deletes the selected cells.
 void display()
          Displays debug data.
 javax.swing.table.TableCellRenderer getCellRenderer(int row, int column)
           
 boolean getChangedStatus()
          Returns the changed status.
 java.util.Vector<Cell> getColumn(int col)
          Returns the column at the given column number.
 java.lang.String getColumnFullLabel(int column)
          Returns the full column label (Cx variable name) for the given column number.
 int getColumnNumber(java.lang.String str)
          Returns the column number represented by the given column label.
 java.util.Vector<java.lang.Integer> getColumnNumbers(java.lang.String str)
          Returns a vector of column numbers represented by the given column label range (for example, c1-c30).
 int[] getColumnNumbersArrayFromString(java.lang.String str)
           
 java.util.Vector<java.lang.Integer> getColumnNumbersFromString(java.lang.String str)
          Returns a vector of column numbers represented by the given string, which contains column labels separated by spaces (e.g.
 int getLastNonEmptyColumn()
          Returns the column number of the last non-empty column.
 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.
 int getLastRowNumber()
          Returns the row number of the last row that contains data.
 java.util.Vector<Cell> getRow(int row)
          Returns the row at the given row number.
 int getRowNumber(java.lang.String str)
          Return the row number represented by the given row label.
 java.util.Vector<java.util.Vector<Cell>> getRowsWithDataAtGivenColumns(int[] columns)
          Returns the rows containing data at the given columns.
 Spreadsheet getSubTable(int minRow, int minCol, int maxRow, int maxCol)
          Get a subset of this spreadsheet specified by the given row and column range.
 java.lang.String getToolTipText(java.awt.event.MouseEvent e)
           
 Cell getValueAt(int row, int col)
          Returns the value at the given row and column numbers.
 void insertCellAbove()
          Inserts a blank cell above the selected cell.
 void insertCellBelow()
          Inserts a blank cell below the selected cell.
 void insertColumn()
          Inserts a blank column at the end of the spreadsheet.
 void insertColumnLeft()
          Inserts a blank column to the left of the selected cell.
 void insertColumnRight()
          Inserts a blank column to the right of the selected cell.
 void insertRow()
          Inserts a blank row at the end of the spreadsheet.
 void insertRowAbove()
          Inserts a blank row above the selected cell.
 void insertRowBelow()
          Inserts a blank row below the selected cell.
 int parseColumnNumber(java.lang.String str)
          Returns the column number embedded in the constructed string "Cx variable_name".
 void populateAllColumnsList(javax.swing.JList List)
          Populates the given list with all existing columns in this object
 void populateColumnsList(javax.swing.JList List)
          Populates the given list with columns in this object that contain data.
 void populateComboBox(javax.swing.JComboBox Combo)
          Populates the given combo box with columns in this object that contain data.
 void populateMutableColumnsList(javax.swing.JList List)
          Populates the given mutable list with columns in this object that contain data.
 void removeUndoableEditListener(javax.swing.event.UndoableEditListener undoableEditListener)
           
 void restoreState(java.util.Hashtable state)
           
 void selectAllCells()
          Selects all the cells.
 void setCellColumn(int column, java.util.Vector<Cell> data)
          Sets the column at the given column number to the given vector of Cells.
 void setCellRow(int row, java.util.Vector<Cell> data)
          Set the row at the given row number to the given vector of cells.
 void setChangedStatus()
          Sets the status to changed and adds an asterisk to the current tab table.
 void setColumn(int column, java.util.Vector<java.lang.String> data)
          Sets the column at the given column number to the given vector of strings.
 void setData(java.lang.String data)
          Puts data in the tab-delimited string in this spreadsheet.
 void setData(java.util.Vector<java.util.Vector<java.lang.String>> data)
          Puts data in the given vectors of vectors of strings in this spreadsheet.
 void setDataUnchangedStatus(java.lang.String data)
          Puts data in the tab-delimited string in this spreadsheet.
 void setDefaultColumnWidths()
          Sets the default widths of the table columns.
 void setFile(java.io.File file)
          Sets the file that saves the data in this spreadsheet.
 void setRow(int row, java.util.Vector<java.lang.String> data)
          Set the row at the given row number to the given vector of Strings.
 void setStringValueAt(java.lang.String value, int row, int col)
          Sets the value at the given row and column numbers to the given string.
 void setUnchangedStatus()
          Sets the status to unchanged and removes any existing asterisk in the current tab title.
 void setValueAt(java.lang.Object value, int row, int col)
           
 void setVariableLabel(int column, java.lang.String name)
          Sets the variable label for the given column to the given string if the label is empty.
 void setVariablesRow(java.util.Vector<java.lang.String> data)
          Sets the variables row to the given vector of Strings.
 void storeState(java.util.Hashtable state)
           
 java.io.File writeToFile(javax.swing.JFrame frame, boolean saveAs)
          Saves the contents of this spreadsheet to a file of one following formats: excel, csv, tab-delimited.
 
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, convertRowIndexToModel, convertRowIndexToView, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, createDefaultTableHeader, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoCreateRowSorter, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getDropLocation, getDropMode, getEditingColumn, getEditingRow, getEditorComponent, getFillsViewportHeight, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getPrintable, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getRowSorter, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getUI, getUIClassID, getUpdateSelectionOnSort, initializeLocalVars, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, prepareRenderer, print, print, print, print, print, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, selectAll, setAutoCreateColumnsFromModel, setAutoCreateRowSorter, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setDropMode, setEditingColumn, setEditingRow, setFillsViewportHeight, setGridColor, setIntercellSpacing, setModel, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setRowSorter, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setUpdateSelectionOnSort, sizeColumnsToFit, sizeColumnsToFit, sorterChanged, tableChanged, unconfigureEnclosingScrollPane, updateUI, valueChanged
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

undoableEditSupport

protected javax.swing.undo.UndoableEditSupport undoableEditSupport

MODEL

protected static final java.lang.String MODEL
See Also:
Constant Field Values

STATUS

protected static final java.lang.String STATUS
See Also:
Constant Field Values
Constructor Detail

Spreadsheet

public Spreadsheet(Statcato app)
Constructor, given the parent frame.

Parameters:
app - parent frame

Spreadsheet

public Spreadsheet(Statcato app,
                   int numRows,
                   int numColumns)
Constructor, given the parent frame, the number of rows, and the number of columns.

Parameters:
app - parent frame
numRows - number of rows
numColumns - number of columns
Method Detail

getToolTipText

public java.lang.String getToolTipText(java.awt.event.MouseEvent e)
Overrides:
getToolTipText in class javax.swing.JTable

addUndoableEditListener

public void addUndoableEditListener(javax.swing.event.UndoableEditListener undoableEditListener)

removeUndoableEditListener

public void removeUndoableEditListener(javax.swing.event.UndoableEditListener undoableEditListener)

storeState

public void storeState(java.util.Hashtable state)
Specified by:
storeState in interface javax.swing.undo.StateEditable

restoreState

public void restoreState(java.util.Hashtable state)
Specified by:
restoreState in interface javax.swing.undo.StateEditable

setChangedStatus

public void setChangedStatus()
Sets the status to changed and adds an asterisk to the current tab table.


setUnchangedStatus

public void setUnchangedStatus()
Sets the status to unchanged and removes any existing asterisk in the current tab title.


getChangedStatus

public boolean getChangedStatus()
Returns the changed status.

Returns:
changed status

closeFile

public void closeFile()
Closes the file associated with this spreadsheet, if any.


setDefaultColumnWidths

public void setDefaultColumnWidths()
Sets the default widths of the table columns.


getCellRenderer

public javax.swing.table.TableCellRenderer getCellRenderer(int row,
                                                           int column)
Overrides:
getCellRenderer in class javax.swing.JTable

populateColumnsList

public void populateColumnsList(javax.swing.JList List)
Populates the given list with columns in this object that contain data.

Parameters:
List - list to which columns will be added

populateMutableColumnsList

public void populateMutableColumnsList(javax.swing.JList List)
Populates the given mutable list with columns in this object that contain data.

Parameters:
List - mutable list to which columns will be added

populateAllColumnsList

public void populateAllColumnsList(javax.swing.JList List)
Populates the given list with all existing columns in this object

Parameters:
List - list to which columns will be added

populateComboBox

public void populateComboBox(javax.swing.JComboBox Combo)
Populates the given combo box with columns in this object that contain data.

Parameters:
Combo - combo box to which columns are added

parseColumnNumber

public int parseColumnNumber(java.lang.String str)
Returns the column number embedded in the constructed string "Cx variable_name".

Parameters:
str - string to be parsed
Returns:
integer (column number)

getColumn

public java.util.Vector<Cell> getColumn(int col)
Returns the column at the given column number.

Parameters:
col - column number
Returns:
vector of Cell (column)

getRow

public java.util.Vector<Cell> getRow(int row)
Returns the row at the given row number.

Parameters:
row - row number
Returns:
vector of Cell (row)

getColumnNumber

public int getColumnNumber(java.lang.String str)
Returns the column number represented by the given column label.

Parameters:
str - string representing the column label
Returns:
column number

getColumnFullLabel

public java.lang.String getColumnFullLabel(int column)
Returns the full column label (Cx variable name) for the given column number.

Parameters:
column - column number
Returns:
full column label

getColumnNumbers

public java.util.Vector<java.lang.Integer> getColumnNumbers(java.lang.String str)
Returns a vector of column numbers represented by the given column label range (for example, c1-c30).

Parameters:
str - a string that has a single column label or one that represents a range of columns (e.g. c1-c30)
Returns:
a vector of Integers (column numbers)

getColumnNumbersFromString

public java.util.Vector<java.lang.Integer> getColumnNumbersFromString(java.lang.String str)
Returns a vector of column numbers represented by the given string, which contains column labels separated by spaces (e.g. C1 C2-30) A continuous range of columns is specified by Ca-b, where a is the beginning column number and b is the end column number.

Parameters:
str - string containing column label delimited by spaces
Returns:
a vector of column numbers

getColumnNumbersArrayFromString

public int[] getColumnNumbersArrayFromString(java.lang.String str)

getRowNumber

public int getRowNumber(java.lang.String str)
Return the row number represented by the given row label.

Parameters:
str - string representating the row label
Returns:
row number

getValueAt

public Cell getValueAt(int row,
                       int col)
Returns the value at the given row and column numbers.

Overrides:
getValueAt in class javax.swing.JTable
Parameters:
row - row number
col - column number
Returns:
cell at the given row and column

getLastRowNumber

public int getLastRowNumber()
Returns the row number of the last row that contains data.

Returns:
row number of the last non-empty row

setColumn

public void setColumn(int column,
                      java.util.Vector<java.lang.String> data)
Sets the column at the given column number to the given vector of strings.

Parameters:
column - column number
data - vector of strings

setCellColumn

public void setCellColumn(int column,
                          java.util.Vector<Cell> data)
Sets the column at the given column number to the given vector of Cells.

Parameters:
column - column number
data - vector of Cells

setRow

public void setRow(int row,
                   java.util.Vector<java.lang.String> data)
Set the row at the given row number to the given vector of Strings.

Parameters:
row - row number
data - vector of Strings

setCellRow

public void setCellRow(int row,
                       java.util.Vector<Cell> data)
Set the row at the given row number to the given vector of cells.

Parameters:
row - row number
data - vector of Cells

setVariablesRow

public void setVariablesRow(java.util.Vector<java.lang.String> data)
Sets the variables row to the given vector of Strings.

Parameters:
data - vector of Strings

setVariableLabel

public void setVariableLabel(int column,
                             java.lang.String name)
Sets the variable label for the given column to the given string if the label is empty.

Parameters:
column - column number
name - variable label

convertColumnLabelsToNumbers

public int[] convertColumnLabelsToNumbers(java.lang.Object[] Labels)
Converts the given array of Objects representing column labels to column numbers.

Parameters:
Labels - array of Objects representing column labels
Returns:
array of integer representing column numbers

getRowsWithDataAtGivenColumns

public java.util.Vector<java.util.Vector<Cell>> getRowsWithDataAtGivenColumns(int[] columns)
Returns the rows containing data at the given columns.

Parameters:
columns - array of integers (column numbers)
Returns:
vector of vector of Cells representing non-empty rows

getLastNonEmptyRow

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

Returns:
integer (row number of the last non-empty row)

getLastNonEmptyColumn

public int getLastNonEmptyColumn(int row)
Returns the column number of the last non-empty column in the given row.

Returns:
integer (column number of the last non-empty column)

getLastNonEmptyColumn

public int getLastNonEmptyColumn()
Returns the column number of the last non-empty column.

Returns:
integer (column number of the last non-empty column)

setData

public void setData(java.lang.String data)
Puts data in the tab-delimited string in this spreadsheet. Sets the status to changed.

Parameters:
data - tab-delimited string

setValueAt

public void setValueAt(java.lang.Object value,
                       int row,
                       int col)
Overrides:
setValueAt in class javax.swing.JTable

setStringValueAt

public void setStringValueAt(java.lang.String value,
                             int row,
                             int col)
Sets the value at the given row and column numbers to the given string.

Parameters:
value - string
row - row number
col - column number

setDataUnchangedStatus

public void setDataUnchangedStatus(java.lang.String data)
Puts data in the tab-delimited string in this spreadsheet. Does not set status to changed.

Parameters:
data - tab-delimited string

setData

public void setData(java.util.Vector<java.util.Vector<java.lang.String>> data)
Puts data in the given vectors of vectors of strings in this spreadsheet.

Parameters:
data - vectors of vectors of strings

getSubTable

public Spreadsheet getSubTable(int minRow,
                               int minCol,
                               int maxRow,
                               int maxCol)
Get a subset of this spreadsheet specified by the given row and column range.

Parameters:
minRow - minimum row number
minCol - minimum column number
maxRow - maximum row number
maxCol - maximum column number
Returns:
a spreadsheet containing a subset of data

display

public void display()
Displays debug data.


writeToFile

public java.io.File writeToFile(javax.swing.JFrame frame,
                                boolean saveAs)
Saves the contents of this spreadsheet to a file of one following formats: excel, csv, tab-delimited. If this spreadsheet has not been saved previously or save as flag is true, opens a file chooser to allow user select a file location.

Parameters:
frame - parent frame
saveAs - whether to save this spreadsheet as
Returns:
file containing saved contents

setFile

public void setFile(java.io.File file)
Sets the file that saves the data in this spreadsheet.

Parameters:
file -

clearSelectedCells

public void clearSelectedCells()
Clear the contents in the selected cells without moving surrouding cells.


clearAllCells

public void clearAllCells()
Clear the contents in all cells without moving surrouding cells.


deleteSelectedCells

public void deleteSelectedCells()
Deletes the selected cells.


insertRow

public void insertRow()
Inserts a blank row at the end of the spreadsheet.


insertRowAbove

public void insertRowAbove()
Inserts a blank row above the selected cell.


insertRowBelow

public void insertRowBelow()
Inserts a blank row below the selected cell.


insertColumn

public void insertColumn()
Inserts a blank column at the end of the spreadsheet.


insertColumnLeft

public void insertColumnLeft()
Inserts a blank column to the left of the selected cell.


insertColumnRight

public void insertColumnRight()
Inserts a blank column to the right of the selected cell.


insertCellAbove

public void insertCellAbove()
Inserts a blank cell above the selected cell.


insertCellBelow

public void insertCellBelow()
Inserts a blank cell below the selected cell.


selectAllCells

public void selectAllCells()
Selects all the cells.