Package com.jgoodies.animation
Class AbstractAnimation
- java.lang.Object
-
- com.jgoodies.animation.AbstractAnimation
-
- All Implemented Interfaces:
Animation
- Direct Known Subclasses:
AnimatedLabel.BlendOverAnimation,Animations.OffsetAnimation,Animations.OneTimeAnimation,Animations.ParallelAnimation,Animations.PauseAnimation,Animations.RepeatedAnimation,Animations.ReversedAnimation,Animations.SequencedAnimation,BasicTextAnimation,FanAnimation,GlyphAnimation
public abstract class AbstractAnimation extends java.lang.Object implements Animation
An abstract class that minimizes the effort required to implement theAnimationinterface. Defines the duration and freezed state and provides a listener list.- Version:
- $Revision: 1.8 $
-
-
Field Summary
Fields Modifier and Type Field Description private booleanactiveprivate longdurationprivate booleanfreezedprivate java.util.List<AnimationListener>listenerList
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractAnimation(long duration)Constructs anAnimationwith the specified duration.protectedAbstractAnimation(long duration, boolean freezed)Constructs anAnimationwith the specified duration and freezed mode.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddAnimationListener(AnimationListener listener)Adds anAnimationListenerto this animation.voidanimate(long time)Performs the animation at the given time: applies the animation effect to the animation target, fires appropriate events, and resets the effect if we exceeded the animations duration.protected abstract voidapplyEffect(long time)Applies the animation effect for the given time to the animation target.longduration()Returns this animation's duration.protected voidfireAnimationStarted(long time)Fires an event that indicates that the animation has been started at the specified time.protected voidfireAnimationStopped(long time)Fires an event that indicates that the animation has been stopped at the specified time.booleanisFreezed()Answers whether the animation effect should be freezed after we exceeded the animation's duration.voidremoveAnimationListener(AnimationListener listener)Removes anAnimationListenerto this animation.java.lang.StringtoString()Returns a string representation for this animation.
-
-
-
Field Detail
-
duration
private final long duration
-
freezed
private final boolean freezed
-
listenerList
private final java.util.List<AnimationListener> listenerList
-
active
private boolean active
-
-
Constructor Detail
-
AbstractAnimation
protected AbstractAnimation(long duration)
Constructs anAnimationwith the specified duration.- Parameters:
duration- the animation's duration
-
AbstractAnimation
protected AbstractAnimation(long duration, boolean freezed)Constructs anAnimationwith the specified duration and freezed mode.- Parameters:
duration- the animation's durationfreezed- true indicates that the effect will be retained after the animation is finished, false resets the effect to the time 0
-
-
Method Detail
-
duration
public final long duration()
Returns this animation's duration.
-
isFreezed
public final boolean isFreezed()
Answers whether the animation effect should be freezed after we exceeded the animation's duration. If this is not the case, the animation effect of time 0 will be set.- Returns:
- true indicates that the effect will be retained if the animation duration exceeded; false indicates that the effect will be reset
-
applyEffect
protected abstract void applyEffect(long time)
Applies the animation effect for the given time to the animation target.- Parameters:
time- the time used to determine the animation effect
-
animate
public void animate(long time)
Performs the animation at the given time: applies the animation effect to the animation target, fires appropriate events, and resets the effect if we exceeded the animations duration.
-
addAnimationListener
public final void addAnimationListener(AnimationListener listener)
Adds anAnimationListenerto this animation.- Specified by:
addAnimationListenerin interfaceAnimation- Parameters:
listener- theAnimationListenerto add
-
removeAnimationListener
public final void removeAnimationListener(AnimationListener listener)
Removes anAnimationListenerto this animation.- Specified by:
removeAnimationListenerin interfaceAnimation- Parameters:
listener- theAnimationListenerto remove
-
fireAnimationStarted
protected final void fireAnimationStarted(long time)
Fires an event that indicates that the animation has been started at the specified time. The event is created lazily.- Parameters:
time- the time that will be reported in the event
-
fireAnimationStopped
protected final void fireAnimationStopped(long time)
Fires an event that indicates that the animation has been stopped at the specified time. The event is created lazily.- Parameters:
time- the time that will be reported in the event
-
toString
public java.lang.String toString()
Returns a string representation for this animation.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation for this animation
-
-