Java DTV API 1.3
18-Nov-2009

com.sun.dtv.lwuit.animations
Class Motion

java.lang.Object
  extended by com.sun.dtv.lwuit.animations.Motion

public class Motion
extends Object

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

Motion

protected Motion(int sourceValue,
                 int destinationValue,
                 int duration)
Construct a point/destination motion.

Parameters:
sourceValue - starting value
destinationValue - destination value
duration - motion duration

Motion

protected Motion(int sourceValue,
                 float initVelocity,
                 float friction)
Construct a velocity motion.

Parameters:
sourceValue - starting value
initVelocity - initial velocity
friction - degree of friction
Method Detail

createLinearMotion

public static Motion createLinearMotion(int sourceValue,
                                        int destinationValue,
                                        int duration)
Creates a linear motion starting from source value all the way to destination value.

Parameters:
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)
Returns:
a Motion object

createSplineMotion

public static Motion createSplineMotion(int sourceValue,
                                        int destinationValue,
                                        int duration)
Creates a spline motion starting from source value all the way to destination value.

Parameters:
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)
Returns:
a Motion object

createFrictionMotion

public static Motion createFrictionMotion(int sourceValue,
                                          float initVelocity,
                                          float friction)
Creates a friction motion starting from source with initial speed and the friction.

Parameters:
sourceValue - the number from which we are starting (usually indicating animation start position)
initVelocity - the starting velocity
friction - the motion friction
Returns:
a Motion object

start

public void start()
Sets the start time to the current time.


isFinished

public boolean isFinished()
Returns true if the motion has run its course and has finished meaning the current time is greater than startTime + duration.

Returns:
true if System.currentTimeMillis() > duration + startTime

getValue

public int getValue()
Returns the value for the motion for the current clock time. The value is dependent on the Motion type.

Returns:
a value that is relative to the source value

getSourceValue

public int getSourceValue()
The number from which we are starting (usually indicating animation start position).

Returns:
the start position
See Also:
setSourceValue(int)

setSourceValue

public void setSourceValue(int sourceValue)
The number from which we are starting (usually indicating animation start position).

Parameters:
sourceValue - the start position
See Also:
getSourceValue()

Java DTV API 1.3
18-Nov-2009

Copyright © 2008-2009 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved.

U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.Products covered by and information contained in this service manual are controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited.

DOCUMENTATION IS PROVIDED AS IS AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.

Use of this document is subject to license terms.