As the applet is contained
within a Web page, we must first create that Web page. If you have don't
have experience with Java applets you can simply copy the following
template into a file ending with a .html extension in your
Note: The anim file must have the same name as the html file and be in he same directory.
This will create a page containing the applet to display animations. The first two lines of the Applet tag indicate the location of the code needed to run the animation. If you would like to run the animaton from Duke rather than your own directory the code base should be http://www.cs.duke.edu/csed/jawaa2. The applet will then grab the script from the specified location and proceed to display the animation.
This brings us to the topic of how to write an animation. Animation scripts are simple text files with one instruction per line. For example, here is the script for the depth first search animation.
The first line of the animation is the keyword begin. Every command between begin and the line end will be drawn on the screen immediately. The user will have to press start to begin the animation. Each line consists of a command and then a parameter list. For example the following line comes from the DFS animation:
node 1 120 30 20 20 1 "1" black lightGray black CIRCLE
The first word in the line, node, is a command to create a node in the animation. The rest of the line contains parameters to this command. The string 1 is the name of the node. The next two numbers, 120 and 30, are the x and y coordinates. The next two numbers indicate the width and height of the node. The next number is the number of data in the node, and the following string is the data to go inside the node. The next three strings are colors which indicate the outline, the backgound, and the text colors respectively. Any line beginning with a "#" is considered a comment.
Therefore, in order to write an animation all one needs to do is look up the command desired along with the required parameters. The commands and valid color names have been listed on the Jawaa Commands page.
The "Java Console " window can also be used with debugging. The window can be opened from the "Options" menu in Netscape. It can be added from the Internet Options menu in Internet Explorer. The java console shows each line of JAWAA as it is executed, so that if it stops early, you can see the last line that was executed.