|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JTable net.sf.jga.swing.spreadsheet.Spreadsheet
public class Spreadsheet
Table that contains a sparse-matrix of functors (Generators, specifically). Each cell in the table can contain a formula, and the table can generate references to cells to be used in formulas in other cells. Cells in the matrix can contain constant values and arbitrary Generators, but to support editing, the calling program must pass an expression that can be parsed via a JFXGParser.
Copyright © 2004-2005 David A. Hall
,
Serialized FormNested Class Summary | |
---|---|
class |
Spreadsheet.Reader
|
class |
Spreadsheet.Writer
|
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 |
---|
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 java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
Spreadsheet(int rows,
int cols)
|
Method Summary | ||
---|---|---|
void |
clear()
|
|
void |
clearCellAt(int row,
int col)
Discards all information about the given cell. |
|
void |
columnSelectionChanged(javax.swing.event.ListSelectionEvent e)
|
|
protected void |
configureEnclosingScrollPane()
In addition to the JTable behaviour of this method (which takes care to add the table's columnheader to an enclosing scrollpane's viewport), add a rowheader to the enclosing scrollpane's viewport as well. |
|
Cell |
getCellAt(int row,
int col)
Returns the cell at the given address, creating one if one does not already exist. |
|
Cell |
getCellByName(java.lang.String name)
Returns the cell with the given name, or null if no cell has the given name. |
|
javax.swing.table.TableCellEditor |
getCellEditor(int row,
int col)
|
|
javax.swing.table.TableCellRenderer |
getCellRenderer(int row,
int col)
|
|
java.lang.Class<?> |
getDefaultCellType()
Returns the type of cells that have not be initialized. |
|
java.lang.Object |
getDefaultCellValue()
Returns the default value of cells that have not been initialized. |
|
FunctorParser |
getParser()
Returns the parser used by the spreadsheet. |
|
|
getReference(java.lang.Class<T> type,
int row,
int col)
Returns a reference to the contents of a given cell |
|
javax.swing.JComponent |
getRowHeader()
Returns the component used as a row header |
|
boolean |
isEditableByDefault()
Returns true if empty and newly created cells are editable. |
|
boolean |
isStrictlyTyped()
Returns true if cells strictly enforce types once a type has been set, or if they allow their types to be changed once set. |
|
void |
readSpreadsheet(java.io.InputStream is)
|
|
|
setCellAt(java.lang.Class<T> type,
Generator<T> gen,
int row,
int col)
Builds a cell to hold the given value |
|
|
setCellAt(java.lang.Class<T> type,
T value,
int row,
int col)
Builds a read-only cell to hold the given value. |
|
Cell |
setCellAt(java.lang.String formula,
int row,
int col)
Builds a possibly editable cell to hold the given formula. |
|
Cell |
setCellAt(java.lang.String formula,
int row,
int col,
boolean editable)
Builds a possibly editable cell to hold the given formula. |
|
Cell |
setCellName(java.lang.String name,
int row,
int col)
Sets the name of the given cell. |
|
void |
setColumnCount(int width)
|
|
void |
setDefaultCellType(java.lang.Class<?> type)
Sets the type returned by cells that have not been initialized. |
|
void |
setDefaultCellValue(java.lang.Object value)
Sets the value returned by cells that have not been initialized. |
|
void |
setEditableByDefault(boolean b)
Sets the option that determines if empty cells and newly created cells are editable. |
|
|
setFormatAt(UnaryFunctor<T,java.lang.String> formatter,
int row,
int col)
Replaces the CellRenderer for the given cell such that the given formatting functor is used to present the contents of the cell. |
|
void |
setModel(javax.swing.table.TableModel model)
|
|
void |
setRowCount(int height)
|
|
void |
setStatus(java.lang.String status)
Updates the spreadsheet's status message. |
|
void |
setStatusHandler(UnaryFunctor<java.lang.String,?> fn)
Sets the functor used by the spreadsheet to display status information. |
|
void |
setStrictTyping(boolean b)
Sets the option that controls whether cells will be strongly or weakly typed. |
|
void |
setUpdateHandler(Generator<?> fn)
|
|
void |
valueChanged(javax.swing.event.ListSelectionEvent e)
|
|
void |
writeSpreadsheet(java.io.OutputStream os)
|
Methods inherited from class javax.swing.JTable |
---|
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, convertColumnIndexToModel, convertColumnIndexToView, convertRowIndexToModel, convertRowIndexToView, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, createDefaultTableHeader, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoCreateRowSorter, getAutoResizeMode, 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, getToolTipText, getUI, getUIClassID, getUpdateSelectionOnSort, getValueAt, 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, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setRowSorter, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setUpdateSelectionOnSort, setValueAt, sizeColumnsToFit, sizeColumnsToFit, sorterChanged, tableChanged, unconfigureEnclosingScrollPane, updateUI |
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 |
Constructor Detail |
---|
public Spreadsheet(int rows, int cols)
Method Detail |
---|
public void setColumnCount(int width)
public void setRowCount(int height)
public FunctorParser getParser()
public java.lang.Class<?> getDefaultCellType()
public void setDefaultCellType(java.lang.Class<?> type)
public java.lang.Object getDefaultCellValue()
public void setDefaultCellValue(java.lang.Object value)
public void setEditableByDefault(boolean b)
public boolean isEditableByDefault()
public boolean isStrictlyTyped()
public void setStrictTyping(boolean b)
public void readSpreadsheet(java.io.InputStream is) throws java.io.IOException
java.io.IOException
public void writeSpreadsheet(java.io.OutputStream os) throws java.io.IOException
java.io.IOException
public javax.swing.JComponent getRowHeader()
public void setStatusHandler(UnaryFunctor<java.lang.String,?> fn)
public void setStatus(java.lang.String status)
public void setUpdateHandler(Generator<?> fn)
public void clearCellAt(int row, int col)
public Cell getCellAt(int row, int col)
java.lang.IndexOutOfBoundsException
- if the row or column is out of boundspublic <T> Cell setCellAt(java.lang.Class<T> type, T value, int row, int col)
java.lang.IndexOutOfBoundsException
- if the row or column is out of boundspublic <T> Cell setCellAt(java.lang.Class<T> type, Generator<T> gen, int row, int col)
java.lang.IndexOutOfBoundsException
- if the row or column is out of boundspublic Cell setCellAt(java.lang.String formula, int row, int col)
java.lang.IndexOutOfBoundsException
- if the row or column is out of boundspublic Cell setCellAt(java.lang.String formula, int row, int col, boolean editable)
java.lang.IndexOutOfBoundsException
- if the row or column is out of boundspublic <T> void setFormatAt(UnaryFunctor<T,java.lang.String> formatter, int row, int col)
public Cell getCellByName(java.lang.String name)
public Cell setCellName(java.lang.String name, int row, int col)
java.lang.IllegalArgumentException
- if the name is already in use.public <T> Generator<T> getReference(java.lang.Class<T> type, int row, int col)
public void clear()
public javax.swing.table.TableCellEditor getCellEditor(int row, int col)
getCellEditor
in class javax.swing.JTable
public javax.swing.table.TableCellRenderer getCellRenderer(int row, int col)
getCellRenderer
in class javax.swing.JTable
public void setModel(javax.swing.table.TableModel model)
setModel
in class javax.swing.JTable
protected void configureEnclosingScrollPane()
configureEnclosingScrollPane
in class javax.swing.JTable
public void valueChanged(javax.swing.event.ListSelectionEvent e)
valueChanged
in interface javax.swing.event.ListSelectionListener
valueChanged
in class javax.swing.JTable
public void columnSelectionChanged(javax.swing.event.ListSelectionEvent e)
columnSelectionChanged
in interface javax.swing.event.TableColumnModelListener
columnSelectionChanged
in class javax.swing.JTable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |