author | henryjen |
Tue, 10 Jun 2014 16:18:54 -0700 | |
changeset 24865 | 09b1d992ca72 |
parent 22584 | eed64ee05369 |
permissions | -rw-r--r-- |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1 |
/* |
22584 | 2 |
* Copyright (c) 1997, 2014, 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 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
38 |
import static sun.java2d.StateTrackable.State.*; |
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 <CODE>DataBuffer</CODE> and stores data internally as |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
42 |
* shorts. Values stored in the short array(s) of this <CODE>DataBuffer</CODE> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
43 |
* are treated as unsigned values. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
44 |
* <p> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
45 |
* <a name="optimizations"> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
46 |
* Note that some implementations may function more efficiently |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
47 |
* if they can maintain control over how the data for an image is |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
48 |
* stored. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
49 |
* For example, optimizations such as caching an image in video |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
50 |
* memory require that the implementation track all modifications |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
51 |
* to that data. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
52 |
* Other implementations may operate better if they can store the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
53 |
* data in locations other than a Java array. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
54 |
* To maintain optimum compatibility with various optimizations |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
55 |
* it is best to avoid constructors and methods which expose the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
56 |
* underlying storage as a Java array as noted below in the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
57 |
* documentation for those methods. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
58 |
* </a> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
59 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
60 |
public final class DataBufferUShort extends DataBuffer |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
61 |
{ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
62 |
/** The default data bank. */ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
63 |
short data[]; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
64 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
65 |
/** All data banks */ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
66 |
short bankdata[][]; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
67 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
68 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
69 |
* Constructs an unsigned-short based <CODE>DataBuffer</CODE> with a single bank and the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
70 |
* specified size. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
71 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
72 |
* @param size The size of the <CODE>DataBuffer</CODE>. |
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 |
public DataBufferUShort(int size) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
75 |
super(STABLE, TYPE_USHORT, size); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
76 |
data = new short[size]; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
77 |
bankdata = new short[1][]; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
78 |
bankdata[0] = data; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
79 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
80 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
81 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
82 |
* Constructs an unsigned-short based <CODE>DataBuffer</CODE> with the specified number of |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
83 |
* banks, all of which are the specified size. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
84 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
85 |
* @param size The size of the banks in the <CODE>DataBuffer</CODE>. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
86 |
* @param numBanks The number of banks in the a<CODE>DataBuffer</CODE>. |
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 |
public DataBufferUShort(int size, int numBanks) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
89 |
super(STABLE, TYPE_USHORT, size, numBanks); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
90 |
bankdata = new short[numBanks][]; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
91 |
for (int i= 0; i < numBanks; i++) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
92 |
bankdata[i] = new short[size]; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
93 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
94 |
data = bankdata[0]; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
95 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
96 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
97 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
98 |
* Constructs an unsigned-short based <CODE>DataBuffer</CODE> with a single bank |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
99 |
* using the specified array. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
100 |
* Only the first <CODE>size</CODE> elements should be used by accessors of |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
101 |
* this <CODE>DataBuffer</CODE>. <CODE>dataArray</CODE> must be large enough to |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
102 |
* hold <CODE>size</CODE> elements. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
103 |
* <p> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
104 |
* Note that {@code DataBuffer} objects created by this constructor |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
105 |
* may be incompatible with <a href="#optimizations">performance |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
106 |
* optimizations</a> used by some implementations (such as caching |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
107 |
* an associated image in video memory). |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
108 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
109 |
* @param dataArray The unsigned-short array for the <CODE>DataBuffer</CODE>. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
110 |
* @param size The size of the <CODE>DataBuffer</CODE> bank. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
111 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
112 |
public DataBufferUShort(short dataArray[], int size) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
113 |
super(UNTRACKABLE, TYPE_USHORT, size); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
114 |
if (dataArray == null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
115 |
throw new NullPointerException("dataArray is null"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
116 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
117 |
data = dataArray; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
118 |
bankdata = new short[1][]; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
119 |
bankdata[0] = data; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
120 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
121 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
122 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
123 |
* Constructs an unsigned-short based <CODE>DataBuffer</CODE> with a single bank |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
124 |
* using the specified array, size, and offset. <CODE>dataArray</CODE> must have at |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
125 |
* least <CODE>offset</CODE> + <CODE>size</CODE> elements. Only elements |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
126 |
* <CODE>offset</CODE> through <CODE>offset</CODE> + <CODE>size</CODE> - 1 should |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
127 |
* be used by accessors of this <CODE>DataBuffer</CODE>. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
128 |
* <p> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
129 |
* Note that {@code DataBuffer} objects created by this constructor |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
130 |
* may be incompatible with <a href="#optimizations">performance |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
131 |
* optimizations</a> used by some implementations (such as caching |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
132 |
* an associated image in video memory). |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
133 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
134 |
* @param dataArray The unsigned-short array for the <CODE>DataBuffer</CODE>. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
135 |
* @param size The size of the <CODE>DataBuffer</CODE> bank. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
136 |
* @param offset The offset into the <CODE>dataArray</CODE>. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
137 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
138 |
public DataBufferUShort(short dataArray[], int size, int offset) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
139 |
super(UNTRACKABLE, TYPE_USHORT, size, 1, offset); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
140 |
if (dataArray == null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
141 |
throw new NullPointerException("dataArray is null"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
142 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
143 |
if ((size+offset) > dataArray.length) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
144 |
throw new IllegalArgumentException("Length of dataArray is less "+ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
145 |
" than size+offset."); |
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 |
data = dataArray; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
148 |
bankdata = new short[1][]; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
149 |
bankdata[0] = data; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
150 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
151 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
152 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
153 |
* Constructs an unsigned-short based <CODE>DataBuffer</CODE> with the specified arrays. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
154 |
* The number of banks will be equal to <CODE>dataArray.length</CODE>. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
155 |
* Only the first <CODE>size</CODE> elements of each array should be used by |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
156 |
* accessors of this <CODE>DataBuffer</CODE>. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
157 |
* <p> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
158 |
* Note that {@code DataBuffer} objects created by this constructor |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
159 |
* may be incompatible with <a href="#optimizations">performance |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
160 |
* optimizations</a> used by some implementations (such as caching |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
161 |
* an associated image in video memory). |
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 |
* @param dataArray The unsigned-short arrays for the <CODE>DataBuffer</CODE>. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
164 |
* @param size The size of the banks in the <CODE>DataBuffer</CODE>. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
165 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
166 |
public DataBufferUShort(short dataArray[][], int size) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
167 |
super(UNTRACKABLE, TYPE_USHORT, size, dataArray.length); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
168 |
if (dataArray == null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
169 |
throw new NullPointerException("dataArray is null"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
170 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
171 |
for (int i=0; i < dataArray.length; i++) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
172 |
if (dataArray[i] == null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
173 |
throw new NullPointerException("dataArray["+i+"] is null"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
174 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
175 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
176 |
|
22584 | 177 |
bankdata = dataArray.clone(); |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
178 |
data = bankdata[0]; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
179 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
180 |
|
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 |
* Constructs an unsigned-short based <CODE>DataBuffer</CODE> with specified arrays, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
183 |
* size, and offsets. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
184 |
* The number of banks is equal to <CODE>dataArray.length</CODE>. Each array must |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
185 |
* be at least as large as <CODE>size</CODE> + the corresponding offset. There must |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
186 |
* be an entry in the offset array for each <CODE>dataArray</CODE> entry. For each |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
187 |
* bank, only elements <CODE>offset</CODE> through |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
188 |
* <CODE>offset</CODE> + <CODE>size</CODE> - 1 should be |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
189 |
* used by accessors of this <CODE>DataBuffer</CODE>. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
190 |
* <p> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
191 |
* Note that {@code DataBuffer} objects created by this constructor |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
192 |
* may be incompatible with <a href="#optimizations">performance |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
193 |
* optimizations</a> used by some implementations (such as caching |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
194 |
* an associated image in video memory). |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
195 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
196 |
* @param dataArray The unsigned-short arrays for the <CODE>DataBuffer</CODE>. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
197 |
* @param size The size of the banks in the <CODE>DataBuffer</CODE>. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
198 |
* @param offsets The offsets into each array. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
199 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
200 |
public DataBufferUShort(short dataArray[][], int size, int offsets[]) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
201 |
super(UNTRACKABLE, TYPE_USHORT, size, dataArray.length, offsets); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
202 |
if (dataArray == null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
203 |
throw new NullPointerException("dataArray is null"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
204 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
205 |
for (int i=0; i < dataArray.length; i++) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
206 |
if (dataArray[i] == null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
207 |
throw new NullPointerException("dataArray["+i+"] is null"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
208 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
209 |
if ((size+offsets[i]) > dataArray[i].length) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
210 |
throw new IllegalArgumentException("Length of dataArray["+i+ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
211 |
"] is less than size+"+ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
212 |
"offsets["+i+"]."); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
213 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
214 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
215 |
} |
22584 | 216 |
bankdata = dataArray.clone(); |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
217 |
data = bankdata[0]; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
218 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
219 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
220 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
221 |
* Returns the default (first) unsigned-short data array. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
222 |
* <p> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
223 |
* Note that calling this method may cause this {@code DataBuffer} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
224 |
* object to be incompatible with <a href="#optimizations">performance |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
225 |
* optimizations</a> used by some implementations (such as caching |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
226 |
* an associated image in video memory). |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
227 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
228 |
* @return The first unsigned-short data array. |
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 |
public short[] getData() { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
231 |
theTrackable.setUntrackable(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
232 |
return data; |
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 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
235 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
236 |
* Returns the data array for the specified bank. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
237 |
* <p> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
238 |
* Note that calling this method may cause this {@code DataBuffer} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
239 |
* object to be incompatible with <a href="#optimizations">performance |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
240 |
* optimizations</a> used by some implementations (such as caching |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
241 |
* an associated image in video memory). |
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 |
* @param bank The bank whose data array you want to get. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
244 |
* @return The data array for the specified bank. |
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 |
public short[] getData(int bank) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
247 |
theTrackable.setUntrackable(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
248 |
return bankdata[bank]; |
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 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
251 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
252 |
* Returns the data arrays for all banks. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
253 |
* <p> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
254 |
* Note that calling this method may cause this {@code DataBuffer} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
255 |
* object to be incompatible with <a href="#optimizations">performance |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
256 |
* optimizations</a> used by some implementations (such as caching |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
257 |
* an associated image in video memory). |
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 |
* @return All of the data arrays. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
260 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
261 |
public short[][] getBankData() { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
262 |
theTrackable.setUntrackable(); |
22584 | 263 |
return bankdata.clone(); |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
264 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
265 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
266 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
267 |
* Returns the requested data array element from the first (default) bank. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
268 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
269 |
* @param i The data array element you want to get. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
270 |
* @return The requested data array element as an integer. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
271 |
* @see #setElem(int, int) |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
272 |
* @see #setElem(int, int, int) |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
273 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
274 |
public int getElem(int i) { |
22584 | 275 |
return data[i+offset]&0xffff; |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
276 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
277 |
|
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 |
* Returns the requested data array element from the specified bank. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
280 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
281 |
* @param bank The bank from which you want to get a data array element. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
282 |
* @param i The data array element you want to get. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
283 |
* @return The requested data array element as an integer. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
284 |
* @see #setElem(int, int) |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
285 |
* @see #setElem(int, int, int) |
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 |
public int getElem(int bank, int i) { |
22584 | 288 |
return bankdata[bank][i+offsets[bank]]&0xffff; |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
289 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
290 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
291 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
292 |
* Sets the requested data array element in the first (default) bank |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
293 |
* to the specified value. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
294 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
295 |
* @param i The data array element you want to set. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
296 |
* @param val The integer value to which you want to set the data array element. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
297 |
* @see #getElem(int) |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
298 |
* @see #getElem(int, int) |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
299 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
300 |
public void setElem(int i, int val) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
301 |
data[i+offset] = (short)(val&0xffff); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
302 |
theTrackable.markDirty(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
303 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
304 |
|
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 |
* Sets the requested data array element in the specified bank |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
307 |
* from the given integer. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
308 |
* @param bank The bank in which you want to set the data array element. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
309 |
* @param i The data array element you want to set. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
310 |
* @param val The integer value to which you want to set the specified data array element. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
311 |
* @see #getElem(int) |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
312 |
* @see #getElem(int, int) |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
313 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
314 |
public void setElem(int bank, int i, int val) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
315 |
bankdata[bank][i+offsets[bank]] = (short)(val&0xffff); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
316 |
theTrackable.markDirty(); |
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 |
} |