author | prr |
Thu, 10 Apr 2008 16:28:45 -0700 | |
changeset 539 | 7952521a4ad3 |
child 715 | f16baef3a20e |
permissions | -rw-r--r-- |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1 |
/* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
2 |
* Portions Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
4 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Sun designates this |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
9 |
* by Sun in the LICENSE file that accompanied this code. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
10 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
15 |
* accompanied this code). |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
16 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
20 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
23 |
* have any questions. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
24 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
25 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
26 |
/* **************************************************************** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
27 |
****************************************************************** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
28 |
****************************************************************** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
29 |
*** COPYRIGHT (c) Eastman Kodak Company, 1997 |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
30 |
*** As an unpublished work pursuant to Title 17 of the United |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
31 |
*** States Code. All rights reserved. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
32 |
****************************************************************** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
33 |
****************************************************************** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
34 |
******************************************************************/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
35 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
36 |
package java.awt.image; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
37 |
import java.awt.Point; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
38 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
39 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
40 |
* WriteableRenderedImage is a common interface for objects which |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
41 |
* contain or can produce image data in the form of Rasters and |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
42 |
* which can be modified and/or written over. The image |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
43 |
* data may be stored/produced as a single tile or a regular array |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
44 |
* of tiles. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
45 |
* <p> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
46 |
* WritableRenderedImage provides notification to other interested |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
47 |
* objects when a tile is checked out for writing (via the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
48 |
* getWritableTile method) and when the last writer of a particular |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
49 |
* tile relinquishes its access (via a call to releaseWritableTile). |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
50 |
* Additionally, it allows any caller to determine whether any tiles |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
51 |
* are currently checked out (via hasTileWriters), and to obtain a |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
52 |
* list of such tiles (via getWritableTileIndices, in the form of a Vector |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
53 |
* of Point objects). |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
54 |
* <p> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
55 |
* Objects wishing to be notified of changes in tile writability must |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
56 |
* implement the TileObserver interface, and are added by a |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
57 |
* call to addTileObserver. Multiple calls to |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
58 |
* addTileObserver for the same object will result in multiple |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
59 |
* notifications. An existing observer may reduce its notifications |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
60 |
* by calling removeTileObserver; if the observer had no |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
61 |
* notifications the operation is a no-op. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
62 |
* <p> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
63 |
* It is necessary for a WritableRenderedImage to ensure that |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
64 |
* notifications occur only when the first writer acquires a tile and |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
65 |
* the last writer releases it. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
66 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
67 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
68 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
69 |
public interface WritableRenderedImage extends RenderedImage |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
70 |
{ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
71 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
72 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
73 |
* Adds an observer. If the observer is already present, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
74 |
* it will receive multiple notifications. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
75 |
* @param to the specified <code>TileObserver</code> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
76 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
77 |
public void addTileObserver(TileObserver to); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
78 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
79 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
80 |
* Removes an observer. If the observer was not registered, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
81 |
* nothing happens. If the observer was registered for multiple |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
82 |
* notifications, it will now be registered for one fewer. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
83 |
* @param to the specified <code>TileObserver</code> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
84 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
85 |
public void removeTileObserver(TileObserver to); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
86 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
87 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
88 |
* Checks out a tile for writing. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
89 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
90 |
* The WritableRenderedImage is responsible for notifying all |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
91 |
* of its TileObservers when a tile goes from having |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
92 |
* no writers to having one writer. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
93 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
94 |
* @param tileX the X index of the tile. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
95 |
* @param tileY the Y index of the tile. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
96 |
* @return a writable tile. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
97 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
98 |
public WritableRaster getWritableTile(int tileX, int tileY); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
99 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
100 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
101 |
* Relinquishes the right to write to a tile. If the caller |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
102 |
* continues to write to the tile, the results are undefined. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
103 |
* Calls to this method should only appear in matching pairs |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
104 |
* with calls to getWritableTile; any other use will lead |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
105 |
* to undefined results. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
106 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
107 |
* The WritableRenderedImage is responsible for notifying all of |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
108 |
* its TileObservers when a tile goes from having one writer |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
109 |
* to having no writers. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
110 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
111 |
* @param tileX the X index of the tile. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
112 |
* @param tileY the Y index of the tile. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
113 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
114 |
public void releaseWritableTile(int tileX, int tileY); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
115 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
116 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
117 |
* Returns whether a tile is currently checked out for writing. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
118 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
119 |
* @param tileX the X index of the tile. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
120 |
* @param tileY the Y index of the tile. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
121 |
* @return <code>true</code> if specified tile is checked out |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
122 |
* for writing; <code>false</code> otherwise. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
123 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
124 |
public boolean isTileWritable(int tileX, int tileY); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
125 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
126 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
127 |
* Returns an array of Point objects indicating which tiles |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
128 |
* are checked out for writing. Returns null if none are |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
129 |
* checked out. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
130 |
* @return an array containing the locations of tiles that are |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
131 |
* checked out for writing. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
132 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
133 |
public Point[] getWritableTileIndices(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
134 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
135 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
136 |
* Returns whether any tile is checked out for writing. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
137 |
* Semantically equivalent to (getWritableTileIndices() != null). |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
138 |
* @return <code>true</code> if any tiles are checked out for |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
139 |
* writing; <code>false</code> otherwise. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
140 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
141 |
public boolean hasTileWriters(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
142 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
143 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
144 |
* Sets a rect of the image to the contents of the Raster r, which is |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
145 |
* assumed to be in the same coordinate space as the WritableRenderedImage. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
146 |
* The operation is clipped to the bounds of the WritableRenderedImage. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
147 |
* @param r the specified <code>Raster</code> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
148 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
149 |
public void setData(Raster r); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
150 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
151 |
} |