Java TV(tm) API 1.0

javax.tv.graphics
Class AlphaColor

java.lang.Object
  |
  +--java.awt.Color
        |
        +--javax.tv.graphics.AlphaColor
All Implemented Interfaces:
java.awt.Paint, java.io.Serializable, java.awt.Transparency

public class AlphaColor
extends java.awt.Color

A class that allows a very simple, interoperable form of compositing. This is achieved by setting an alpha value for alpha blending on a color. Higher alpha values indicate greater opacity of the color; lower values indicate greater transparency. The alpha value will be respected by all instances of java.awt.Graphics given to applications.

In the final composition between the graphics and video, the underlying video stream will be alpha-blended with the AWT graphics plane using that pixel's alpha value by default, i.e. source over compositing will be used between the video plane and the AWT graphics plane by default. This behavior can be changed using other APIs, possibly APIs defined outside of Java TV.

This API supports up to 256 levels of alpha blending. However, an individual graphics system may support fewer levels. Such systems will round the alpha value specified in an AlphaColor constructor to some nearest value when the AlphaColor instance is used, e.g. rounding to the nearest implemented alpha value.

Systems on which alpha blending is not supported will interpret alpha values other than 255 as if they were 255 (opaque) instead.

The actual color used in rendering will depend on finding the best match given the color space available for a given output device.

Within the AWT graphics plane, the actual compositing done will be platform-dependent.

See Also:
getAlpha(), Serialized Form

Fields inherited from class java.awt.Color
black, blue, cyan, darkGray, gray, green, lightGray, magenta, orange, pink, red, white, yellow
 
Fields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT
 
Constructor Summary
AlphaColor(java.awt.Color c)
          Constructs a new AlphaColor using the specified java.awt.Color.
AlphaColor(float r, float g, float b, float a)
          Creates an sRGB color with the specified red, green, blue, and alpha values in the range [0.0 - 1.0].
AlphaColor(int argb, boolean hasAlpha)
          Creates an sRGB color with the specified combined RGBA value consisting of the alpha component in bits 24-31, the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7.
AlphaColor(int r, int g, int b, int a)
          Creates an sRGB color with the specified red, green, blue, and alpha values in the range 0-255, inclusive.
 
Method Summary
 java.awt.Color brighter()
          Creates a brighter version of this color.
 java.awt.Color darker()
          Creates a darker version of this color.
 boolean equals(java.lang.Object obj)
          Determines whether another object is equal to this AlphaColor.
 int getAlpha()
          Reports the alpha value of this AlphaColor instance.
 int getRGB()
          Returns the RGB value representing the color in the default sRGB ColorModel.
 int hashCode()
          Computes the hash code for this color.
 java.lang.String toString()
          Creates a string that represents this AlphaColor.
 
Methods inherited from class java.awt.Color
createContext, decode, getBlue, getColor, getColor, getColor, getColorComponents, getColorComponents, getColorSpace, getComponents, getComponents, getGreen, getHSBColor, getRed, getRGBColorComponents, getRGBComponents, getTransparency, HSBtoRGB, RGBtoHSB
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AlphaColor

public AlphaColor(float r,
                  float g,
                  float b,
                  float a)
Creates an sRGB color with the specified red, green, blue, and alpha values in the range [0.0 - 1.0].
Parameters:
r - The red component.
g - The green component.
b - The blue component.
a - The alpha component.
Throws:
java.lang.IllegalArgumentException - If any of the input parameters are outside the range [0.0 - 1.0].
See Also:
Color.getRed(), Color.getGreen(), Color.getBlue(), getAlpha(), getRGB()

AlphaColor

public AlphaColor(int r,
                  int g,
                  int b,
                  int a)
Creates an sRGB color with the specified red, green, blue, and alpha values in the range 0-255, inclusive.
Parameters:
r - The red component.
g - The green component.
b - The blue component.
a - The alpha component.
Throws:
java.lang.IllegalArgumentException - If any of the input parameters are outside the range [0 - 255].
See Also:
Color.getRed(), Color.getGreen(), Color.getBlue(), getAlpha(), getRGB()

AlphaColor

public AlphaColor(int argb,
                  boolean hasAlpha)
Creates an sRGB color with the specified combined RGBA value consisting of the alpha component in bits 24-31, the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7. If the hasAlpha argument is false, alpha is set to 255.
Parameters:
argb - The combined ARGB components
hasAlpha - true if the alpha bits are to be used, false otherwise.
See Also:
Color.getRed(), Color.getGreen(), Color.getBlue(), getAlpha(), getRGB()

AlphaColor

public AlphaColor(java.awt.Color c)
Constructs a new AlphaColor using the specified java.awt.Color. If this color has no alpha value, alpha will be set to 255 (opaque).
Parameters:
c - the color
Method Detail

brighter

public java.awt.Color brighter()
Creates a brighter version of this color.

Although brighter and darker are inverse operations, the results of a series of invocations of these two methods may be inconsistent because of rounding errors.

Overrides:
brighter in class java.awt.Color
Returns:
A new AlphaColor object
See Also:
darker()

darker

public java.awt.Color darker()
Creates a darker version of this color.

Although brighter and darker are inverse operations, the results of a series of invocations of these two methods may be inconsistent because of rounding errors.

Overrides:
darker in class java.awt.Color
Returns:
A new AlphaColor object
See Also:
brighter()

equals

public boolean equals(java.lang.Object obj)
Determines whether another object is equal to this AlphaColor.

The result is true if and only if the argument is not null and is a AlphaColor object that has the same red, green, blue and alpha values as this object.

Overrides:
equals in class java.awt.Color
Parameters:
obj - The object to test for equality with this AlphaColor
Returns:
true if the objects are the same; false otherwise.

hashCode

public int hashCode()
Computes the hash code for this color.
Overrides:
hashCode in class java.awt.Color
Returns:
a hash code for this object.

getAlpha

public int getAlpha()
Reports the alpha value of this AlphaColor instance.
Overrides:
getAlpha in class java.awt.Color
Returns:
The alpha value, in the range 0-255 inclusive.
See Also:
getRGB()

getRGB

public int getRGB()
Returns the RGB value representing the color in the default sRGB ColorModel. (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue).
Overrides:
getRGB in class java.awt.Color
Returns:
The RGB value as an int.
See Also:
ColorModel.getRGBdefault(), Color.getRed(), Color.getGreen(), Color.getBlue()

toString

public java.lang.String toString()
Creates a string that represents this AlphaColor.
Overrides:
toString in class java.awt.Color
Returns:
a representation of this color as a String object.

Java TV(tm) API 1.0

Copyright © 1998 - 2000 Sun Microsystems, Inc.