DataGraph addObject Method

DataGraph allows the addition of geometric shapes using the addObject method:

addObject(String name, String attributes).

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:

id=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

calculation
text followed by a calculation. 
same as calculation object

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)

cfunction
analytic function: f(x,t)

re- string the real part.  Usually Re[f(x,t)]
im- string the imaginary part.  Usually Im[f(x,t)]
var- string the independent variable: default=x
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
centered- boolean center the wave function
A function will use the graph's current xmin and xmax values if the following are not specified. Functions can be explicit functions of time.  The function will animate if the clock is running.

complexdata
See cfunction for analytic complex functions

centered- boolean center the wave function
This object is a placeholder for a complex function that is sent using a data-connection.

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
analytic function: f(x,t)

f- string the function.  Usually f(x) or f(x,t).
var- string the independent variable
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
A function will use the graph's current xmin and xmax values if the following are not specified. Functions can be explicit functions of time.  The function will animate if the clock is running.

graph
a placeholder for the data points

No attributes.  Use this parameter to determine the drawing order for the data points relative to the geometric objects.

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 code-base directory.  This is the directory containing the jar files.
You may use subdirectories relative to the code-base to organize images.
Example: addObject("image","file=mechanics/car.gif");

phasewheel  
shows angle as color
See complex functions.

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

protractor
a protractor for measuring angles

x- double x position of the vertex in world units
y- double
y position of the vertex in world units.
s- int base size in pixel
theta- double vertex interior angle
theta0- double vertex base angle
fixedbase-
fixes the base angle
fixedsize-
fixes the length of the arm

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)

vectorfield
analytic expression for a vector field

fx- string the x component
fy- string the y component
n- int the number of evaluation points