org.jvnet.lafwidget.animation
Class FadeIgnoreManager

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

public class FadeIgnoreManager
extends java.lang.Object

This class is used to decide whether the automatic animations in the FadeStateListener#trackModelChange(org.jvnet.lafwidget.utils.FadeTracker.FadeKind, boolean, boolean) should be applied on a specific component. The specific LAF implementation may decide to ignore animations on cell renderers and editors.

At runtime, the manager is populated from META-INF/lafwidget.animations.properties resources found in classpath. This allows providing additional application-specific components to be registered as animation-"free". Each such resource should contain a list of fully qualified class names, one class name per line. The class name may be a "leaf" class (such as JToggleButton), or can be a parent class / interface (such as ListCellRenderer). In the later case, the animations will be ignored on all components that extend such class / implement such interface.

In addition, the addToIgnoreAnimations(Class) and addToIgnoreAnimations(String) API can be used to register additional application-specific components.

Author:
Kirill Grouchnikov

Field Summary
protected  java.util.Set<java.lang.Class<?>> cache
          Contains Class instances.
protected  java.util.Set<java.lang.Class<?>> ignoreAnimationsOn
          Contains Class instances.
 
Constructor Summary
FadeIgnoreManager()
          Creates a new empty manager.
 
Method Summary
 void addToIgnoreAnimations(java.lang.Class<?> clazz)
          Adds the specified class to the set of components that should ignore animations.
 void addToIgnoreAnimations(java.lang.String className)
          Adds the specified class name to the set of components that should ignore animations.
 void populate()
          Populates the ignoreAnimationsOn set.
protected  void populateFrom(java.net.URL url)
          Populates the ignoreAnimationsOn set from the specific URL resource.
 boolean toIgnoreAnimations(java.awt.Component comp)
          Returns indication whether the specified component should ignore animations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ignoreAnimationsOn

protected java.util.Set<java.lang.Class<?>> ignoreAnimationsOn
Contains Class instances. If a class instance is in this set, all components of this class (directly, via extension or via inheritance) will not have animations on model changes.


cache

protected java.util.Set<java.lang.Class<?>> cache
Contains Class instances. This serves as a cache to speed up the subsequent processing.

See Also:
toIgnoreAnimations(Component)
Constructor Detail

FadeIgnoreManager

public FadeIgnoreManager()
Creates a new empty manager.

Method Detail

populate

public void populate()
Populates the ignoreAnimationsOn set. The classpath is scanned for all resources that match the name META-INF/lafwidget.animations.properties.

See Also:
populateFrom(URL)

populateFrom

protected void populateFrom(java.net.URL url)
Populates the ignoreAnimationsOn set from the specific URL resource. The resource should contain a list of fully qualified class names, one class name per line. The class name may be a "leaf" class (such as JToggleButton), or can be a parent class / interface (such as ListCellRenderer). In the later case, the animations will be ignored on all components that extend such class / implement such interface.

Parameters:
url - Resource URL.

addToIgnoreAnimations

public void addToIgnoreAnimations(java.lang.Class<?> clazz)
Adds the specified class to the set of components that should ignore animations.

Parameters:
clazz - Component class.

addToIgnoreAnimations

public void addToIgnoreAnimations(java.lang.String className)
Adds the specified class name to the set of components that should ignore animations.

Parameters:
className - Component class name.

toIgnoreAnimations

public boolean toIgnoreAnimations(java.awt.Component comp)
Returns indication whether the specified component should ignore animations. The component hierarchy is scanned from the component up. At each stage, the current ascendant is checked against all entries in the ignoreAnimationsOn set. If the class of the current ascendant matches one of the entries, true is returned. Otherwise, false is returned (no ascendant found matching any of the entries in the ignoreAnimationsOn set).

The implementation uses the cache tp speed up the processing. When a component class is determined to ignore animations, its class is put in this cache. The implementation first consults this cache - if the component class is found, true is returned. Otherwise, the above algorithm is performed.

Parameters:
comp - Component.
Returns:
true if the specified component should ignore animations, false otherwise.