org.jvnet.lafwidget.animation
Class FadeTracker

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

public class FadeTracker
extends java.lang.Object

Tracker class for fade animations.

Author:
Kirill Grouchnikov

Nested Class Summary
protected static class FadeTracker.ComponentId
          Information on a single component under fade.
 
Field Summary
static boolean DEBUG_MODE
          Debug mode indicator.
static int END_VALUE
          Max value for fade cycle.
 
Method Summary
 void cancelFadeInstance(long fadeInstanceId)
          Cancels the specified fade instance.
 java.util.Set<java.awt.Component> getAllComponentsByFadeKind(FadeKind fadeKind)
          Returns all components that are currently under the specified fade kind.
 long getCurrLoopId()
          Returns the ID of the current loop iteration.
 float getFade10(java.awt.Component comp, java.lang.Comparable<?> componentId, FadeKind fadeKind)
          Returns the fade cycle for the specified component.
 float getFade10(java.awt.Component comp, FadeKind fadeKind)
          Returns the fade cycle for the specified component.
 float getFade10(java.awt.Component comp, int componentId, FadeKind fadeKind)
          Returns the fade cycle for the specified component.
 FadeState getFadeState(java.awt.Component comp, java.lang.Comparable<?> componentId, FadeKind fadeKind)
          Returns the fade state of specified component if it's being tracked by this tracker or null.
 FadeState getFadeState(java.awt.Component comp, FadeKind fadeKind)
          Returns the fade state of specified component if it's being tracked by this tracker or null.
 FadeState getFadeState(java.awt.Component comp, int componentId, FadeKind fadeKind)
          Returns the fade state of specified component if it's being tracked by this tracker or null.
static FadeTracker getInstance()
          Gets singleton instance.
 boolean isTracked(java.awt.Component comp, java.lang.Comparable<?> componentId, FadeKind fadeKind)
          Checks whether the specified component is being tracked by this tracker.
 boolean isTracked(java.awt.Component comp, java.lang.Comparable<?> componentId, FadeKind fadeKind, boolean checkFadeIn)
          Checks whether the specified component is being tracked by this tracker.
 boolean isTracked(java.awt.Component comp, FadeKind fadeKind)
          Checks whether the specified component is being tracked by this tracker.
 boolean isTracked(java.awt.Component comp, int componentId, FadeKind fadeKind)
          Checks whether the specified component is being tracked by this tracker.
 void requestStopOnCycleBreak(long fadeInstanceId)
          Requests that the specified fade instance should stop at the end of the fade-out.
 void stopAllTimers()
          Stops tracking of all components.
 long trackFade(java.awt.Component comp, FadeKind fadeKind, boolean isFadeIn, boolean toRepaintParent)
          Requests start of fade tracking on the specified component.
 long trackFade(java.awt.Component comp, FadeKind fadeKind, boolean isFadeIn, boolean toRepaintParent, FadeTrackerCallback callback)
          Requests start of fade tracking on the specified component.
 long trackFadeIn(FadeKind fadeKind, java.awt.Component comp, boolean toRepaintParent, FadeTrackerCallback callback)
          Requests start of fade-in tracking on the specified component.
 long trackFadeIn(FadeKind fadeKind, java.awt.Component comp, java.lang.Comparable<?> componentId, boolean toRepaintParent, FadeTrackerCallback callback)
          Requests start of fade-in tracking on the specified component.
 long trackFadeIn(FadeKind fadeKind, java.awt.Component comp, java.lang.Comparable<?> componentId, boolean toRepaintParent, FadeTrackerCallback callback, LafConstants.AnimationKind aKind)
          Requests start of fade-in tracking on the specified component.
 long trackFadeIn(FadeKind fadeKind, java.awt.Component comp, int componentId, boolean toRepaintParent, FadeTrackerCallback callback)
          Requests start of fade-in tracking on the specified component.
 long trackFadeLooping(FadeKind fadeKind, LafConstants.AnimationKind animationKind, java.awt.Component comp, java.lang.Comparable<?> componentId, boolean toRepaintParent, FadeTrackerCallback callback, int loopCount, boolean isLoopingReverse)
          Requests start of looping fade tracking on the specified component.
 long trackFadeOut(FadeKind fadeKind, java.awt.Component comp, boolean toRepaintParent, FadeTrackerCallback callback)
          Requests start of fade-out tracking on the specified component.
 long trackFadeOut(FadeKind fadeKind, java.awt.Component comp, java.lang.Comparable<?> componentId, boolean toRepaintParent, FadeTrackerCallback callback)
          Requests start of fade-out tracking on the specified component.
 long trackFadeOut(FadeKind fadeKind, java.awt.Component comp, java.lang.Comparable<?> componentId, boolean toRepaintParent, FadeTrackerCallback callback, LafConstants.AnimationKind aKind)
          Requests start of fade-out tracking on the specified component.
 long trackFadeOut(FadeKind fadeKind, java.awt.Component comp, int componentId, boolean toRepaintParent, FadeTrackerCallback callback)
          Requests start of fade-out tracking on the specified component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

END_VALUE

public static final int END_VALUE
Max value for fade cycle.

See Also:
Constant Field Values

DEBUG_MODE

public static boolean DEBUG_MODE
Debug mode indicator. Set to true to have trace messages on console.

Method Detail

getInstance

public static FadeTracker getInstance()
Gets singleton instance.

Returns:
Singleton instance.

trackFadeIn

public long trackFadeIn(FadeKind fadeKind,
                        java.awt.Component comp,
                        boolean toRepaintParent,
                        FadeTrackerCallback callback)
Requests start of fade-in tracking on the specified component.

Parameters:
fadeKind - Fade kind.
comp - The component to track.
toRepaintParent - Indication whether the component parent should be repainted.
callback - Optional callback to be called on each fade cycle.
Returns:
ID of the fade instance. Guaranteed to be unique. Value -1 signifies that there was no fade instance created (this may happen when the specified component is not visible).

trackFadeIn

public long trackFadeIn(FadeKind fadeKind,
                        java.awt.Component comp,
                        int componentId,
                        boolean toRepaintParent,
                        FadeTrackerCallback callback)
Requests start of fade-in tracking on the specified component.

Parameters:
fadeKind - Fade kind.
comp - The component to track.
componentId - Component id. Relevant for such components as tabbed panes (where fade is performed on component "sub" parts).
toRepaintParent - Indication whether the component parent should be repainted.
callback - Optional callback to be called on each fade cycle.
Returns:
ID of the fade instance. Guaranteed to be unique. Value -1 signifies that there was no fade instance created (this may happen when the specified component is not visible).

trackFadeIn

public long trackFadeIn(FadeKind fadeKind,
                        java.awt.Component comp,
                        java.lang.Comparable<?> componentId,
                        boolean toRepaintParent,
                        FadeTrackerCallback callback)
Requests start of fade-in tracking on the specified component.

Parameters:
fadeKind - Fade kind.
comp - The component to track.
componentId - Component id. Relevant for such components as tabbed panes, lists, tables, trees and others (where fade is performed on component "sub" parts). May be null.
toRepaintParent - Indication whether the component parent should be repainted.
callback - Optional callback to be called on each fade cycle.
Returns:
ID of the fade instance. Guaranteed to be unique. Value -1 signifies that there was no fade instance created (this may happen when the specified component is not visible).

trackFadeIn

public long trackFadeIn(FadeKind fadeKind,
                        java.awt.Component comp,
                        java.lang.Comparable<?> componentId,
                        boolean toRepaintParent,
                        FadeTrackerCallback callback,
                        LafConstants.AnimationKind aKind)
Requests start of fade-in tracking on the specified component.

Parameters:
fadeKind - Fade kind.
comp - The component to track.
componentId - Component id. Relevant for such components as tabbed panes, lists, tables, trees and others (where fade is performed on component "sub" parts). May be null.
toRepaintParent - Indication whether the component parent should be repainted.
callback - Optional callback to be called on each fade cycle.
aKind - Animation kind. Should not be null.
Returns:
ID of the fade instance. Guaranteed to be unique. Value -1 signifies that there was no fade instance created (this may happen when the specified component is not visible).

trackFadeOut

public long trackFadeOut(FadeKind fadeKind,
                         java.awt.Component comp,
                         boolean toRepaintParent,
                         FadeTrackerCallback callback)
Requests start of fade-out tracking on the specified component.

Parameters:
fadeKind - Fade kind.
comp - The component to track.
toRepaintParent - Indication whether the component parent should be repainted.
callback - Optional callback to be called on each fade cycle.
Returns:
ID of the fade instance. Guaranteed to be unique. Value -1 signifies that there was no fade instance created (this may happen when the specified component is not visible).

trackFadeOut

public long trackFadeOut(FadeKind fadeKind,
                         java.awt.Component comp,
                         int componentId,
                         boolean toRepaintParent,
                         FadeTrackerCallback callback)
Requests start of fade-out tracking on the specified component.

Parameters:
fadeKind - Fade kind.
comp - The component to track.
componentId - Component id. Relevant for such components as tabbed panes (where fade is performed on component "sub" parts).
toRepaintParent - Indication whether the component parent should be repainted.
callback - Optional callback to be called on each fade cycle.
Returns:
ID of the fade instance. Guaranteed to be unique. Value -1 signifies that there was no fade instance created (this may happen when the specified component is not visible).

trackFadeOut

public long trackFadeOut(FadeKind fadeKind,
                         java.awt.Component comp,
                         java.lang.Comparable<?> componentId,
                         boolean toRepaintParent,
                         FadeTrackerCallback callback)
Requests start of fade-out tracking on the specified component.

Parameters:
fadeKind - Fade kind.
comp - The component to track.
componentId - Component id. Relevant for such components as tabbed panes, lists, tables, trees and others (where fade is performed on component "sub" parts). May be null.
toRepaintParent - Indication whether the component parent should be repainted.
callback - Optional callback to be called on each fade cycle.
Returns:
ID of the fade instance. Guaranteed to be unique. Value -1 signifies that there was no fade instance created (this may happen when the specified component is not visible).

trackFadeOut

public long trackFadeOut(FadeKind fadeKind,
                         java.awt.Component comp,
                         java.lang.Comparable<?> componentId,
                         boolean toRepaintParent,
                         FadeTrackerCallback callback,
                         LafConstants.AnimationKind aKind)
Requests start of fade-out tracking on the specified component.

Parameters:
fadeKind - Fade kind.
comp - The component to track.
componentId - Component id. Relevant for such components as tabbed panes, lists, tables, trees and others (where fade is performed on component "sub" parts). May be null.
toRepaintParent - Indication whether the component parent should be repainted.
callback - Optional callback to be called on each fade cycle.
aKind - Animation kind. Should not be null.
Returns:
ID of the fade instance. Guaranteed to be unique. Value -1 signifies that there was no fade instance created (this may happen when the specified component is not visible).

trackFade

public long trackFade(java.awt.Component comp,
                      FadeKind fadeKind,
                      boolean isFadeIn,
                      boolean toRepaintParent)
Requests start of fade tracking on the specified component.

Parameters:
comp - The component to track.
fadeKind - Fade kind.
isFadeIn - Indication whether fade-in or fade-out should be commenced.
toRepaintParent - Indication whether the component parent should be repainted.
Returns:
ID of the fade instance. Guaranteed to be unique. Value -1 signifies that there was no fade instance created (this may happen when the specified component is not visible).

trackFade

public long trackFade(java.awt.Component comp,
                      FadeKind fadeKind,
                      boolean isFadeIn,
                      boolean toRepaintParent,
                      FadeTrackerCallback callback)
Requests start of fade tracking on the specified component.

Parameters:
comp - The component to track.
fadeKind - Fade kind.
isFadeIn - Indication whether fade-in or fade-out should be commenced.
toRepaintParent - Indication whether the component parent should be repainted.
callback - Optional callback to be called on each fade cycle.
Returns:
ID of the fade instance. Guaranteed to be unique. Value -1 signifies that there was no fade instance created (this may happen when the specified component is not visible).

trackFadeLooping

public long trackFadeLooping(FadeKind fadeKind,
                             LafConstants.AnimationKind animationKind,
                             java.awt.Component comp,
                             java.lang.Comparable<?> componentId,
                             boolean toRepaintParent,
                             FadeTrackerCallback callback,
                             int loopCount,
                             boolean isLoopingReverse)
Requests start of looping fade tracking on the specified component.

Parameters:
fadeKind - Fade kind.
animationKind - Animation kind.
comp - The component to track.
componentId - Component id. Relevant for such components as tabbed panes, lists, tables, trees and others (where fade is performed on component "sub" parts). May be null.
toRepaintParent - Indication whether the component parent should be repainted.
callback - Optional callback to be called on each fade cycle.
loopCount - Loop count.
isLoopingReverse - If true, when the fade value gets to the maximal value, the fade cycle will begin fade-out. Otherwise the fade cycle will begin from 0, continuing to fade-in.
Returns:
ID of the fade instance. Guaranteed to be unique. Value -1 signifies that there was no fade instance created (this may happen when the specified component is not visible).

isTracked

public boolean isTracked(java.awt.Component comp,
                         FadeKind fadeKind)
Checks whether the specified component is being tracked by this tracker. Effectively returns indication whether the specified component is in fade-in or fade-out animation of the specified kind.

Parameters:
comp - Component.
fadeKind - Fade kind.
Returns:
true if the specified component is being tracked by this tracker, false otherwise.

isTracked

public boolean isTracked(java.awt.Component comp,
                         int componentId,
                         FadeKind fadeKind)
Checks whether the specified component is being tracked by this tracker. Effectively returns indication whether the specified component is in fade-in or fade-out animation of the specified kind.

Parameters:
comp - Component.
componentId - Component id. Relevant for such components as tabbed panes (where fade is performed on component "sub" parts).
fadeKind - Fade kind.
Returns:
true if the specified component is being tracked by this tracker, false otherwise.

isTracked

public boolean isTracked(java.awt.Component comp,
                         java.lang.Comparable<?> componentId,
                         FadeKind fadeKind)
Checks whether the specified component is being tracked by this tracker. Effectively returns indication whether the specified component is in fade-in or fade-out animation of the specified kind.

Parameters:
comp - Component.
componentId - Component id. Relevant for such components as tabbed panes, lists, tables, trees and others (where fade is performed on component "sub" parts). May be null.
fadeKind - Fade kind.
Returns:
true if the specified component is being tracked by this tracker, false otherwise.

isTracked

public boolean isTracked(java.awt.Component comp,
                         java.lang.Comparable<?> componentId,
                         FadeKind fadeKind,
                         boolean checkFadeIn)
Checks whether the specified component is being tracked by this tracker. Effectively returns indication whether the specified component is in the specified animation (fade-in / fade-out) of the specified kind.

Parameters:
comp - Component.
componentId - Component id. Relevant for such components as tabbed panes, lists, tables, trees and others (where fade is performed on component "sub" parts). May be null.
fadeKind - Fade kind. May be null - not recommended.
checkFadeIn - Specifies whether the check should be done for fade-in state. If true, the returned value will be true only if the component is tracked and it is in the fade-in state.
Returns:
true if the specified component is being tracked by this tracker, false otherwise.

