|
Java DTV API 1.3 18-Nov-2009 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.dtv.lwuit.animations.Motion
public class Motion
Abstracts the notion of physical motion over time from a numeric location to another. This class can be subclassed to implement any motion equation for appropriate physics effects.
This class relies on the System.currentTimeMillis() method to provide transitions between coordinates. The motion can be subclassed to provide every type of motion feel from parabolic motion to spline and linear motion. The default implementation provides a simple algorithm giving the feel of acceleration and deceleration.
Constructor Summary | |
---|---|
protected |
Motion(int sourceValue,
float initVelocity,
float friction)
Construct a velocity motion. |
protected |
Motion(int sourceValue,
int destinationValue,
int duration)
Construct a point/destination motion. |
Method Summary | |
---|---|
static Motion |
createFrictionMotion(int sourceValue,
float initVelocity,
float friction)
Creates a friction motion starting from source with initial speed and the friction. |
static Motion |
createLinearMotion(int sourceValue,
int destinationValue,
int duration)
Creates a linear motion starting from source value all the way to destination value. |
static Motion |
createSplineMotion(int sourceValue,
int destinationValue,
int duration)
Creates a spline motion starting from source value all the way to destination value. |
int |
getSourceValue()
The number from which we are starting (usually indicating animation start position). |
int |
getValue()
Returns the value for the motion for the current clock time. |
boolean |
isFinished()
Returns true if the motion has run its course and has finished meaning the current time is greater than startTime + duration. |
void |
setSourceValue(int sourceValue)
The number from which we are starting (usually indicating animation start position). |
void |
start()
Sets the start time to the current time. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected Motion(int sourceValue, int destinationValue, int duration)
sourceValue
- starting valuedestinationValue
- destination valueduration
- motion durationprotected Motion(int sourceValue, float initVelocity, float friction)
sourceValue
- starting valueinitVelocity
- initial velocityfriction
- degree of frictionMethod Detail |
---|
public static Motion createLinearMotion(int sourceValue, int destinationValue, int duration)
sourceValue
- the number from which we are starting (usually indicating animation start position)destinationValue
- the number to which we are heading (usually indicating animation destination)duration
- the length in milliseconds of the motion (time it takes to get from sourceValue to
destinationValue)
public static Motion createSplineMotion(int sourceValue, int destinationValue, int duration)
sourceValue
- the number from which we are starting (usually indicating animation start position)destinationValue
- the number to which we are heading (usually indicating animation destination)duration
- the length in milliseconds of the motion (time it takes to get from sourceValue to
destinationValue)
public static Motion createFrictionMotion(int sourceValue, float initVelocity, float friction)
sourceValue
- the number from which we are starting (usually indicating animation start position)initVelocity
- the starting velocityfriction
- the motion friction
public void start()
public boolean isFinished()
public int getValue()
public int getSourceValue()
setSourceValue(int)
public void setSourceValue(int sourceValue)
sourceValue
- the start positiongetSourceValue()
|
Java DTV API 1.3 18-Nov-2009 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |