public abstract class AbstractMotion extends java.lang.Object implements Motion
| Modifier and Type | Field and Description |
|---|---|
protected long |
duration
Duration.
|
protected boolean |
finished
true if finished, false otherwise. |
protected int |
start
Start value.
|
protected long |
startTime
Start time.
|
protected int |
stop
Stop value.
|
| Constructor and Description |
|---|
AbstractMotion(int start,
int stop,
long duration)
Creates a motion for a move from start to stop.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract int |
computeCurrentValue(long elapsed)
Computes current value.
|
int |
getCurrentValue()
Computes the current value of the motion.
|
long |
getDuration()
Gets the motion duration.
|
int |
getStartValue()
Gets the start value of the motion.
|
int |
getStopValue()
Gets the stop value of the motion.
|
int |
getValue(long elapsed)
Gets the value of the motion for a specific elapsed time.
|
boolean |
isFinished()
Gets whether the motion is finished or not.
|
protected boolean |
isFinished(int value)
Checks whether the motion is finished or not, considering the given value.
|
void |
start()
Starts (or starts again) the motion.
|
protected final int start
protected final int stop
protected final long duration
protected long startTime
start()protected boolean finished
true if finished, false otherwise.isFinished(),
isFinished(int)public AbstractMotion(int start,
int stop,
long duration)
start - the start value.stop - the stop value.duration - the maximum duration of the motion.public long getDuration()
MotiongetDuration in interface Motionpublic void start()
Motionpublic boolean isFinished()
MotionA motion is finished when the current value is the stop one.
isFinished in interface Motiontrue if the motion is finished, false otherwise.public int getStartValue()
MotiongetStartValue in interface Motionpublic int getStopValue()
MotiongetStopValue in interface Motionpublic int getCurrentValue()
MotionIf the motion is finished, returns the stop value.
getCurrentValue in interface MotionMotion.isFinished()public int getValue(long elapsed)
Motionprotected boolean isFinished(int value)
By default, the motion is finished if the value reach (or exceed) the stop value.
value - the value to check with.true if the motion is finished, false otherwise.protected abstract int computeCurrentValue(long elapsed)
elapsed - the elapsed time since the beginning.