net.rim.device.api.animation
Class AnimatedVector

java.lang.Object
  extended by net.rim.device.api.animation.AnimatedVector
All Implemented Interfaces:
Animatable

public class AnimatedVector
extends Object
implements Animatable

Defines an animatable vector. It is a general purpose animation target.

This class supports animation of multi-channel animation data with a maximum component size of AnimationKeyframeSequence.PROPERTY_COUNT_MAX.

Targetting an AnimatedVector for Animation

 // Vector data.
 float[] rgb = {1.0, 0.0, 0.0};
 // Create a vector with one channel of data, and a property component size of three.
 AnimatedVector vector = new AnimatedVector(1, 3, rgb, 0);
 // Create an animation targetting the vector.
 Animation vectorAnimation = animator.addAnimation(vector, AnimatedVector.ANIMATION_PROPERTY_VECTOR, 3, new float[] {0.0f, 0.5f, 1.0f}, 0, 
    new float[] {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}, 0, Animation.EASINGCURVE_ELASTIC_OUT, 1000L);
 

The vector can now be used to represent the desired animatable property. In this case, the vector represents color and the animation is a three keyframe animation that will animate the vector from red, to green, to blue.

Since:
BlackBerry API 6.0.0

Field Summary
static int ANIMATION_PROPERTY_VECTOR
          Constant that represents the Animatable property.
 
Constructor Summary
AnimatedVector(float[] array)
           Class constructor that initializes the vector with a float array.
AnimatedVector(int componentCount, float[] array, int offset)
           Class constructor.
AnimatedVector(int channelCount, int componentCount, float[] array, int offset)
          Constructor.
 
Method Summary
 int getAnimationPropertyComponentCount(int property)
           Gets the number of components of the specified property.
 void getAnimationValue(int property, AnimationValue value)
           Gets the value or values of the specified property.
 Buffer getBuffer()
          Gets the data as a Buffer.
 void getFloat(float[] value, int offset)
           Gets the value of the AnimatedVector.
 float getFloat(int index)
          Gets the value for the given component of the AnimatedVector as a float.
 void getFloat(int channel, float[] value, int offset)
           Gets the value of the AnimatedVector on the specified data channel.
 float getFloat(int channel, int index)
          Gets the value for the given component of the AnimatedVector as a float on the specified data channel.
 int getInt(int index)
           Gets the value of the specified component of the AnimatedVector as an int.
 int getInt(int channel, int index)
           Gets the value of the specified component of the AnimatedVector as an int on the specified data channel.
 void getInt(int channel, int[] value, int offset)
           Gets the value of the AnimatedVector on the specified data channel.
 void getInt(int[] value, int offset)
           Gets the value of the AnimatedVector.
 void setAnimationValue(int property, AnimationValue value)
           Sets the value or values of the specified property.
 void setFloat(float[] value, int offset)
           Sets the value of the AnimatedVector.
 void setFloat(int index, float value)
           Sets the value of the specified component of the AnimatedVector.
 void setFloat(int channel, float[] value, int offset)
           Sets the value of the AnimatedVector on the specified data channel.
 void setFloat(int channel, int index, float value)
           Sets the value of the specified component of the AnimatedVector on the specified data channel.
 void setInt(int index, int value)
           Sets the value of the specified component of the AnimatedVector.
 void setInt(int channel, int index, int value)
           Sets the value for the given component of the AnimatedVector on the specified data channel.
 void setInt(int channel, int[] value, int offset)
           Sets the value of the AnimatedVector on the specified data channel.
 void setInt(int[] value, int offset)
           Sets the value of the AnimatedVector.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Field Detail

ANIMATION_PROPERTY_VECTOR

public static int ANIMATION_PROPERTY_VECTOR
Constant that represents the Animatable property.

Since:
BlackBerry API 6.0.0


Constructor Detail

AnimatedVector

public AnimatedVector(float[] array)

Class constructor that initializes the vector with a float array.

Parameters:
array - The array of data to populate the AnimatedVector with.
Throws:
IllegalArgumentException - if array is null.
IllegalArgumentException - if array.length == 0 or array.length > AnimationKeyframeSequence.PROPERTY_COUNT_MAX.
Since:
BlackBerry API 6.0.0

AnimatedVector

public AnimatedVector(int componentCount,
                      float[] array,
                      int offset)

Class constructor.

Parameters:
componentCount - The number of components that comprise the AnimatedVector.
array - The array of data to populate the AnimatedVector with.
offset - The offset into the given array.
Throws:
IllegalArgumentException - if componentCount < 1 or componentCount > AnimationKeyframeSequence.PROPERTY_COUNT_MAX.}
IllegalArgumentException - if array is null
IllegalArgumentException - if offset < 0.
IllegalArgumentException - if array.length - componentCount + offset < 1 or array.length - componentCount + offset > AnimationKeyframeSequence.PROPERTY_COUNT_MAX.
Since:
BlackBerry API 6.0.0

AnimatedVector

public AnimatedVector(int channelCount,
                      int componentCount,
                      float[] array,
                      int offset)
Constructor.

The length of the array being passed in must be at least channelCount * componentCount + offset.

Parameters:
channelCount - The number data channels on the AnimatedVector.
componentCount - The number of components that comprise the AnimatedVector.
array - The array of data to populate the AnimatedVector with.
offset - The offset into the given array.
Throws:
IllegalArgumentException - if channelCount < 1.
IllegalArgumentException - if componentCount < 1 or componentCount > AnimationKeyframeSequence.PROPERTY_COUNT_MAX.
IllegalArgumentException - if array is null.
IllegalArgumentException - if offset < 0.
IllegalArgumentException - if array.length - offset < 1 or array.length - offset > AnimationKeyframeSequence.PROPERTY_COUNT_MAX.
Since:
BlackBerry API 6.0.0


Method Detail

getBuffer

public Buffer getBuffer()
Gets the data as a Buffer.

Returns:
Buffer.
Since:
BlackBerry API 6.0.0

getFloat

public float getFloat(int index)
Gets the value for the given component of the AnimatedVector as a float.

Parameters:
index - The index of the component to get the value from.
Returns:
The value for the given component of the AnimatedVector.
Throws:
IllegalArgumentException - if index < 0 or index >= the component count.
Since:
BlackBerry API 6.0.0

getFloat

public float getFloat(int channel,
                      int index)
Gets the value for the given component of the AnimatedVector as a float on the specified data channel.

Parameters:
channel - The data channel to get the value from.
index - The index of the component to get the value from.
Returns:
The value for the given component of the AnimatedVector.
Throws:
IllegalArgumentException - if channel < 0 or channel >= the channel count.
IllegalArgumentException - if index < 0 or index >= the component count.
Since:
BlackBerry API 6.0.0

setFloat

public void setFloat(int index,
                     float value)

Sets the value of the specified component of the AnimatedVector.

Parameters:
index - The index of the component to set the value on.
value - The value to set in the component of the AnimatedVector.
Throws:
IllegalArgumentException - if index < 0 or index >= the component count.
Since:
BlackBerry API 6.0.0

setFloat

public void setFloat(int channel,
                     int index,
                     float value)

Sets the value of the specified component of the AnimatedVector on the specified data channel.

Parameters:
channel - The data channel to set the data on.
index - The index of the component to set the value on.
value - The value to set in the component of the AnimatedVector.
Throws:
IllegalArgumentException - if channel < 0 or channel >= the channel count.
IllegalArgumentException - if index < 0 or index >= the component count.
Since:
BlackBerry API 6.0.0

getFloat

public void getFloat(float[] value,
                     int offset)

Gets the value of the AnimatedVector.

Parameters:
value - The array to populate with the AnimatedVector's values.
offset - The offset into the array to start populating at.
Throws:
IllegalArgumentException - if value is null.
IllegalArgumentException - if offset < 0.
IllegalArgumentException - if value.length < offset + the component count.
Since:
BlackBerry API 6.0.0

getFloat

public void getFloat(int channel,
                     float[] value,
                     int offset)

Gets the value of the AnimatedVector on the specified data channel.

Parameters:
channel - The data channel to get the value from.
value - The array to populate with the AnimatedVector's values.
offset - The offset into the array to start populating at; must be non-negative.
Throws:
IllegalArgumentException - if channel < 0 or channel >= the channel count.
IllegalArgumentException - if value is null.
IllegalArgumentException - if offset < 0.
IllegalArgumentException - if value.length < offset + the component count.
Since:
BlackBerry API 6.0.0

setFloat

public void setFloat(float[] value,
                     int offset)

Sets the value of the AnimatedVector.

Parameters:
value - The array to populate the AnimatedVector's values with.
offset - The offset into the array to start copying from.
Throws:
IllegalArgumentException - if value is null.
IllegalArgumentException - if offset < 0.
IllegalArgumentException - if value.length < offset + the component count and offset.
Since:
BlackBerry API 6.0.0

setFloat

public void setFloat(int channel,
                     float[] value,
                     int offset)

Sets the value of the AnimatedVector on the specified data channel.

Parameters:
channel - The data channel to set the data on.
value - The array to populate the AnimatedVector's values with.
offset - The offset into the array to start copying from.
Throws:
IllegalArgumentException - if channel < 0 or channel >= the channel count.
IllegalArgumentException - if value is null.
IllegalArgumentException - if offset < 0.
IllegalArgumentException - if value.length < offset + the component count.
Since:
BlackBerry API 6.0.0

getInt

public int getInt(int index)

Gets the value of the specified component of the AnimatedVector as an int.

Parameters:
index - The index of the component to get the value from.
Returns:
The value for the given component of the AnimatedVector.
Throws:
IllegalArgumentException - if index < 0 or index >= the component count.
Since:
BlackBerry API 6.0.0

getInt

public int getInt(int channel,
                  int index)

Gets the value of the specified component of the AnimatedVector as an int on the specified data channel.

Parameters:
channel - The data channel to get the value from.
index - The index of the component to get the value from.
Returns:
The value for the given component of the AnimatedVector.
Throws:
IllegalArgumentException - if channel < 0 or channel >= the channel count.
IllegalArgumentException - if index< 0 or index >= the component count.
Since:
BlackBerry API 6.0.0

setInt

public void setInt(int index,
                   int value)

Sets the value of the specified component of the AnimatedVector.

Parameters:
index - The index of the component to set the value on.
value - The value to set in the component of the AnimatedVector.
Throws:
IllegalArgumentException - if index < 0 or index >= the component count.
Since:
BlackBerry API 6.0.0

setInt

public void setInt(int channel,
                   int index,
                   int value)

Sets the value for the given component of the AnimatedVector on the specified data channel.

Parameters:
channel - The data channel to set the data on.
index - The index of the component to set the value on.
value - The value to set in the component of the AnimatedVector.
Throws:
IllegalArgumentException - if channel < 0 or channel >= the channel count.
IllegalArgumentException - if index < 0 or index >= the component count.
Since:
BlackBerry API 6.0.0

getInt

public void getInt(int[] value,
                   int offset)

Gets the value of the AnimatedVector.

Parameters:
value - The array to populate with the AnimatedVector's values.
offset - The offset into the array to start populating at.
Throws:
IllegalArgumentException - if value is null.
IllegalArgumentException - if offset < 0.
IllegalArgumentException - if value.length < offset + the component count.
Since:
BlackBerry API 6.0.0

getInt

public void getInt(int channel,
                   int[] value,
                   int offset)

Gets the value of the AnimatedVector on the specified data channel.

Parameters:
channel - The data channel to get the value from.
value - The array to populate with the AnimatedVector's values.
offset - The offset into the array to start populating at.
Throws:
IllegalArgumentException - if channel < 0 or channel >= the channel count.
IllegalArgumentException - if value is null.
IllegalArgumentException - if offset < 0.
IllegalArgumentException - if value.length < offset + the component count.
Since:
BlackBerry API 6.0.0

setInt

public void setInt(int[] value,
                   int offset)

Sets the value of the AnimatedVector.

Parameters:
value - The array to populate the AnimatedVector's values with.
offset - The offset into the array to start copying from.
Throws:
IllegalArgumentException - if value is null.
IllegalArgumentException - if offset < 0.
IllegalArgumentException - if value.length < offset + the component count.
Since:
BlackBerry API 6.0.0

setInt

public void setInt(int channel,
                   int[] value,
                   int offset)

Sets the value of the AnimatedVector on the specified data channel.

Parameters:
channel - The data channel to set the data on.
value - The array to populate the AnimatedVector's values with.
offset - The offset into the array to start copying from.
Throws:
IllegalArgumentException - if channel < 0 or channel >= the channel count.
IllegalArgumentException - if value is null.
IllegalArgumentException - if offset < 0.
IllegalArgumentException - if value.length < offset + the component count.
Since:
BlackBerry API 6.0.0

getAnimationValue

public void getAnimationValue(int property,
                              AnimationValue value)
Description copied from interface: Animatable

Gets the value or values of the specified property.

Used by the Animation framework to get the values of the specified property on the Animatable. The implementer must set the value of the specified target property in the AnimationValue parameter.

Specified by:
getAnimationValue in interface Animatable
Parameters:
property - The property to get the current value or values of.
value - An AnimationValue used to store the returned property values.
See Also:
Animatable.getAnimationValue(int,AnimationValue)
Since:
BlackBerry API 6.0.0

setAnimationValue

public void setAnimationValue(int property,
                              AnimationValue value)
Description copied from interface: Animatable

Sets the value or values of the specified property.

Used by the Animation framework to update the value or values of the specified target property on the Animatable with the currently calculated animation value. The implementer must update the current value or values of the given target property with the values in the AnimationValue parameter.

Specified by:
setAnimationValue in interface Animatable
Parameters:
property - The property to set the current value or values of.
value - The AnimationValue used to specify the value or values to set.
See Also:
Animatable.setAnimationValue(int,AnimationValue)
Since:
BlackBerry API 6.0.0

getAnimationPropertyComponentCount

public int getAnimationPropertyComponentCount(int property)
Description copied from interface: Animatable

Gets the number of components of the specified property.

The implementer must define the component size of every animatable property defined for the Animatable.

Specified by:
getAnimationPropertyComponentCount in interface Animatable
Parameters:
property - The property to retrieve the component count for.
Returns:
The number of components comprising the specified property.
See Also:
Animatable.getAnimationPropertyComponentCount(int)
Since:
BlackBerry API 6.0.0





Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.