KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > awt > Composite


1 /*
2  * @(#)Composite.java 1.23 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.awt;
9
10 import java.awt.image.ColorModel JavaDoc;
11
12 /**
13  * The <code>Composite</code> interface, along with
14  * {@link CompositeContext}, defines the methods to compose a draw
15  * primitive with the underlying graphics area.
16  * After the <code>Composite</code> is set in the
17  * {@link Graphics2D} context, it combines a shape, text, or an image
18  * being rendered with the colors that have already been rendered
19  * according to pre-defined rules. The classes
20  * implementing this interface provide the rules and a method to create
21  * the context for a particular operation.
22  * <code>CompositeContext</code> is an environment used by the
23  * compositing operation, which is created by the <code>Graphics2D</code>
24  * prior to the start of the operation. <code>CompositeContext</code>
25  * contains private information and resources needed for a compositing
26  * operation. When the <code>CompositeContext</code> is no longer needed,
27  * the <code>Graphics2D</code> object disposes of it in order to reclaim
28  * resources allocated for the operation.
29  * <p>
30  * Instances of classes implementing <code>Composite</code> must be
31  * immutable because the <code>Graphics2D</code> does not clone
32  * these objects when they are set as an attribute with the
33  * <code>setComposite</code> method or when the <code>Graphics2D</code>
34  * object is cloned. This is to avoid undefined rendering behavior of
35  * <code>Graphics2D</code>, resulting from the modification of
36  * the <code>Composite</code> object after it has been set in the
37  * <code>Graphics2D</code> context.
38  * <p>
39  * Since this interface must expose the contents of pixels on the
40  * target device or image to potentially arbitrary code, the use of
41  * custom objects which implement this interface when rendering directly
42  * to a screen device is governed by the <code>readDisplayPixels</code>
43  * {@link AWTPermission}. The permission check will occur when such
44  * a custom object is passed to the <code>setComposite</code> method
45  * of a <code>Graphics2D</code> retrieved from a {@link Component}.
46  * @see AlphaComposite
47  * @see CompositeContext
48  * @see Graphics2D#setComposite
49  * @version 10 Feb 1997
50  */

51 public interface Composite {
52
53     /**
54      * Creates a context containing state that is used to perform
55      * the compositing operation. In a multi-threaded environment,
56      * several contexts can exist simultaneously for a single
57      * <code>Composite</code> object.
58      * @param srcColorModel the {@link ColorModel} of the source
59      * @param dstColorModel the <code>ColorModel</code> of the destination
60      * @param hints the hint that the context object uses to choose between
61      * rendering alternatives
62      * @return the <code>CompositeContext</code> object used to perform the
63      * compositing operation.
64      */

65     public CompositeContext JavaDoc createContext(ColorModel JavaDoc srcColorModel,
66                       ColorModel JavaDoc dstColorModel,
67                                           RenderingHints JavaDoc hints);
68
69 }
70
Popular Tags