diff options
author | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-07-31 16:14:11 +0000 |
---|---|---|
committer | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-07-31 16:14:11 +0000 |
commit | 9c2ec3049a5634f1c916d792e81fc80edb669ea8 (patch) | |
tree | 0d634e179761581cadbffe852e7f9a9f049b5c6e /java/gjt/animation/Sequence.java | |
parent | 6540653cf736840d5aad719c73a8e43a549080be (diff) | |
download | ATCD-9c2ec3049a5634f1c916d792e81fc80edb669ea8.tar.gz |
This commit was manufactured by cvs2svn to create tag 'TAO-1_4_2'.TAO-1_4_2
Diffstat (limited to 'java/gjt/animation/Sequence.java')
-rw-r--r-- | java/gjt/animation/Sequence.java | 119 |
1 files changed, 0 insertions, 119 deletions
diff --git a/java/gjt/animation/Sequence.java b/java/gjt/animation/Sequence.java deleted file mode 100644 index 7b777ecd0d8..00000000000 --- a/java/gjt/animation/Sequence.java +++ /dev/null @@ -1,119 +0,0 @@ -package gjt.animation; - -import java.util.Vector; -import java.awt.*; -import java.awt.image.ImageObserver; -import gjt.Util; -import gjt.Stopwatch; - -/** - * A sequence of images used in an animation. Each sequence - * keeps track of the number of cycles the sequence is to run, - * and reports whether or not the cycles have been completed - * via the boolean animationOver() method. - * - * @version 1.0, Apr 1 1996 - * @author David Geary - * @see Sprite - * @see Playfield - * @see gjt.test.SimpleAnimationTest - * @see gjt.test.BumpAnimationTest - * @see gjt.test.TwoDrinkersAnimationTest - */ -public class Sequence { - private static long infiniteCycle = -1; - - private Vector cells = new Vector(); - private Point lastPaintLocation = new Point(0,0); - private Stopwatch cellAdvanceTimer = new Stopwatch(); - private Image currentImage, lastImagePainted; - private long cellAdvanceInterval = 0, - currentCycle = 0, - cyclesPerAnimation = 0; - - public Sequence() { } - - public Sequence(Component component, Image[] images) { - for(int i=0; i < images.length; ++i) { - addImage(component, images[i]); - } - cyclesPerAnimation = infiniteCycle; - } - public void start () { cellAdvanceTimer.start(); } - public Image getLastImage () { return lastImagePainted; } - public Point getLastLocation() { return lastPaintLocation; } - public int getNumImages () { return cells.size(); } - - public long getCurrentCycle() { return currentCycle; } - public void setCurrentCycle(long c) { currentCycle = c; } - - public long getCyclesPerAnimation() { - return currentCycle; - } - public void setCyclesPerAnimation(long cyclesPerAnimation) { - this.cyclesPerAnimation = cyclesPerAnimation; - } - public Image getFirstImage() { - return (Image)cells.firstElement(); - } - public Image getCurrentImage() { - return currentImage; - } - public int getCurrentImagePosition() { - return cells.indexOf(currentImage); - } - public Image getNextImage() { - int index = cells.indexOf(currentImage); - Image image; - - if(index == cells.size() - 1) - image = (Image)cells.elementAt(0); - else - image = (Image)cells.elementAt(index + 1); - - return image; - } - public void setAdvanceInterval(long interval) { - cellAdvanceInterval = interval; - } - public void addImage(Component component, Image image) { - if(currentImage == null) - currentImage = image; - - Util.waitForImage(component, image); - cells.addElement(image); - } - public void removeImage(Image image) { - cells.removeElement(image); - } - public boolean needsRepainting(Point point) { - return (lastPaintLocation.x != point.x || - lastPaintLocation.y != point.y || - lastImagePainted != currentImage); - } - public void paint(Graphics g, int x, int y, - ImageObserver observer) { - g.drawImage(currentImage, x, y, observer); - lastPaintLocation.x = x; - lastPaintLocation.y = y; - lastImagePainted = currentImage; - } - public boolean isAtLastImage() { - return getCurrentImagePosition() == (cells.size() - 1); - } - public boolean timeToAdvanceCell() { - return - cellAdvanceTimer.elapsedTime() > cellAdvanceInterval; - } - public boolean animationOver() { - return (cyclesPerAnimation != infiniteCycle) && - (currentCycle >= cyclesPerAnimation); - } - public void advance() { - if(isAtLastImage()) - ++currentCycle; - - currentImage = getNextImage(); - cellAdvanceTimer.reset(); - } -} |