author | tvaleev |
Thu, 04 Oct 2018 12:40:55 -0700 | |
changeset 52248 | 2e330da7cbf4 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1 |
/* |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. |
539
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 |
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
539
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 |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
539
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 |
* |
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
539
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.Rectangle; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
38 |
import java.awt.Point; |
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 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
41 |
* This class extends Raster to provide pixel writing capabilities. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
42 |
* Refer to the class comment for Raster for descriptions of how |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
43 |
* a Raster stores pixels. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
44 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
45 |
* <p> The constructors of this class are protected. To instantiate |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
46 |
* a WritableRaster, use one of the createWritableRaster factory methods |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
47 |
* in the Raster class. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
48 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
49 |
public class WritableRaster extends Raster { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
50 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
51 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
52 |
* Constructs a WritableRaster with the given SampleModel. The |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
53 |
* WritableRaster's upper left corner is origin and it is the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
54 |
* same size as the SampleModel. A DataBuffer large enough to |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
55 |
* describe the WritableRaster is automatically created. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
56 |
* @param sampleModel The SampleModel that specifies the layout. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
57 |
* @param origin The Point that specifies the origin. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
58 |
* @throws RasterFormatException if computing either |
35667 | 59 |
* {@code origin.x + sampleModel.getWidth()} or |
60 |
* {@code origin.y + sampleModel.getHeight()} results |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
61 |
* in integer overflow |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
62 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
63 |
protected WritableRaster(SampleModel sampleModel, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
64 |
Point origin) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
65 |
this(sampleModel, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
66 |
sampleModel.createDataBuffer(), |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
67 |
new Rectangle(origin.x, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
68 |
origin.y, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
69 |
sampleModel.getWidth(), |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
70 |
sampleModel.getHeight()), |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
71 |
origin, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
72 |
null); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
73 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
74 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
75 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
76 |
* Constructs a WritableRaster with the given SampleModel and DataBuffer. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
77 |
* The WritableRaster's upper left corner is origin and it is the same |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
78 |
* size as the SampleModel. The DataBuffer is not initialized and must |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
79 |
* be compatible with SampleModel. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
80 |
* @param sampleModel The SampleModel that specifies the layout. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
81 |
* @param dataBuffer The DataBuffer that contains the image data. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
82 |
* @param origin The Point that specifies the origin. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
83 |
* @throws RasterFormatException if computing either |
35667 | 84 |
* {@code origin.x + sampleModel.getWidth()} or |
85 |
* {@code origin.y + sampleModel.getHeight()} results |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
86 |
* in integer overflow |
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 |
protected WritableRaster(SampleModel sampleModel, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
89 |
DataBuffer dataBuffer, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
90 |
Point origin) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
91 |
this(sampleModel, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
92 |
dataBuffer, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
93 |
new Rectangle(origin.x, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
94 |
origin.y, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
95 |
sampleModel.getWidth(), |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
96 |
sampleModel.getHeight()), |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
97 |
origin, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
98 |
null); |
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 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
102 |
* Constructs a WritableRaster with the given SampleModel, DataBuffer, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
103 |
* and parent. aRegion specifies the bounding rectangle of the new |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
104 |
* Raster. When translated into the base Raster's coordinate |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
105 |
* system, aRegion must be contained by the base Raster. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
106 |
* (The base Raster is the Raster's ancestor which has no parent.) |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
107 |
* sampleModelTranslate specifies the sampleModelTranslateX and |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
108 |
* sampleModelTranslateY values of the new Raster. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
109 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
110 |
* Note that this constructor should generally be called by other |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
111 |
* constructors or create methods, it should not be used directly. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
112 |
* @param sampleModel The SampleModel that specifies the layout. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
113 |
* @param dataBuffer The DataBuffer that contains the image data. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
114 |
* @param aRegion The Rectangle that specifies the image area. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
115 |
* @param sampleModelTranslate The Point that specifies the translation |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
116 |
* from SampleModel to Raster coordinates. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
117 |
* @param parent The parent (if any) of this raster. |
35667 | 118 |
* @throws RasterFormatException if {@code aRegion} has width |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
119 |
* or height less than or equal to zero, or computing either |
35667 | 120 |
* {@code aRegion.x + aRegion.width} or |
121 |
* {@code aRegion.y + aRegion.height} results in integer |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
122 |
* overflow |
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 |
protected WritableRaster(SampleModel sampleModel, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
125 |
DataBuffer dataBuffer, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
126 |
Rectangle aRegion, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
127 |
Point sampleModelTranslate, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
128 |
WritableRaster parent){ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
129 |
super(sampleModel,dataBuffer,aRegion,sampleModelTranslate,parent); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
130 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
131 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
132 |
/** Returns the parent WritableRaster (if any) of this WritableRaster, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
133 |
* or else null. |
35667 | 134 |
* @return the parent of this {@code WritableRaster}, or |
135 |
* {@code null}. |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
136 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
137 |
public WritableRaster getWritableParent() { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
138 |
return (WritableRaster)parent; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
139 |
} |
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 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
142 |
* Create a WritableRaster with the same size, SampleModel and DataBuffer |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
143 |
* as this one, but with a different location. The new WritableRaster |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
144 |
* will possess a reference to the current WritableRaster, accessible |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
145 |
* through its getParent() and getWritableParent() methods. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
146 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
147 |
* @param childMinX X coord of the upper left corner of the new Raster. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
148 |
* @param childMinY Y coord of the upper left corner of the new Raster. |
35667 | 149 |
* @return a {@code WritableRaster} the same as this one except |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
150 |
* for the specified location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
151 |
* @throws RasterFormatException if computing either |
35667 | 152 |
* {@code childMinX + this.getWidth()} or |
153 |
* {@code childMinY + this.getHeight()} results in integer |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
154 |
* overflow |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
155 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
156 |
public WritableRaster createWritableTranslatedChild(int childMinX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
157 |
int childMinY) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
158 |
return createWritableChild(minX,minY,width,height, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
159 |
childMinX,childMinY,null); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
160 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
161 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
162 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
163 |
* Returns a new WritableRaster which shares all or part of this |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
164 |
* WritableRaster's DataBuffer. The new WritableRaster will |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
165 |
* possess a reference to the current WritableRaster, accessible |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
166 |
* through its getParent() and getWritableParent() methods. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
167 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
168 |
* <p> The parentX, parentY, width and height parameters form a |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
169 |
* Rectangle in this WritableRaster's coordinate space, indicating |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
170 |
* the area of pixels to be shared. An error will be thrown if |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
171 |
* this Rectangle is not contained with the bounds of the current |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
172 |
* WritableRaster. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
173 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
174 |
* <p> The new WritableRaster may additionally be translated to a |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
175 |
* different coordinate system for the plane than that used by the current |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
176 |
* WritableRaster. The childMinX and childMinY parameters give |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
177 |
* the new (x, y) coordinate of the upper-left pixel of the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
178 |
* returned WritableRaster; the coordinate (childMinX, childMinY) |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
179 |
* in the new WritableRaster will map to the same pixel as the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
180 |
* coordinate (parentX, parentY) in the current WritableRaster. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
181 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
182 |
* <p> The new WritableRaster may be defined to contain only a |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
183 |
* subset of the bands of the current WritableRaster, possibly |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
184 |
* reordered, by means of the bandList parameter. If bandList is |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
185 |
* null, it is taken to include all of the bands of the current |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
186 |
* WritableRaster in their current order. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
187 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
188 |
* <p> To create a new WritableRaster that contains a subregion of |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
189 |
* the current WritableRaster, but shares its coordinate system |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
190 |
* and bands, this method should be called with childMinX equal to |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
191 |
* parentX, childMinY equal to parentY, and bandList equal to |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
192 |
* null. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
193 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
194 |
* @param parentX X coordinate of the upper left corner in this |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
195 |
* WritableRaster's coordinates. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
196 |
* @param parentY Y coordinate of the upper left corner in this |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
197 |
* WritableRaster's coordinates. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
198 |
* @param w Width of the region starting at (parentX, parentY). |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
199 |
* @param h Height of the region starting at (parentX, parentY). |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
200 |
* @param childMinX X coordinate of the upper left corner of |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
201 |
* the returned WritableRaster. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
202 |
* @param childMinY Y coordinate of the upper left corner of |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
203 |
* the returned WritableRaster. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
204 |
* @param bandList Array of band indices, or null to use all bands. |
35667 | 205 |
* @return a {@code WritableRaster} sharing all or part of the |
206 |
* {@code DataBuffer} of this {@code WritableRaster}. |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
207 |
* @exception RasterFormatException if the subregion is outside of the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
208 |
* raster bounds. |
35667 | 209 |
* @throws RasterFormatException if {@code w} or |
210 |
* {@code h} |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
211 |
* is less than or equal to zero, or computing any of |
35667 | 212 |
* {@code parentX + w}, {@code parentY + h}, |
213 |
* {@code childMinX + w}, or |
|
214 |
* {@code childMinY + h} results in integer |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
215 |
* overflow |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
216 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
217 |
public WritableRaster createWritableChild(int parentX, int parentY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
218 |
int w, int h, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
219 |
int childMinX, int childMinY, |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
220 |
int[] bandList) { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
221 |
if (parentX < this.minX) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
222 |
throw new RasterFormatException("parentX lies outside raster"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
223 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
224 |
if (parentY < this.minY) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
225 |
throw new RasterFormatException("parentY lies outside raster"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
226 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
227 |
if ((parentX+w < parentX) || (parentX+w > this.width + this.minX)) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
228 |
throw new RasterFormatException("(parentX + width) is outside raster"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
229 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
230 |
if ((parentY+h < parentY) || (parentY+h > this.height + this.minY)) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
231 |
throw new RasterFormatException("(parentY + height) is outside raster"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
232 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
233 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
234 |
SampleModel sm; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
235 |
// Note: the SampleModel for the child Raster should have the same |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
236 |
// width and height as that for the parent, since it represents |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
237 |
// the physical layout of the pixel data. The child Raster's width |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
238 |
// and height represent a "virtual" view of the pixel data, so |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
239 |
// they may be different than those of the SampleModel. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
240 |
if (bandList != null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
241 |
sm = sampleModel.createSubsetSampleModel(bandList); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
242 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
243 |
else { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
244 |
sm = sampleModel; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
245 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
246 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
247 |
int deltaX = childMinX - parentX; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
248 |
int deltaY = childMinY - parentY; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
249 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
250 |
return new WritableRaster(sm, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
251 |
getDataBuffer(), |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
252 |
new Rectangle(childMinX,childMinY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
253 |
w, h), |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
254 |
new Point(sampleModelTranslateX+deltaX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
255 |
sampleModelTranslateY+deltaY), |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
256 |
this); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
257 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
258 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
259 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
260 |
* Sets the data for a single pixel from a |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
261 |
* primitive array of type TransferType. For image data supported by |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
262 |
* the Java 2D(tm) API, this will be one of DataBuffer.TYPE_BYTE, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
263 |
* DataBuffer.TYPE_USHORT, DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
264 |
* DataBuffer.TYPE_FLOAT, or DataBuffer.TYPE_DOUBLE. Data in the array |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
265 |
* may be in a packed format, thus increasing efficiency for data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
266 |
* transfers. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
267 |
* An ArrayIndexOutOfBoundsException may be thrown if the coordinates are |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
268 |
* not in bounds, or if inData is not large enough to hold the pixel data. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
269 |
* However, explicit bounds checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
270 |
* A ClassCastException will be thrown if the input object is not null |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
271 |
* and references anything other than an array of TransferType. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
272 |
* @see java.awt.image.SampleModel#setDataElements(int, int, Object, DataBuffer) |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
273 |
* @param x The X coordinate of the pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
274 |
* @param y The Y coordinate of the pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
275 |
* @param inData An object reference to an array of type defined by |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
276 |
* getTransferType() and length getNumDataElements() |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
277 |
* containing the pixel data to place at x,y. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
278 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
279 |
* @throws ArrayIndexOutOfBoundsException if the coordinates are not |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
280 |
* in bounds, or if inData is too small to hold the input. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
281 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
282 |
public void setDataElements(int x, int y, Object inData) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
283 |
sampleModel.setDataElements(x-sampleModelTranslateX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
284 |
y-sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
285 |
inData, dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
286 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
287 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
288 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
289 |
* Sets the data for a rectangle of pixels from an input Raster. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
290 |
* The input Raster must be compatible with this WritableRaster |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
291 |
* in that they must have the same number of bands, corresponding bands |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
292 |
* must have the same number of bits per sample, the TransferTypes |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
293 |
* and NumDataElements must be the same, and the packing used by |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
294 |
* the getDataElements/setDataElements must be identical. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
295 |
* An ArrayIndexOutOfBoundsException may be thrown if the coordinates are |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
296 |
* not in bounds. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
297 |
* However, explicit bounds checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
298 |
* @param x The X coordinate of the pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
299 |
* @param y The Y coordinate of the pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
300 |
* @param inRaster Raster containing data to place at x,y. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
301 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
302 |
* @throws NullPointerException if inRaster is null. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
303 |
* @throws ArrayIndexOutOfBoundsException if the coordinates are not |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
304 |
* in bounds. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
305 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
306 |
public void setDataElements(int x, int y, Raster inRaster) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
307 |
int dstOffX = x+inRaster.getMinX(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
308 |
int dstOffY = y+inRaster.getMinY(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
309 |
int width = inRaster.getWidth(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
310 |
int height = inRaster.getHeight(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
311 |
if ((dstOffX < this.minX) || (dstOffY < this.minY) || |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
312 |
(dstOffX + width > this.minX + this.width) || |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
313 |
(dstOffY + height > this.minY + this.height)) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
314 |
throw new ArrayIndexOutOfBoundsException |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
315 |
("Coordinate out of bounds!"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
316 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
317 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
318 |
int srcOffX = inRaster.getMinX(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
319 |
int srcOffY = inRaster.getMinY(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
320 |
Object tdata = null; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
321 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
322 |
for (int startY=0; startY < height; startY++) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
323 |
tdata = inRaster.getDataElements(srcOffX, srcOffY+startY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
324 |
width, 1, tdata); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
325 |
setDataElements(dstOffX, dstOffY+startY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
326 |
width, 1, tdata); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
327 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
328 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
329 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
330 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
331 |
* Sets the data for a rectangle of pixels from a |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
332 |
* primitive array of type TransferType. For image data supported by |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
333 |
* the Java 2D API, this will be one of DataBuffer.TYPE_BYTE, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
334 |
* DataBuffer.TYPE_USHORT, DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
335 |
* DataBuffer.TYPE_FLOAT, or DataBuffer.TYPE_DOUBLE. Data in the array |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
336 |
* may be in a packed format, thus increasing efficiency for data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
337 |
* transfers. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
338 |
* An ArrayIndexOutOfBoundsException may be thrown if the coordinates are |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
339 |
* not in bounds, or if inData is not large enough to hold the pixel data. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
340 |
* However, explicit bounds checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
341 |
* A ClassCastException will be thrown if the input object is not null |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
342 |
* and references anything other than an array of TransferType. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
343 |
* @see java.awt.image.SampleModel#setDataElements(int, int, int, int, Object, DataBuffer) |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
344 |
* @param x The X coordinate of the upper left pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
345 |
* @param y The Y coordinate of the upper left pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
346 |
* @param w Width of the pixel rectangle. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
347 |
* @param h Height of the pixel rectangle. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
348 |
* @param inData An object reference to an array of type defined by |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
349 |
* getTransferType() and length w*h*getNumDataElements() |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
350 |
* containing the pixel data to place between x,y and |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
351 |
* x+w-1, y+h-1. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
352 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
353 |
* @throws NullPointerException if inData is null. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
354 |
* @throws ArrayIndexOutOfBoundsException if the coordinates are not |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
355 |
* in bounds, or if inData is too small to hold the input. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
356 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
357 |
public void setDataElements(int x, int y, int w, int h, Object inData) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
358 |
sampleModel.setDataElements(x-sampleModelTranslateX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
359 |
y-sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
360 |
w,h,inData,dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
361 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
362 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
363 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
364 |
* Copies pixels from Raster srcRaster to this WritableRaster. Each pixel |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
365 |
* in srcRaster is copied to the same x,y address in this raster, unless |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
366 |
* the address falls outside the bounds of this raster. srcRaster |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
367 |
* must have the same number of bands as this WritableRaster. The |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
368 |
* copy is a simple copy of source samples to the corresponding destination |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
369 |
* samples. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
370 |
* <p> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
371 |
* If all samples of both source and destination Rasters are of |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
372 |
* integral type and less than or equal to 32 bits in size, then calling |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
373 |
* this method is equivalent to executing the following code for all |
35667 | 374 |
* {@code x,y} addresses valid in both Rasters. |
19169 | 375 |
* <pre>{@code |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
376 |
* Raster srcRaster; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
377 |
* WritableRaster dstRaster; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
378 |
* for (int b = 0; b < srcRaster.getNumBands(); b++) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
379 |
* dstRaster.setSample(x, y, b, srcRaster.getSample(x, y, b)); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
380 |
* } |
19169 | 381 |
* }</pre> |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
382 |
* Thus, when copying an integral type source to an integral type |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
383 |
* destination, if the source sample size is greater than the destination |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
384 |
* sample size for a particular band, the high order bits of the source |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
385 |
* sample are truncated. If the source sample size is less than the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
386 |
* destination size for a particular band, the high order bits of the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
387 |
* destination are zero-extended or sign-extended depending on whether |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
388 |
* srcRaster's SampleModel treats the sample as a signed or unsigned |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
389 |
* quantity. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
390 |
* <p> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
391 |
* When copying a float or double source to an integral type destination, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
392 |
* each source sample is cast to the destination type. When copying an |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
393 |
* integral type source to a float or double destination, the source |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
394 |
* is first converted to a 32-bit int (if necessary), using the above |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
395 |
* rules for integral types, and then the int is cast to float or |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
396 |
* double. |
25770
d132697706ea
8037511: Tidy warnings cleanup for java.awt - 2d part
avstepan
parents:
23010
diff
changeset
|
397 |
* |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
398 |
* @param srcRaster The Raster from which to copy pixels. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
399 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
400 |
* @throws NullPointerException if srcRaster is null. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
401 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
402 |
public void setRect(Raster srcRaster) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
403 |
setRect(0,0,srcRaster); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
404 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
405 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
406 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
407 |
* Copies pixels from Raster srcRaster to this WritableRaster. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
408 |
* For each (x, y) address in srcRaster, the corresponding pixel |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
409 |
* is copied to address (x+dx, y+dy) in this WritableRaster, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
410 |
* unless (x+dx, y+dy) falls outside the bounds of this raster. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
411 |
* srcRaster must have the same number of bands as this WritableRaster. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
412 |
* The copy is a simple copy of source samples to the corresponding |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
413 |
* destination samples. For details, see |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
414 |
* {@link WritableRaster#setRect(Raster)}. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
415 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
416 |
* @param dx The X translation factor from src space to dst space |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
417 |
* of the copy. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
418 |
* @param dy The Y translation factor from src space to dst space |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
419 |
* of the copy. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
420 |
* @param srcRaster The Raster from which to copy pixels. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
421 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
422 |
* @throws NullPointerException if srcRaster is null. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
423 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
424 |
public void setRect(int dx, int dy, Raster srcRaster) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
425 |
int width = srcRaster.getWidth(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
426 |
int height = srcRaster.getHeight(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
427 |
int srcOffX = srcRaster.getMinX(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
428 |
int srcOffY = srcRaster.getMinY(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
429 |
int dstOffX = dx+srcOffX; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
430 |
int dstOffY = dy+srcOffY; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
431 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
432 |
// Clip to this raster |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
433 |
if (dstOffX < this.minX) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
434 |
int skipX = this.minX - dstOffX; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
435 |
width -= skipX; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
436 |
srcOffX += skipX; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
437 |
dstOffX = this.minX; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
438 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
439 |
if (dstOffY < this.minY) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
440 |
int skipY = this.minY - dstOffY; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
441 |
height -= skipY; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
442 |
srcOffY += skipY; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
443 |
dstOffY = this.minY; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
444 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
445 |
if (dstOffX+width > this.minX+this.width) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
446 |
width = this.minX + this.width - dstOffX; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
447 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
448 |
if (dstOffY+height > this.minY+this.height) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
449 |
height = this.minY + this.height - dstOffY; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
450 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
451 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
452 |
if (width <= 0 || height <= 0) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
453 |
return; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
454 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
455 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
456 |
switch (srcRaster.getSampleModel().getDataType()) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
457 |
case DataBuffer.TYPE_BYTE: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
458 |
case DataBuffer.TYPE_SHORT: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
459 |
case DataBuffer.TYPE_USHORT: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
460 |
case DataBuffer.TYPE_INT: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
461 |
int[] iData = null; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
462 |
for (int startY=0; startY < height; startY++) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
463 |
// Grab one scanline at a time |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
464 |
iData = |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
465 |
srcRaster.getPixels(srcOffX, srcOffY+startY, width, 1, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
466 |
iData); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
467 |
setPixels(dstOffX, dstOffY+startY, width, 1, iData); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
468 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
469 |
break; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
470 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
471 |
case DataBuffer.TYPE_FLOAT: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
472 |
float[] fData = null; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
473 |
for (int startY=0; startY < height; startY++) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
474 |
fData = |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
475 |
srcRaster.getPixels(srcOffX, srcOffY+startY, width, 1, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
476 |
fData); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
477 |
setPixels(dstOffX, dstOffY+startY, width, 1, fData); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
478 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
479 |
break; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
480 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
481 |
case DataBuffer.TYPE_DOUBLE: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
482 |
double[] dData = null; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
483 |
for (int startY=0; startY < height; startY++) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
484 |
// Grab one scanline at a time |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
485 |
dData = |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
486 |
srcRaster.getPixels(srcOffX, srcOffY+startY, width, 1, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
487 |
dData); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
488 |
setPixels(dstOffX, dstOffY+startY, width, 1, dData); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
489 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
490 |
break; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
491 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
492 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
493 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
494 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
495 |
* Sets a pixel in the DataBuffer using an int array of samples for input. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
496 |
* An ArrayIndexOutOfBoundsException may be thrown if the coordinates are |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
497 |
* not in bounds. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
498 |
* However, explicit bounds checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
499 |
* @param x The X coordinate of the pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
500 |
* @param y The Y coordinate of the pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
501 |
* @param iArray The input samples in a int array. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
502 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
503 |
* @throws NullPointerException if iArray is null. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
504 |
* @throws ArrayIndexOutOfBoundsException if the coordinates are not |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
505 |
* in bounds, or if iArray is too small to hold the input. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
506 |
*/ |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
507 |
public void setPixel(int x, int y, int[] iArray) { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
508 |
sampleModel.setPixel(x-sampleModelTranslateX,y-sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
509 |
iArray,dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
510 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
511 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
512 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
513 |
* Sets a pixel in the DataBuffer using a float array of samples for input. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
514 |
* An ArrayIndexOutOfBoundsException may be thrown if the coordinates are |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
515 |
* not in bounds. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
516 |
* However, explicit bounds checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
517 |
* @param x The X coordinate of the pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
518 |
* @param y The Y coordinate of the pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
519 |
* @param fArray The input samples in a float array. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
520 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
521 |
* @throws NullPointerException if fArray is null. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
522 |
* @throws ArrayIndexOutOfBoundsException if the coordinates are not |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
523 |
* in bounds, or if fArray is too small to hold the input. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
524 |
*/ |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
525 |
public void setPixel(int x, int y, float[] fArray) { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
526 |
sampleModel.setPixel(x-sampleModelTranslateX,y-sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
527 |
fArray,dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
528 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
529 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
530 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
531 |
* Sets a pixel in the DataBuffer using a double array of samples for input. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
532 |
* An ArrayIndexOutOfBoundsException may be thrown if the coordinates are |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
533 |
* not in bounds. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
534 |
* However, explicit bounds checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
535 |
* @param x The X coordinate of the pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
536 |
* @param y The Y coordinate of the pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
537 |
* @param dArray The input samples in a double array. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
538 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
539 |
* @throws NullPointerException if dArray is null. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
540 |
* @throws ArrayIndexOutOfBoundsException if the coordinates are not |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
541 |
* in bounds, or if dArray is too small to hold the input. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
542 |
*/ |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
543 |
public void setPixel(int x, int y, double[] dArray) { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
544 |
sampleModel.setPixel(x-sampleModelTranslateX,y-sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
545 |
dArray,dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
546 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
547 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
548 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
549 |
* Sets all samples for a rectangle of pixels from an int array containing |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
550 |
* one sample per array element. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
551 |
* An ArrayIndexOutOfBoundsException may be thrown if the coordinates are |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
552 |
* not in bounds. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
553 |
* However, explicit bounds checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
554 |
* @param x The X coordinate of the upper left pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
555 |
* @param y The Y coordinate of the upper left pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
556 |
* @param w Width of the pixel rectangle. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
557 |
* @param h Height of the pixel rectangle. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
558 |
* @param iArray The input int pixel array. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
559 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
560 |
* @throws NullPointerException if iArray is null. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
561 |
* @throws ArrayIndexOutOfBoundsException if the coordinates are not |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
562 |
* in bounds, or if iArray is too small to hold the input. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
563 |
*/ |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
564 |
public void setPixels(int x, int y, int w, int h, int[] iArray) { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
565 |
sampleModel.setPixels(x-sampleModelTranslateX,y-sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
566 |
w,h,iArray,dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
567 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
568 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
569 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
570 |
* Sets all samples for a rectangle of pixels from a float array containing |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
571 |
* one sample per array element. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
572 |
* An ArrayIndexOutOfBoundsException may be thrown if the coordinates are |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
573 |
* not in bounds. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
574 |
* However, explicit bounds checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
575 |
* @param x The X coordinate of the upper left pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
576 |
* @param y The Y coordinate of the upper left pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
577 |
* @param w Width of the pixel rectangle. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
578 |
* @param h Height of the pixel rectangle. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
579 |
* @param fArray The input float pixel array. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
580 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
581 |
* @throws NullPointerException if fArray is null. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
582 |
* @throws ArrayIndexOutOfBoundsException if the coordinates are not |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
583 |
* in bounds, or if fArray is too small to hold the input. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
584 |
*/ |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
585 |
public void setPixels(int x, int y, int w, int h, float[] fArray) { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
586 |
sampleModel.setPixels(x-sampleModelTranslateX,y-sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
587 |
w,h,fArray,dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
588 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
589 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
590 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
591 |
* Sets all samples for a rectangle of pixels from a double array containing |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
592 |
* one sample per array element. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
593 |
* An ArrayIndexOutOfBoundsException may be thrown if the coordinates are |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
594 |
* not in bounds. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
595 |
* However, explicit bounds checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
596 |
* @param x The X coordinate of the upper left pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
597 |
* @param y The Y coordinate of the upper left pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
598 |
* @param w Width of the pixel rectangle. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
599 |
* @param h Height of the pixel rectangle. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
600 |
* @param dArray The input double pixel array. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
601 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
602 |
* @throws NullPointerException if dArray is null. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
603 |
* @throws ArrayIndexOutOfBoundsException if the coordinates are not |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
604 |
* in bounds, or if dArray is too small to hold the input. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
605 |
*/ |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
606 |
public void setPixels(int x, int y, int w, int h, double[] dArray) { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
607 |
sampleModel.setPixels(x-sampleModelTranslateX,y-sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
608 |
w,h,dArray,dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
609 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
610 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
611 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
612 |
* Sets a sample in the specified band for the pixel located at (x,y) |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
613 |
* in the DataBuffer using an int for input. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
614 |
* An ArrayIndexOutOfBoundsException may be thrown if the coordinates are |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
615 |
* not in bounds. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
616 |
* However, explicit bounds checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
617 |
* @param x The X coordinate of the pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
618 |
* @param y The Y coordinate of the pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
619 |
* @param b The band to set. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
620 |
* @param s The input sample. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
621 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
622 |
* @throws ArrayIndexOutOfBoundsException if the coordinates or |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
623 |
* the band index are not in bounds. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
624 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
625 |
public void setSample(int x, int y, int b, int s) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
626 |
sampleModel.setSample(x-sampleModelTranslateX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
627 |
y-sampleModelTranslateY, b, s, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
628 |
dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
629 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
630 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
631 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
632 |
* Sets a sample in the specified band for the pixel located at (x,y) |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
633 |
* in the DataBuffer using a float for input. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
634 |
* An ArrayIndexOutOfBoundsException may be thrown if the coordinates are |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
635 |
* not in bounds. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
636 |
* However, explicit bounds checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
637 |
* @param x The X coordinate of the pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
638 |
* @param y The Y coordinate of the pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
639 |
* @param b The band to set. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
640 |
* @param s The input sample as a float. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
641 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
642 |
* @throws ArrayIndexOutOfBoundsException if the coordinates or |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
643 |
* the band index are not in bounds. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
644 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
645 |
public void setSample(int x, int y, int b, float s){ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
646 |
sampleModel.setSample(x-sampleModelTranslateX,y-sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
647 |
b,s,dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
648 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
649 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
650 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
651 |
* Sets a sample in the specified band for the pixel located at (x,y) |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
652 |
* in the DataBuffer using a double for input. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
653 |
* An ArrayIndexOutOfBoundsException may be thrown if the coordinates are |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
654 |
* not in bounds. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
655 |
* However, explicit bounds checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
656 |
* @param x The X coordinate of the pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
657 |
* @param y The Y coordinate of the pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
658 |
* @param b The band to set. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
659 |
* @param s The input sample as a double. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
660 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
661 |
* @throws ArrayIndexOutOfBoundsException if the coordinates or |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
662 |
* the band index are not in bounds. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
663 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
664 |
public void setSample(int x, int y, int b, double s){ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
665 |
sampleModel.setSample(x-sampleModelTranslateX,y-sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
666 |
b,s,dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
667 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
668 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
669 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
670 |
* Sets the samples in the specified band for the specified rectangle |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
671 |
* of pixels from an int array containing one sample per array element. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
672 |
* An ArrayIndexOutOfBoundsException may be thrown if the coordinates are |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
673 |
* not in bounds. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
674 |
* However, explicit bounds checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
675 |
* @param x The X coordinate of the upper left pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
676 |
* @param y The Y coordinate of the upper left pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
677 |
* @param w Width of the pixel rectangle. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
678 |
* @param h Height of the pixel rectangle. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
679 |
* @param b The band to set. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
680 |
* @param iArray The input int sample array. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
681 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
682 |
* @throws NullPointerException if iArray is null. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
683 |
* @throws ArrayIndexOutOfBoundsException if the coordinates or |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
684 |
* the band index are not in bounds, or if iArray is too small to |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
685 |
* hold the input. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
686 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
687 |
public void setSamples(int x, int y, int w, int h, int b, |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
688 |
int[] iArray) { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
689 |
sampleModel.setSamples(x-sampleModelTranslateX,y-sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
690 |
w,h,b,iArray,dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
691 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
692 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
693 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
694 |
* Sets the samples in the specified band for the specified rectangle |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
695 |
* of pixels from a float array containing one sample per array element. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
696 |
* An ArrayIndexOutOfBoundsException may be thrown if the coordinates are |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
697 |
* not in bounds. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
698 |
* However, explicit bounds checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
699 |
* @param x The X coordinate of the upper left pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
700 |
* @param y The Y coordinate of the upper left pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
701 |
* @param w Width of the pixel rectangle. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
702 |
* @param h Height of the pixel rectangle. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
703 |
* @param b The band to set. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
704 |
* @param fArray The input float sample array. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
705 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
706 |
* @throws NullPointerException if fArray is null. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
707 |
* @throws ArrayIndexOutOfBoundsException if the coordinates or |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
708 |
* the band index are not in bounds, or if fArray is too small to |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
709 |
* hold the input. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
710 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
711 |
public void setSamples(int x, int y, int w, int h, int b, |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
712 |
float[] fArray) { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
713 |
sampleModel.setSamples(x-sampleModelTranslateX,y-sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
714 |
w,h,b,fArray,dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
715 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
716 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
717 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
718 |
* Sets the samples in the specified band for the specified rectangle |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
719 |
* of pixels from a double array containing one sample per array element. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
720 |
* An ArrayIndexOutOfBoundsException may be thrown if the coordinates are |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
721 |
* not in bounds. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
722 |
* However, explicit bounds checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
723 |
* @param x The X coordinate of the upper left pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
724 |
* @param y The Y coordinate of the upper left pixel location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
725 |
* @param w Width of the pixel rectangle. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
726 |
* @param h Height of the pixel rectangle. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
727 |
* @param b The band to set. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
728 |
* @param dArray The input double sample array. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
729 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
730 |
* @throws NullPointerException if dArray is null. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
731 |
* @throws ArrayIndexOutOfBoundsException if the coordinates or |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
732 |
* the band index are not in bounds, or if dArray is too small to |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
733 |
* hold the input. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
734 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
735 |
public void setSamples(int x, int y, int w, int h, int b, |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
736 |
double[] dArray) { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
737 |
sampleModel.setSamples(x-sampleModelTranslateX,y-sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
738 |
w,h,b,dArray,dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
739 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
740 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
741 |
} |