net.rim.device.api.math
Class Color4f

java.lang.Object
  extended by net.rim.device.api.math.Color4f
All Implemented Interfaces:
Animatable

public class Color4f
extends Object
implements Animatable

Defines a color made up of red, green, blue, and alpha components. Note: The alpha value defaults to 1.0 (opaque).

Since:
BlackBerry API 6.0.0

Field Summary
static int ANIMATION_PROPERTY_A
          Used to animate the alpha component.
static int ANIMATION_PROPERTY_B
          Used to animate the blue component.
static int ANIMATION_PROPERTY_G
          Used to animate the green component.
static int ANIMATION_PROPERTY_R
          Used to animate the red component.
static int ANIMATION_PROPERTY_RGB
          Used to animate the red, green and blue components.
static int ANIMATION_PROPERTY_RGBA
          Used to animate the red, green, blue and alpha components.
 
Constructor Summary
Color4f()
          Constructs a new color initialized to solid (opaque) black.
Color4f(float r, float g, float b)
          Constructs a new color initialized to the specified values (with alpha equal to 1.0).
Color4f(float r, float g, float b, float a)
          Constructs a new color initialized to the specified values.
Color4f(float[] array, int offset)
          Constructs a new color initialized to the specified values.
Color4f(int color)
          Constructs a new color initialized to the given color represented in 32-bit integer ARGB format.
Color4f(Color4f color)
          Constructs a new color from the given color.
 
Method Summary
 boolean equals(Object obj)
          Determines if the specified object is of type Color4f and all of its elements are equal to the elements of this color.
 boolean equals(Color4f color)
          Returns true if all elements of the specified color are equal to the elements of this color.
 float getAlpha()
          Gets the alpha component of the color.
 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.
 float getBlue()
          Gets the blue component of the color.
 float getGreen()
          Gets the green component of the color.
 float getRed()
          Gets the red component of the color.
 int hashCode()
          Returns a hash code based on the elements of this color.
 void set(float r, float g, float b)
          Sets this color to the specified values (this method does not modify alpha).
 void set(float r, float g, float b, float a)
          Sets this color to the specified values.
 void set(float[] array, int offset)
          Sets this color to the specified values.
 void set(int color)
          Sets this color to the given color represented in 32-bit integer ARGB format.
 void set(Color4f color)
          Sets this color to the given color.
 void setAlpha(float a)
          Sets the alpha component of the color.
 void setAnimationValue(int property, AnimationValue value)
           Sets the value or values of the specified property.
 void setBlue(float b)
          Sets the blue component of the color.
 void setGreen(float g)
          Sets the green component of the color.
 void setRed(float r)
          Sets the red component of the color.
 String toString()
          Returns a String representation of this color.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 



Field Detail

ANIMATION_PROPERTY_R

public static final int ANIMATION_PROPERTY_R
Used to animate the red component.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

ANIMATION_PROPERTY_G

public static final int ANIMATION_PROPERTY_G
Used to animate the green component.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

ANIMATION_PROPERTY_B

public static final int ANIMATION_PROPERTY_B
Used to animate the blue component.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

ANIMATION_PROPERTY_A

public static final int ANIMATION_PROPERTY_A
Used to animate the alpha component.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

ANIMATION_PROPERTY_RGB

public static final int ANIMATION_PROPERTY_RGB
Used to animate the red, green and blue components.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

ANIMATION_PROPERTY_RGBA

public static final int ANIMATION_PROPERTY_RGBA
Used to animate the red, green, blue and alpha components.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0


Constructor Detail

Color4f

public Color4f()
Constructs a new color initialized to solid (opaque) black.

Since:
BlackBerry API 6.0.0

Color4f

public Color4f(int color)
Constructs a new color initialized to the given color represented in 32-bit integer ARGB format.

Parameters:
color - The color to set this color to (in 32-bit integer ARGB format).
See Also:
Color
Since:
BlackBerry API 6.0.0

Color4f

public Color4f(float[] array,
               int offset)
Constructs a new color initialized to the specified values.

Parameters:
array - An array containing the red, green, blue, and alpha values (in that order) for the new color.
offset - The offset into the array to begin reading at.
Throws:
NullPointerException - If array is null.
IllegalArgumentException - If offset is less than zero or offset + 3 is greater than or equal to array.length.
IllegalArgumentException - If any of the float values are less than 0 or greater than 1.
Since:
BlackBerry API 6.0.0

Color4f

public Color4f(float r,
               float g,
               float b)
Constructs a new color initialized to the specified values (with alpha equal to 1.0).

Parameters:
r - The red component.
g - The green component.
b - The blue component.
Throws:
IllegalArgumentException - If r, g, or b is less than 0 or greater than 1.
Since:
BlackBerry API 6.0.0

Color4f

public Color4f(float r,
               float g,
               float b,
               float a)
Constructs a new color initialized to the specified values.

Parameters:
r - The red component.
g - The green component.
b - The blue component.
a - The alpha component.
Since:
BlackBerry API 6.0.0

Color4f

public Color4f(Color4f color)
Constructs a new color from the given color.

Parameters:
color - The color to copy.
Throws:
NullPointerException - If color is null.
Since:
BlackBerry API 6.0.0


Method Detail

getAlpha

public float getAlpha()
Gets the alpha component of the color.

Returns:
The alpha component of the color.
Since:
BlackBerry API 6.0.0

getBlue

public float getBlue()
Gets the blue component of the color.

Returns:
The blue component of the color.
Since:
BlackBerry API 6.0.0

getGreen

public float getGreen()
Gets the green component of the color.

Returns:
The green component of the color.
Since:
BlackBerry API 6.0.0

getRed

public float getRed()
Gets the red component of the color.

Returns:
The red component of the color.
Since:
BlackBerry API 6.0.0

set

public void set(int color)
Sets this color to the given color represented in 32-bit integer ARGB format.

Parameters:
color - The color to set this color to (in 32-bit integer ARGB format).
See Also:
Color
Since:
BlackBerry API 6.0.0

set

public void set(float[] array,
                int offset)
Sets this color to the specified values.

Parameters:
array - An array containing the red, green, blue, and alpha values (in that order) for the new color.
offset - The offset into the array to begin reading at.
Throws:
NullPointerException - If array is null.
IllegalArgumentException - If offset is less than zero or offset + 3 is greater than or equal to array.length.
IllegalArgumentException - If any of the float values are less than 0 or greater than 1.
Since:
BlackBerry API 6.0.0

set

public void set(float r,
                float g,
                float b)
Sets this color to the specified values (this method does not modify alpha).

Parameters:
r - The red component.
g - The green component.
b - The blue component.
Throws:
IllegalArgumentException - If r, g, or b is less than 0 or greater than 1.
Since:
BlackBerry API 6.0.0

set

public void set(float r,
                float g,
                float b,
                float a)
Sets this color to the specified values.

Parameters:
r - The red component.
g - The green component.
b - The blue component.
a - The alpha component.
Throws:
IllegalArgumentException - If r, g, or b is less than 0 or greater than 1.
Since:
BlackBerry API 6.0.0

set

public void set(Color4f color)
Sets this color to the given color.

Parameters:
color - The color to set to.
Throws:
NullPointerException - If color is null.
Since:
BlackBerry API 6.0.0

setAlpha

public void setAlpha(float a)
Sets the alpha component of the color.

Parameters:
a - The alpha component of the color.
Throws:
IllegalArgumentException - If a is less than 0 or greater than 1.
Since:
BlackBerry API 6.0.0

setBlue

public void setBlue(float b)
Sets the blue component of the color.

Parameters:
b - The blue component of the color.
Throws:
IllegalArgumentException - If b is less than 0 or greater than 1.
Since:
BlackBerry API 6.0.0

setGreen

public void setGreen(float g)
Sets the green component of the color.

Parameters:
g - The green component of the color.
Throws:
IllegalArgumentException - If g is less than 0 or greater than 1.
Since:
BlackBerry API 6.0.0

setRed

public void setRed(float r)
Sets the red component of the color.

Parameters:
r - The red component of the color.
Throws:
IllegalArgumentException - If r is less than 0 or greater than 1.
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

equals

public boolean equals(Color4f color)
Returns true if all elements of the specified color are equal to the elements of this color.

Parameters:
color - The color to compare.
Returns:
true if this color is equal to color; false otherwise.
Throws:
NullPointerException - If color is null.
Since:
BlackBerry API 6.0.0

equals

public boolean equals(Object obj)
Determines if the specified object is of type Color4f and all of its elements are equal to the elements of this color.

Overrides:
equals in class Object
Parameters:
obj - The object to compare.
Returns:
true if this color is equal to obj; false otherwise.
Throws:
NullPointerException - If obj is null.
See Also:
Boolean.hashCode(), Hashtable
Since:
BlackBerry API 6.0.0

hashCode

public int hashCode()
Returns a hash code based on the elements of this color.

Overrides:
hashCode in class Object
Returns:
The hash code for this color.
See Also:
Object.equals(java.lang.Object), Hashtable
Since:
BlackBerry API 6.0.0

toString

public String toString()
Returns a String representation of this color.

Overrides:
toString in class Object
Returns:
A String representation of this color.
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.