org.jdesktop.swing.animation.timing.triggers
Class TriggerUtility

java.lang.Object
  extended by org.jdesktop.swing.animation.timing.triggers.TriggerUtility

@Immutable
@Utility
public final class TriggerUtility
extends Object

A utility that creates triggers for Swing applications.

Author:
Chet Haase, Tim Halloran

Method Summary
static org.jdesktop.core.animation.timing.Trigger addActionTrigger(Object object, org.jdesktop.core.animation.timing.Animator target)
          Creates an action trigger and adds it as an ActionListener to the passed object.
static org.jdesktop.core.animation.timing.Trigger addFocusTrigger(JComponent component, org.jdesktop.core.animation.timing.Animator target, org.jdesktop.core.animation.timing.triggers.FocusTriggerEvent event)
          Creates a non-auto-reversing focus trigger and adds it as a FocusListener to the passed component.
static org.jdesktop.core.animation.timing.Trigger addFocusTrigger(JComponent component, org.jdesktop.core.animation.timing.Animator target, org.jdesktop.core.animation.timing.triggers.FocusTriggerEvent event, boolean autoReverse)
          Creates a focus trigger and adds it as a FocusListener to the passed component.
static org.jdesktop.core.animation.timing.Trigger addMouseTrigger(JComponent component, org.jdesktop.core.animation.timing.Animator target, org.jdesktop.core.animation.timing.triggers.MouseTriggerEvent event)
          Creates a non-auto-reversing mouse trigger and adds it as a MouseListener to the passed component.
static org.jdesktop.core.animation.timing.Trigger addMouseTrigger(JComponent component, org.jdesktop.core.animation.timing.Animator target, org.jdesktop.core.animation.timing.triggers.MouseTriggerEvent event, boolean autoReverse)
          Creates a mouse trigger and adds it as a MouseListener to the passed component.
static org.jdesktop.core.animation.timing.Trigger addTimingTrigger(org.jdesktop.core.animation.timing.Animator source, org.jdesktop.core.animation.timing.Animator target, org.jdesktop.core.animation.timing.triggers.TimingTriggerEvent event)
          Creates a non-auto-reversing timing trigger and adds it as a target to the source animation.
static org.jdesktop.core.animation.timing.Trigger addTimingTrigger(org.jdesktop.core.animation.timing.Animator source, org.jdesktop.core.animation.timing.Animator target, org.jdesktop.core.animation.timing.triggers.TimingTriggerEvent event, boolean autoReverse)
          Creates a timing trigger and adds it as a target to the source animation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addTimingTrigger

public static org.jdesktop.core.animation.timing.Trigger addTimingTrigger(org.jdesktop.core.animation.timing.Animator source,
                                                                          org.jdesktop.core.animation.timing.Animator target,
                                                                          org.jdesktop.core.animation.timing.triggers.TimingTriggerEvent event)
Creates a non-auto-reversing timing trigger and adds it as a target to the source animation. 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:
 Trigger trigger = TimingTrigger.addTrigger(anim1, anim2, TimingTriggerEvent.STOP);
 
The returned trigger object can be safely ignored if the code never needs to disarm the trigger.
 TimingTrigger.addTrigger(anim1, anim2, TimingTriggerEvent.STOP);
 

Parameters:
source - the animation that will be listened to for events to start the target animation.
target - the animation that will start when the event occurs.
event - the TimingTriggerEvent on source that will cause target to start.
Returns:
the resulting trigger.
Throws:
IllegalArgumentException - if any of the parameters is null.
See Also:
TimingTrigger

addTimingTrigger

public static org.jdesktop.core.animation.timing.Trigger addTimingTrigger(org.jdesktop.core.animation.timing.Animator source,
                                                                          org.jdesktop.core.animation.timing.Animator target,
                                                                          org.jdesktop.core.animation.timing.triggers.TimingTriggerEvent event,
                                                                          boolean autoReverse)
Creates a timing trigger and adds it as a target to the source animation. For example, one Animator can be set to start when another ends using this trigger. For example, to have anim2 start when anim1 ends and visa versa, have anim2 stop when anim1 starts, one might write the following:
 Trigger trigger = TimingTrigger.addTrigger(anim1, anim2, TimingTriggerEvent.STOP, true);
 
The returned trigger object can be safely ignored if the code never needs to disarm the trigger.
 TimingTrigger.addTrigger(anim1, anim2, TimingTriggerEvent.STOP, true);
 

Parameters:
source - the animation that will be listened to for events to start the target animation.
target - the animation that will start when the event occurs.
event - the TimingTriggerEvent on source that will cause target to start.
autoReverse - true if the animation should be reversed on opposite trigger events, false otherwise.
Returns:
the resulting trigger.
Throws:
IllegalArgumentException - if any of the parameters is null.
See Also:
TimingTrigger

addActionTrigger

public static org.jdesktop.core.animation.timing.Trigger addActionTrigger(Object object,
                                                                          org.jdesktop.core.animation.timing.Animator target)
