|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JLabel PIRL.Viewers.Animator
public class Animator
An Animator is a JLabel that displays an animation of a series of Icons.
Once started, an Animator will sequentially display the sequence of Icons that it has been given. The rate at which Icons are displayed and the number of animation cycles is controllable. The animation sequence may be stopped and started again from where it left off, or restarted from the beginning of a cycle.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JLabel |
---|
JLabel.AccessibleJLabel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
static int |
CYCLES
The default number of animation cycles: INDEFINITELY. |
static int |
INDEFINITELY
Constant to specify an indefinate number of animation cycles; i.e. forever until stopped. |
static int |
INITIAL_DELAY
The default initial delay before animation starts: 0 milliseconds (immediately after start). |
static int |
INTERVAL
The default animation interval: 1000 milliseconds. |
static int |
MINIMUM_INTERVAL
The minimum animation interval: 50 milliseconds. |
Fields inherited from class javax.swing.JLabel |
---|
labelFor |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.SwingConstants |
---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
Animator()
Constructs a disabled Animator with default Animator parameters. |
|
Animator(Icon[] icons)
Constructs an Animator using all of the default Animator parameters. |
|
Animator(Icon[] icons,
int cycles,
int initial_delay,
int interval)
Constructs an Icon Animator. |
Method Summary | |
---|---|
void |
actionPerformed(ActionEvent event)
Performs the animation event at the Timer interval. |
int |
Cycle()
Gets the current animation cycle. |
int |
getDelay()
Gets the delay between the display of each Icon in the animation sequence. |
int |
getInitialDelay()
Gets the initial delay. |
int |
getRepeats()
Gets the number of animation cycles. |
Icon[] |
Icons()
Gets the array of Icons to be animated. |
Animator |
Icons(Icon[] icons)
Sets the Icon array to be animated. |
boolean |
isRunning()
Tests if the animation sequence is running. |
void |
restart()
Restarts the Animator at the beginning of a cycle. |
Animator |
setDelay(int interval)
Set the delay between the display of each Icon in the animation sequence. |
Animator |
setInitialDelay(int initial_delay)
Sets the initial delay. |
Animator |
setRepeats(int cycles)
Sets the maximum number of animation cycles. |
void |
start()
Starts the animation. |
int |
Step()
Gets the current animation step. |
void |
stop()
Stops the animation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int INDEFINITELY
public static final int CYCLES
public static final int INITIAL_DELAY
public static final int INTERVAL
public static final int MINIMUM_INTERVAL
Constructor Detail |
---|
public Animator(Icon[] icons, int cycles, int initial_delay, int interval)
icons
- An array of Icon objects to be animated.cycles
- The maximum number of animation cycles. Use the
INDEFINITELY
value to continue the
animation until stopped.initial_delay
- The initial delay, after first starting,
before animation begins. A value <= 0 means no initial delay.interval
- The interval between the display of each Icon in
the animation sequence. A MINIMUM_INTERVAL
is enforced.public Animator(Icon[] icons)
icons
- An array of Icon objects to be animated.public Animator()
Method Detail |
---|
public void start()
If the animator was stopped
in the middle of an
animation cycle it pickes up from where it left off.
Use restart to start the animation from the beginning of a cycle.
public void stop()
public void restart()
public Animator setRepeats(int cycles)
cycles
- The maximum number of times to cycle through the Icons.
Use the INDEFINITELY
value to continue
the animation until stopped.
public int getRepeats()
INDEFINITELY
value.public int getInitialDelay()
setInitialDelay(int)
public Animator setInitialDelay(int initial_delay)
The intial delay occurs before the first animation cycle starts
or is restarted
.
initial_delay
- The intial delay time in milliseconds. A value
less than or equal to zero means no initial delay.
public int getDelay()
setDelay(int)
public Animator setDelay(int interval)
After the animation sequence is started
the next
Icon is displayed after the interval delay. Because the time can not
guarantee its accuracy, especially when the display component must be
rendered during the interval, the interval may be longer than
expected at times. In general, a longer interval is more likely to
result in a smoother animation than a short interval.
interval
- The delay between the display of each Icon during
an animation sequence. A MINIMUM_INTERVAL
is enforced.
public boolean isRunning()
public void actionPerformed(ActionEvent event)
If the animation is active the next Icon is painted.
actionPerformed
in interface ActionListener
public Animator Icons(Icon[] icons)
The animation is stopped
and the cycle
count is
reset to zero.
icons
- An array of Icon objects to be animated.
public Icon[] Icons()
public int Step()
public int Cycle()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |