dataTable
Class DataTable

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Panel
              extended byjava.applet.Applet
                  extended byedu.davidson.tools.SApplet
                      extended bydataTable.DataTable
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class DataTable
extends SApplet

This applet shows a row-column table of double values. Each data column is refered to as a series. A series is identified by a series number and has a unique color and style. Whenever data is added using a data connection, the appropriate series number must be specified.

The following embedding parameters are defined:

Parameter  Value  Type Description
NumRows 10 int The number of rows.
NumCols 2 int The number of columns.
CellWidth 40 int The size of a cell in pixels.
ShowRowHeader true booelan Show the top header row.
ShowRowHeader true boolean Show the left most header column.
LastOnTop false boolean Add data to the top of the table rather than the bottom.
ShowScrollBars true boolean Create a scrollable table.  Useful for large data set.
SizeToFit false boolean Make the data table fit the embedding size.
ShowControls true boolean Show the user interface.

DataTable is designed to be used as a data listener with other Physlets.  The object identifier for the data listener is passed to a data connection.  This value is is obtained using the following method.

getTableID().

See Also:
Serialized Form

Field Summary
 
Fields inherited from class edu.davidson.tools.SApplet
destroyed
 
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
 
Method Summary
 void addDatum(int sid, double x)
          Add a data point to the series.
 void clearAllSeries()
          Clear the data from all series.
 void clearSeries(int s)
          Clear the data from a series.
 int getActiveCellCol()
          Read the row of the active cell.
 int getActiveCellRow()
          Read the row of the active cell.
 double getActiveCellValue()
          Read the value of the active cell.
 int getSeriesID(int sid)
          Get the object identifier for the series from the series number.
 int getSeriesWidth(int sid)
          Get the width of the cells in a column.
 int getTableID()
          Get the object identifier for the table.
 void loadDataFile(int sid, java.lang.String fileName)
          Read a data file of data values into a series.
 boolean setActiveCell(int row, int col)
          Set the active cell.
 boolean setActiveCellValue(double val)
          Set the value of the active cell.
 void setAutoRefresh(boolean autoRefresh)
          Repaint every time data is added.
 void setDataStride(int sid, int stride)
          Do not register all data as entries in the table.
 void setDefault()
          Clears the data from the grid and sets the stride to 1 for all series.
 boolean setFormat(int id, java.lang.String str)
          Set the numeric format for the display of numbers using the object identifier.
 void setNumericFormat(int sid, java.lang.String str)
          Set the numeric format for the display of numbers using the series identifier.
 boolean setSeriesLabel(int sid, java.lang.String str)
          Set the column header for the series.
 void setSeriesWidth(int id, int width)
          Set the width of the cells in a column.
 void setShowActiveCell(boolean show)
          Highlight a cell when it is clicked to show that it is active.
 void sizeToFit(boolean stf)
          Attempts to fit the size of the grid to the window.
 
Methods inherited from class edu.davidson.tools.SApplet
addDataListener, addDataSource, checkAppletNames, cleanupDataConnections, clearAllData, clearData, deleteDataConnection, deleteDataConnections, formatValue, forward, getAppletName, getClockID, getClockTime, getDataFromDS, getDataListener, getDataSource, getDataSource, getDebugLevel, getID, getSourceData, getSourceVariables, isClockRunning, isValidFunction, makeDataConnection, pause, removeDataListener, removeDataSource, reset, reverse, sendDataToListener, setClockContinous, setClockCycle, setClockOneShot, setClockTime, setConnectionBlock, setConnectionListener, setConnectionSmoothing, setConnectionSource, setConnectionStride, setConnectionWindowX, setConnectionWindowY, setDebugLevel, setDt, setExternalClock, setFPS, setIndependentClock, setTimeContinuous, setTimeCycle, setTimeOneShot, startClock, stepClock, stepTime, stepTimeBack, stepTimeForward, stop, stopClock, updateDataConnection, updateDataConnections
 
Methods inherited from class java.applet.Applet
destroy, getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, init, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

loadDataFile

public void loadDataFile(int sid,
                         java.lang.String fileName)
Read a data file of data values into a series.

Parameters:
sid - The series id.
fileName - The file name

clearSeries

public void clearSeries(int s)
Clear the data from a series. Series properties such as color and style remain unchanged.


clearAllSeries

public void clearAllSeries()
Clear the data from all series. Series properties such as color and style remain unchanged.


addDatum

public void addDatum(int sid,
                     double x)
Add a data point to the series.

Parameters:
x - x value

getTableID

public int getTableID()
Get the object identifier for the table. This identifier is used to make a data connection.

Returns:
The id.

setAutoRefresh

public void setAutoRefresh(boolean autoRefresh)
Repaint every time data is added.

Overrides:
setAutoRefresh in class SApplet
Parameters:
autoRefresh - Automatic repaint?

sizeToFit

public void sizeToFit(boolean stf)
Attempts to fit the size of the grid to the window. Works best if the ShowScrollBara parameter is set to false.


setDefault

public void setDefault()
Clears the data from the grid and sets the stride to 1 for all series.

Overrides:
setDefault in class SApplet

setDataStride

public void setDataStride(int sid,
                          int stride)
Do not register all data as entries in the table. This is useful when the data rate is too high. The first dat point is always registered.

Parameters:
sid - the series number
stride - The number of data points to skip before registering.

getSeriesID

public int getSeriesID(int sid)
Get the object identifier for the series from the series number. First column is series number 1.

Parameters:
sid - the series number
Returns:
the objevct identifier

getSeriesWidth

public int getSeriesWidth(int sid)
Get the width of the cells in a column.

Parameters:
sid - the series number
Returns:
The width of the cells.

setSeriesWidth

public void setSeriesWidth(int id,
                           int width)
Set the width of the cells in a column.

Parameters:
id - the series number
width - The width of the cells.

setSeriesLabel

public boolean setSeriesLabel(int sid,
                              java.lang.String str)
Set the column header for the series. Series 0 is the A column. Series 1 is the B column. Etc.

Parameters:
sid - the series number
str - the header.

setNumericFormat

public void setNumericFormat(int sid,
                             java.lang.String str)
Set the numeric format for the display of numbers using the series identifier.

Parameters:
sid - the series number
str - the format string For example: %-+6.2f

setFormat

public boolean setFormat(int id,
                         java.lang.String str)
Set the numeric format for the display of numbers using the object identifier.

Parameters:
id - the object identifier
str - the format string For example: %-+6.2f
Returns:
true if successful

setShowActiveCell

public void setShowActiveCell(boolean show)
Highlight a cell when it is clicked to show that it is active. The value of the active cell can be read by getActiveCellValue

Parameters:
show - true if cell should highlight on click

getActiveCellValue

public double getActiveCellValue()
Read the value of the active cell. The active cell is selected with a mouse click. It is then highlighed on the screen.


getActiveCellRow

public int getActiveCellRow()
Read the row of the active cell. The active cell is selected with a mouse click. It is then highlighed on the screen.


getActiveCellCol

public int getActiveCellCol()
Read the row of the active cell. The active cell is selected with a mouse click. It is then highlighed on the screen.


setActiveCellValue

public boolean setActiveCellValue(double val)
Set the value of the active cell. The active cell is selected with a mouse click. It is then highlighed on the screen.

Returns:
true if the cell exists false otherwise

setActiveCell

public boolean setActiveCell(int row,
                             int col)
Set the active cell. The active cell is then highlighed on the screen.

Parameters:
row - the row
col - the column
Returns:
true if the cell exists false otherwise


Visit the Davidson College Physlet Site for additional information.