Class DrawingSequence
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class DrawingSequence

public abstract class netscape.application.DrawingSequence
    extends netscape.application.Image
    implements netscape.application.Target,
               netscape.util.Codable
{
    /* Fields
     */
    public final static int BACKWARD;
    public final static int BACKWARD_LOOP;
    public final static int BOUNCE;
    public final static int FORWARD;
    public final static int FORWARD_LOOP;
    public final static java.lang.String NEXT_FRAME;
    public final static java.lang.String START;
    public final static java.lang.String STOP;

    /* Constructors
     */
    public DrawingSequence();
    public DrawingSequence(DrawingSequenceOwner);

    /* Methods
     */
    public int currentFrameNumber();
    public void decode(Decoder);
    public void describeClassInfo(ClassInfo);
    public boolean doesLoop();
    public boolean doesResetOnStart();
    public boolean doesResetOnStop();
    public abstract void drawAt(Graphics, int, int);
    public void encode(Encoder);
    public void finishDecoding();
    public int frameCount();
    public int frameRate();
    public abstract int height();
    public boolean isAnimating();
    public String name();
    public boolean nextFrame();
    public DrawingSequenceOwner owner();
    public void performCommand(String, Object);
    public int playbackMode();
    public void reset();
    public void setCurrentFrameNumber(int);
    public void setFrameCount(int);
    public void setFrameRate(int);
    public void setName(String);
    public void setOwner(DrawingSequenceOwner);
    public void setPlaybackMode(int);
    public void setResetOnStart(boolean);
    public void setResetOnStop(boolean);
    public void start();
    public void stop();
    public abstract int width();
}
Abstract Image subclass that simplifies frame-by-frame animation. A DrawingSequence works with a collection of "frames." It animates its frames by incrementing or decrementing its current frame number and drawing the new frame. A DrawingSequence is not a View - it must ask its owner, typically a View, to display its new frame by calling its drawingSequenceFrameChanged() method.

Note that the machinery within the DrawingSequence abstract class does not know what it's animating, only that it has a current frame number that must be incremented or decremented. As a subclasser overriding the drawAt() method, you can perform whatever drawing operation you want, such as draw a Bitmap or fill a Rect, based on the value returned by currentFrameNumber(). The ImageSequence class is a DrawingSequence subclass that specifically animates a collection of Images. If you only need to animate Images, you should use an instance of the ImageSequence class.

See Also:
DrawingSequenceOwner, ImageSequence

Fields

FORWARD

  public final static int FORWARD
Increment the frame number; upon reaching the sequence's last frame, stop animating.

FORWARD_LOOP

  public final static int FORWARD_LOOP
Increment the frame number; upon reaching the sequence's last frame, return to the first frame and continue animating.

BACKWARD

  public final static int BACKWARD
Decrement the frame number; upon reaching the sequence's first frame, stop animating.

BACKWARD_LOOP

  public final static int BACKWARD_LOOP
Decrement the frame number; upon reaching the sequence's first frame, return to the last frame and continue animating.

BOUNCE

  public final static int BOUNCE
Increment the frame number; upon reaching the sequence's last frame, decrement to the first frame, then start again.

START

  public final static String START
Command that starts the DrawingSequence.

STOP

  public final static String STOP
Command that stops the DrawingSequence.

NEXT_FRAME

  public final static String NEXT_FRAME
Command that moves the DrawingSequence to its next frame.

Constructors

DrawingSequence

  public DrawingSequence()
Constructs a DrawingSequence without an owner.

DrawingSequence

  public DrawingSequence(DrawingSequenceOwner owner)
Constructs a DrawingSequence with owner owner, frame rate of 1 millisecond, current frame number of 0, and FORWARD direction.

Methods

setOwner

  public void setOwner(DrawingSequenceOwner anObject)
Sets the DrawingSequence's owner, the object that the DrawingSequence contacts when its current frame number changes or the DrawingSequence reaches its final frame.
See Also:
DrawingSequenceOwner

owner

  public DrawingSequenceOwner owner()
Returns the DrawingSequence's owner.
See Also:
setOwner

setName

  public void setName(String aName)
Sets the DrawingSequence's name.

name

  public String name()
Returns the DrawingSequence's name.
Overrides:
name in class Image
See Also:
setName

performCommand

  public void performCommand(String command,
                             Object data)
Implemented to respond to the NEXT_FRAME, START and STOP commands. The NEXT_FRAME command results in calls to the nextFrame() method. If the DrawingSequence completes its animation, it sends the drawingSequenceCompleted() message to its owner and calls its stop() method, otherwise it sends the drawingSequenceFrameChanged() message to its owner. When the frame changes, the owner is responsible for redisplaying the DrawingSequence. The START and STOP commands start or stop the DrawingSequence.
See Also:
DrawingSequenceOwner, stop

start

  public void start()
Instructs the DrawingSequence to animate itself by changing its current frame every frameRate() milliseconds.
See Also:
setFrameRate

isAnimating

  public boolean isAnimating()
Returns true if the DrawingSequence is currently animating itself.
See Also:
start

stop

  public void stop()
Stops the DrawingSequence's animation.
See Also:
start

reset

  public void reset()
Sets the DrawingSequence's current frame to its initial frame: the first frame if it has a forward or bounce direction, its last if a backward direction.

setFrameCount

  public void setFrameCount(int count)
Sets the number of frames the DrawingSequence animates.

frameCount

  public int frameCount()
Returns the number of frames the DrawingSequence animates.
See Also:
setFrameCount

setCurrentFrameNumber

  public void setCurrentFrameNumber(int anInt)
Sets the DrawingSequence's current frame number. When asked to draw itself, a DrawingSequence displays its current frame.

currentFrameNumber

  public int currentFrameNumber()
Returns the DrawingSequence's current frame number.
See Also:
setCurrentFrameNumber

setFrameRate

  public void setFrameRate(int milliseconds)
Sets the millisecond delay between calls to nextFrame().
See Also:
nextFrame

frameRate

  public int frameRate()
Returns the millisecond delay between calls to nextFrame().
See Also:
setFrameRate

setPlaybackMode

  public void setPlaybackMode(int mode)
Sets the DrawingSequence's frame playback mode. Currently, the five options are FORWARD, FORWARD_LOOP, BACKWARD, BACKWARD_LOOP, and BOUNCE. Resets the DrawingSequence's current frame to its initial frame by calling reset().
See Also:
reset

playbackMode

  public int playbackMode()
Returns the DrawingSequence's playback mode.
See Also:
setPlaybackMode

setResetOnStart

  public void setResetOnStart(boolean flag)
Configures the DrawingSequence to automatically reset its frame to its initial frame (by calling reset()) before it begins animating.
See Also:
setPlaybackMode, reset, start

doesResetOnStart

  public boolean doesResetOnStart()
Returns true if the DrawingSequence resets its frame to its initial frame before it begins animating.
See Also:
setResetOnStart

setResetOnStop

  public void setResetOnStop(boolean flag)
Sets the DrawingSequence to automatically reset its frame to its initial frame (by calling reset()) after it finishes animating.
See Also:
setPlaybackMode, reset, stop

doesResetOnStop

  public boolean doesResetOnStop()
Returns true if the DrawingSequence resets its frame to its initial frame after it finishes animating.
See Also:
setResetOnStop

doesLoop

  public boolean doesLoop()
Returns true if the DrawingSequence continues animating from its initial frame after reaching its final frame, or if it animates in BOUNCE mode.
See Also:
setPlaybackMode

nextFrame

  public boolean nextFrame()
Moves the DrawingSequence to its next frame, incrementing or decrementing its frame number. Returns false if the DrawingSequence has reached its final frame and its playback mode does not allow it to loop back to its initial frame.
See Also:
setPlaybackMode

width

  public abstract int width()
Subclassers must implement this method to return the DrawingSequence's width.
Overrides:
width in class Image

height

  public abstract int height()
Subclassers must implement this method to return the DrawingSequence's height.
Overrides:
height in class Image

drawAt

  public abstract void drawAt(Graphics g,
                              int x,
                              int y)
Displays the DrawingSequence's current frame at the given location. Subclassers must implement this method to display the current frame.
Overrides:
drawAt in class Image

describeClassInfo

  public void describeClassInfo(ClassInfo info)
Describes the DrawingSequence class' information.
Overrides:
describeClassInfo in class Image
See Also:
describeClassInfo

encode

  public void encode(Encoder encoder) throws CodingException
Encodes the DrawingSequence instance.
Overrides:
encode in class Image
See Also:
encode

decode

  public void decode(Decoder decoder) throws CodingException
Decodes the DrawingSequence instance.
Overrides:
decode in class Image
See Also:
decode

finishDecoding

  public void finishDecoding() throws CodingException
Finishes the DrawingSequence decoding.
Overrides:
finishDecoding in class Image
See Also:
finishDecoding

All Packages  Class Hierarchy  This Package  Previous  Next  Index