|
|||||||
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 | +--java.applet.Applet | +--edu.davidson.tools.SApplet | +--dataGraph.DataGraph
This applet plots data sets and functions. Each data set is a "series" of of coordinate pairs, (x,y). A series is identified by a series numeber. Each series a unique color and style. Whenever data are added, the appropriate series number must be specified.
The following embedding parameters are defined:
Parameter | Value | Type | Description |
---|---|---|---|
Function | null | string | An analytic function, f(x). |
XMin | -1.0 | double | Minimum value along x axis. |
XMin | 1.0 | double | Maximum value along x axis. |
YMin | -1.0 | double | Minimum value along y axis. |
YMax | 1.0 | double | Maximum value along y axis. |
AutoScaleX | true | boolean | Autoscale the x axis. |
AutoScaleY | true | boolean | Autoscale the y axis. |
ShowControls | true | boolean | Show the user interface. |
A DataTable can be used as a data listener by obtaining its object identifier and passing this value to a data connection. This value is obtained using
getGraphID().
A data series is a data source. This enables other data listeners to change whenever data are added to a series. This interface, SDataSource, enables inter-applet data passing between Physlets.
Object | Identifier | Variables |
---|---|---|
series | id=getSeriesID(int sid | x,y,u,v Note: u and v are the differences between neighboring data points, Dx, Dy. |
clock | id=getClockID() | t |
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 |
Constructor Summary | |
DataGraph()
|
Method Summary | |
int |
addCursor(double x,
double y)
Add a dragable cursor to the graph. |
void |
addData(int sid,
double[] x,
double[] y)
Add a data vector to the series. |
void |
addDatum(int sid,
double x,
double y)
Add a data point to the series. |
int |
addObject(java.lang.String name,
java.lang.String parList)
Create an object and add it to the Physlet. |
void |
clearAllSeries()
Clear all data from the graph. |
void |
clearSeries(int s)
Clear the data from a series. |
int |
createSeries(int sid)
Create a series and return the series ID for use by a data connector. |
void |
deleteAllFunctions()
Delete all functions from the plot. |
void |
deleteAllSeries()
Delete all series from the graph |
void |
deleteFunction(int id)
Delete a function from the plot. |
void |
deleteSeries(int s)
Delete a series from the graph |
void |
destroy()
Destroy all threads and cleanup the applet. |
java.lang.String |
getAppletInfo()
|
java.lang.String |
getFunctionString(int id)
Get the function that is being ploted. |
int |
getGraphID()
Get the series ID for the applet. |
java.lang.String |
getParameter(java.lang.String key,
java.lang.String def)
|
java.lang.String[][] |
getParameterInfo()
|
int |
getRegressionID(int sid,
int start,
int end)
The id to the linear regression data source. |
int |
getSeriesID(int sid)
|
void |
init()
|
void |
loadDataFile(int sid,
java.lang.String fileName)
Read a data file of x,y coordinate pairs. |
int |
plotRegression(int sid,
int start,
int end)
Plot a linear regression for the data in a series. |
boolean |
set(int id,
java.lang.String name,
java.lang.String parList)
Change the properies of an object. |
void |
setAddRepeatedDatum(int sid,
boolean add)
Set the addRepeatedDataum property. |
void |
setAutoRefresh(boolean auto)
Set the autoRefresh property. |
void |
setAutoReplaceData(int id,
boolean auto)
Set the series to replace rather than add on to dataset when the addDatum method is called. |
void |
setAutoscaleX(boolean autoOn)
Set the autoscaleX property for the graph. |
void |
setAutoscaleY(boolean autoOn)
Set the autoscaleY property for the graph. |
void |
setDefault()
Set the graph to default. |
boolean |
setDisplayOffset(int id,
int xOff,
int yOff)
Offset the object's position on the screen from its default drawing position. |
boolean |
setDragable(int id,
boolean drag)
Make the object with the given id dragable. |
void |
setDrawGrid(boolean drawOn)
Set the draw grid property for the graph. |
void |
setDrawZero(boolean drawOn)
Set the graph to draw lines at x=0 and y=0. |
void |
setEnableMouse(boolean mouseOn)
Enable to mouse to show coordinates. |
boolean |
setFormat(int id,
java.lang.String fstr)
Change the object's format for the display of numeric data. |
void |
setFormat(java.lang.String str)
Change the display format for mouse actions. |
void |
setFunctionRange(int id,
double xmin,
double xmax,
int n)
Set the range of an analytic function. |
boolean |
setFunctionString(int id,
java.lang.String str)
Change the function that is being ploted. |
boolean |
setFunctionVariable(int id,
java.lang.String str)
Change the function's independent variable. |
void |
setGutters(int g1,
int g2,
int g3,
int g4)
Set the gutters i.e., margins, around the graph. |
void |
setLabelX(java.lang.String s)
Set the x axis label. |
void |
setLabelY(java.lang.String s)
Set the y axis label. |
void |
setLastPointMarker(int id,
boolean lpm)
Set the series so that the last point in the dataset has a distinctive marker. |
void |
setMarkerSize(int id,
double size)
Set the marker size. |
void |
setMinMaxX(double min,
double max)
Set the x axis minimum and maximum values. |
void |
setMinMaxY(double min,
double max)
Set the y axis minimum and maximum values. |
void |
setRGB(int id,
int r,
int g,
int b)
Set the color of the object. |
void |
setSeriesLegend(int id,
int xpix,
int ypix,
java.lang.String legend)
Set the series legend. |
void |
setSeriesLegendRGB(int id,
int r,
int g,
int b)
Set the series legend color. |
void |
setSeriesRGB(int id,
int r,
int g,
int b)
Set the series line and marker color. |
void |
setSeriesStyle(int id,
boolean conPts,
int m)
Set the series style. |
void |
setShowAxes(boolean show)
Show or hide the the X and Y axes on the graph. |
void |
setSorted(int sid,
boolean sorted)
Sort the series data according to the x value. |
void |
setSquare(boolean isSquare)
Set the aspect ratio=1 so that both axes have the same pixels per unit. |
void |
setTitle(java.lang.String str)
Set the graph title. |
boolean |
setVisibility(int id,
boolean show)
Show the visibility of the object. |
void |
start()
|
void |
stop()
|
void |
updateDataConnections()
Have all series and functions transfer their data to their connections. |
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 |
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,
setCursor,
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,
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 |
public DataGraph()
Method Detail |
public java.lang.String getParameter(java.lang.String key, java.lang.String def)
public void init()
public void destroy()
public void start()
public void stop()
public java.lang.String getAppletInfo()
public java.lang.String[][] getParameterInfo()
public int getGraphID()
public int getSeriesID(int sid)
public int getRegressionID(int sid, int start, int end)
sid
- the series id.start
- the first point to use in the regressionend
- the last point to use in the regressionpublic void addData(int sid, double[] x, double[] y)
id
- series IDx[]
- x vectory[]
- y vectorpublic void addDatum(int sid, double x, double y)
id
- series IDx
- x valuey
- y valuepublic int addCursor(double x, double y)
x
- The initial x coordinate.y
- The initial y coordinate.public int addObject(java.lang.String name, java.lang.String parList)
addObject ("circle", "x = 0, y = -1.0, r = 10");
name
- the type of object to be created.parList
- a list of parameters to be setpublic boolean set(int id, java.lang.String name, java.lang.String parList)
set(id, "sale", "xmin=0, xmax=2, autoscalx=false");
id
- the identifier of the objectname
- the type of property to be created.parList
- a list of parameterspublic void deleteFunction(int id)
id
- The id of the function;public void deleteAllFunctions()
public int createSeries(int sid)
series
- Series IDpublic void deleteSeries(int s)
Series
- IDpublic void deleteAllSeries()
public void clearSeries(int s)
Series
- IDpublic void clearAllSeries()
public void updateDataConnections()
public void loadDataFile(int sid, java.lang.String fileName)
sid
- The series id.fileName
- The file namepublic int plotRegression(int sid, int start, int end)
sid
- the series id.start
- the first point to use in the regressionend
- the last point to use in the regressionpublic void setAutoRefresh(boolean auto)
auto
- AutoRefresh the graph?public void setAddRepeatedDatum(int sid, boolean add)
add
- Added repeated data values to the graph?public void setAutoscaleX(boolean autoOn)
autoOn
- Autoscale the x axis?public void setAutoscaleY(boolean autoOn)
autoOn
- Autoscale the y axis?public void setDrawGrid(boolean drawOn)
drawOn
- Draw the grid?public void setDrawZero(boolean drawOn)
drawOn
- Draw the zero lines?public void setDefault()
public boolean setVisibility(int id, boolean show)
st
- show object on screen?public boolean setDisplayOffset(int id, int xOff, int yOff)
id
- The id of the object.xoff
- The x offset.yoff
- The y offset.public boolean setDragable(int id, boolean drag)
id
- The id of the object.drag
- Dragable?public void setEnableMouse(boolean mouseOn)
mouseOn
- Enable the mouse?public void setFunctionRange(int id, double xmin, double xmax, int n)
id
- The id of the function.xmin
- Minimum value of the range.xmax
- Maximum value of the range.n
- The number of data points.public boolean setFunctionString(int id, java.lang.String str)
str
- The function string, f(x);public java.lang.String getFunctionString(int id)
id
- The id of the function.public boolean setFunctionVariable(int id, java.lang.String str)
id
- The id of the function.str
- The new independent variable.public void setGutters(int g1, int g2, int g3, int g4)
g1
- The gutter on the left of the graph.g1
- The gutter on the top of the graph.g1
- The gutter on the right of the graph.g1
- The gutter on the bottom of the graph.public void setFormat(java.lang.String str)
str
- The format for cooridinate display.public boolean setFormat(int id, java.lang.String fstr)
id
- The id of the object.fstr
- the format string.public void setLabelX(java.lang.String s)
The
- label value.public void setLabelY(java.lang.String s)
The
- label value.public void setMarkerSize(int id, double size)
id
- Series id.size
- Marker size.public void setMinMaxX(double min, double max)
min
- Minumum value.max
- Maximum value.public void setMinMaxY(double min, double max)
min
- Minumum value.max
- Maximum value.public void setSeriesLegend(int id, int xpix, int ypix, java.lang.String legend)
id
- The series id.xpix
- The x postion in pixels.ypix
- The y postion in pixels.legend
- The legend.public void setSeriesLegendRGB(int id, int r, int g, int b)
id
- The series id.r
- red.g
- green.b
- blue.public void setSeriesStyle(int id, boolean conPts, int m)
id
- The series id.conPts
- Connect the points?m
- Marker style. (m=1 is cross; m=2 is square, m=3 is
circle)public void setSeriesRGB(int id, int r, int g, int b)
id
- The series id.r
- red.g
- green.b
- blue.public void setRGB(int id, int r, int g, int b)
id
- The series id.r
- red.g
- green.b
- blue.public void setAutoReplaceData(int id, boolean auto)
id
- The series id.auto
- AutoReplacepublic void setLastPointMarker(int id, boolean lpm)
id
- The series id.lpm
- Enable the marker.public void setTitle(java.lang.String str)
str
- Title string.public void setShowAxes(boolean show)
show
- Show the axis?public void setSquare(boolean isSquare)
isSquare?
- public void setSorted(int sid, boolean sorted)
sid
- the series numbersorted
- true if data should be sorted
|
Copyright Wolfgang Christian | ||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |