|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.animation.AnimationKeyframeSequence
public final class AnimationKeyframeSequence
Defines a class that represents animation sequence data as an ordering of two or more keyframes on a time scale between 0.0 and 1.0. The class also contains information that specifies how to interpolate between the values of each keyframe.
// Create a two channel, three keyframe sequence for a property with a component size of two. AnimationKeyframeSequence sequence = new AnimationKeyframeSequence(2, 3, 2, Animation.EASINGCURVE_BOUNCE_IN); float[] keyValuesChannelOne = {50.0f, 50.0f, 100.0f, 100.0f, 160.0f, 230.0f}; float[] keyValuesChannelTwo = {30.0f, 80.0f, 75.0f, 80.0f, 200.0f, 145.0f}; float[] keyTimes = {0.0f, 0.5f, 1.0f}; // Populate the keyframes. // Channel 1 keyframes sequence.setKeyframe(0, 0, keyTimes[0], keyValuesChannelOne, 0); sequence.setKeyframe(0, 1, keyTimes[1], keyValuesChannelOne, 2); sequence.setKeyframe(0, 2, keyTimes[2], keyValuesChannelOne, 4); // Channel 2 keyframes sequence.setKeyframe(1, 0, keyTimes[0], keyValuesChannelTwo, 0); sequence.setKeyframe(1, 1, keyTimes[1], keyValuesChannelTwo, 2); sequence.setKeyframe(1, 2, keyTimes[2], keyValuesChannelTwo, 4);
// Create the sequence AnimationKeyframeSequence = new AnimationKeyframeSequence(2, 2, Animation.EASINGCURVE_LINEAR); float[] keyValues = {25, 40, 55, 60}; float[] keyTimes = {0.0f, 1.0f}; // Populate the keyframes sequence.setKeyframe(0, keyTimes[0], keyValues, 0); sequence.setKeyframe(1, keyTimes[1], keyValues, 2); // Set the values to be by-values. sequence.setBy(true);
AnimationKeyframeSequence.VALUE_TYPE_VECTOR
, AnimationKeyframeSequence.VALUE_TYPE_QUATERNION
,
AnimationKeyframeSequence.VALUE_TYPE_TRANSFORM2D
, and AnimationKeyframeSequence.VALUE_TYPE_TRANSFORM3D
. The default value type is AnimationKeyframeSequence.VALUE_TYPE_VECTOR
which is suitable for
most animations. The other value types, are for more complex cases of animating quaternions and 2D and 3D transforms. These should be used for
creating sequence data in conjunction with corresponding classes in the net.rim.device.api.math
package that implement Animatable
.
// Create the sequence AnimationKeyframeSequence = new AnimationKeyframeSequence(2, 2, Animation.EASINGCURVE_LINEAR); float[] keyValues = {25, 40, 55, 60}; float[] keyTimes = {0.0f, 1.0f}; // Populate the keyframes sequence.setKeyframe(0, keyTimes[0], keyValues, 0); sequence.setKeyframe(1, keyTimes[1], keyValues, 2); sequence.setValueType(VALUE_TYPE_TRANSFORM3D);
// Create the sequence, specifying EASINGCURVE_SPLINE as the easing curve. AnimationKeyframeSequence = new AnimationKeyframeSequence(3, 1, Animation.EASINGCURVE_SPLINE); float[] keyValues = {25, 75, 125}; float[] keyTimes = {0.0f, 0.5f, 1.0f}; // Populate the keyframes sequence.setKeyframe(0, keyTimes[0], keyValues, 0); sequence.setKeyframe(1, keyTimes[1], keyValues, 1); sequence.setKeyframe(2, keyTimes[2], keyValues, 2); // Set the control points. The interpolation between the first two keyframes will be linear. The interpolation // of the second two keyframes will use a different spline curve that is similar to an ease-in curve. float[] splinePoints = {0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.75f, 1.0f, 0.25f}; sequence.setKeysplines(splinePoints)
Field Summary | ||
---|---|---|
static int |
CHANNEL_COUNT_MAX
Constant that specifies the maximum number of channels. |
|
static int |
KEYFRAME_COUNT_MAX
Constant that specifies the maximum number of keyframes. |
|
static float |
KEYFRAME_RELATIVE
Constant that indicates that the sequence data is relative. |
|
static int |
PROPERTY_COUNT_MAX
Constant that specifies the maximum number of property values that can be animated in one channel of data. |
|
static int |
VALUE_TYPE_QUATERNION
Constant that specifies a quaternion value type. |
|
static int |
VALUE_TYPE_TRANSFORM2D
Constant that specifies a transform 2D value type. |
|
static int |
VALUE_TYPE_TRANSFORM3D
Constant that specifies a transform 3D value type. |
|
static int |
VALUE_TYPE_VECTOR
Constant that specifies a vector value type. |
Constructor Summary | ||
---|---|---|
AnimationKeyframeSequence(int keyframeCount,
int propertyComponentCount,
int easingCurve)
Class constructor. |
||
AnimationKeyframeSequence(int channelCount,
int keyframeCount,
int propertyComponentCount,
int easingCurve)
Class constructor. |
Method Summary | ||
---|---|---|
int |
getChannelCount()
Gets the number of data channels in the sequence. |
|
int |
getEasingCurve()
Gets the easing curve currently being applied on the sequence. |
|
float |
getKeyTime(int index)
Gets the key time for the specified keyframe. |
|
float |
getKeyframe(int index,
float[] value,
int offset)
Gets the time stamp and key values for the specified keyframe. |
|
float |
getKeyframe(int channel,
int index,
float[] value,
int offset)
Gets the time stamp and key values for the specified keyframe on the speficied data channel. |
|
int |
getKeyframeCount()
Gets the number of keyframes in the sequence. |
|
int |
getKeysplines(float[] controlPoints)
Gets the spline control points used across all keyframes in the sequence. |
|
int |
getValueType()
Gets the value type of the sequence. |
|
boolean |
isBy()
Indicates if the key values in the sequence are treated as by-values. |
|
void |
setBy(boolean isBy)
Configures whether the key values in the sequence are treated as by-values. |
|
void |
setEasingCurve(int easingCurve)
Sets the easing curve used to interpolate the data on the sequence. |
|
void |
setKeyframe(int index,
float time,
float[] value,
int offset)
Sets the time stamp and key value for the given keyframe. |
|
void |
setKeyframe(int channel,
int index,
float time,
float[] value,
int offset)
Sets the time stamp and key value for the specified keyframe on the specified data channel. |
|
void |
setKeysplines(float[] controlPoints)
Sets the spline control points for all keyframes in the sequence. |
|
void |
setValueType(int valueType)
Sets the value type of the sequence. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int VALUE_TYPE_VECTOR
AnimationKeyframeSequence.setValueType(int)
,
AnimationKeyframeSequence.getValueType()
,
Constant Field Valuespublic static final int VALUE_TYPE_QUATERNION
AnimationKeyframeSequence.setValueType(int)
,
AnimationKeyframeSequence.getValueType()
,
Constant Field Valuespublic static final int VALUE_TYPE_TRANSFORM2D
AnimationKeyframeSequence.setValueType(int)
,
AnimationKeyframeSequence.getValueType()
,
Constant Field Valuespublic static final int VALUE_TYPE_TRANSFORM3D
AnimationKeyframeSequence.setValueType(int)
,
AnimationKeyframeSequence.getValueType()
,
Constant Field Valuespublic static final float KEYFRAME_RELATIVE
AnimationKeyframeSequence.setKeyframe(int,int,float,float[],int)
,
AnimationKeyframeSequence.setKeyframe(int,float,float[],int)
,
AnimationKeyframeSequence.getKeyframe(int,int,float[],int)
,
AnimationKeyframeSequence.getKeyframe(int,float[],int)
,
Constant Field Valuespublic static final int PROPERTY_COUNT_MAX
public static final int CHANNEL_COUNT_MAX
AnimationKeyframeSequence.AnimationKeyframeSequence(int, int, int, int)
,
Constant Field Valuespublic static final int KEYFRAME_COUNT_MAX
AnimationKeyframeSequence.AnimationKeyframeSequence(int, int, int)
,
AnimationKeyframeSequence.AnimationKeyframeSequence(int, int, int, int)
,
Constant Field ValuesConstructor Detail |
---|
public AnimationKeyframeSequence(int keyframeCount, int propertyComponentCount, int easingCurve)
Class constructor.
Creates an AnimationKeyframeSequence
with the specified number of keyframes for a property with the given property
component count.
keyframeCount
- The number of keyframes in the sequence.propertyComponentCount
- The number of components that compose the animatable property that the sequence will animate.easingCurve
- The easing curve to be used to interpolate through the sequence data.
IllegalArgumentException
- if keyframeCount < 2
.
IllegalArgumentException
- if propertyComponentCount < 1
or propertyComponentCount >
AnimationKeyframeSequence.PROPERTY_COUNT_MAX
.
IllegalArgumentException
- if easingCurve
is not a valid type.public AnimationKeyframeSequence(int channelCount, int keyframeCount, int propertyComponentCount, int easingCurve)
Class constructor.
Creates anAnimationKeyframeSequence
consisting of the specified number of data channels and the specified number of keyframes
for a property with the specified property component count.
channelCount
- The number of data channels in the sequence.keyframeCount
- The number of keyframes in the sequence.propertyComponentCount
- The number of components that compose the animatable property that the sequence will animate.easingCurve
- The easing curve to be used to interpolate through the sequence data.
IllegalArgumentException
- if channelCount < 1
.
IllegalArgumentException
- if keyframeCount < 2
.
IllegalArgumentException
- if propertyComponentCount < 1
or propertyComponentCount >
AnimationKeyframeSequence.PROPERTY_COUNT_MAX
.
IllegalArgumentException
- if easingCurve
is not a valid type.Method Detail |
---|
public int getChannelCount()
Gets the number of data channels in the sequence.
public int getKeyframeCount()
Gets the number of keyframes in the sequence.
public int getEasingCurve()
Gets the easing curve currently being applied on the sequence.
public void setEasingCurve(int easingCurve)
Sets the easing curve used to interpolate the data on the sequence.
easingCurve
- The easing curve to be used to interpolate through the sequence data.
IllegalArgumentException
- if easingCurve
is not a valid type.public int getValueType()
Gets the value type of the sequence.
Value type will be one ofAnimationKeyframeSequence.VALUE_TYPE_VECTOR
, AnimationKeyframeSequence.VALUE_TYPE_QUATERNION
,
AnimationKeyframeSequence.VALUE_TYPE_TRANSFORM2D
, or AnimationKeyframeSequence.VALUE_TYPE_TRANSFORM3D
.
AnimationKeyframeSequence.VALUE_TYPE_VECTOR
,
AnimationKeyframeSequence.VALUE_TYPE_QUATERNION
,
AnimationKeyframeSequence.VALUE_TYPE_TRANSFORM2D
,
AnimationKeyframeSequence.VALUE_TYPE_TRANSFORM3D
public void setValueType(int valueType)
Sets the value type of the sequence. The default value type is AnimationKeyframeSequence.VALUE_TYPE_VECTOR
.
valueType
- The type of the data. Must be one of AnimationKeyframeSequence.VALUE_TYPE_VECTOR
, AnimationKeyframeSequence.VALUE_TYPE_QUATERNION
,
AnimationKeyframeSequence.VALUE_TYPE_TRANSFORM3D
, or AnimationKeyframeSequence.VALUE_TYPE_TRANSFORM3D
.
IllegalArgumentException
- if valueType
is not one of the constants defined above.AnimationKeyframeSequence.VALUE_TYPE_VECTOR
,
AnimationKeyframeSequence.VALUE_TYPE_QUATERNION
,
AnimationKeyframeSequence.VALUE_TYPE_TRANSFORM2D
,
AnimationKeyframeSequence.VALUE_TYPE_TRANSFORM3D
public float getKeyframe(int index, float[] value, int offset)
Gets the time stamp and key values for the specified keyframe.
index
- The index of the keyframe to retrieve.value
- Array used to store the keyframe value vector, or null
to only return the time stamp.offset
- The offset at which to populate the value
float array.
AnimationKeyframeSequence.KEYFRAME_RELATIVE
if querying the first keyframe and the sequence is relative.
IllegalArgumentException
- if index < 0
or index >=
the keyframe count.
IllegalArgumentException
- if offset < 0
.
IllegalArgumentException
- if value.length < offset +
the property component count.public float getKeyframe(int channel, int index, float[] value, int offset)
Gets the time stamp and key values for the specified keyframe on the speficied data channel.
channel
- The data channel to get keyframe information for.index
- The index of the keyframe to retrieve.value
- Array used to store the keyframe value vector, or null
to only return the time stamp.offset
- The offset at which to populate the value
float array.
AnimationKeyframeSequence.KEYFRAME_RELATIVE
if querying the first keyframe and the sequence is relative.
IllegalArgumentException
- if channel < 0
or channel >=
the channel count.
IllegalArgumentException
- if index < 0
or index >=
the keyframe count.
IllegalArgumentException
- if offset < 0
.
IllegalArgumentException
- if value.length < offset +
the property component count.public void setKeyframe(int index, float time, float[] value, int offset)
Sets the time stamp and key value for the given keyframe.
To create a relative "By-Animation" or "To-Animation", one must pass in AnimationKeyframeSequence.KEYFRAME_RELATIVE
for the keytime value
of the first keyframe (index == 0). By default, the first key frame is treated as a relative value.
index
- The index of the keyframe to set.time
- The time stamp for this keyframe.value
- Array containing the value vector for this keyframe.offset
- The offset of the value vector in the value
float array.
IllegalArgumentException
- if value
is null
.
IllegalArgumentException
- if index < 0
or index >=
the keyframe count.
IllegalArgumentException
- if offset < 0
.
IllegalArgumentException
- if value.length < offset +
the property component count.
IllegalArgumentException
- if time < 0.0
or time > 1.0
.
IllegalArgumentException
- if index == 0
and time != 0.0f
.
IllegalArgumentException
- if index ==
the last keyframe and time != 1.0f
.public void setKeyframe(int channel, int index, float time, float[] value, int offset)
Sets the time stamp and key value for the specified keyframe on the specified data channel.
To create a relative "By-Animation" or "To-Animation", you must pass in AnimationKeyframeSequence.KEYFRAME_RELATIVE
for the keytime value
of the first keyframe (index == 0). By default, the first key frame is treated as a relative value.
channel
- The data channel to get keyframe information for.index
- The index of the keyframe to set.time
- The time stamp for this keyframe.value
- Array containing the value vector for this keyframe.offset
- The offset of the value vector in the value
float array.
IllegalArgumentException
- if channel < 0
or channel >=
the channel count.
IllegalArgumentException
- if value
is null
.
IllegalArgumentException
- if index < 0
or index >=
the keyframe count.
IllegalArgumentException
- if offset < 0
.
IllegalArgumentException
- if value.length < offset +
the property component count.
IllegalArgumentException
- if time < 0.0
or time > 1.0
.
IllegalArgumentException
- if index == 0
and time != 0.0f
.
IllegalArgumentException
- if index ==
the last keyframe and time != 1.0f
.public float getKeyTime(int index)
Gets the key time for the specified keyframe.
index
- The key frame.
IndexOutOfBoundsException
- if index < 0
or index >=
keyframe count.public void setKeysplines(float[] controlPoints)
Sets the spline control points for all keyframes in the sequence.
controlPoints
- The control points to be set.
IllegalArgumentException
- if controlPoints
is null.
IllegalArgumentException
- if controlPoints.length % 4 != 0
.
IllegalArgumentException
- if any of the values in controlPoints
is outside of the range [0.0, 1.0].public int getKeysplines(float[] controlPoints)
Gets the spline control points used across all keyframes in the sequence.
If no key splines have been set on the sequence at the time this method is invoked, it will return 0 and
controlPoints
will be unmodified.
controlPoints
- The control points to be fill. Passing null will only return number of keyframes there are keysplines defined for.
IllegalArgumentException
- if controlPoints
is not null
and controlPoints.length < getKeySplines(null)
.public boolean isBy()
Indicates if the key values in the sequence are treated as by-values.
true
if the sequence contains to-values, false
if the sequence contains by-values.public void setBy(boolean isBy)
Configures whether the key values in the sequence are treated as by-values.
isBy
- if true
the key values will be treated as by-values,
if false
the key values will be treated as to-values, which is the default.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal