2
|
1 |
/*
|
|
2 |
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation. Sun designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* 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 |
*/
|
|
50 |
|
|
51 |
public interface Paint extends Transparency {
|
|
52 |
/**
|
|
53 |
* Creates and returns a {@link PaintContext} used to
|
|
54 |
* generate the color pattern.
|
|
55 |
* Since the ColorModel argument to createContext is only a
|
|
56 |
* hint, implementations of Paint should accept a null argument
|
|
57 |
* for ColorModel. Note that if the application does not
|
|
58 |
* prefer a specific ColorModel, the null ColorModel argument
|
|
59 |
* will give the Paint implementation full leeway in using the
|
|
60 |
* most efficient ColorModel it prefers for its raster processing.
|
|
61 |
* <p>
|
|
62 |
* Since the API documentation was not specific about this in
|
|
63 |
* releases before 1.4, there may be implementations of
|
|
64 |
* <code>Paint</code> that do not accept a null
|
|
65 |
* <code>ColorModel</code> argument.
|
|
66 |
* If a developer is writing code which passes a null
|
|
67 |
* <code>ColorModel</code> argument to the
|
|
68 |
* <code>createContext</code> method of <code>Paint</code>
|
|
69 |
* objects from arbitrary sources it would be wise to code defensively
|
|
70 |
* by manufacturing a non-null <code>ColorModel</code> for those
|
|
71 |
* objects which throw a <code>NullPointerException</code>.
|
|
72 |
* @param cm the {@link ColorModel} that receives the
|
|
73 |
* <code>Paint</code> data. This is used only as a hint.
|
|
74 |
* @param deviceBounds the device space bounding box
|
|
75 |
* of the graphics primitive being rendered
|
|
76 |
* @param userBounds the user space bounding box
|
|
77 |
* of the graphics primitive being rendered
|
|
78 |
* @param xform the {@link AffineTransform} from user
|
|
79 |
* space into device space
|
|
80 |
* @param hints the hint that the context object uses to
|
|
81 |
* choose between rendering alternatives
|
|
82 |
* @return the <code>PaintContext</code> for
|
|
83 |
* generating color patterns
|
|
84 |
* @see PaintContext
|
|
85 |
*/
|
|
86 |
public PaintContext createContext(ColorModel cm,
|
|
87 |
Rectangle deviceBounds,
|
|
88 |
Rectangle2D userBounds,
|
|
89 |
AffineTransform xform,
|
|
90 |
RenderingHints hints);
|
|
91 |
|
|
92 |
}
|