getFade10

public float getFade10(java.awt.Component comp,
                       FadeKind fadeKind)
Returns the fade cycle for the specified component. The result will be in 0.0-10.0 range.

Parameters:
comp - Component.
fadeKind - Fade kind.
Returns:
The fade cycle for the specified component. For components that are not tracked (when #isTracked(Component, org.jvnet.lafwidget.animation.FadeTracker.FadeKind) returns false), value 0 (zero) is returned.

getFade10

public float getFade10(java.awt.Component comp,
                       int componentId,
                       FadeKind fadeKind)
Returns the fade cycle for the specified component. The result will be in 0.0-10.0 range.

Parameters:
comp - Component.
componentId - Component id. Relevant for such components as tabbed panes (where fade is performed on component "sub" parts).
fadeKind - Fade kind.
Returns:
The fade cycle for the specified component. For components that are not tracked (when #isTracked(Component, org.jvnet.lafwidget.animation.FadeTracker.FadeKind) returns false), value 0 (zero) is returned.

getFade10

public float getFade10(java.awt.Component comp,
                       java.lang.Comparable<?> componentId,
                       FadeKind fadeKind)
Returns the fade cycle for the specified component. The result will be in 0.0-10.0 range.

Parameters:
comp - Component.
componentId - Component id. Relevant for such components as tabbed panes, lists, tables, trees and others (where fade is performed on component "sub" parts). May be null.
fadeKind - Fade kind.
Returns:
The fade cycle for the specified component. For components that are not tracked (when #isTracked(Component, org.jvnet.lafwidget.animation.FadeTracker.FadeKind) returns false), value 0 (zero) is returned.

getFadeState

public FadeState getFadeState(java.awt.Component comp,
                              FadeKind fadeKind)
Returns the fade state of specified component if it's being tracked by this tracker or null.

Parameters:
comp - Component.
fadeKind - Fade kind.
Returns:
Fade state of specified component if it's being tracked by this tracker or null.

getFadeState

public FadeState getFadeState(java.awt.Component comp,
                              int componentId,
                              FadeKind fadeKind)
Returns the fade state of specified component if it's being tracked by this tracker or null.

Parameters:
comp - Component.
componentId - Component id. Relevant for such components as tabbed panes (where fade is performed on component "sub" parts).
fadeKind - Fade kind.
Returns:
Fade state of specified component if it's being tracked by this tracker or null.

getFadeState

public FadeState getFadeState(java.awt.Component comp,
                              java.lang.Comparable<?> componentId,
                              FadeKind fadeKind)
Returns the fade state of specified component if it's being tracked by this tracker or null.

Parameters:
comp - Component.
componentId - Component id. Relevant for such components as tabbed panes, lists, tables, trees and others (where fade is performed on component "sub" parts). May be null.
fadeKind - Fade kind.
Returns:
Fade state of specified component if it's being tracked by this tracker or null.

stopAllTimers

public void stopAllTimers()
Stops tracking of all components. Note that this function does not stop the fade thread (trackerThread).


cancelFadeInstance

public void cancelFadeInstance(long fadeInstanceId)
Cancels the specified fade instance.

Parameters:
fadeInstanceId - Fade instance ID.

requestStopOnCycleBreak

public void requestStopOnCycleBreak(long fadeInstanceId)
Requests that the specified fade instance should stop at the end of the fade-out. This method should be called only on looping fades.

Parameters:
fadeInstanceId - Fade instance ID.

getAllComponentsByFadeKind

public java.util.Set<java.awt.Component> getAllComponentsByFadeKind(FadeKind fadeKind)
Returns all components that are currently under the specified fade kind.

Parameters:
fadeKind - Fade kind.
Returns:
Non-null set of all components that are currently under the specified fade kind.

getCurrLoopId

public long getCurrLoopId()
Returns the ID of the current loop iteration.

Returns:
ID of the current loop iteration.