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. There is no new thread, objects are inserted in the EventDispatcher-Thread.

Author:
Benjamin Sigg

Field Summary
private  int current
          the current location, something between 0 and duration
private  int duration
          the duration of the change
private  long last
          the time at the last pulse
private  javax.swing.Timer timer
          a timer which pulses this changer
 
Constructor Summary
SmoothChanger()
          Constructor, sets duration to 250 milliseconds.
SmoothChanger(int duration)
          Constructs a new changer.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 int getDuration()
          Gets the duration of a transition
protected abstract  boolean isActive()
          The direction of the change.
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
 

Field Detail

last

private long last
the time at the last pulse


current

private int current
the current location, something between 0 and duration


duration

private int duration
the duration of the change


timer

private javax.swing.Timer timer
a timer which pulses this changer

Constructor Detail

SmoothChanger

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


SmoothChanger

public SmoothChanger(int duration)
Constructs a new changer.

Parameters:
duration - the duration of one transition, should not be less than 1
Method Detail

isActive

protected abstract boolean isActive()
The direction of the change. If active, then the counter of this changer is increasing. Otherwise, the value of this changer is decreasing.

Returns:
whether to in- or to decrease the counter

repaint

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

Parameters:
current - the counter

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

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