bibliothek.extension.gui.dock.theme.bubble
Class BubbleColorAnimation

java.lang.Object
  extended by bibliothek.extension.gui.dock.theme.bubble.BubbleColorAnimation

public class BubbleColorAnimation
extends java.lang.Object

A BubbleColorAnimation has the ability to convert one or many color-pairs smoothly from source to destination color. It basically is a map storing String-Color pairs. Clients have to call putColor(String, Color) to start an animation. They can call getColor(String) any time to get the current intermediate color. Adding a task will allow a client to be informed whenever the colors change.
The animation itself takes duration milliseconds.

Author:
Benjamin Sigg

Constructor Summary
BubbleColorAnimation()
          Creates a new animation.
 
Method Summary
 void addTask(java.lang.Runnable runnable)
          Adds a task to this animation.
 java.awt.Color getColor(java.lang.String key)
          Gets the current color of the pair key.
 int getDuration()
          Gets the length of one transformation.
 void kick()
          Immediately puts all colors to their final state and stops the animation.
protected  void pulse()
          Called when the animation has to perform another step.
 void putColor(java.lang.String key, java.awt.Color color)
          If there is already a color stored under key, then a new animation is started that smoothly changes the color key from its current value to color.
 void putColors(java.lang.String key, java.awt.Color source, java.awt.Color destination)
          Sets a color-pair.
 void removeTask(java.lang.Runnable runnable)
          Removes a task which was earlier added to this animation.
 void setDuration(int duration)
          Sets the length of one transformation.
protected  void start()
          Starts the animation if it is not yet running.
 void stop()
          Stops the animation immediately, possibly leaving the animation in an unfinished state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BubbleColorAnimation

public BubbleColorAnimation()
Creates a new animation.

Method Detail

putColors

public void putColors(java.lang.String key,
                      java.awt.Color source,
                      java.awt.Color destination)
Sets a color-pair. The color destination is shown after maximal duration milliseconds. This method does not start an animation, it just modifies an existing transition.

Parameters:
key - the key of the pair
source - where the animation starts
destination - the destination of the animation

putColor

public void putColor(java.lang.String key,
                     java.awt.Color color)
If there is already a color stored under key, then a new animation is started that smoothly changes the color key from its current value to color. If no color is stored, then color is just set without starting an animation.

Parameters:
key - the key of the pair
color - the destination of the animation

getColor

public java.awt.Color getColor(java.lang.String key)
Gets the current color of the pair key.

Parameters:
key - the key of the pair
Returns:
the color of the pair or null

addTask

public void addTask(java.lang.Runnable runnable)
Adds a task to this animation. The task will be executed whenever the animation makes a new step.

Parameters:
runnable - the task to execute

removeTask

public void removeTask(java.lang.Runnable runnable)
Removes a task which was earlier added to this animation.

Parameters:
runnable - the task to remove

setDuration

public void setDuration(int duration)
Sets the length of one transformation.

Parameters:
duration - the duration in milliseconds

getDuration

public int getDuration()
Gets the length of one transformation.

Returns:
the duration in milliseconds

stop

public void stop()
Stops the animation immediately, possibly leaving the animation in an unfinished state.


kick

public void kick()
Immediately puts all colors to their final state and stops the animation.


start

protected void start()
Starts the animation if it is not yet running.


pulse

protected void pulse()
Called when the animation has to perform another step.