@Immutable @Utility public final class TriggerUtility extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static Trigger |
addActionTrigger(java.lang.Object object,
Animator target)
Creates an action trigger and adds it as an
ActionListener to the
passed object. |
static Trigger |
addFocusTrigger(javax.swing.JComponent component,
Animator target,
FocusTriggerEvent event)
Creates a non-auto-reversing focus trigger and adds it as a
FocusListener to the passed component. |
static Trigger |
addFocusTrigger(javax.swing.JComponent component,
Animator target,
FocusTriggerEvent event,
boolean autoReverse)
Creates a focus trigger and adds it as a
FocusListener to the
passed component. |
static Trigger |
addMouseTrigger(javax.swing.JComponent component,
Animator target,
MouseTriggerEvent event)
Creates a non-auto-reversing mouse trigger and adds it as a
MouseListener to the passed component. |
static Trigger |
addMouseTrigger(javax.swing.JComponent component,
Animator target,
MouseTriggerEvent event,
boolean autoReverse)
Creates a mouse trigger and adds it as a
MouseListener to the
passed component. |
static Trigger |
addTimingTrigger(Animator source,
Animator target,
TimingTriggerEvent event)
Creates a non-auto-reversing timing trigger and adds it as a target to the
source animation.
|
static Trigger |
addTimingTrigger(Animator source,
Animator target,
TimingTriggerEvent event,
boolean autoReverse)
Creates a timing trigger and adds it as a target to the source animation.
|
public static Trigger addTimingTrigger(Animator source, Animator target, TimingTriggerEvent event)
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);
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.java.lang.IllegalArgumentException
- if any of the parameters is null
.TimingTrigger
public static Trigger addTimingTrigger(Animator source, Animator target, TimingTriggerEvent event, boolean autoReverse)
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);
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.java.lang.IllegalArgumentException
- if any of the parameters is null
.TimingTrigger
public static Trigger addActionTrigger(java.lang.Object object, Animator target)
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);
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.java.lang.IllegalArgumentException
- if either of the parameters is null
or if object
has no addActionListener
method.public static Trigger addFocusTrigger(javax.swing.JComponent component, Animator target, FocusTriggerEvent event)
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);
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.java.lang.IllegalArgumentException
- if any of the parameters is null
.public static Trigger addFocusTrigger(javax.swing.JComponent component, Animator target, FocusTriggerEvent event, boolean autoReverse)
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);
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.java.lang.IllegalArgumentException
- if any of the parameters is null
.public static Trigger addMouseTrigger(javax.swing.JComponent component, Animator target, MouseTriggerEvent event)
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);
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.java.lang.IllegalArgumentException
- if any of the parameters is null
.public static Trigger addMouseTrigger(javax.swing.JComponent component, Animator target, MouseTriggerEvent event, boolean autoReverse)
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);
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.java.lang.IllegalArgumentException
- if any of the parameters is null
.