@ThreadSafe(implementationOnly=true) public class TimingTargetAdapter extends java.lang.Object implements TimingTarget
TimingTarget
interface, providing stubs for all timing
target methods. Subclasses may extend this adapter rather than implementing
the TimingTarget
interface if they only care about a subset of the
events provided. For example, sequencing animations may only require
monitoring the TimingTarget.end(org.jdesktop.core.animation.timing.Animator)
method, so subclasses of this adapter
may ignore the other methods such as timingEvent.
This class provides a useful "debug" name via setDebugName(String)
and getDebugName()
. The debug name is also output by
toString()
. This feature is intended to aid debugging.
Constructor and Description |
---|
TimingTargetAdapter() |
Modifier and Type | Method and Description |
---|---|
void |
begin(Animator source)
Called once when the animation begins.
|
void |
end(Animator source)
Called once when the animation ends.
|
java.lang.String |
getDebugName() |
void |
repeat(Animator source)
Called when the animation repeats the animation cycle.
|
void |
reverse(Animator source)
Called when a running animation is reversed via
Animator.reverseNow() . |
void |
setDebugName(java.lang.String name) |
void |
timingEvent(Animator source,
double fraction)
This method will receive all of the timing events during an animation.
|
java.lang.String |
toString() |
public void begin(Animator source)
TimingTarget
This is always the first call made to any timing target.
begin
in interface TimingTarget
source
- the animation.public void end(Animator source)
TimingTarget
This is always the last call made to any timing target.
end
in interface TimingTarget
source
- the animation.public void repeat(Animator source)
TimingTarget
Animator.getRepeatCount()
- 1 times, unless
Animator.getRepeatCount()
== Animator.INFINITE
in which
case it will be invoked until the animation is manually stopped.
if Animator.RepeatBehavior.REVERSE
is used then the animation will
reverse direction on repeat.
repeat
in interface TimingTarget
source
- the animation.public void reverse(Animator source)
TimingTarget
Animator.reverseNow()
. This method is not invoked when
Animator.startReverse()
is called or when the direction changes on
repeat—it is only used as a notification when an animation is
reversed via Animator.reverseNow()
.
Notifications occur at the rate of the TimingSource
being used by
the animation. Therefore, several calls to Animator.reverseNow()
may be coalesced into a single call of this method. However, all directed
reversals take place, i.e., calls to Animator.reverseNow()
are not
ignored.
It is also possible, if Animator.RepeatBehavior.REVERSE
is used,
that a repeat which reverses the animation could occur during the same tick
of the TimingSource
that a reversal due to
Animator.reverseNow()
does. In this case both reversals are taken
into account before this method is invoked. If this occurs this method is
invoked before TimingTarget.repeat(Animator)
.
Overall, client code should understand that this method is not a general
notification that the animation's direction has changed. If such a
mechanism is needed the value of Animator.getCurrentDirection()
should be monitored in calls to TimingTarget.timingEvent(Animator, double)
.
This method's purpose is to inform that the Animator.reverseNow()
method has been invoked one or more times on the animation.
reverse
in interface TimingTarget
source
- the animation.public void timingEvent(Animator source, double fraction)
TimingTarget
timingEvent
in interface TimingTarget
source
- the animation.fraction
- the fraction of completion between the start and end of the
current cycle. Note that on reversing cycles (
Animator.Direction.BACKWARD
) the fraction decreases from
1.0 to 0 on backwards-running cycles (A call to
Animator.getCurrentDirection()
will report which direction
the animation is going). Note also that animations with a duration
of INFINITE
will have an undefined value
for the fraction, since there is no fraction that makes sense if
the animation has no defined length.public final void setDebugName(@Nullable java.lang.String name)
@Nullable public final java.lang.String getDebugName()
public java.lang.String toString()
toString
in class java.lang.Object