|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread acm.util.Animator
public class Animator
This class extends Thread
to provide several features that make it
easier to build animations. These features include a pause
method that does not raise an exception and a requestTermination
method that signals that the execution of this thread should stop at its
next opportunity. It also includes hooks to support a start/stop/single-step
model for algorithm animation.
Field Summary | |
---|---|
int |
CALLING
|
int |
FINISHED
run method. |
int |
INITIAL
|
int |
RUNNING
|
int |
STEPPING
|
int |
STOPPED
|
int |
STOPPING
|
int |
TERMINATING
|
Constructor Summary | |
---|---|
Animator()
Animator object. |
Method Summary | |
---|---|
void |
breakpoint()
|
boolean |
buttonAction(String actionCommand)
|
void |
callAction()
"call" action, as if the Call button
is pushed. |
void |
checkForTermination()
Animator has been asked
to terminate. |
void |
delay()
|
int |
getAnimatorState()
|
double |
getSpeed()
|
Component |
getSpeedBar()
|
void |
pause(double milliseconds)
|
void |
registerSpeedBar(JScrollBar scrollBar)
|
void |
registerSpeedBar(JSlider slider)
|
void |
requestTermination()
Animator that it should stop running at the
next available opportunity, which is when the client next calls
pause or checkForTermination . |
void |
run()
|
void |
setSpeed(double speed)
|
void |
start()
|
void |
startAction()
"start" action, as if the Start button
is pushed. |
void |
stepAction()
"step" action, as if the Step button
is pushed. |
void |
stopAction()
"stop" action, as if the Stop button
is pushed. |
void |
trace()
|
void |
trace(int depth)
|
Field Detail |
---|
public static final int CALLING
public static final int FINISHED
run
method.
public static final int INITIAL
public static final int RUNNING
public static final int STEPPING
public static final int STOPPED
public static final int STOPPING
public static final int TERMINATING
Constructor Detail |
---|
public Animator()
Animator
object.
Usage: | Animator animator = new Animator(); |
Method Detail |
---|
public void breakpoint()
Usage: | animator.breakpoint(); |
public boolean buttonAction(String actionCommand)
Usage: | boolean ok = animator.buttonAction(actionCommand); | ||
Parameter: |
| ||
Returns: | true if the action command is recognized
|
public void callAction()
"call"
action, as if the Call
button
is pushed.
Usage: | animator.callAction(); |
public void checkForTermination()
Animator
has been asked
to terminate. If so, the Animator
stops running,
and the call never returns. If not, other threads are given a
chance to run, after which this Animator
will return
to the caller.
Usage: | checkForTermination(); |
public void delay()
Usage: | animator.delay(); |
public int getAnimatorState()
INITIAL
,
RUNNING
,
STEPPING
,
CALLING
,
STOPPING
,
STOPPED
,
FINISHED
, or
TERMINATING
,
as defined in this class.
Usage: | int state = animator.getAnimatorState(); |
Returns: | The current state of the animator |
public double getSpeed()
double
between 0.0 and 1.0, for which 0.0 is very slow and 1.0 is as fast as the
system can manage.
Usage: | double speed = animator.getSpeed(); |
Returns: | A double between 0.0 (slow) and 1.0 (fast) |
public Component getSpeedBar()
JSlider
or a JScrollBar
; it is the caller's
responsibility to cast the result to the appropriate class.
Returns: | The speed bar, or null if none exists
|
public void pause(double milliseconds)
Thread.sleep
, this method never
throws an exception.
Usage: | animator.pause(milliseconds); | ||
Parameter: |
|
public void registerSpeedBar(JScrollBar scrollBar)
Usage: | registerSpeedBar(scrollBar); | ||
Parameter: |
|
public void registerSpeedBar(JSlider slider)
Usage: | registerSpeedBar(slider); | ||
Parameter: |
|
public void requestTermination()
Animator
that it should stop running at the
next available opportunity, which is when the client next calls
pause
or checkForTermination
. Making this
check at well-managed times makes it possible for the client to
ensure that objects are left in a consistent state and thereby
avoids the problems that led Sun to deprecate Thread.stop
.
Usage: | requestTermination(); |
public void run()
run
in interface Runnable
public void setSpeed(double speed)
double
between 0.0 and 1.0, for which 0.0 is very slow and 1.0 is as fast as the
system can manage.
Usage: | animator.setSpeed(speed); | ||
Parameter: |
|
public void start()
Usage: | animator.start(); |
public void startAction()
"start"
action, as if the Start
button
is pushed.
Usage: | animator.startAction(); |
public void stepAction()
"step"
action, as if the Step
button
is pushed.
Usage: | animator.stepAction(); |
public void stopAction()
"stop"
action, as if the Stop
button
is pushed.
Usage: | animator.stopAction(); |
public void trace()
Usage: | animator.trace(); |
public void trace(int depth)
Call
button functionality.
Usage: | animator.trace(depth); | ||
Parameter: |
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |