org.jvnet.lafwidget.animation
Class FadeStateListener

java.lang.Object
  extended by org.jvnet.lafwidget.animation.FadeStateListener

public class FadeStateListener
extends java.lang.Object

Implements listener on model changes of some component. Once model changes (select, arm, focus, ...), the listener notifies the FadeTracker.

Author:
Kirill Grouchnikov

Field Summary
protected  javax.swing.ButtonModel buttonModel
          The associated model.
protected  FadeTrackerCallback callback
          Optional application callback.
protected  java.awt.Component comp
          The associated component.
protected  java.lang.Comparable<?> extraKey
           
protected  java.awt.event.FocusListener focusListener
          Listener on the focus gain and loss.
protected  long focusLoopFadeInstanceId
          Instance ID of focus loop animation.
protected  javax.swing.event.ChangeListener modelListener
          Listener on the model changes.
protected  java.util.Map<FadeKind,java.lang.Boolean> prevStateMap
          Key - FadeKind, value - Boolean
protected  java.util.Set<FadeKind> toIgnore
          A set of fade kinds to ignore.
 
Constructor Summary
FadeStateListener(java.awt.Component comp, javax.swing.ButtonModel buttonModel, FadeTrackerCallback callback)
          Creates a new listener on model changes that can cause fade animation transitions.
FadeStateListener(java.awt.Component comp, java.lang.Comparable<?> extraKey, javax.swing.ButtonModel buttonModel, FadeTrackerCallback callback, java.util.Set<FadeKind> toIgnore)
          Creates a new listener on model changes that can cause fade animation transitions.
 
Method Summary
protected  void initiateFocusFadeLoop()
          Initiates the looping animation on focus ring.
 void registerListeners()
          Registers listeners on all model changes.
 void registerListeners(boolean toRepaintParent)
          Registers listeners on all model changes.
protected  void trackModelChange(FadeKind fadeKind, boolean newValue, boolean toRepaintParent)
          Tracks a single change to the model.
 void unregisterListeners()
          Unregisters all listeners on model changes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

callback

protected FadeTrackerCallback callback
Optional application callback.


comp

protected java.awt.Component comp
The associated component.


buttonModel

protected javax.swing.ButtonModel buttonModel
The associated model.


extraKey

protected java.lang.Comparable<?> extraKey

prevStateMap

protected java.util.Map<FadeKind,java.lang.Boolean> prevStateMap
Key - FadeKind, value - Boolean


modelListener

protected javax.swing.event.ChangeListener modelListener
Listener on the model changes.


focusListener

protected java.awt.event.FocusListener focusListener
Listener on the focus gain and loss.


focusLoopFadeInstanceId

protected long focusLoopFadeInstanceId
Instance ID of focus loop animation.


toIgnore

protected java.util.Set<FadeKind> toIgnore
A set of fade kinds to ignore.

Constructor Detail

FadeStateListener

public FadeStateListener(java.awt.Component comp,
                         javax.swing.ButtonModel buttonModel,
                         FadeTrackerCallback callback)
Creates a new listener on model changes that can cause fade animation transitions.

Parameters:
comp - Component.
buttonModel - Model for the component.
callback - Optional application callback.

FadeStateListener

public FadeStateListener(java.awt.Component comp,
                         java.lang.Comparable<?> extraKey,
                         javax.swing.ButtonModel buttonModel,
                         FadeTrackerCallback callback,
                         java.util.Set<FadeKind> toIgnore)
Creates a new listener on model changes that can cause fade animation transitions.

Parameters:
comp - Component.
buttonModel - Model for the component.
callback - Optional application callback.
toIgnore - Set of fade kinds to ignore.
Method Detail

trackModelChange

protected void trackModelChange(FadeKind fadeKind,
                                boolean newValue,
                                boolean toRepaintParent)
Tracks a single change to the model.

Parameters:
fadeKind - Fade animation kind.
newValue - New value of the relevant attribute of the model.
toRepaintParent - If true, the component parent will be repainted at every animation cycle. If false, the component itself will be repainted at every animation cycle.

registerListeners

public void registerListeners()
Registers listeners on all model changes.


registerListeners

public void registerListeners(boolean toRepaintParent)
Registers listeners on all model changes.

Parameters:
toRepaintParent - If true, the component parent will be repainted at every animation cycle. If false, the component itself will be repainted at every animation cycle.

initiateFocusFadeLoop

protected void initiateFocusFadeLoop()
Initiates the looping animation on focus ring.


unregisterListeners

public void unregisterListeners()
Unregisters all listeners on model changes.