| 
 | JavaTM 2 Platform Std. Ed. v1.4.2 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.awt.AlphaComposite
This AlphaComposite class implements the basic alpha 
 compositing rules for combining source and destination pixels to achieve
 blending and transparency effects with graphics and images.
 The rules implemented by this class are the set of Porter-Duff
 rules described in
 T. Porter and T. Duff, "Compositing Digital Images", SIGGRAPH 84,
 253-259.
If any input does not have an alpha channel, an alpha value of 1.0, which is completely opaque, is assumed for all pixels. A constant alpha value can also be specified to be multiplied with the alpha value of the source pixels.
The following abbreviations are used in the description of the rules:
The color and alpha components produced by the compositing operation are calculated as follows:
Cd = Cs*Fs + Cd*Fd Ad = As*Fs + Ad*Fdwhere Fs and Fd are specified by each rule. The above equations assume that both source and destination pixels have the color components premultiplied by the alpha component. Similarly, the equations expressed in the definitions of compositing rules below assume premultiplied alpha.
 For performance reasons, it is preferrable that Rasters passed to the compose
 method of a CompositeContext object created by the 
 AlphaComposite class have premultiplied data.
 If either source or destination Rasters are not premultiplied, however,
 appropriate conversions are performed before and after the compositing
 operation.
The alpha resulting from the compositing operation is stored in the destination if the destination has an alpha channel. Otherwise, the resulting color is divided by the resulting alpha before being stored in the destination and the alpha is discarded. If the alpha value is 0.0, the color values are set to 0.0.
Composite, 
CompositeContext| Field Summary | |
| static AlphaComposite | ClearAlphaCompositeobject that implements the opaque CLEAR rule
 with an alpha of 1.0f. | 
| static int | CLEARPorter-Duff Clear rule. | 
| static AlphaComposite | DstAlphaCompositeobject that implements the opaque DST rule
 with an alpha of 1.0f. | 
| static int | DSTPorter-Duff Destination rule. | 
| static int | DST_ATOPPorter-Duff Destination Atop Source rule. | 
| static int | DST_INPorter-Duff Destination In Source rule. | 
| static int | DST_OUTPorter-Duff Destination Held Out By Source rule. | 
| static int | DST_OVERPorter-Duff Destination Over Source rule. | 
| static AlphaComposite | DstAtopAlphaCompositeobject that implements the opaque DST_ATOP rule
 with an alpha of 1.0f. | 
| static AlphaComposite | DstInAlphaCompositeobject that implements the opaque DST_IN rule
 with an alpha of 1.0f. | 
| static AlphaComposite | DstOutAlphaCompositeobject that implements the opaque DST_OUT rule
 with an alpha of 1.0f. | 
| static AlphaComposite | DstOverAlphaCompositeobject that implements the opaque DST_OVER rule
 with an alpha of 1.0f. | 
| static AlphaComposite | SrcAlphaCompositeobject that implements the opaque SRC rule
 with an alpha of 1.0f. | 
| static int | SRCPorter-Duff Source rule. | 
| static int | SRC_ATOPPorter-Duff Source Atop Destination rule. | 
| static int | SRC_INPorter-Duff Source In Destination rule. | 
| static int | SRC_OUTPorter-Duff Source Held Out By Destination rule. | 
| static int | SRC_OVERPorter-Duff Source Over Destination rule. | 
| static AlphaComposite | SrcAtopAlphaCompositeobject that implements the opaque SRC_ATOP rule
 with an alpha of 1.0f. | 
| static AlphaComposite | SrcInAlphaCompositeobject that implements the opaque SRC_IN rule
 with an alpha of 1.0f. | 
| static AlphaComposite | SrcOutAlphaCompositeobject that implements the opaque SRC_OUT rule
 with an alpha of 1.0f. | 
| static AlphaComposite | SrcOverAlphaCompositeobject that implements the opaque SRC_OVER rule
 with an alpha of 1.0f. | 
| static AlphaComposite | XorAlphaCompositeobject that implements the opaque XOR rule
 with an alpha of 1.0f. | 
| static int | XORPorter-Duff Source Xor Destination rule. | 
| Method Summary | |
|  CompositeContext | createContext(ColorModel srcColorModel,
              ColorModel dstColorModel,
              RenderingHints hints)Creates a context for the compositing operation. | 
|  boolean | equals(Object obj)Determines whether the specified object is equal to this AlphaComposite. | 
|  float | getAlpha()Returns the alpha value of this AlphaComposite. | 
| static AlphaComposite | getInstance(int rule)Creates an AlphaCompositeobject with the specified rule. | 
| static AlphaComposite | getInstance(int rule,
            float alpha)Creates an AlphaCompositeobject with the specified rule and
 the constant alpha to multiply with the alpha of the source. | 
|  int | getRule()Returns the compositing rule of this AlphaComposite. | 
|  int | hashCode()Returns the hashcode for this composite. | 
| Methods inherited from class java.lang.Object | 
| clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
public static final int CLEAR
Fs = 0 and Fd = 0, thus:
Cd = 0 Ad = 0
public static final int SRC
Fs = 1 and Fd = 0, thus:
Cd = Cs Ad = As
public static final int DST
Fs = 0 and Fd = 1, thus:
Cd = Cd Ad = Ad
public static final int SRC_OVER
Fs = 1 and Fd = (1-As), thus:
Cd = Cs + Cd*(1-As) Ad = As + Ad*(1-As)
public static final int DST_OVER
Fs = (1-Ad) and Fd = 1, thus:
Cd = Cs*(1-Ad) + Cd Ad = As*(1-Ad) + Ad
public static final int SRC_IN
Fs = Ad and Fd = 0, thus:
Cd = Cs*Ad Ad = As*Ad
public static final int DST_IN
Fs = 0 and Fd = As, thus:
Cd = Cd*As Ad = Ad*As
public static final int SRC_OUT
Fs = (1-Ad) and Fd = 0, thus:
Cd = Cs*(1-Ad) Ad = As*(1-Ad)
public static final int DST_OUT
Fs = 0 and Fd = (1-As), thus:
Cd = Cd*(1-As) Ad = Ad*(1-As)
public static final int SRC_ATOP
Fs = Ad and Fd = (1-As), thus:
Cd = Cs*Ad + Cd*(1-As) Ad = As*Ad + Ad*(1-As) = Ad
public static final int DST_ATOP
Fs = (1-Ad) and Fd = As, thus:
Cd = Cs*(1-Ad) + Cd*As Ad = As*(1-Ad) + Ad*As = As
public static final int XOR
Fs = (1-Ad) and Fd = (1-As), thus:
Cd = Cs*(1-Ad) + Cd*(1-As) Ad = As*(1-Ad) + Ad*(1-As)
public static final AlphaComposite Clear
AlphaComposite object that implements the opaque CLEAR rule
 with an alpha of 1.0f.
CLEARpublic static final AlphaComposite Src
AlphaComposite object that implements the opaque SRC rule
 with an alpha of 1.0f.
SRCpublic static final AlphaComposite Dst
AlphaComposite object that implements the opaque DST rule
 with an alpha of 1.0f.
DSTpublic static final AlphaComposite SrcOver
AlphaComposite object that implements the opaque SRC_OVER rule
 with an alpha of 1.0f.
SRC_OVERpublic static final AlphaComposite DstOver
AlphaComposite object that implements the opaque DST_OVER rule
 with an alpha of 1.0f.
DST_OVERpublic static final AlphaComposite SrcIn
AlphaComposite object that implements the opaque SRC_IN rule
 with an alpha of 1.0f.
SRC_INpublic static final AlphaComposite DstIn
AlphaComposite object that implements the opaque DST_IN rule
 with an alpha of 1.0f.
DST_INpublic static final AlphaComposite SrcOut
AlphaComposite object that implements the opaque SRC_OUT rule
 with an alpha of 1.0f.
SRC_OUTpublic static final AlphaComposite DstOut
AlphaComposite object that implements the opaque DST_OUT rule
 with an alpha of 1.0f.
DST_OUTpublic static final AlphaComposite SrcAtop
AlphaComposite object that implements the opaque SRC_ATOP rule
 with an alpha of 1.0f.
SRC_ATOPpublic static final AlphaComposite DstAtop
AlphaComposite object that implements the opaque DST_ATOP rule
 with an alpha of 1.0f.
DST_ATOPpublic static final AlphaComposite Xor
AlphaComposite object that implements the opaque XOR rule
 with an alpha of 1.0f.
XOR| Method Detail | 
public static AlphaComposite getInstance(int rule)
AlphaComposite object with the specified rule.
rule - the compositing rule
IllegalArgumentException - if rule is not one of 
         the following:  CLEAR, SRC, DST,
         SRC_OVER, DST_OVER, SRC_IN, 
         DST_IN, SRC_OUT, DST_OUT,
         SRC_ATOP, DST_ATOP, or XOR
public static AlphaComposite getInstance(int rule,
                                         float alpha)
AlphaComposite object with the specified rule and
 the constant alpha to multiply with the alpha of the source.
 The source is multiplied with the specified alpha before being composited
 with the destination.
rule - the compositing rulealpha - the constant alpha to be multiplied with the alpha of
 the source. alpha must be a floating point number in the
 inclusive range [0.0, 1.0].
IllegalArgumentException - if 
         alpha is less than 0.0 or greater than 1.0, or if
         rule is not one of 
         the following:  CLEAR, SRC, DST,
         SRC_OVER, DST_OVER, SRC_IN, 
         DST_IN, SRC_OUT, DST_OUT,
         SRC_ATOP, DST_ATOP, or XOR
public CompositeContext createContext(ColorModel srcColorModel,
                                      ColorModel dstColorModel,
                                      RenderingHints hints)
createContext in interface CompositesrcColorModel - the ColorModel of the sourcedstColorModel - the ColorModel of the destinationhints - the hint that the context object uses to choose between
 rendering alternatives
CompositeContext object to be used to perform
 compositing operations.public float getAlpha()
AlphaComposite.  If this
 AlphaComposite does not have an alpha value, 1.0 is returned.
AlphaComposite.public int getRule()
AlphaComposite.
AlphaComposite.public int hashCode()
hashCode in class ObjectObject.equals(java.lang.Object), 
Hashtablepublic boolean equals(Object obj)
AlphaComposite.
 
 The result is true if and only if
 the argument is not null and is an
 AlphaComposite object that has the same
 compositing rule and alpha value as this object.
equals in class Objectobj - the Object to test for equality
true if obj equals this
 AlphaComposite; false otherwise.Object.hashCode(), 
Hashtable| 
 | JavaTM 2 Platform Std. Ed. v1.4.2 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.