java.awt
Class AlphaComposite

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.awt.AlphaComposite
All Implemented Interfaces:
Composite sample code for java.awt.Composite definition code for java.awt.Composite

public final class AlphaComposite
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements Composite sample code for java.awt.Composite definition code for java.awt.Composite

The AlphaComposite class implements basic alpha compositing rules for combining source and destination colors to achieve blending and transparency effects with graphics and images. The specific rules implemented by this class are the basic set of 12 rules described in T. Porter and T. Duff, "Compositing Digital Images", SIGGRAPH 84, 253-259. The rest of this documentation assumes some familiarity with the definitions and concepts outlined in that paper.

This class extends the standard equations defined by Porter and Duff to include one additional factor. An instance of the AlphaComposite class can contain an alpha value that is used to modify the opacity or coverage of every source pixel before it is used in the blending equations.

It is important to note that the equations defined by the Porter and Duff paper are all defined to operate on color components that are premultiplied by their corresponding alpha components. Since the ColorModel and Raster classes allow the storage of pixel data in either premultiplied or non-premultiplied form, all input data must be normalized into premultiplied form before applying the equations and all results might need to be adjusted back to the form required by the destination before the pixel values are stored.

Also note that this class defines only the equations for combining color and alpha values in a purely mathematical sense. The accurate application of its equations depends on the way the data is retrieved from its sources and stored in its destinations. See Implementation Caveats for further information.

The following factors are used in the description of the blending equation in the Porter and Duff paper:

Factor  Definition
Asthe alpha component of the source pixel
Csa color component of the source pixel in premultiplied form
Adthe alpha component of the destination pixel
Cda color component of the destination pixel in premultiplied form
Fsthe fraction of the source pixel that contributes to the output
Fdthe fraction of the destination pixel that contributes to the output
Arthe alpha component of the result
Cra color component of the result in premultiplied form

Using these factors, Porter and Duff define 12 ways of choosing the blending factors Fs and Fd to produce each of 12 desirable visual effects. The equations for determining Fs and Fd are given in the descriptions of the 12 static fields that specify visual effects. For example, the description for SRC_OVER specifies that Fs = 1 and Fd = (1-As). Once a set of equations for determining the blending factors is known they can then be applied to each pixel to produce a result using the following set of equations:

        Fs = f(Ad)
        Fd = f(As)
        Ar = As*Fs + Ad*Fd
        Cr = Cs*Fs + Cd*Fd

The following factors will be used to discuss our extensions to the blending equation in the Porter and Duff paper:

Factor  Definition
Csr one of the raw color components of the source pixel
Cdr one of the raw color components of the destination pixel
Aac the "extra" alpha component from the AlphaComposite instance
Asr the raw alpha component of the source pixel
Adrthe raw alpha component of the destination pixel
Adf the final alpha component stored in the destination
Cdf the final raw color component stored in the destination

Preparing Inputs

The AlphaComposite class defines an additional alpha value that is applied to the source alpha. This value is applied as if an implicit SRC_IN rule were first applied to the source pixel against a pixel with the indicated alpha by multiplying both the raw source alpha and the raw source colors by the alpha in the AlphaComposite. This leads to the following equation for producing the alpha used in the Porter and Duff blending equation:

        As = Asr * Aac 
All of the raw source color components need to be multiplied by the alpha in the AlphaComposite instance. Additionally, if the source was not in premultiplied form then the color components also need to be multiplied by the source alpha. Thus, the equation for producing the source color components for the Porter and Duff equation depends on whether the source pixels are premultiplied or not:
        Cs = Csr * Asr * Aac     (if source is not premultiplied)
        Cs = Csr * Aac           (if source is premultiplied) 
No adjustment needs to be made to the destination alpha:
        Ad = Adr 

The destination color components need to be adjusted only if they are not in premultiplied form:

        Cd = Cdr * Ad    (if destination is not premultiplied) 
        Cd = Cdr         (if destination is premultiplied) 

Applying the Blending Equation

The adjusted As, Ad, Cs, and Cd are used in the standard Porter and Duff equations to calculate the blending factors Fs and Fd and then the resulting premultiplied components Ar and Cr.

Preparing Results

The results only need to be adjusted if they are to be stored back into a destination buffer that holds data that is not premultiplied, using the following equations:

        Adf = Ar
        Cdf = Cr                 (if dest is premultiplied)
        Cdf = Cr / Ar            (if dest is not premultiplied) 
Note that since the division is undefined if the resulting alpha is zero, the division in that case is omitted to avoid the "divide by zero" and the color components are left as all zeros.

Performance Considerations

For performance reasons, it is preferrable that Raster objects passed to the compose method of a CompositeContext sample code for java.awt.CompositeContext definition code for java.awt.CompositeContext object created by the AlphaComposite class have premultiplied data. If either the source Raster or the destination Raster is not premultiplied, however, appropriate conversions are performed before and after the compositing operation.

Implementation Caveats

See Also:
Composite sample code for java.awt.Composite definition code for java.awt.Composite , CompositeContext sample code for java.awt.CompositeContext definition code for java.awt.CompositeContext

Field Summary
static AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite Clear sample code for java.awt.AlphaComposite.Clear definition code for java.awt.AlphaComposite.Clear
          AlphaComposite object that implements the opaque CLEAR rule with an alpha of 1.0f.
static int CLEAR sample code for java.awt.AlphaComposite.CLEAR definition code for java.awt.AlphaComposite.CLEAR
          Both the color and the alpha of the destination are cleared (Porter-Duff Clear rule).
static AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite Dst sample code for java.awt.AlphaComposite.Dst definition code for java.awt.AlphaComposite.Dst
          AlphaComposite object that implements the opaque DST rule with an alpha of 1.0f.
static int DST sample code for java.awt.AlphaComposite.DST definition code for java.awt.AlphaComposite.DST
          The destination is left untouched (Porter-Duff Destination rule).
static int DST_ATOP sample code for java.awt.AlphaComposite.DST_ATOP definition code for java.awt.AlphaComposite.DST_ATOP
          The part of the destination lying inside of the source is composited over the source and replaces the destination (Porter-Duff Destination Atop Source rule).
static int DST_IN sample code for java.awt.AlphaComposite.DST_IN definition code for java.awt.AlphaComposite.DST_IN
          The part of the destination lying inside of the source replaces the destination (Porter-Duff Destination In Source rule).
static int DST_OUT sample code for java.awt.AlphaComposite.DST_OUT definition code for java.awt.AlphaComposite.DST_OUT
          The part of the destination lying outside of the source replaces the destination (Porter-Duff Destination Held Out By Source rule).
static int DST_OVER sample code for java.awt.AlphaComposite.DST_OVER definition code for java.awt.AlphaComposite.DST_OVER
          The destination is composited over the source and the result replaces the destination (Porter-Duff Destination Over Source rule).
static AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite DstAtop sample code for java.awt.AlphaComposite.DstAtop definition code for java.awt.AlphaComposite.DstAtop
          AlphaComposite object that implements the opaque DST_ATOP rule with an alpha of 1.0f.
static AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite DstIn sample code for java.awt.AlphaComposite.DstIn definition code for java.awt.AlphaComposite.DstIn
          AlphaComposite object that implements the opaque DST_IN rule with an alpha of 1.0f.
static AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite DstOut sample code for java.awt.AlphaComposite.DstOut definition code for java.awt.AlphaComposite.DstOut
          AlphaComposite object that implements the opaque DST_OUT rule with an alpha of 1.0f.
static AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite DstOver sample code for java.awt.AlphaComposite.DstOver definition code for java.awt.AlphaComposite.DstOver
          AlphaComposite object that implements the opaque DST_OVER rule with an alpha of 1.0f.
static AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite Src sample code for java.awt.AlphaComposite.Src definition code for java.awt.AlphaComposite.Src
          AlphaComposite object that implements the opaque SRC rule with an alpha of 1.0f.
static int SRC sample code for java.awt.AlphaComposite.SRC definition code for java.awt.AlphaComposite.SRC
          The source is copied to the destination (Porter-Duff Source rule).
static int SRC_ATOP sample code for java.awt.AlphaComposite.SRC_ATOP definition code for java.awt.AlphaComposite.SRC_ATOP
          The part of the source lying inside of the destination is composited onto the destination (Porter-Duff Source Atop Destination rule).
static int SRC_IN sample code for java.awt.AlphaComposite.SRC_IN definition code for java.awt.AlphaComposite.SRC_IN
          The part of the source lying inside of the destination replaces the destination (Porter-Duff Source In Destination rule).
static int SRC_OUT sample code for java.awt.AlphaComposite.SRC_OUT definition code for java.awt.AlphaComposite.SRC_OUT
          The part of the source lying outside of the destination replaces the destination (Porter-Duff Source Held Out By Destination rule).
static int SRC_OVER sample code for java.awt.AlphaComposite.SRC_OVER definition code for java.awt.AlphaComposite.SRC_OVER
          The source is composited over the destination (Porter-Duff Source Over Destination rule).
static AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite SrcAtop sample code for java.awt.AlphaComposite.SrcAtop definition code for java.awt.AlphaComposite.SrcAtop
          AlphaComposite object that implements the opaque SRC_ATOP rule with an alpha of 1.0f.
static AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite SrcIn sample code for java.awt.AlphaComposite.SrcIn definition code for java.awt.AlphaComposite.SrcIn
          AlphaComposite object that implements the opaque SRC_IN rule with an alpha of 1.0f.
static AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite SrcOut sample code for java.awt.AlphaComposite.SrcOut definition code for java.awt.AlphaComposite.SrcOut
          AlphaComposite object that implements the opaque SRC_OUT rule with an alpha of 1.0f.
static AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite SrcOver sample code for java.awt.AlphaComposite.SrcOver definition code for java.awt.AlphaComposite.SrcOver
          AlphaComposite object that implements the opaque SRC_OVER rule with an alpha of 1.0f.
static AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite Xor sample code for java.awt.AlphaComposite.Xor definition code for java.awt.AlphaComposite.Xor
          AlphaComposite object that implements the opaque XOR rule with an alpha of 1.0f.
static int XOR sample code for java.awt.AlphaComposite.XOR definition code for java.awt.AlphaComposite.XOR
          The part of the source that lies outside of the destination is combined with the part of the destination that lies outside of the source (Porter-Duff Source Xor Destination rule).
 
Method Summary
 CompositeContext sample code for java.awt.CompositeContext definition code for java.awt.CompositeContext createContext sample code for java.awt.AlphaComposite.createContext(java.awt.image.ColorModel, java.awt.image.ColorModel, java.awt.RenderingHints) definition code for java.awt.AlphaComposite.createContext(java.awt.image.ColorModel, java.awt.image.ColorModel, java.awt.RenderingHints) (ColorModel sample code for java.awt.image.ColorModel definition code for java.awt.image.ColorModel  srcColorModel, ColorModel sample code for java.awt.image.ColorModel definition code for java.awt.image.ColorModel  dstColorModel, RenderingHints sample code for java.awt.RenderingHints definition code for java.awt.RenderingHints  hints)
          Creates a context for the compositing operation.
 boolean equals sample code for java.awt.AlphaComposite.equals(java.lang.Object) definition code for java.awt.AlphaComposite.equals(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  obj)
          Determines whether the specified object is equal to this AlphaComposite.
 float getAlpha sample code for java.awt.AlphaComposite.getAlpha() definition code for java.awt.AlphaComposite.getAlpha() ()
          Returns the alpha value of this AlphaComposite.
static AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite getInstance sample code for java.awt.AlphaComposite.getInstance(int) definition code for java.awt.AlphaComposite.getInstance(int) (int rule)
          Creates an AlphaComposite object with the specified rule.
static AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite getInstance sample code for java.awt.AlphaComposite.getInstance(int, float) definition code for java.awt.AlphaComposite.getInstance(int, float) (int rule, float alpha)
          Creates an AlphaComposite object with the specified rule and the constant alpha to multiply with the alpha of the source.
 int getRule sample code for java.awt.AlphaComposite.getRule() definition code for java.awt.AlphaComposite.getRule() ()
          Returns the compositing rule of this AlphaComposite.
 int hashCode sample code for java.awt.AlphaComposite.hashCode() definition code for java.awt.AlphaComposite.hashCode() ()
          Returns the hashcode for this composite.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

CLEAR sample code for java.awt.AlphaComposite.CLEAR

public static final int CLEAR
Both the color and the alpha of the destination are cleared (Porter-Duff Clear rule). Neither the source nor the destination is used as input.

Fs = 0 and Fd = 0, thus:

        Ar = 0
        Cr = 0

See Also:
Constant Field Values

SRC sample code for java.awt.AlphaComposite.SRC

public static final int SRC
The source is copied to the destination (Porter-Duff Source rule). The destination is not used as input.

Fs = 1 and Fd = 0, thus:

        Ar = As
        Cr = Cs

See Also:
Constant Field Values

DST sample code for java.awt.AlphaComposite.DST

public static final int DST
The destination is left untouched (Porter-Duff Destination rule).

Fs = 0 and Fd = 1, thus:

        Ar = Ad
        Cr = Cd

Since:
1.4
See Also:
Constant Field Values

SRC_OVER sample code for java.awt.AlphaComposite.SRC_OVER

public static final int SRC_OVER
The source is composited over the destination (Porter-Duff Source Over Destination rule).

Fs = 1 and Fd = (1-As), thus:

        Ar = As + Ad*(1-As)
        Cr = Cs + Cd*(1-As)

See Also:
Constant Field Values

DST_OVER sample code for java.awt.AlphaComposite.DST_OVER

public static final int DST_OVER
The destination is composited over the source and the result replaces the destination (Porter-Duff Destination Over Source rule).

Fs = (1-Ad) and Fd = 1, thus:

        Ar = As*(1-Ad) + Ad
        Cr = Cs*(1-Ad) + Cd

See Also:
Constant Field Values

SRC_IN sample code for java.awt.AlphaComposite.SRC_IN

public static final int SRC_IN
The part of the source lying inside of the destination replaces the destination (Porter-Duff Source In Destination rule).

Fs = Ad and Fd = 0, thus:

        Ar = As*Ad
        Cr = Cs*Ad

See Also:
Constant Field Values

DST_IN sample code for java.awt.AlphaComposite.DST_IN

public static final int DST_IN
The part of the destination lying inside of the source replaces the destination (Porter-Duff Destination In Source rule).

Fs = 0 and Fd = As, thus:

        Ar = Ad*As
        Cr = Cd*As

See Also:
Constant Field Values

SRC_OUT sample code for java.awt.AlphaComposite.SRC_OUT

public static final int SRC_OUT
The part of the source lying outside of the destination replaces the destination (Porter-Duff Source Held Out By Destination rule).

Fs = (1-Ad) and Fd = 0, thus:

        Ar = As*(1-Ad)
        Cr = Cs*(1-Ad)

See Also:
Constant Field Values

DST_OUT sample code for java.awt.AlphaComposite.DST_OUT

public static final int DST_OUT
The part of the destination lying outside of the source replaces the destination (Porter-Duff Destination Held Out By Source rule).

Fs = 0 and Fd = (1-As), thus:

        Ar = Ad*(1-As)
        Cr = Cd*(1-As)

See Also:
Constant Field Values

SRC_ATOP sample code for java.awt.AlphaComposite.SRC_ATOP

public static final int SRC_ATOP
The part of the source lying inside of the destination is composited onto the destination (Porter-Duff Source Atop Destination rule).

Fs = Ad and Fd = (1-As), thus:

        Ar = As*Ad + Ad*(1-As) = Ad
        Cr = Cs*Ad + Cd*(1-As)

Since:
1.4
See Also:
Constant Field Values

DST_ATOP sample code for java.awt.AlphaComposite.DST_ATOP

public static final int DST_ATOP
The part of the destination lying inside of the source is composited over the source and replaces the destination (Porter-Duff Destination Atop Source rule).

Fs = (1-Ad) and Fd = As, thus:

        Ar = As*(1-Ad) + Ad*As = As
        Cr = Cs*(1-Ad) + Cd*As

Since:
1.4
See Also:
Constant Field Values

XOR sample code for java.awt.AlphaComposite.XOR

public static final int XOR
The part of the source that lies outside of the destination is combined with the part of the destination that lies outside of the source (Porter-Duff Source Xor Destination rule).

Fs = (1-Ad) and Fd = (1-As), thus:

        Ar = As*(1-Ad) + Ad*(1-As)
        Cr = Cs*(1-Ad) + Cd*(1-As)

Since:
1.4
See Also:
Constant Field Values

Clear sample code for java.awt.AlphaComposite.Clear

public static final AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite  Clear
AlphaComposite object that implements the opaque CLEAR rule with an alpha of 1.0f.

See Also:
CLEAR sample code for java.awt.AlphaComposite.CLEAR definition code for java.awt.AlphaComposite.CLEAR

Src sample code for java.awt.AlphaComposite.Src

public static final AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite  Src
AlphaComposite object that implements the opaque SRC rule with an alpha of 1.0f.

See Also:
SRC sample code for java.awt.AlphaComposite.SRC definition code for java.awt.AlphaComposite.SRC

Dst sample code for java.awt.AlphaComposite.Dst

public static final AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite  Dst
AlphaComposite object that implements the opaque DST rule with an alpha of 1.0f.

Since:
1.4
See Also:
DST sample code for java.awt.AlphaComposite.DST definition code for java.awt.AlphaComposite.DST

SrcOver sample code for java.awt.AlphaComposite.SrcOver

public static final AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite  SrcOver
AlphaComposite object that implements the opaque SRC_OVER rule with an alpha of 1.0f.

See Also:
SRC_OVER sample code for java.awt.AlphaComposite.SRC_OVER definition code for java.awt.AlphaComposite.SRC_OVER

DstOver sample code for java.awt.AlphaComposite.DstOver

public static final AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite  DstOver
AlphaComposite object that implements the opaque DST_OVER rule with an alpha of 1.0f.

See Also:
DST_OVER sample code for java.awt.AlphaComposite.DST_OVER definition code for java.awt.AlphaComposite.DST_OVER

SrcIn sample code for java.awt.AlphaComposite.SrcIn

public static final AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite  SrcIn
AlphaComposite object that implements the opaque SRC_IN rule with an alpha of 1.0f.

See Also:
SRC_IN sample code for java.awt.AlphaComposite.SRC_IN definition code for java.awt.AlphaComposite.SRC_IN

DstIn sample code for java.awt.AlphaComposite.DstIn

public static final AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite  DstIn
AlphaComposite object that implements the opaque DST_IN rule with an alpha of 1.0f.

See Also:
DST_IN sample code for java.awt.AlphaComposite.DST_IN definition code for java.awt.AlphaComposite.DST_IN

SrcOut sample code for java.awt.AlphaComposite.SrcOut

public static final AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite  SrcOut
AlphaComposite object that implements the opaque SRC_OUT rule with an alpha of 1.0f.

See Also:
SRC_OUT sample code for java.awt.AlphaComposite.SRC_OUT definition code for java.awt.AlphaComposite.SRC_OUT

DstOut sample code for java.awt.AlphaComposite.DstOut

public static final AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite  DstOut
AlphaComposite object that implements the opaque DST_OUT rule with an alpha of 1.0f.

See Also:
DST_OUT sample code for java.awt.AlphaComposite.DST_OUT definition code for java.awt.AlphaComposite.DST_OUT

SrcAtop sample code for java.awt.AlphaComposite.SrcAtop

public static final AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite  SrcAtop
AlphaComposite object that implements the opaque SRC_ATOP rule with an alpha of 1.0f.

Since:
1.4
See Also:
SRC_ATOP sample code for java.awt.AlphaComposite.SRC_ATOP definition code for java.awt.AlphaComposite.SRC_ATOP

DstAtop sample code for java.awt.AlphaComposite.DstAtop

public static final AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite  DstAtop
AlphaComposite object that implements the opaque DST_ATOP rule with an alpha of 1.0f.

Since:
1.4
See Also:
DST_ATOP sample code for java.awt.AlphaComposite.DST_ATOP definition code for java.awt.AlphaComposite.DST_ATOP

Xor sample code for java.awt.AlphaComposite.Xor

public static final AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite  Xor
AlphaComposite object that implements the opaque XOR rule with an alpha of 1.0f.

Since:
1.4
See Also:
XOR sample code for java.awt.AlphaComposite.XOR definition code for java.awt.AlphaComposite.XOR
Method Detail

getInstance sample code for java.awt.AlphaComposite.getInstance(int) definition code for java.awt.AlphaComposite.getInstance(int)

public static AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite  getInstance(int rule)
Creates an AlphaComposite object with the specified rule.

Parameters:
rule - the compositing rule
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if rule is not one of the following: CLEAR sample code for java.awt.AlphaComposite.CLEAR definition code for java.awt.AlphaComposite.CLEAR , SRC sample code for java.awt.AlphaComposite.SRC definition code for java.awt.AlphaComposite.SRC , DST sample code for java.awt.AlphaComposite.DST definition code for java.awt.AlphaComposite.DST , SRC_OVER sample code for java.awt.AlphaComposite.SRC_OVER definition code for java.awt.AlphaComposite.SRC_OVER , DST_OVER sample code for java.awt.AlphaComposite.DST_OVER definition code for java.awt.AlphaComposite.DST_OVER , SRC_IN sample code for java.awt.AlphaComposite.SRC_IN definition code for java.awt.AlphaComposite.SRC_IN , DST_IN sample code for java.awt.AlphaComposite.DST_IN definition code for java.awt.AlphaComposite.DST_IN , SRC_OUT sample code for java.awt.AlphaComposite.SRC_OUT definition code for java.awt.AlphaComposite.SRC_OUT , DST_OUT sample code for java.awt.AlphaComposite.DST_OUT definition code for java.awt.AlphaComposite.DST_OUT , SRC_ATOP sample code for java.awt.AlphaComposite.SRC_ATOP definition code for java.awt.AlphaComposite.SRC_ATOP , DST_ATOP sample code for java.awt.AlphaComposite.DST_ATOP definition code for java.awt.AlphaComposite.DST_ATOP , or XOR sample code for java.awt.AlphaComposite.XOR definition code for java.awt.AlphaComposite.XOR

getInstance sample code for java.awt.AlphaComposite.getInstance(int, float) definition code for java.awt.AlphaComposite.getInstance(int, float)

public static AlphaComposite sample code for java.awt.AlphaComposite definition code for java.awt.AlphaComposite  getInstance(int rule,
                                         float alpha)
Creates an 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.

Parameters:
rule - the compositing rule
alpha - 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].
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if alpha is less than 0.0 or greater than 1.0, or if rule is not one of the following: CLEAR sample code for java.awt.AlphaComposite.CLEAR definition code for java.awt.AlphaComposite.CLEAR , SRC sample code for java.awt.AlphaComposite.SRC definition code for java.awt.AlphaComposite.SRC , DST sample code for java.awt.AlphaComposite.DST definition code for java.awt.AlphaComposite.DST , SRC_OVER sample code for java.awt.AlphaComposite.SRC_OVER definition code for java.awt.AlphaComposite.SRC_OVER , DST_OVER sample code for java.awt.AlphaComposite.DST_OVER definition code for java.awt.AlphaComposite.DST_OVER , SRC_IN sample code for java.awt.AlphaComposite.SRC_IN definition code for java.awt.AlphaComposite.SRC_IN , DST_IN sample code for java.awt.AlphaComposite.DST_IN definition code for java.awt.AlphaComposite.DST_IN , SRC_OUT sample code for java.awt.AlphaComposite.SRC_OUT definition code for java.awt.AlphaComposite.SRC_OUT , DST_OUT sample code for java.awt.AlphaComposite.DST_OUT definition code for java.awt.AlphaComposite.DST_OUT , SRC_ATOP sample code for java.awt.AlphaComposite.SRC_ATOP definition code for java.awt.AlphaComposite.SRC_ATOP , DST_ATOP sample code for java.awt.AlphaComposite.DST_ATOP definition code for java.awt.AlphaComposite.DST_ATOP , or XOR sample code for java.awt.AlphaComposite.XOR definition code for java.awt.AlphaComposite.XOR

createContext sample code for java.awt.AlphaComposite.createContext(java.awt.image.ColorModel, java.awt.image.ColorModel, java.awt.RenderingHints) definition code for java.awt.AlphaComposite.createContext(java.awt.image.ColorModel, java.awt.image.ColorModel, java.awt.RenderingHints)

public CompositeContext sample code for java.awt.CompositeContext definition code for java.awt.CompositeContext  createContext(ColorModel sample code for java.awt.image.ColorModel definition code for java.awt.image.ColorModel  srcColorModel,
                                      ColorModel sample code for java.awt.image.ColorModel definition code for java.awt.image.ColorModel  dstColorModel,
                                      RenderingHints sample code for java.awt.RenderingHints definition code for java.awt.RenderingHints  hints)
Creates a context for the compositing operation. The context contains state that is used in performing the compositing operation.

Specified by:
createContext sample code for java.awt.Composite.createContext(java.awt.image.ColorModel, java.awt.image.ColorModel, java.awt.RenderingHints) definition code for java.awt.Composite.createContext(java.awt.image.ColorModel, java.awt.image.ColorModel, java.awt.RenderingHints) in interface Composite sample code for java.awt.Composite definition code for java.awt.Composite
Parameters:
srcColorModel - the ColorModel sample code for java.awt.image.ColorModel definition code for java.awt.image.ColorModel of the source
dstColorModel - the ColorModel of the destination
hints - the hint that the context object uses to choose between rendering alternatives
Returns:
the CompositeContext object to be used to perform compositing operations.

getAlpha sample code for java.awt.AlphaComposite.getAlpha() definition code for java.awt.AlphaComposite.getAlpha()

public float getAlpha()
Returns the alpha value of this AlphaComposite. If this AlphaComposite does not have an alpha value, 1.0 is returned.

Returns:
the alpha value of this AlphaComposite.

getRule sample code for java.awt.AlphaComposite.getRule() definition code for java.awt.AlphaComposite.getRule()

public int getRule()
Returns the compositing rule of this AlphaComposite.

Returns:
the compositing rule of this AlphaComposite.

hashCode sample code for java.awt.AlphaComposite.hashCode() definition code for java.awt.AlphaComposite.hashCode()

public int hashCode()
Returns the hashcode for this composite.

Overrides:
hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
a hash code for this composite.
See Also:
Object.equals(java.lang.Object) sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable

equals sample code for java.awt.AlphaComposite.equals(java.lang.Object) definition code for java.awt.AlphaComposite.equals(java.lang.Object)

public boolean equals(Object sample code for java.lang.Object definition code for java.lang.Object  obj)
Determines whether the specified object is equal to this 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.

Overrides:
equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) in class Object sample code for java.lang.Object definition code for java.lang.Object
Parameters:
obj - the Object to test for equality
Returns:
true if obj equals this AlphaComposite; false otherwise.
See Also:
Object.hashCode() sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable