|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.princeton.cs.algs4.growingtree.framework.AbstractAnimation
public abstract class AbstractAnimation
The Abstract Animation object defines numerous methods of an Animation that are independent of the specific type of Animation, resulting in much repeated code. Therefore, that code has been inserted in this abstract class that many Animations extend to take use of these methods.
drawAnimation
must be defined to extend this class appropriately.
Field Summary | |
---|---|
static int |
DEFAULT_CONVERSION
The Default step conversion used in animation (400). |
static int |
DEFAULT_STEP
The Default step size used in the animation (16). |
Fields inherited from interface edu.princeton.cs.algs4.growingtree.framework.Animation |
---|
ANIMATION_MESSAGE, BEGIN, FINISH, PAUSE, PLAY, REDRAW, REWIND, STEP, STOP |
Constructor Summary | |
---|---|
AbstractAnimation()
The constructor which initiates the abstract animation. |
Method Summary | |
---|---|
void |
addAnimationListener(AnimationListener l)
Adds an animationListener that recieves meaningful events from the animation, according to the Animation interface and the AnimationEvent . |
void |
addDescription(java.lang.String d)
Adds a description that may be used to describe to the listener the type of event occuring. |
void |
drawAnimation(java.awt.Graphics2D g2)
Draws the animation of the next step, using the status of the animation (Animation.PLAY, Animation.PAUSE and so forth). |
void |
drawAnimation(java.awt.Graphics2D g2,
java.lang.String startingStatus)
Draws the animation of the next step, using the status of the animation (Animation.PLAY, Animation.PAUSE and so forth). |
java.lang.String |
getDescription()
Gets the description added with addDescription and should be accessed through the listener. |
AnimationListener[] |
getListeners()
Returns an array of all the listeners that were added to this Animation with addAnimationListener . |
java.lang.String |
getStatus()
Gets the status of the Animation using a command within Animation interface. |
boolean |
getStep()
Gets whether the current animation is in stepping mode or not. |
int |
getStepTime()
Gets the step time for the animation. |
void |
removeAnimationListener(AnimationListener l)
Removes an animationListener from the animation, according to the Animation interface and the AnimationEvent . |
void |
setStatus(java.lang.String cmd)
Sets the status of the Animation using a command within Animation interface. |
void |
setStep(boolean b)
Sets whether the current animation is in stepping mode or not. |
void |
setStepTime(int t)
Sets the step time for the animation. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_STEP
public static final int DEFAULT_CONVERSION
Constructor Detail |
---|
public AbstractAnimation()
Method Detail |
---|
public int getStepTime()
getStepTime
in interface Animation
public java.lang.String getDescription()
addDescription
and should be accessed through the listener.
getDescription
in interface Animation
public boolean getStep()
getStep
in interface Animation
public java.lang.String getStatus()
Animation
interface.
getStatus
in interface Animation
public AnimationListener[] getListeners()
addAnimationListener
.
If no such listener list exists, then an empty array is returned.
AnimationListeners
.public void setStepTime(int t)
setStepTime
in interface Animation
t
- the step timepublic void addDescription(java.lang.String d)
getDescription
.
addDescription
in interface Animation
d
- the string defining the description.public void setStep(boolean b)
setStep
in interface Animation
b
- boolean defining whether it is skipping.public void setStatus(java.lang.String cmd)
Animation
interface.
setStatus
in interface Animation
cmd
- cmd that the Animation's status is set to.public void addAnimationListener(AnimationListener l)
AnimationEvent
.
addAnimationListener
in interface Animation
l
- the listener for the AnimationEvents occuring within this Animation.public void removeAnimationListener(AnimationListener l)
AnimationEvent
.
removeAnimationListener
in interface Animation
l
- the listener removed from recieving the AnimationEvents occuring within this Animation.public void drawAnimation(java.awt.Graphics2D g2)
The starting status used for the animation is the one previously defined.
drawAnimation
in interface Animation
b
- boolean defining whether it is skipping.public void drawAnimation(java.awt.Graphics2D g2, java.lang.String startingStatus)
drawAnimation
in interface Animation
g2
- the graphics to which the animation step should be drawn.startingStatus
- the status used as the starting command of animation, if needed.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |