KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > awt > Paint


1 /*
2  * @(#)Paint.java 1.27 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 import java.awt.geom.AffineTransform JavaDoc;
12 import java.awt.geom.Point2D JavaDoc;
13 import java.awt.geom.Rectangle2D JavaDoc;
14
15 /**
16  * This <code>Paint</code> interface defines how color patterns
17  * can be generated for {@link Graphics2D} operations. A class
18  * implementing the <code>Paint</code> interface is added to the
19  * <code>Graphics2D</code> context in order to define the color
20  * pattern used by the <code>draw</code> and <code>fill</code> methods.
21  * <p>
22  * Instances of classes implementing <code>Paint</code> must be
23  * read-only because the <code>Graphics2D</code> does not clone
24  * these objects when they are set as an attribute with the
25  * <code>setPaint</code> method or when the <code>Graphics2D</code>
26  * object is itself cloned.
27  * @see PaintContext
28  * @see Color
29  * @see GradientPaint
30  * @see TexturePaint
31  * @see Graphics2D#setPaint
32  * @version 1.27, 12/19/03
33  */

34
35 public interface Paint extends Transparency JavaDoc {
36     /**
37      * Creates and returns a {@link PaintContext} used to
38      * generate the color pattern.
39      * Since the ColorModel argument to createContext is only a
40      * hint, implementations of Paint should accept a null argument
41      * for ColorModel. Note that if the application does not
42      * prefer a specific ColorModel, the null ColorModel argument
43      * will give the Paint implementation full leeway in using the
44      * most efficient ColorModel it prefers for its raster processing.
45      * <p>
46      * Since the API documentation was not specific about this in
47      * releases before 1.4, there may be implementations of
48      * <code>Paint</code> that do not accept a null
49      * <code>ColorModel</code> argument.
50      * If a developer is writing code which passes a null
51      * <code>ColorModel</code> argument to the
52      * <code>createContext</code> method of <code>Paint</code>
53      * objects from arbitrary sources it would be wise to code defensively
54      * by manufacturing a non-null <code>ColorModel</code> for those
55      * objects which throw a <code>NullPointerException</code>.
56      * @param cm the {@link ColorModel} that receives the
57      * <code>Paint</code> data. This is used only as a hint.
58      * @param deviceBounds the device space bounding box
59      * of the graphics primitive being rendered
60      * @param userBounds the user space bounding box
61      * of the graphics primitive being rendered
62      * @param xform the {@link AffineTransform} from user
63      * space into device space
64      * @param hints the hint that the context object uses to
65      * choose between rendering alternatives
66      * @return the <code>PaintContext</code> for
67      * generating color patterns
68      * @see PaintContext
69      */

70     public PaintContext JavaDoc createContext(ColorModel JavaDoc cm,
71                       Rectangle JavaDoc deviceBounds,
72                       Rectangle2D JavaDoc userBounds,
73                       AffineTransform JavaDoc xform,
74                                       RenderingHints JavaDoc hints);
75
76 }
77
78
Popular Tags