The Animator Applet

The Animator applet is a general purpose animation tool. The current version, v1.8, has these features: Please try out the Animator applet for your own animations and let us know what you think. Here's the source code. You can save it by bringing up the View Source window for it, and clicking the Save button. Then compile it (with javac, the Java compiler) and try it out. Or grab all of the .class files here: Animator.class, ImageNotFoundException.class, ParseException.class, and DescriptionFrame.class.

The Animator applet isn't finished -- we plan to add more features -- but we'd appreciate your suggestions. Send bug reports and feature requests to java@java.sun.com.

You can get a bunch of information about Animator by pressing the SHIFT key while clicking the mouse in an Animation.

Tag Syntax

<APPLET CODE="Animator.class"
     WIDTH="aNumber"             -- the width (in pixels) of the widest frame
     HEIGHT="aNumber">           -- the height (in pixels) of the tallest frame
<PARAM NAME="IMAGESOURCE"
     VALUE="aDirectory">         -- the directory that has the animation
                                    frames (a series of pictures in GIF or JPEG
                                    format, by default named T1.gif, T2.gif,
                                    ...)
<PARAM NAME="STARTUP"
     VALUE="aFile">              -- an image to display at load time
<PARAM NAME="BACKGROUND"
     VALUE="aFile">              -- an image to paint the frames against
<PARAM NAME="BACKGROUNDCOLOR"
     VALUE="aColor">             -- a solid color to paint the frames against
<PARAM NAME="STARTIMAGE"
     VALUE="aNumber">            -- number of the starting frame (1..n)
<PARAM NAME="ENDIMAGE"
     VALUE="aNumber">            -- number of the end frame (1..n)
<PARAM NAME="NAMEPATTERN"
     VALUE="dir/prefix%N.suffix" -- a pattern to use for generating names
                                    based on STARTIMAGE, ENDIMAGE, or IMAGES. (See
                                    below.)
<PARAM NAME="PAUSE"
     VALUE="100">                -- milliseconds to pause between images
                                    default - can be overridden by PAUSES)
<PARAM NAME="PAUSES"
     VALUE="300|200||400|200">   -- millisecond delay per frame.  Blank
                                    uses default PAUSE value
<PARAM NAME="REPEAT"
     VALUE="true">               -- repeat the sequence?
<PARAM NAME="POSITIONS"
     VALUE="100@200||200@100||200@200|100@100|105@105">
                                 -- positions (X@Y) for each frame.  Blank
                                    means use previous frame's position
<PARAM NAME="IMAGES"
     VALUE="3|3|2|1|2|3|17">     -- explicit order for frames - see below
<PARAM NAME="SOUNDSOURCE"
     VALUE="aDirectory">         -- the directory that has the audio files
<PARAM NAME="SOUNDTRACK"
     VALUE="aFile">              -- an audio file to play throughout
<PARAM NAME="SOUNDS"
     VALUE="aFile.au|||||bFile.au">
				 -- audio files keyed to individual frames
<PARAM NAME="HREF"
     VALUE="aURL">               -- The URL of the page to visit when
                                    user clicks on the animation (if not set, 
                                    click pauses/resumes the animation)
</APPLET>

The IMAGES, STARTIMAGE, ENDIMAGE, and NAMEPATTERN parameters

You can specify either an IMAGES list or a STARTIMAGE/ENDIMAGE range, but not both. The IMAGES list is a string of frame numbers in the order in which you wish them to display, separated by vertical bars. You can use NAMEPATTERN with IMAGES or STARTIMAGE/ENDIMAGE to generate the file names to use.

STARTIMAGE and ENDIMAGE let you specify a range of images. Specifying an ENDIMAGE that is numerically less than the STARTIMAGE will display the images in reverse order. Both parameters have default values of 1, so specifying only STARTIMAGE="15" means "play the frames in reverse order from 15 to 1." Saying only ENDIMAGE="13" means "play the frames from 1 to 13." Of course, you can use both STARTIMAGE and ENDIMAGE together.

NAMEPATTERN lets you specify how to generate the names of the files in the range STARTIMAGE to ENDIMAGE. The pattern is like a URL with substitution. Any instance of the characters '%N' will have the current index (integer in the STARTIMAGE..ENDIMAGE range) substituted for it; any instance of '%[digit]' -- for example, '%5' -- will have the index plugged in, left-padded with zeroes. Finally, '%%' substitutes a single '%'.

Some examples (all assume STARTIMAGE = 1 and ENDIMAGE = 10):

NAMEPATTERN = "T%N.gif"
This is the default pattern, and will generate the names T1.gif, T2.gif, ...T10.gif.
NAMEPATTERN = "anim%3/anim%3.jpg"
This will generate the names anim001/anim001.jpg, ... anim010/anim010.jpg
NAMEPATTERN = "100%%frame%N.jpg"
This will generate the names 100%frame1.jpg, 100%frame2.jpg, etc.

Example files

example1.html
Java beans, with a soundtrack and per-frame sound effects.
example2.html
A simple two-frame animation.
example3.html
A simple beany animation with start-up image.
example4.html
Java beans with POSITIONS, HREF, and BACKGROUNDCOLOR.

Herb Jellinek | jellinek@eng.sun.com