|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTable
org.statcato.spreadsheet.Spreadsheet
public class Spreadsheet
A spreadsheet represented by a table of Cell
s.
Cell
,
SpreadsheetModel
,
Serialized FormNested 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 |
---|
protected javax.swing.undo.UndoableEditSupport undoableEditSupport
protected static final java.lang.String MODEL
protected static final java.lang.String STATUS
Constructor Detail |
---|
public Spreadsheet(Statcato app)
app
- parent framepublic Spreadsheet(Statcato app, int numRows, int numColumns)
app
- parent framenumRows
- number of rowsnumColumns
- number of columnsMethod Detail |
---|
public java.lang.String getToolTipText(java.awt.event.MouseEvent e)
getToolTipText
in class javax.swing.JTable
public void addUndoableEditListener(javax.swing.event.UndoableEditListener undoableEditListener)
public void removeUndoableEditListener(javax.swing.event.UndoableEditListener undoableEditListener)
public void storeState(java.util.Hashtable state)
storeState
in interface javax.swing.undo.StateEditable
public void restoreState(java.util.Hashtable state)
restoreState
in interface javax.swing.undo.StateEditable
public void setChangedStatus()
public void setUnchangedStatus()
public boolean getChangedStatus()
public void closeFile()
public void setDefaultColumnWidths()
public javax.swing.table.TableCellRenderer getCellRenderer(int row, int column)
getCellRenderer
in class javax.swing.JTable
public void populateColumnsList(javax.swing.JList List)
List
- list to which columns will be addedpublic void populateMutableColumnsList(javax.swing.JList List)
List
- mutable list to which columns will be addedpublic void populateAllColumnsList(javax.swing.JList List)
List
- list to which columns will be addedpublic void populateComboBox(javax.swing.JComboBox Combo)
Combo
- combo box to which columns are addedpublic int parseColumnNumber(java.lang.String str)
str
- string to be parsed
public java.util.Vector<Cell> getColumn(int col)
col
- column number
Cell
(column)public java.util.Vector<Cell> getRow(int row)
row
- row number
Cell
(row)public int getColumnNumber(java.lang.String str)
str
- string representing the column label
public java.lang.String getColumnFullLabel(int column)
column
- column number
public java.util.Vector<java.lang.Integer> getColumnNumbers(java.lang.String str)
str
- a string that has a single column label or one that
represents a range of columns (e.g. c1-c30)
public java.util.Vector<java.lang.Integer> getColumnNumbersFromString(java.lang.String str)
str
- string containing column label delimited by spaces
public int[] getColumnNumbersArrayFromString(java.lang.String str)
public int getRowNumber(java.lang.String str)
str
- string representating the row label
public Cell getValueAt(int row, int col)
getValueAt
in class javax.swing.JTable
row
- row numbercol
- column number
public int getLastRowNumber()
public void setColumn(int column, java.util.Vector<java.lang.String> data)
column
- column numberdata
- vector of stringspublic void setCellColumn(int column, java.util.Vector<Cell> data)
column
- column numberdata
- vector of Cellspublic void setRow(int row, java.util.Vector<java.lang.String> data)
row
- row numberdata
- vector of Stringspublic void setCellRow(int row, java.util.Vector<Cell> data)
row
- row numberdata
- vector of Cellspublic void setVariablesRow(java.util.Vector<java.lang.String> data)
data
- vector of Stringspublic void setVariableLabel(int column, java.lang.String name)
column
- column numbername
- variable labelpublic int[] convertColumnLabelsToNumbers(java.lang.Object[] Labels)
Labels
- array of Objects representing column labels
public java.util.Vector<java.util.Vector<Cell>> getRowsWithDataAtGivenColumns(int[] columns)
columns
- array of integers (column numbers)
public int getLastNonEmptyRow()
public int getLastNonEmptyColumn(int row)
public int getLastNonEmptyColumn()
public void setData(java.lang.String data)
data
- tab-delimited stringpublic void setValueAt(java.lang.Object value, int row, int col)
setValueAt
in class javax.swing.JTable
public void setStringValueAt(java.lang.String value, int row, int col)
value
- stringrow
- row numbercol
- column numberpublic void setDataUnchangedStatus(java.lang.String data)
data
- tab-delimited stringpublic void setData(java.util.Vector<java.util.Vector<java.lang.String>> data)
data
- vectors of vectors of stringspublic Spreadsheet getSubTable(int minRow, int minCol, int maxRow, int maxCol)
minRow
- minimum row numberminCol
- minimum column numbermaxRow
- maximum row numbermaxCol
- maximum column number
public void display()
public java.io.File writeToFile(javax.swing.JFrame frame, boolean saveAs)
frame
- parent framesaveAs
- whether to save this spreadsheet as
public void setFile(java.io.File file)
file
- public void clearSelectedCells()
public void clearAllCells()
public void deleteSelectedCells()
public void insertRow()
public void insertRowAbove()
public void insertRowBelow()
public void insertColumn()
public void insertColumnLeft()
public void insertColumnRight()
public void insertCellAbove()
public void insertCellBelow()
public void selectAllCells()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |