Package org.jdesktop.animation.timing.triggers

# Class Trigger

java.lang.Object
org.jdesktop.animation.timing.triggers.Trigger

Direct Known Subclasses:
  `ActionTrigger`, `FocusTrigger`, `MouseTrigger`, `TimingTrigger`

public abstract class Trigger extends 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 either `fire()` or `fire(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 when `fire()` is called.
`protected`
`Trigger(Animator animator, TriggerEvent triggerEvent)`
Creates a Trigger that will start the animator when `fire(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 when `fire(TriggerEvent)` is called with an event that equals triggerEvent.

## Method Summary

Modifier and Type
Method
Description
`void`
`disarm()`
This method disables this Trigger and effectively noop's any actions that would otherwise occur
`protected 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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### Trigger

protected Trigger(Animator animator)
Creates a Trigger that will start the animator when `fire()` is called. Subclasses call this method to set up a simple Trigger that will be started by calling `fire()`, and will have no dependency upon the specific `TriggerEvent` 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 when `fire(TriggerEvent)` is called with an event that equals triggerEvent.

Parameters:
  `animator` - the Animator that will start when the Trigger is fired
  `triggerEvent` - 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 when `fire(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 fired
  `triggerEvent` - the TriggerEvent that must occur for this Trigger to fire
  `autoReverse` - flag to determine whether the animator should stop and reverse based on opposite triggerEvents.
See Also:
  - `TriggerEvent.getOppositeEvent()`

## Method Details

### 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` - the `TriggerEvent` 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.