Creates an action trigger and adds it as an ActionListener to the passed object. For example, to have anim start when a button is clicked, one might write the following:
 Trigger trigger = TriggerUtility.addActionTrigger(button, anim);
 
The returned trigger object can be safely ignored if the code never needs to disarm the trigger.
 TriggerUtility.addActionTrigger(button, anim);
 

Parameters:
object - an object that will be used as an event source for this trigger. This object must have an addActionListener method.
target - the animation that will start when the event occurs.
Returns:
the resulting trigger.
Throws:
IllegalArgumentException - if either of the parameters is null or if object has no addActionListener method.

addFocusTrigger

public static org.jdesktop.core.animation.timing.Trigger addFocusTrigger(JComponent component,
                                                                         org.jdesktop.core.animation.timing.Animator target,
                                                                         org.jdesktop.core.animation.timing.triggers.FocusTriggerEvent event)
Creates a non-auto-reversing focus trigger and adds it as a FocusListener to the passed component. For example, to have anim start when component receives an IN event, one might write the following:
 Trigger trigger = TriggerUtility.addFocusTrigger(component, anim, FocusTriggerEvent.IN);
 
The returned trigger object can be safely ignored if the code never needs to disarm the trigger.
 TriggerUtility.addFocusTrigger(component, anim, FocusTriggerEvent.IN);
 

Parameters:
component - the component that will generate focus events for this trigger.
target - the animation that will start when the event occurs.
event - the FocusTriggerEvent on component that will cause target to start.
Returns:
the resulting trigger.
Throws:
IllegalArgumentException - if any of the parameters is null.

addFocusTrigger

public static org.jdesktop.core.animation.timing.Trigger addFocusTrigger(JComponent component,
                                                                         org.jdesktop.core.animation.timing.Animator target,
                                                                         org.jdesktop.core.animation.timing.triggers.FocusTriggerEvent event,
                                                                         boolean autoReverse)
Creates a focus trigger and adds it as a FocusListener to the passed component. For example, to have anim start when component receives an IN event, and reverse anim when component receives an OUT event, one might write the following:
 Trigger trigger = TriggerUtility.addFocusTrigger(component, anim, FocusTriggerEvent.IN, true);
 
The returned trigger object can be safely ignored if the code never needs to disarm the trigger.
 TriggerUtility.addFocusTrigger(component, anim, FocusTriggerEvent.IN, true);
 

Parameters:
component - the component that will generate focus events for this trigger.
target - the animation that will start when the event occurs.
event - the FocusTriggerEvent on component that will cause target to start.
autoReverse - true if the animation should be reversed on opposite trigger events, false otherwise.
Returns:
the resulting trigger.
Throws:
IllegalArgumentException - if any of the parameters is null.

addMouseTrigger

public static org.jdesktop.core.animation.timing.Trigger addMouseTrigger(JComponent component,
                                                                         org.jdesktop.core.animation.timing.Animator target,
                                                                         org.jdesktop.core.animation.timing.triggers.MouseTriggerEvent event)
Creates a non-auto-reversing mouse trigger and adds it as a MouseListener to the passed component. For example, to have anim start when component receives an CLICK event, one might write the following:
 Trigger trigger = TriggerUtility.addMouseTrigger(component, anim, MouseTriggerEvent.CLICK);
 
The returned trigger object can be safely ignored if the code never needs to disarm the trigger.
 TriggerUtility.addMouseTrigger(component, anim, MouseTriggerEvent.CLICK);
 

Parameters:
component - the component that will generate mouse events for this trigger.
target - the animation that will start when the event occurs.
event - the MouseTriggerEvent on component that will cause target to start.
Returns:
the resulting trigger.
Throws:
IllegalArgumentException - if any of the parameters is null.

addMouseTrigger

public static org.jdesktop.core.animation.timing.Trigger addMouseTrigger(JComponent component,
                                                                         org.jdesktop.core.animation.timing.Animator target,
                                                                         org.jdesktop.core.animation.timing.triggers.MouseTriggerEvent event,
                                                                         boolean autoReverse)
Creates a mouse trigger and adds it as a MouseListener to the passed component. For example, to have anim start when component receives an ENTER event, and reverse anim when component receives an EXIT event, one might write the following:
 Trigger trigger = TriggerUtility.addMouseTrigger(component, anim, MouseTriggerEvent.ENTER, true);
 
The returned trigger object can be safely ignored if the code never needs to disarm the trigger.
 TriggerUtility.addMouseTrigger(component, anim, MouseTriggerEvent.ENTER, true);
 

Parameters:
component - the component that will generate mouse events for this trigger.
target - the animation that will start when the event occurs.
event - the MouseTriggerEvent on component that will cause target to start.
autoReverse - true if the animation should be reversed on opposite trigger events, false otherwise.
Returns:
the resulting trigger.
Throws:
IllegalArgumentException - if any of the parameters is null.


Copyright © 2012. All Rights Reserved.