The Animator class provides the basic functionality to display the state of an animation and to step that animation forward at a regular frame rate.
This class extends JPanel, to provide a component upon which the animation is drawn. It also implements Runnable in order to provide a thread which periodically steps the state of the animation to the next frame and calls repaint() to persuade the event dispatch thread to paint that frame.
The state of the animation is actually managed by an aggregated object of a class which implements the {@link Animatable} interface. This providesmethods by which the state may be stepped or painted.
To ensure thread safety, the methods of this class, except for run()
which shouldn't be called directly anyway, should only be called from within the event dispatch thread.
|
|