Class TimingTrigger
- java.lang.Object
-
- org.jdesktop.animation.timing.triggers.Trigger
-
- org.jdesktop.animation.timing.triggers.TimingTrigger
-
- All Implemented Interfaces:
TimingTarget
public class TimingTrigger extends Trigger implements TimingTarget
TimingTrigger handles timing events and starts the animator when those events occur. This class can be useful in sequencing different Animators. For example, one Animator can be set to start when another ends using this Trigger. For example, to have anim2 start when anim1 ends, one might write the following:TimingTrigger trigger = TimingTrigger.addTrigger(anim1, anim2, TimingTriggerEvent.STOP);
-
-
Constructor Summary
Constructors Constructor Description TimingTrigger(Animator animator, TimingTriggerEvent event)
Creates a non-auto-reversing TimingTrigger, which should be added to an Animator which will generate the events sent to the trigger.TimingTrigger(Animator animator, TimingTriggerEvent event, boolean autoReverse)
Creates a TimingTrigger, which should be added to an Animator which will generate the events sent to the trigger.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TimingTrigger
addTrigger(Animator source, Animator target, TimingTriggerEvent event)
Creates a non-auto-reversing TimingTrigger and adds it as a target to the source Animator.static TimingTrigger
addTrigger(Animator source, Animator target, TimingTriggerEvent event, boolean autoReverse)
Creates a TimingTrigger and adds it as a target to the source Animator.void
begin()
Called by Animator when starting.void
end()
Called by Animator when ending.void
repeat()
Called by Animator when repeating.void
timingEvent(float fraction)
Implementation of TimingTarget method; this method does nothing in this implementation since the events of TimingTrigger are limited to START, STOP, and REPEAT
-
-
-
Constructor Detail
-
TimingTrigger
public TimingTrigger(Animator animator, TimingTriggerEvent event)
Creates a non-auto-reversing TimingTrigger, which should be added to an Animator which will generate the events sent to the trigger.
-
TimingTrigger
public TimingTrigger(Animator animator, TimingTriggerEvent event, boolean autoReverse)
Creates a TimingTrigger, which should be added to an Animator which will generate the events sent to the trigger.
-
-
Method Detail
-
addTrigger
public static TimingTrigger addTrigger(Animator source, Animator target, TimingTriggerEvent event)
Creates a non-auto-reversing TimingTrigger and adds it as a target to the source Animator.- Parameters:
source
- the Animator that will be listened to for events to start the target Animatortarget
- the Animator that will start when the event occursevent
- the TimingTriggerEvent that will cause targetAnimator to start- Returns:
- TimingTrigger the resulting trigger
- See Also:
Animator.addTarget(TimingTarget)
-
addTrigger
public static TimingTrigger addTrigger(Animator source, Animator target, TimingTriggerEvent event, boolean autoReverse)
Creates a TimingTrigger and adds it as a target to the source Animator.- Parameters:
source
- the Animator that will be listened to for events to start the target Animatortarget
- the Animator that will start when the event occursevent
- the TimingTriggerEvent that will cause targetAnimator to startautoReverse
- flag to determine whether the animator should stop and reverse based on opposite triggerEvents.- Returns:
- TimingTrigger the resulting trigger
- See Also:
Animator.addTarget(TimingTarget)
-
timingEvent
public void timingEvent(float fraction)
Implementation of TimingTarget method; this method does nothing in this implementation since the events of TimingTrigger are limited to START, STOP, and REPEAT- Specified by:
timingEvent
in interfaceTimingTarget
- Parameters:
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. Note also that animations with a duration ofINFINITE
will call timingEvent with an undefined value for fraction, since there is no fraction that makes sense if the animation has no defined length.- See Also:
Animator.Direction
-
begin
public void begin()
Called by Animator when starting. Sends the TimingTriggerEvent.START event to the Trigger.- Specified by:
begin
in interfaceTimingTarget
-
end
public void end()
Called by Animator when ending. Sends the TimingTriggerEvent.STOP event to the Trigger.- Specified by:
end
in interfaceTimingTarget
-
repeat
public void repeat()
Called by Animator when repeating. Sends the TimingTriggerEvent.REPEAT event to the Trigger.- Specified by:
repeat
in interfaceTimingTarget
-
-