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.Raster;
29 import java.awt.image.ColorModel;
30
31 /**
32 * The <code>PaintContext</code> interface defines the encapsulated
33 * and optimized environment to generate color patterns in device
34 * space for fill or stroke operations on a
35 * {@link Graphics2D}. The <code>PaintContext</code> provides
36 * the necessary colors for <code>Graphics2D</code> operations in the
37 * form of a {@link Raster} associated with a {@link ColorModel}.
38 * The <code>PaintContext</code> maintains state for a particular paint
39 * operation. In a multi-threaded environment, several
40 * contexts can exist simultaneously for a single {@link Paint} object.
41 * @see Paint
42 */
43
44 public interface PaintContext {
45 /**
46 * Releases the resources allocated for the operation.
47 */
48 public void dispose();
49
50 /**
51 * Returns the <code>ColorModel</code> of the output. Note that
52 * this <code>ColorModel</code> might be different from the hint
53 * specified in the
54 * {@link Paint#createContext(ColorModel, Rectangle, Rectangle2D,
55 AffineTransform, RenderingHints) createContext} method of
56 * <code>Paint</code>. Not all <code>PaintContext</code> objects are
57 * capable of generating color patterns in an arbitrary
58 * <code>ColorModel</code>.
59 * @return the <code>ColorModel</code> of the output.
60 */
61 ColorModel getColorModel();
62
63 /**
64 * Returns a <code>Raster</code> containing the colors generated for
65 * the graphics operation.
66 * @param x the x coordinate of the area in device space
67 * for which colors are generated.
68 * @param y the y coordinate of the area in device space
69 * for which colors are generated.
70 * @param w the width of the area in device space
71 * @param h the height of the area in device space
72 * @return a <code>Raster</code> representing the specified
73 * rectangular area and containing the colors generated for
74 * the graphics operation.
75 */
76 Raster getRaster(int x,
77 int y,
78 int w,
79 int h);
80
81 }