public abstract class AbstractMotion extends 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 long duration
protected boolean finished
true
if finished, false
otherwise.isFinished()
,
isFinished(int)
protected final int start
protected long startTime
start()
protected final int stop
public AbstractMotion(int start, int stop, long duration)
start
- the start value.stop
- the stop value.duration
- the maximum duration of the motion.protected abstract int computeCurrentValue(long elapsed)
elapsed
- the elapsed time since the beginning.public int getCurrentValue()
Motion
If the motion is finished, returns the stop value.
getCurrentValue
in interface Motion
Motion.isFinished()
public long getDuration()
Motion
getDuration
in interface Motion
public int getStartValue()
Motion
getStartValue
in interface Motion
public int getStopValue()
Motion
getStopValue
in interface Motion
public int getValue(long elapsed)
Motion
public boolean isFinished()
Motion
A motion is finished when the current value is the stop one.
isFinished
in interface Motion
true
if the motion is finished, false
otherwise.protected 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.