dataTable
Class DataTable

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--edu.davidson.tools.SApplet
                                |
                                +--dataTable.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

Fields inherited from class edu.davidson.tools.SApplet
clock, dataConnections, dataListeners, dataSources, lock
 
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
DataTable()
           
 
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.
 java.lang.String getAppletInfo()
           
 java.lang.String getParameter(java.lang.String key, java.lang.String def)
           
 java.lang.String[][] getParameterInfo()
           
 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 init()
           
 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.
 void start()
           
 
Methods inherited from class edu.davidson.tools.SApplet
addDataListener, addDataSource, cleanupDataConnections, clearAllData, clearData, deleteDataConnection, deleteDataConnections, destroy, forward, getClockID, getClockTime, getDataConnectionFromDL, getDataConnectionFromDS, getDataFromDS, getDataListener, getDataListener, getDataSource, getDataSource, getID, getRunningID, getSourceData, getSourceVariables, isAutoRefresh, isClockRunning, makeDataConnection, pause, removeDataListener, removeDataSource, reset, reverse, setClockContinous, setClockCycle, setClockOneShot, setClockTime, setConnectionBlock, setConnectionListener, setConnectionSmoothing, setConnectionSource, setConnectionStride, setDt, setExternalClock, setFPS, setRunningID, setRunningID, setTimeContinuous, setTimeCycle, setTimeOneShot, startClock, stepClock, stepTime, stepTimeBack, stepTimeForward, stopClock, updateDataConnection, updateDataConnections
 
Methods inherited from class java.applet.Applet
getAccessibleContext, getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataTable

public DataTable()
Method Detail

addDatum

public void addDatum(int sid,
                     double x)
Add a data point to the series.
Parameters:
id - series ID
x - x value

clearAllSeries

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

clearSeries

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

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.

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.

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.

getAppletInfo

public final java.lang.String getAppletInfo()
Overrides:
getAppletInfo in class java.applet.Applet

getParameter

public java.lang.String getParameter(java.lang.String key,
                                     java.lang.String def)

getParameterInfo

public java.lang.String[][] getParameterInfo()
Overrides:
getParameterInfo in class java.applet.Applet

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.

getTableID

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

init

public void init()
Overrides:
init in class java.applet.Applet

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

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

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

setAutoRefresh

public void setAutoRefresh(boolean autoRefresh)
Repaint every time data is added.
Overrides:
setAutoRefresh in class SApplet
Parameters:
autoRefresh - Automatic repaint?

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.

setDefault

public void setDefault()
Clears the data from the grid and sets the stride to 1 for all series.
Overrides:
setDefault in class SApplet

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

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

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.

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.

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

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.

start

public void start()
Overrides:
start in class java.applet.Applet

Copyright Wolfgang Christian

Visit the Davidson CollegePhyslets Page