|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Panel | +--edu.hws.jcm.awt.DataTableInput
A DataTableInput lets the user input a grid of real numbers arranged in rows and columns. Each column has a name, and rows are numberd starting from 1. The column names and row numbers can be displayed, optionally. By default, a new row is added automatically if the user moves down out of the last row by pressing return or down-arrow, provided the last row is non-empty. Rows can also be added programmatically. Columns are usually added in the constructor, but they can also be added later. If the user leaves a cell at a time when the content of that cell does not represent a legal number, then the message "bad input" will be displayed in the cell.
A DataTableInput can be given a name and can then be added to a parser. The parser will then recognize the name of the table. In an expression, the table name can be followed by a ".", then one of the column names from table, then an expression in parentheses. This represents a reference to the number in one of the cells in the table. The expression gives the number of the row, where rows are numbered starting from 1. For example: "data.A(3)" represents the third number in column "A" in a table named data. The table name and "." can also be followed by the word "sum" and an expression in parentheses. An expression used in this way can include references to the column names in the table and to the special value "rowNumber". The value of expression is computed for each row in the table and the sum of the values is computed. In the expression that is being summed, a column name represents the number in that column and rowNumber represents the number of the row. For example: "data.sum(A^2)". Finally, the "." can be followed by the word "count". "count" can, optionally be followed by an empty pair of parentheses. This represents the number of rows. For example: "data.count". Empty rows at the bottom of the table are ignored in both "sum" and "count".
Note that rows are numbered starting from 1 because row numbers can be visible to the user, who shouldn't be subjected to zero-based numbering. However, columns are always numbered from zero.
Inner classes inherited from class java.awt.Panel |
java.awt.Panel.AccessibleAWTPanel |
Inner classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
Inner classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent |
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 | |
DataTableInput()
Create a DataTableInput with no columns. |
|
DataTableInput(java.lang.String name,
int columns)
Create a table with the specified number of columns, named "A", "B", etc. |
|
DataTableInput(java.lang.String name,
java.lang.String[] columnNames)
Create a table with the specified column names. |
Method Summary | |
int |
addColumn()
Add a column at the right side of the table, with all cells initially empty. |
int |
addColumn(java.lang.String name)
Add a column with the specified name at the right side of the table, with all cells initially empty. |
void |
addRows(int rowCt)
Add the specified number of empty rows at the bottom of the table. |
void |
addVariablesToParser(Parser p)
Add a row number variable (from the getRowNumberVariable() method) and a column variable for each column (from the getColumnVariable() method) to the parser. |
void |
clear()
Remove all rows from the table, leaving just one empty row. |
void |
deleteCurrentRow()
Delete the row that contains the cell that the user is editing. |
void |
doParse(Parser parser,
ParserContext context)
Required by the ParserExtension interface and not meant to be called directly. |
boolean |
getAutoAddRows()
Get the value of the autoAddRows property, which determines whether empty rows are automatically added to the bottom of the table when needed. |
java.awt.Color |
getBlankBackground()
Returns the color that is used for blank areas in the table, below the rows of cells. |
java.awt.Color |
getCellBackground()
Returns the color that is used as a background for cells in the table. |
double |
getCellContents(int row,
int col)
Get the number in the specified row and column. |
int |
getColumnCount()
Get the number of columns in the table. |
java.lang.String |
getColumnName(int i)
Get the name of column number i, where columns are numbered starting from zero. |
protected Variable |
getColumnVariable(int columnNum)
Return a column variable for the specified column, where columns are numbered starting from 1. |
int |
getCurrentRowNumber()
Return the current row number. |
double |
getEmptyCellValue()
Get the value that is represented by an empty cell. |
java.awt.Color |
getGridColor()
Returns the color that is used for the lines between cells in the table. |
java.awt.Color |
getLabelBackground()
Returns the color that is used as a background for row numbers and column titles. |
java.lang.String |
getName()
Get the name of the DataInputTable (which might be null). |
int |
getNonEmptyRowCount()
Return the number of rows in the table, ignoring empty rows at the bottom of the table. |
protected Variable |
getRowNumberVariable()
Get a variable that represents the current row number in the table, as set by the setCurrentRowNumber() method. |
long |
getSerialNumber()
Get the serial number of the table. |
boolean |
getShowColumnTitles()
Test whether the column name is shown at the top of each column. |
boolean |
getShowRowNumbers()
Test whether row numbers are shown. |
boolean |
getThrowErrors()
Get the value of the throwErrors property, which determines whether an error is thrown when an attempt is made to refer to the value of a cell that contains an invalid string. |
void |
insertRow()
Insert a row before the row that contains the cell that the user is editing. |
boolean |
readFromStream(java.io.Reader in)
Read data for table from the specified Reader. |
void |
setAutoAddRows(boolean auto)
If the value of autoAddRows is true, then an empty row is added to the table automatically when the user attempts to move down from the last row of the table, provided that the last row is non-empty (so there can only be one auto-added row at a time). |
void |
setBlankBackground(java.awt.Color color)
Get the color to be used as a background blank areas in the table, below the rows of cells. |
void |
setCellBackground(java.awt.Color color)
Set the color to be used as a background for cells in the table. |
void |
setCellContents(int row,
int col,
double val)
Put the given real number, val, in the cell in the specified row and column, where rows are numbered starting from 1 and columns are numbered starting from zero. |
void |
setColumnName(int i,
java.lang.String name)
Set the name of column number i, where columns are numbered starting from zero. |
void |
setCurrentRowNumber(int i)
Set the current row in the table. |
void |
setEmptyCellValue(double val)
Set the value that should be returned when the value of an empty cell is requested. |
void |
setGridColor(java.awt.Color color)
Get the color to be used for the lines between cells in the table. |
void |
setLabelBackground(java.awt.Color color)
Set the color to be used as a background for row numbers and column titles. |
void |
setName(java.lang.String name)
Set the name of this DataTableInput. |
void |
setShowColumnTitles(boolean show)
If set to true, then the column name is shown at the top of each column. |
void |
setShowRowNumbers(boolean show)
If set to true, then the row number is shown at the left of each row. |
void |
setThrowErrors(boolean throwErr)
Set the throwErrors property. |
Methods inherited from class java.awt.Panel |
addNotify, getAccessibleContext |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setSize, setSize, setVisible, show, show, size, toString, transferFocus |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public DataTableInput()
public DataTableInput(java.lang.String name, java.lang.String[] columnNames)
public DataTableInput(java.lang.String name, int columns)
Method Detail |
public void doParse(Parser parser, ParserContext context)
doParse
in interface ParserExtension
public int getNonEmptyRowCount()
public double getCellContents(int row, int col)
public void setCellContents(int row, int col, double val)
public void setCurrentRowNumber(int i)
public int getCurrentRowNumber()
protected Variable getColumnVariable(int columnNum)
protected Variable getRowNumberVariable()
public void addVariablesToParser(Parser p)
public long getSerialNumber()
public void setThrowErrors(boolean throwErr)
public boolean getThrowErrors()
public void setEmptyCellValue(double val)
public double getEmptyCellValue()
public void setAutoAddRows(boolean auto)
public boolean getAutoAddRows()
public void setName(java.lang.String name)
setName
in interface MathObject
setName
in class java.awt.Component
public java.lang.String getName()
getName
in interface MathObject
getName
in class java.awt.Component
public void setColumnName(int i, java.lang.String name)
public java.lang.String getColumnName(int i)
public void addRows(int rowCt)
public void insertRow()
public void deleteCurrentRow()
public void clear()
public int getColumnCount()
public int addColumn()
public int addColumn(java.lang.String name)
public boolean getShowColumnTitles()
public void setShowColumnTitles(boolean show)
public boolean getShowRowNumbers()
public void setShowRowNumbers(boolean show)
public java.awt.Color getLabelBackground()
public void setLabelBackground(java.awt.Color color)
public java.awt.Color getCellBackground()
public void setCellBackground(java.awt.Color color)
public java.awt.Color getBlankBackground()
public void setBlankBackground(java.awt.Color color)
public java.awt.Color getGridColor()
public void setGridColor(java.awt.Color color)
public boolean readFromStream(java.io.Reader in)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |