com.jgoodies.animation
Class Animator

java.lang.Object
  extended by com.jgoodies.animation.Animator
All Implemented Interfaces:
ActionListener, EventListener

public final class Animator
extends Object
implements ActionListener

Starts and stops an animation and triggers the animation at a given frame rate.

Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch

Constructor Summary
Animator(Animation animation, int framesPerSecond)
          Constructs an Animator for the given animation and frame rate.
 
Method Summary
 void actionPerformed(ActionEvent e)
          Implements the ActionListener interface used by the Timer.
 Animation animation()
          Returns the animator's animation.
 long elapsedTime()
          Returns the elapsed time since animation start.
 int framesPerSecond()
          Returns the desired frame rate.
 void start()
          Starts the animator and in turn the animation.
 void stop()
          Stops the animator.
 String toString()
          Returns a string representation for the animator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Animator

public Animator(Animation animation,
                int framesPerSecond)
Constructs an Animator for the given animation and frame rate.

Parameters:
animation - the animation to animate
framesPerSecond - the desired frame rate
Throws:
NullPointerException - if the animation is null
IllegalArgumentException - if the frame rate is non-positive
Method Detail

animation

public Animation animation()
Returns the animator's animation.

Returns:
the animator's animation

framesPerSecond

public int framesPerSecond()
Returns the desired frame rate.

Returns:
the desired frame rate per second

elapsedTime

public long elapsedTime()
Returns the elapsed time since animation start.

Returns:
time elapsed since the animation start

start

public void start()
Starts the animator and in turn the animation.


stop

public void stop()
Stops the animator.


actionPerformed

public void actionPerformed(ActionEvent e)
Implements the ActionListener interface used by the Timer.

Specified by:
actionPerformed in interface ActionListener
Parameters:
e - the action event

toString

public String toString()
Returns a string representation for the animator.

Overrides:
toString in class Object
Returns:
a string representation for the animator


Copyright © 2001-2006 JGoodies Karsten Lentzsch. All Rights Reserved.