DataGraph AddObject Method

Almost all Physlets support one or more add methods designed to create an object and add it to the applet.  The addObject method with the following signature

addObject(String name, String attributes)

These objects usually, but not always, have an on-screen representation.  The first argument is the name of the object to be added, and the second is a comma-delimited list of parameters.  A lens can be added using the following JavaScript statement:

document.physletname.addObject("box", "x=1,y=2,w=50,h=20");.

The addObject method is very forgiving since not all parameters need to be specified.  Default values are overridden only if the parameter appears in the list.  Incorrect and unsupported parameters do not affect the applet and are ignored.

Name

Attributes

arrow
An arrow.

x- double x position of the center in world units
y- double y position of the center in world units
h- double horizontal component
s- int size of the arrow head
v- double vertical component

box
A hollow rectangle.

x- double x position of the center in world units
y- double y position of the center in world units
h- int height in pixels
w- int width in pixels

caption
Text

x- double x position of the center in world units
y- double y position of the center in world units
text- String the text

circle  
A filled circle with radius r.

x- double x position of the center in world units
y- double y position of the center in world units.
r- int radius in pixels

cursor
A circle with crosshair.

x- double x position of the center in world units
y- double y position of the center in world units
text- String the text
calc- String the calculation function, f(x,y,t)

function
A graph of an analytic function.

f- String the function.  Usually f(x) or f(x,t).
var- String the independent variable

A function will use the graph's current xmin and xmax values if the following are not specified.

n- int the number of evaluation points
xmin- double the minimum value for the independent variable
xmax- double the maximum value for the independent variable

Functions can be explicit functions of time.  The function will animate if the clock is running.

image 
A gif image

x- double x position of the center in world units
y- double y position of the center in world units.
gif- String a gif image
file- String same as gif

DataGraph will search for images in the directory containing the jar files and in the directory containing the html file.  Both directories work from a server, but the html directory search will fail in IE if the html file is located on local hard drive.

You may use subdirectories to organize images.
addObject("image","file=mechanics/car.gif");

rectangle
A filled rectangle.

x- double x position of the center in world units
y- double y position of the center in world units
h- int height in pixels
w- int width in pixels

shell 
A hollow circle with radius r.

x- double x position of the center in world units
y- double y position of the center in world units.
r- int radius in pixels

tangent
A tangent line with
slope=rise/run.

x- double x position of the center in world units
y- double y position of the center in world units
h- double the rise
w- double the run

text
Text followed by a calculation.

x- double x position of the center in world units
y- double y position of the center in world units
text- String the text
calc- String the calculation function, f(x,y,t)