|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.math.Transform2D
public class Transform2D
Defines a 2-dimensional transformation.
Note: When using the scale
, shear
, rotate
, and translate
methods,
only the transform's corresponding scale, shear, rotation, or translation component is updated (it is not as if the
scale, shear, rotate, or translate is applied to the transform's matrix).
For example, if the user calls t.rotate(angle)
, this updates t
's internal
rotation component by rotating it counter-clockwise by angle
radians. The following
code demonstrates this more clearly:
// Create a non-identity transform and get a copy of its matrix.
Transform2D t1 = new Transform2D(new Vector2f(1.2f, 1.7f), new Vector2f(), 0.0f, new Vector2f(10.0f, -2.0f)); Matrix3f t2 = new Matrix3f(t1.getMatrix());// Rotate the transform's rotation component by 35 degrees (counter-clockwise) and get the new matrix.
t1.rotate((float)Math.toRadians(35.0f)); Matrix3f t1Matrix = t1.getMatrix();// Multiply t1's original matrix by a matrix representing the same rotation as above.
Matrix3f rotate = new Matrix3f(); Matrix3f.createRotation((float)Math.toRadians(35.0f), rotate); t2.multiply(rotate);// At this point, t1Matrix is not equal to t2!
if (t1Matrix.equals(t2)) throw new RuntimeException();
Note: To construct a Transform2D from a transformation matrix stored as a Matrix3f,
first decompose the Matrix3f into its separate translation, scale, shear, and rotation
components using Matrix3f.decompose(Vector2f, Vector2f, Matrix3f, Vector2f)
and then
pass those arguments to the appropriate constructor or set methods of Transform2D.
Matrix3f.decompose(Vector2f, Vector2f, Matrix3f, Vector2f)
Field Summary | ||
---|---|---|
static int |
ANIMATION_PROPERTY_ROTATE
Used to animate the rotation component. |
|
static int |
ANIMATION_PROPERTY_SCALE
Used to animate the scale component. |
|
static int |
ANIMATION_PROPERTY_SHEAR
Used to animate the shear component. |
|
static int |
ANIMATION_PROPERTY_TRANSFORM
Used to animate the all components. |
|
static int |
ANIMATION_PROPERTY_TRANSLATE
Used to animate the translation component. |
|
static int |
ANIMATION_PROPERTY_TRANSLATE_ROTATE
Used to animate the translation-rotation component. |
Constructor Summary | ||
---|---|---|
Transform2D()
Constructs the identity transform. |
||
Transform2D(Transform2D transform)
Constructs a new transform from the given transform. |
||
Transform2D(Vector2f scale,
Vector2f shear,
float rotation,
Vector2f translation)
Constructs a new transform from the specified values. |
Method Summary | ||
---|---|---|
boolean |
equals(Object obj)
Determines if the specified object is of type Transform2D and all of its elements are equal to the elements of this transform. |
|
boolean |
equals(Transform2D transform)
Returns true if all elements of the specified transform are equal to the elements of this transform. |
|
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. |
|
Matrix3f |
getMatrix()
Gets the matrix corresponding to this transform. |
|
void |
getMatrix(Matrix3f matrix)
Gets the matrix corresponding to the transform in the specified matrix. |
|
float |
getRotation()
Gets the orientation angle of this transform. |
|
void |
getScale(Vector2f scale)
Gets the scale component of this transform in the specified vector. |
|
void |
getShear(Vector2f shear)
Gets the shear component of this transform in the specified vector. |
|
void |
getTranslation(Vector2f translation)
Gets the translation component of this transform in the specified vector. |
|
int |
hashCode()
Returns a hash code based on the elements of this transform. |
|
void |
rotate(float angle)
Rotates this transform by the given rotation defined as an angle about the origin. |
|
void |
rotate(float angle,
Transform2D dst)
Rotates this transform by the given rotation defined as an angle about the origin and stores the result in the given destination transform. |
|
void |
scale(float scale)
Scales this transform's scale component by the given factor along all axes. |
|
void |
scale(float sx,
float sy)
Scales this transform's scale component by the given factors along each axis. |
|
void |
scale(float sx,
float sy,
Transform2D dst)
Scales this transform's scale component by the given factors along each axis and stores the result in the given destination transform. |
|
void |
scale(float scale,
Transform2D dst)
Scales this transform's scale component by the given factor along all axes and stores the result in the given destination transform. |
|
void |
scale(Vector2f scale)
Scales this transform's scale component by the given scale vector. |
|
void |
scale(Vector2f scale,
Transform2D dst)
Scales this transform's scale component by the given scale vector and stores the result in the given destination transform. |
|
void |
scaleX(float sx)
Scales this transform's scale component by the given scale factor along the x axis. |
|
void |
scaleX(float sx,
Transform2D dst)
Scales this transform's scale component by the given scale factor along the x axis and stores the result in the given destination transform. |
|
void |
scaleY(float sy)
Scales this transform's scale component by the given scale factor along the y axis. |
|
void |
scaleY(float sy,
Transform2D dst)
Scales this transform's scale component by the given scale factor along the y axis and stores the result in the given destination transform. |
|
void |
set(Transform2D transform)
Sets this transform to the specified transform. |
|
void |
set(Vector2f scale,
Vector2f shear,
float rotation,
Vector2f translation)
Sets the transform to the specified values. |
|
void |
setAnimationValue(int property,
AnimationValue value)
Sets the value or values of the specified property. |
|
void |
setRotation(float angle)
Sets the orientation angle of this transform to the specified values. |
|
void |
setScale(float scale)
Sets the scale factor along all axes for this transform to the specified value. |
|
void |
setScale(float sx,
float sy)
Sets the scale component of this transform to the specified values. |
|
void |
setScale(Vector2f scale)
Sets the scale component of this transform to the specified scale vector. |
|
void |
setShear(float shear)
Sets the shear factor along all axes for this transform to the specified value. |
|
void |
setShear(float shx,
float shy)
Sets the shear component of this transform to the specified values. |
|
void |
setShear(Vector2f shear)
Sets the shear component of this transform to the specified vector. |
|
void |
setTranslation(float tx,
float ty)
Sets the translation component for this transform to the specified values. |
|
void |
setTranslation(Vector2f translation)
Sets the translation component for this transform to the specified translation vector. |
|
void |
shear(float shear)
Shears this transform's shear component by the given shear factor along both axes. |
|
void |
shear(float shx,
float shy)
Shears this transform's shear component by the given factors along each axis. |
|
void |
shear(float shx,
float shy,
Transform2D dst)
Shears this transform's shear component by the given factors along each axis and stores the result in the given destination transform. |
|
void |
shear(float shear,
Transform2D dst)
Shears this transform's shear component by the given shear factor along both axes and stores the result in the given destination transform. |
|
void |
shear(Vector2f shear)
Shears this transform's shear component by the given shear vector. |
|
void |
shear(Vector2f shear,
Transform2D dst)
Shears this transform's shear component by the given shear vector and stores the result in the given destination transform. |
|
void |
shearX(float shx)
Shears this transform's shear component by the given factor along the x-axis. |
|
void |
shearX(float shx,
Transform2D dst)
Shears this transform's shear component by the given factor along the x-axis and stores the result in the given destination transform. |
|
void |
shearY(float shy)
Shears this transform's shear component by the given factor along the y-axis. |
|
void |
shearY(float shy,
Transform2D dst)
Shears this transform's shear component by the given factor along the y-axis and stores the result in the given destination transform. |
|
String |
toString()
Returns a String representation of this transform. |
|
void |
transformPoint(Vector2f point)
Transforms the specified point and stores the result in the original point. |
|
void |
transformPoint(Vector2f point,
Vector2f dst)
Transforms the specified point and stores the result in the specified destination point. |
|
void |
transformVector(Vector2f vector)
Transforms the specified vector and stores the result in the original vector. |
|
void |
transformVector(Vector2f vector,
Vector2f dst)
Transforms the specified vector and stores the result in the specified destination vector. |
|
void |
translate(float tx,
float ty)
Translates this transform's translation component by the given values along each axis. |
|
void |
translate(float tx,
float ty,
Transform2D dst)
Translates this transform's translation component by the given values along each axis and stores the result in the given destination transform. |
|
void |
translate(Vector2f translation)
Translates this transform's translation component by the given translation vector. |
|
void |
translate(Vector2f translation,
Transform2D dst)
Translates this transform's translation component by the given translation vector and stores the result in the given destination transform. |
|
void |
translateX(float tx)
Translates this transform's translation component by the given value along the x axis. |
|
void |
translateX(float tx,
Transform2D dst)
Translates this transform's translation component by the given value along the x axis and stores the result in the given destination transform. |
|
void |
translateY(float ty)
Translates this transform's translation component by the given value along the y axis. |
|
void |
translateY(float ty,
Transform2D dst)
Translates this transform's translation component by the given value along the y axis and stores the result in the given destination transform. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int ANIMATION_PROPERTY_TRANSLATE
Required AnimationKeyframeSequence data format:
float[] data = { translation.x, translation.y }
public static final int ANIMATION_PROPERTY_ROTATE
Required AnimationKeyframeSequence data format:
float[] data = { (float)Math.toRadians(angleInDegrees) }
public static final int ANIMATION_PROPERTY_SCALE
Required AnimationKeyframeSequence data format:
float[] data = { scale.x, scale.y }
public static final int ANIMATION_PROPERTY_SHEAR
Required AnimationKeyframeSequence data format:
float[] data = { shear.x, shear.y }
public static final int ANIMATION_PROPERTY_TRANSLATE_ROTATE
Required AnimationKeyframeSequence data format:
float[] data = { translate.x, translate.y, (float)Math.toRadians(angleInDegrees), shear.x, shear.y, scale.x, scale.y }
public static final int ANIMATION_PROPERTY_TRANSFORM
Constructor Detail |
---|
public Transform2D()
public Transform2D(Vector2f scale, Vector2f shear, float rotation, Vector2f translation)
scale
- The scale vector.shear
- The shear vector.rotation
- The rotation angle, in radians.translation
- The translation vector.
NullPointerException
- If scale
, rotation
, or translation
is null
.public Transform2D(Transform2D transform)
transform
- The transform to copy.
NullPointerException
- If transform
is null
.Method Detail |
---|
public void getMatrix(Matrix3f matrix)
matrix
- The matrix to store the transformation matrix in.
NullPointerException
- If matrix
is null
.public Matrix3f getMatrix()
Note: The matrix returned from this method is mathematically equivalent to this transform only as long as this transform is not changed (i.e. by calling set(), setScale(), translate(), rotate(), etc.). Once the transform has been changed, the user must call getMatrix() again to get the updated matrix. Also note that changing the matrix returned from this method does not change this transform.
public void getScale(Vector2f scale)
scale
- The vector to store the scale in.
NullPointerException
- If scale
is null
.public void getShear(Vector2f shear)
shear
- The vector to store the shear in.
NullPointerException
- If shear
is null
.public float getRotation()
rotation
- The matrix to store the rotation in.
public void getTranslation(Vector2f translation)
translation
- The vector to store the translation in.
NullPointerException
- If translation
is null
.public void rotate(float angle)
angle
- The angle to rotate by.public void rotate(float angle, Transform2D dst)
angle
- The angle to rotate by, in radians.dst
- The destination transform.
NullPointerException
- If dst
is null
.public void scale(float scale)
scale
- The factor to scale by.public void scale(float scale, Transform2D dst)
scale
- The factor to scale by.dst
- The destination transform.
NullPointerException
- If dst
is null
.public void scale(float sx, float sy)
sx
- The factor to scale by in the x direction.sy
- The factor to scale by in the y direction.public void scale(float sx, float sy, Transform2D dst)
sx
- The factor to scale by in the x direction.sy
- The factor to scale by in the y direction.dst
- The destination transform.
NullPointerException
- If dst
is null
.public void scale(Vector2f scale)
scale
- The vector to scale by.
NullPointerException
- If scale
is null
.public void scale(Vector2f scale, Transform2D dst)
scale
- The vector to scale by.dst
- The destination transform.
NullPointerException
- If scale
or dst
is null
.public void scaleX(float sx)
sx
- The scale factor along the x axis.public void scaleX(float sx, Transform2D dst)
sx
- The scale factor along the x axis.dst
- The destination transform.
NullPointerException
- If dst
is null
.public void scaleY(float sy)
sy
- The scale factor along the y axis.public void scaleY(float sy, Transform2D dst)
sy
- The scale factor along the y axis.dst
- The destination transform.
NullPointerException
- If dst
is null
.public void shear(float shear)
shear
- The factor to shear by.public void shear(float shear, Transform2D dst)
shear
- The factor to shear by.dst
- The destination transform.
NullPointerException
- If dst
is null
.public void shear(float shx, float shy)
shx
- The factor to shear by in the x direction.shy
- The factor to shear by in the y direction.public void shear(float shx, float shy, Transform2D dst)
shx
- The factor to shear by in the x direction.shy
- The factor to shear by in the y direction.dst
- The destination transform.
NullPointerException
- If dst
is null
.public void shear(Vector2f shear)
shear
- The vector to shear by.
NullPointerException
- If shear
is null
.public void shear(Vector2f shear, Transform2D dst)
shear
- The vector to shear by.dst
- The destination transform.
NullPointerException
- If shear
or dst
is null
.public void shearX(float shx)
shx
- The factor to shear by.public void shearX(float shx, Transform2D dst)
shx
- The factor to shear by.dst
- The destination transform.
NullPointerException
- If dst
is null
.public void shearY(float shy)
shy
- The factor to shear by.public void shearY(float shy, Transform2D dst)
shy
- The factor to shear by.dst
- The destination transform.
NullPointerException
- If dst
is null
.public void set(Vector2f scale, Vector2f shear, float rotation, Vector2f translation)
scale
- The scale vector.shear
- The shear vector.rotation
- The angle of rotation, in radians.translation
- The translation vector.
NullPointerException
- If scale
, shear
, or translation
is null
.public void set(Transform2D transform)
transform
- The transform to set this transform to.
NullPointerException
- If transform
is null
.public void setScale(Vector2f scale)
scale
- The scale vector.
NullPointerException
- If scale
is null
.public void setScale(float sx, float sy)
sx
- The scale factor along the x axis.sy
- The scale factor along the y axis.public void setScale(float scale)
scale
- The scale factor along all axes.public void setShear(Vector2f shear)
shear
- The shear vector.
NullPointerException
- If scale
is null
.public void setShear(float shx, float shy)
sx
- The shear factor along the x-axis.sy
- The shear factor along the y-axis.public void setShear(float shear)
shear
- The shear factor along all axes.public void setRotation(float angle)
angle
- The angle of rotation, in radians.public void setTranslation(Vector2f translation)
translation
- The translation vector.
NullPointerException
- If translation
is null
.public void setTranslation(float tx, float ty)
tx
- The translation amount in the x direction.ty
- The translation amount in the y direction.public void transformPoint(Vector2f point)
point
- The point to transform.
NullPointerException
- If point
is null
.public void transformPoint(Vector2f point, Vector2f dst)
point
- The point to transform.dst
- The point to store the result in.
NullPointerException
- If point
or dst
is null
.public void transformVector(Vector2f vector)
vector
- The vector to transform.
NullPointerException
- If vector
is null
.public void transformVector(Vector2f vector, Vector2f dst)
vector
- The vector to transform.dst
- The vector to store the result in.
NullPointerException
- If vector
or dst
is null
.public void translate(float tx, float ty)
tx
- The amount to translate along the x axis.ty
- The amount to translate along the y axis.public void translate(float tx, float ty, Transform2D dst)
tx
- The amount to translate along the x axis.ty
- The amount to translate along the y axis.dst
- The destination transform.
NullPointerException
- If dst
is null
.public void translate(Vector2f translation)
translation
- The amount to translate.
NullPointerException
- If translation
is null
.public void translate(Vector2f translation, Transform2D dst)
translation
- The amount to translate.dst
- The destination transform.
NullPointerException
- If translation
or dst
is null
.public void translateX(float tx)
tx
- The amount to translate along the x axis.public void translateX(float tx, Transform2D dst)
tx
- The amount to translate along the x axis.dst
- The destination transform.
NullPointerException
- If dst
is null
.public void translateY(float ty)
ty
- The amount to translate along the y axis.public void translateY(float ty, Transform2D dst)
ty
- The amount to translate along the y axis.dst
- The destination transform.
NullPointerException
- If dst
is null
.public boolean equals(Object obj)
equals
in class Object
obj
- The object to compare.
true
if this transform is equal to obj
;
false
otherwise.
NullPointerException
- If obj
is null
.Boolean.hashCode()
,
Hashtable
public boolean equals(Transform2D transform)
transform
- The transform to compare.
true
if this transform is equal to transform
;
false
otherwise.
NullPointerException
- If transform
is null
.public int hashCode()
hashCode
in class Object
Object.equals(java.lang.Object)
,
Hashtable
public String toString()
toString
in class Object
public void getAnimationValue(int property, AnimationValue value)
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.
getAnimationValue
in interface Animatable
property
- The property to get the current value or values of.value
- An AnimationValue
used to store the returned property values.Animatable.getAnimationValue(int,AnimationValue)
public void setAnimationValue(int property, AnimationValue value)
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.
setAnimationValue
in interface Animatable
property
- The property to set the current value or values of.value
- The AnimationValue
used to specify the value or values to set.Animatable.setAnimationValue(int,AnimationValue)
public int getAnimationPropertyComponentCount(int property)
Animatable
Gets the number of components of the specified property.
The implementer must define the component size of every animatable property defined for theAnimatable
.
getAnimationPropertyComponentCount
in interface Animatable
property
- The property to retrieve the component count for.
Animatable.getAnimationPropertyComponentCount(int)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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.