01 /*
02 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
03 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04 *
05 * This code is free software; you can redistribute it and/or modify it
06 * under the terms of the GNU General Public License version 2 only, as
07 * published by the Free Software Foundation. Sun designates this
08 * particular file as subject to the "Classpath" exception as provided
09 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26 package java.awt;
27
28 import java.awt.image.ColorModel;
29 import java.awt.geom.AffineTransform;
30 import java.awt.geom.Rectangle2D;
31
32 /**
33 * This <code>Paint</code> interface defines how color patterns
34 * can be generated for {@link Graphics2D} operations. A class
35 * implementing the <code>Paint</code> interface is added to the
36 * <code>Graphics2D</code> context in order to define the color
37 * pattern used by the <code>draw</code> and <code>fill</code> methods.
38 * <p>
39 * Instances of classes implementing <code>Paint</code> must be
40 * read-only because the <code>Graphics2D</code> does not clone
41 * these objects when they are set as an attribute with the
42 * <code>setPaint</code> method or when the <code>Graphics2D</code>
43 * object is itself cloned.
44 * @see PaintContext
45 * @see Color
46 * @see GradientPaint
47 * @see TexturePaint
48 * @see Graphics2D#setPaint
49 * @version 1.36, 06/05/07
50 */
51
52 public interface Paint extends Transparency {
53 /**
54 * Creates and returns a {@link PaintContext} used to
55 * generate the color pattern.
56 * Since the ColorModel argument to createContext is only a
57 * hint, implementations of Paint should accept a null argument
58 * for ColorModel. Note that if the application does not
59 * prefer a specific ColorModel, the null ColorModel argument
60 * will give the Paint implementation full leeway in using the
61 * most efficient ColorModel it prefers for its raster processing.
62 * <p>
63 * Since the API documentation was not specific about this in
64 * releases before 1.4, there may be implementations of
65 * <code>Paint</code> that do not accept a null
66 * <code>ColorModel</code> argument.
67 * If a developer is writing code which passes a null
68 * <code>ColorModel</code> argument to the
69 * <code>createContext</code> method of <code>Paint</code>
70 * objects from arbitrary sources it would be wise to code defensively
71 * by manufacturing a non-null <code>ColorModel</code> for those
72 * objects which throw a <code>NullPointerException</code>.
73 * @param cm the {@link ColorModel} that receives the
74 * <code>Paint</code> data. This is used only as a hint.
75 * @param deviceBounds the device space bounding box
76 * of the graphics primitive being rendered
77 * @param userBounds the user space bounding box
78 * of the graphics primitive being rendered
79 * @param xform the {@link AffineTransform} from user
80 * space into device space
81 * @param hints the hint that the context object uses to
82 * choose between rendering alternatives
83 * @return the <code>PaintContext</code> for
84 * generating color patterns
85 * @see PaintContext
86 */
87 public PaintContext createContext(ColorModel cm,
88 Rectangle deviceBounds, Rectangle2D userBounds,
89 AffineTransform xform, RenderingHints hints);
90
91 }
|