public abstract class SmoothChanger
extends java.lang.Object
implements java.awt.event.ActionListener
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.Constructor and Description |
---|
SmoothChanger(int states)
Constructor, sets
duration to 250 milliseconds. |
SmoothChanger(int duration,
int states)
Constructs a new changer.
|
Modifier and Type | Method and Description |
---|---|
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
|
public SmoothChanger(int states)
duration
to 250 milliseconds.states
- the number of states this changer can havepublic SmoothChanger(int duration, int states)
duration
- the duration of one transition, should not be less than 1states
- the number of states this changer can have, should
at least be 2protected abstract int destination()
destination()
will always rise, while the other
counters decent.protected abstract void repaint(int[] current)
current
- for each state a number between 0 and getDuration()
,
the state with the highest number is the best selected statepublic void setDuration(int duration)
duration
- the durationjava.lang.IllegalStateException
- if the duration is less than 1public boolean isRunning()
true
if active, false
if notpublic int getDuration()
setDuration(int)
public void trigger()
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener