bibliothek.extension.gui.dock.theme.smooth
Class SmoothChanger

java.lang.Object
  extended by bibliothek.extension.gui.dock.theme.smooth.SmoothChanger
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener

public abstract class SmoothChanger
extends java.lang.Object
implements java.awt.event.ActionListener

A class which counts milliseconds from 0 to duration or in the other direction. This class contains an array of states: one state is counted upwards (the destination()), all the other states are counted downwards. Clients can use this class to smoothly switch between different states.
This class works on the EDT, no new threads are created.

Author:
Benjamin Sigg

Constructor Summary
SmoothChanger(int states)
          Constructor, sets duration to 250 milliseconds.
SmoothChanger(int duration, int states)
          Constructs a new changer.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
protected abstract  int destination()
          The direction of the change.
 int getDuration()
          Gets the duration of a transition
 boolean isRunning()
          Tells whether this changer is currently active or not.
protected abstract  void repaint(int[] current)
          Triggered during a transition when the counter has been changed
 void setDuration(int duration)
          Sets the duration of the transition.
 void trigger()
          Starts a transition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SmoothChanger

public SmoothChanger(int states)
Constructor, sets duration to 250 milliseconds.

Parameters:
states - the number of states this changer can have

SmoothChanger

public SmoothChanger(int duration,
                     int states)
Constructs a new changer.

Parameters:
duration - the duration of one transition, should not be less than 1
states - the number of states this changer can have, should at least be 2
Method Detail

destination

protected abstract int destination()
The direction of the change. The counter of for the state destination() will always rise, while the other counters decent.

Returns:
the favored state

repaint

protected abstract void repaint(int[] current)
Triggered during a transition when the counter has been changed

Parameters:
current - for each state a number between 0 and getDuration(), the state with the highest number is the best selected state

setDuration

public void setDuration(int duration)
Sets the duration of the transition.

Parameters:
duration - the duration
Throws:
java.lang.IllegalStateException - if the duration is less than 1

isRunning

public boolean isRunning()
Tells whether this changer is currently active or not.

Returns:
true if active, false if not

getDuration

public int getDuration()
Gets the duration of a transition

Returns:
the duration
See Also:
setDuration(int)

trigger

public void trigger()
Starts a transition


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener