net.sourceforge.webcompmath.awt.beans
Class WCMDataTableInputBean

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by net.sourceforge.webcompmath.awt.DataTableInput
                      extended by net.sourceforge.webcompmath.awt.beans.WCMDataTableInputBean
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, ParserMathObject, MathObject, ParserExtension

public class WCMDataTableInputBean
extends DataTableInput
implements ParserMathObject

This class extends DataTableInput to make it easier to use in GUI builder environments. It also limits the flexibility somewhat, so that if you need the full capabilities of the superclass, then you will need to hand-code calls to its methods.

This bean provides two columns and an expanding number of rows. The columns are names "X" and "Y" by default, but you can change these names, or hide them. If you give the bean a name and add it to a parser, then you can access certain capabilities in expressions. For example, if you set the name to "data", then data.X(3) will refer to the value in the 3rd row in the X column. data.sum{X} will sum the values in column X, and data.sum(X^2) will sum the squares of the values in column X. data.count provides the number of rows. Note that these values, and any graph of the data table, are not updated while the user edits the table. You should include a WCMComputeButtonBean to cause the updates to occur.

If you need more columns, need to manually initialize the table, access row or column variables outside of a parsed expression, or read data from a file into the table, then you will need to hand-code method calls to the superclass DataTableInput.

Author:
Tom Downey
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
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.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
WCMDataTableInputBean()
          Default constructor
 
Method Summary
 java.awt.Color getBlankBackground()
          get blank background color.
 java.awt.Color getCellBackground()
          Get cell background color.
 java.awt.Color getGridColor()
          Get grid color.
 java.awt.Color getLabelBackground()
          Get label background color.
 MathObject getMathObject()
          Returns the object that can be added to a parser.
 java.lang.String getName()
          Get the name of the bean.
 Parser getParser()
          Get the parser.
 boolean getShowColumnTitles()
          Get whether to show column titles.
 boolean getShowRowNumbers()
          Get whether to show row numbers.
 java.lang.String getXColumnName()
          Get the column name for the first column.
 java.lang.String getYColumnName()
          Get the column name for the second column.
 void setBlankBackground(java.awt.Color color)
          Set blank background color.
 void setCellBackground(java.awt.Color color)
          Set cell background color.
 void setGridColor(java.awt.Color color)
          Set grid color.
 void setLabelBackground(java.awt.Color color)
          set label background color.
 void setName(java.lang.String name)
          Set the name of the bean.
 void setParser(Parser newParser)
          Set the parser to use.
 void setShowColumnTitles(boolean show)
          Set whether to show column titles.
 void setShowRowNumbers(boolean show)
          Set whether to show row numbers.
 void setXColumnName(java.lang.String name)
          Set the column name for the first column.
 void setYColumnName(java.lang.String name)
          Set the column name for the second column.
 
Methods inherited from class net.sourceforge.webcompmath.awt.DataTableInput
addColumn, addColumn, addRows, addVariablesToParser, clear, deleteCurrentRow, doParse, getAutoAddRows, getCellContents, getColumnCount, getColumnName, getColumnVariable, getCurrentRowNumber, getEmptyCellValue, getNonEmptyRowCount, getRowNumberVariable, getSerialNumber, getThrowErrors, insertRow, readFromStream, setAutoAddRows, setCellContents, setColumnName, setCurrentRowNumber, setEmptyCellValue, setThrowErrors
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, 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, 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, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, 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, doLayout, 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, 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, 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
 
Methods inherited from interface net.sourceforge.webcompmath.data.beans.ParserMathObject
addPropertyChangeListener, removePropertyChangeListener
 

Constructor Detail

WCMDataTableInputBean

public WCMDataTableInputBean()
Default constructor

Method Detail

getName

public java.lang.String getName()
Get the name of the bean.

Specified by:
getName in interface MathObject
Overrides:
getName in class DataTableInput
Returns:
name of the table
See Also:
DataTableInput.getName()

setName

public void setName(java.lang.String name)
Set the name of the bean.

Specified by:
setName in interface MathObject
Overrides:
setName in class DataTableInput
Parameters:
name - name of the table
See Also:
DataTableInput.setName(java.lang.String)

getMathObject

public MathObject getMathObject()
Returns the object that can be added to a parser. Since DataTableInput implemements ParserExtension, just returns itself.

Specified by:
getMathObject in interface ParserMathObject
Returns:
the MathObject that will be added to a parser
See Also:
ParserMathObject.getMathObject()

getXColumnName

public java.lang.String getXColumnName()
Get the column name for the first column.

Returns:
the column name

setXColumnName

public void setXColumnName(java.lang.String name)
Set the column name for the first column.

Parameters:
name - the new name.

getYColumnName

public java.lang.String getYColumnName()
Get the column name for the second column.

Returns:
the column name

setYColumnName

public void setYColumnName(java.lang.String name)
Set the column name for the second column.

Parameters:
name - the new name.

getShowColumnTitles

public boolean getShowColumnTitles()
Get whether to show column titles.

Overrides:
getShowColumnTitles in class DataTableInput
Returns:
true or false
See Also:
DataTableInput.getShowColumnTitles()

setShowColumnTitles

public void setShowColumnTitles(boolean show)
Set whether to show column titles.

Overrides:
setShowColumnTitles in class DataTableInput
Parameters:
show - true or false
See Also:
DataTableInput.setShowColumnTitles(boolean)

getShowRowNumbers

public boolean getShowRowNumbers()
Get whether to show row numbers.

Overrides:
getShowRowNumbers in class DataTableInput
Returns:
true or false
See Also:
DataTableInput.getShowRowNumbers()

setShowRowNumbers

public void setShowRowNumbers(boolean show)
Set whether to show row numbers.

Overrides:
setShowRowNumbers in class DataTableInput
Parameters:
show - true or false
See Also:
DataTableInput.setShowRowNumbers(boolean)

getLabelBackground

public java.awt.Color getLabelBackground()
Get label background color.

Overrides:
getLabelBackground in class DataTableInput
Returns:
background color
See Also:
DataTableInput.getLabelBackground()

setLabelBackground

public void setLabelBackground(java.awt.Color color)
set label background color.

Overrides:
setLabelBackground in class DataTableInput
Parameters:
color - desired background color
See Also:
DataTableInput.setLabelBackground(java.awt.Color)

getCellBackground

public java.awt.Color getCellBackground()
Get cell background color.

Overrides:
getCellBackground in class DataTableInput
Returns:
cell background color
See Also:
DataTableInput.getCellBackground()

setCellBackground

public void setCellBackground(java.awt.Color color)
Set cell background color.

Overrides:
setCellBackground in class DataTableInput
Parameters:
color - cell background color
See Also:
DataTableInput.setCellBackground(java.awt.Color)

getBlankBackground

public java.awt.Color getBlankBackground()
get blank background color.

Overrides:
getBlankBackground in class DataTableInput
Returns:
background color
See Also:
DataTableInput.getBlankBackground()

setBlankBackground

public void setBlankBackground(java.awt.Color color)
Set blank background color.

Overrides:
setBlankBackground in class DataTableInput
Parameters:
color - background color
See Also:
DataTableInput.setBlankBackground(java.awt.Color)

getGridColor

public java.awt.Color getGridColor()
Get grid color.

Overrides:
getGridColor in class DataTableInput
Returns:
line color
See Also:
DataTableInput.getGridColor()

setGridColor

public void setGridColor(java.awt.Color color)
Set grid color.

Overrides:
setGridColor in class DataTableInput
Parameters:
color - line color
See Also:
DataTableInput.setGridColor(java.awt.Color)

getParser

public Parser getParser()
Get the parser.

Returns:
the parser

setParser

public void setParser(Parser newParser)
Set the parser to use. This is just a way to add the column and row variables.

Parameters:
newParser -