Class Trigger
- java.lang.Object
-
- org.jdesktop.animation.timing.triggers.Trigger
-
- Direct Known Subclasses:
ActionTrigger
,FocusTrigger
,MouseTrigger
,TimingTrigger
public abstract class Trigger extends java.lang.Object
This abstract class should be overridden by any class wanting to implement a new Trigger. The subclass will define the events to trigger off of and any listeners to handle those events. That subclass will call eitherfire()
orfire(TriggerEvent)
to start the animator based on an event that occurred.Subclasses should call one of the constructors in Trigger, according to whether they want Trigger to discern between different TriggerEvents and whether they want Trigger to auto-reverse the animation based on opposite TriggerEvents.
Subclasses should call one of the
fire
methods based on whether they want Trigger to perform any event logic or simply start the animation.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Trigger(Animator animator)
Creates a Trigger that will start the animator whenfire()
is called.protected
Trigger(Animator animator, TriggerEvent triggerEvent)
Creates a Trigger that will start the animator whenfire(TriggerEvent)
is called with an event that equals triggerEvent.protected
Trigger(Animator animator, TriggerEvent triggerEvent, boolean autoReverse)
Creates a Trigger that will start the animator whenfire(TriggerEvent)
is called with an event that equals triggerEvent.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
disarm()
This method disables this Trigger and effectively noop's any actions that would otherwise occurprotected void
fire()
Utility method called by subclasses to start the animator.protected void
fire(TriggerEvent currentEvent)
Called by subclasses to start the animator if currentEvent equals the event that the Trigger is based upon.
-
-
-
Constructor Detail
-
Trigger
protected Trigger(Animator animator)
Creates a Trigger that will start the animator whenfire()
is called. Subclasses call this method to set up a simple Trigger that will be started by callingfire()
, and will have no dependency upon the specificTriggerEvent
that must have occurred to start the animator.- Parameters:
animator
- the Animator that will start when the Trigger is fired
-
Trigger
protected Trigger(Animator animator, TriggerEvent triggerEvent)
Creates a Trigger that will start the animator whenfire(TriggerEvent)
is called with an event that equals triggerEvent.- Parameters:
animator
- the Animator that will start when the Trigger is firedtriggerEvent
- the TriggerEvent that must occur for this Trigger to fire
-
Trigger
protected Trigger(Animator animator, TriggerEvent triggerEvent, boolean autoReverse)
Creates a Trigger that will start the animator whenfire(TriggerEvent)
is called with an event that equals triggerEvent. Also, automatically stops and reverses animator when opposite event occurs, and stops reversing animator likewise when triggerEvent occurs.- Parameters:
animator
- the Animator that will start when the Trigger is firedtriggerEvent
- the TriggerEvent that must occur for this Trigger to fireautoReverse
- flag to determine whether the animator should stop and reverse based on opposite triggerEvents.- See Also:
TriggerEvent.getOppositeEvent()
-
-
Method Detail
-
disarm
public void disarm()
This method disables this Trigger and effectively noop's any actions that would otherwise occur
-
fire
protected void fire(TriggerEvent currentEvent)
Called by subclasses to start the animator if currentEvent equals the event that the Trigger is based upon. Also, if the Trigger is set to autoReverse, stops and reverses the animator running in the opposite direction as appropriate.- Parameters:
currentEvent
- theTriggerEvent
that just occurred, which will be compared with the TriggerEvent used to construct this Trigger and determine whether the animator should be started or reversed
-
fire
protected void fire()
Utility method called by subclasses to start the animator. This variant assumes that there need be no check of the TriggerEvent that fired, which is useful for subclasses with simple events.
-
-