Update the loopslot frame number and the
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* from this software without specific prior written permission.
*
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Graphics;
/**
* @author jag
/*
* TumbleItem.java requires these files:
* the appropriate code to specify that the applet be executed,
* such as the HTML code in TumbleItem.html or TumbleItem.atag,
implements ActionListener {
int loopslot = -1; //the current frame number
int pause; //the length of the pause between revs
int offset; //how much to offset between loops
Animator animator; //the applet's content pane
ImageIcon imgs[]; //the images
//Get the applet parameters.
String at = getParameter("img");
offset = (at != null) ? Integer.valueOf(at).intValue() : 0;
at = getParameter("speed");
maxWidth = (at != null) ? Integer.valueOf(at).intValue() : 0;
}
private void createGUI() {
//Animate from right to left if offset is negative.
//Custom component to draw the current image
//at a particular offset.
//Put a "Loading Images..." label in the middle of
//the content pane. To center the label's text in
JLabel.CENTER);
animator.add(statusLabel, BorderLayout.CENTER);
public ImageIcon[] doInBackground() {
final ImageIcon[] innerImgs = new ImageIcon[nimgs];
}
@Override
try {
imgs = get();
if (cause != null) {
why = cause.getMessage();
}
}
//Execute a job on the event-dispatching thread:
//creating this applet's GUI.
}
});
timer = new Timer(speed, this);
timer.setInitialDelay(pause);
//The component that actually presents the GUI.
public class Animator extends JPanel {
super.paintComponent(g);
if (worker.isDone() &&
}
}
public void actionPerformed(ActionEvent e) {
//If still loading, can't animate.
if (loopslot >= nimgs) {
loopslot = 0;
off = 0;
}
}
}
}
public void stop() {
* this runs as an applet, we use getResourceAsStream for
* efficiency and so it'll work in older versions of Java Plug-in.
//your biggest image, in bytes.
int count = 0;
try {
count = imgStream.read(buf);
}
if (count <= 0) {
} else {
System.err.println("Couldn't find file: " + path);
return "Title: TumbleItem v1.2, 23 Jul 1997\n"
+ "Author: James Gosling\n"
{"img", "string", "the directory containing the images to loop"},
{"pause", "int", "pause between complete loops; default is 3900"},
{"nimgs", "int", "the number of images to be looped; default is 16"},
{"maxwidth", "int", "the maximum width of any image in the loop; "
}
