Source Code Cross Referenced for DataBufferDouble.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » javax » media » jai » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » Java Advanced Imaging » javax.media.jai 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: DataBufferDouble.java,v $
003:         *
004:         * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * Use is subject to license terms.
007:         *
008:         * $Revision: 1.1 $
009:         * $Date: 2005/02/11 04:57:07 $
010:         * $State: Exp $
011:         */
012:        package javax.media.jai;
013:
014:        import java.awt.image.DataBuffer;
015:
016:        /**
017:         * An extension of <code>DataBuffer</code> that stores data internally
018:         * in <code>double</code> form.
019:         *
020:         * @see java.awt.image.DataBuffer
021:         */
022:        public class DataBufferDouble extends DataBuffer {
023:
024:            /** The array of data banks. */
025:            protected double bankdata[][];
026:
027:            /** A reference to the default data bank. */
028:            protected double data[];
029:
030:            /**
031:             * Constructs a <code>double</code>-based <code>DataBuffer</code>
032:             * with a specified size.
033:             *
034:             * @param size The number of elements in the <code>DataBuffer</code>.
035:             */
036:            public DataBufferDouble(int size) {
037:                super (TYPE_DOUBLE, size);
038:                data = new double[size];
039:                bankdata = new double[1][];
040:                bankdata[0] = data;
041:            }
042:
043:            /**
044:             * Constructs a <code>double</code>-based <code>DataBuffer</code>
045:             * with a specified number of banks, all of which are of a
046:             * specified size.
047:             *
048:             * @param size The number of elements in each bank of the
049:             *        <code>DataBuffer</code>.
050:             * @param numBanks The number of banks in the <code>DataBuffer</code>.
051:             */
052:            public DataBufferDouble(int size, int numBanks) {
053:                super (TYPE_DOUBLE, size, numBanks);
054:                bankdata = new double[numBanks][];
055:                for (int i = 0; i < numBanks; i++) {
056:                    bankdata[i] = new double[size];
057:                }
058:                data = bankdata[0];
059:            }
060:
061:            /**
062:             * Constructs a <code>double</code>-based <code>DataBuffer</code>
063:             * with the specified data array.  Only the first
064:             * <code>size</code> elements are available for use by this
065:             * <code>DataBuffer</code>.  The array must be large enough to
066:             * hold <code>size</code> elements.
067:             *
068:             * @param dataArray An array of <code>double</code>s to be used as the
069:             *                  first and only bank of this <code>DataBuffer</code>.
070:             * @param size The number of elements of the array to be used.
071:             */
072:            public DataBufferDouble(double dataArray[], int size) {
073:                super (TYPE_DOUBLE, size);
074:                if (dataArray.length < size)
075:                    throw new RuntimeException(JaiI18N.getString("DataBuffer0"));
076:                data = dataArray;
077:                bankdata = new double[1][];
078:                bankdata[0] = data;
079:            }
080:
081:            /**
082:             * Constructs a <code>double</code>-based <code>DataBuffer</code>
083:             * with the specified data array.  Only the elements between
084:             * <code>offset</code> and <code>offset + size - 1</code> are
085:             * available for use by this <code>DataBuffer</code>.  The array
086:             * must be large enough to hold <code>offset + size</code> elements.
087:             *
088:             * @param dataArray An array of <code>double</code>s to be used as the
089:             *                  first and only bank of this <code>DataBuffer</code>.
090:             * @param size The number of elements of the array to be used.
091:             * @param offset The offset of the first element of the array
092:             *               that will be used.
093:             */
094:            public DataBufferDouble(double dataArray[], int size, int offset) {
095:                super (TYPE_DOUBLE, size, 1, offset);
096:                if (dataArray.length < size)
097:                    throw new RuntimeException(JaiI18N.getString("DataBuffer1"));
098:                data = dataArray;
099:                bankdata = new double[1][];
100:                bankdata[0] = data;
101:            }
102:
103:            /**
104:             * Constructs a <code>double</code>-based <code>DataBuffer</code>
105:             * with the specified data arrays.  Only the first
106:             * <code>size</code> elements of each array are available for use
107:             * by this <code>DataBuffer</code>.  The number of banks will be
108:             * equal <code>to dataArray.length</code>.
109:             *
110:             * @param dataArray An array of arrays of <code>double</code>s to be
111:             *        used as the banks of this <code>DataBuffer</code>.
112:             * @param size The number of elements of each array to be used.
113:             */
114:            public DataBufferDouble(double dataArray[][], int size) {
115:                super (TYPE_DOUBLE, size, dataArray.length);
116:                bankdata = dataArray;
117:                data = bankdata[0];
118:            }
119:
120:            /**
121:             * Constructs a <code>double</code>-based <code>DataBuffer</code>
122:             * with the specified data arrays, size, and per-bank offsets.
123:             * The number of banks is equal to dataArray.length.  Each array
124:             * must be at least as large as <code>size plus the corresponding
125:             * offset.  There must be an entry in the <code>offsets</code>
126:             * array for each data array.
127:             *
128:             * @param dataArray An array of arrays of <code>double</code>s to be
129:             *        used as the banks of this <code>DataBuffer</code>.
130:             * @param size The number of elements of each array to be used.
131:             * @param offsets An array of integer offsets, one for each bank.
132:             */
133:            public DataBufferDouble(double dataArray[][], int size,
134:                    int offsets[]) {
135:                super (TYPE_DOUBLE, size, dataArray.length, offsets);
136:                bankdata = dataArray;
137:                data = bankdata[0];
138:            }
139:
140:            /** Returns the <code>double</code> data array of the default(first) bank. */
141:            public double[] getData() {
142:                return data;
143:            }
144:
145:            /** Returns the data array for the specified bank. */
146:            public double[] getData(int bank) {
147:                return bankdata[bank];
148:            }
149:
150:            /** Returns the data array for all banks. */
151:            public double[][] getBankData() {
152:                return bankdata;
153:            }
154:
155:            /**
156:             * Returns the requested data array element from the first
157:             * (default) bank as an <code>int</code>.
158:             *
159:             * @param i The desired data array element.
160:             *
161:             * @return The data entry as an <code>int</code>.
162:             */
163:            public int getElem(int i) {
164:                return (int) (data[i + offset]);
165:            }
166:
167:            /**
168:             * Returns the requested data array element from the specified
169:             * bank as an <code>int</code>.
170:             *
171:             * @param bank The bank number.
172:             * @param i The desired data array element.
173:             *
174:             * @return The data entry as an <code>int</code>.
175:             */
176:            public int getElem(int bank, int i) {
177:                return (int) (bankdata[bank][i + offsets[bank]]);
178:            }
179:
180:            /**
181:             * Sets the requested data array element in the first (default)
182:             * bank to the given <code>int</code>.
183:             *
184:             * @param i The desired data array element.
185:             * @param val The value to be set.
186:             */
187:            public void setElem(int i, int val) {
188:                data[i + offset] = (double) val;
189:            }
190:
191:            /**
192:             * Sets the requested data array element in the specified bank
193:             * to the given <code>int</code>.
194:             *
195:             * @param bank The bank number.
196:             * @param i The desired data array element.
197:             * @param val The value to be set.
198:             */
199:            public void setElem(int bank, int i, int val) {
200:                bankdata[bank][i + offsets[bank]] = (double) val;
201:            }
202:
203:            /**
204:             * Returns the requested data array element from the first
205:             * (default) bank as a <code>float</code>.
206:             *
207:             * @param i The desired data array element.
208:             *
209:             * @return The data entry as a <code>float</code>.
210:             */
211:            public float getElemFloat(int i) {
212:                return (float) data[i + offset];
213:            }
214:
215:            /**
216:             * Returns the requested data array element from the specified
217:             * bank as a <code>float</code>.
218:             *
219:             * @param bank The bank number.
220:             * @param i The desired data array element.
221:             *
222:             * @return The data entry as a <code>float</code>.
223:             */
224:            public float getElemFloat(int bank, int i) {
225:                return (float) bankdata[bank][i + offsets[bank]];
226:            }
227:
228:            /**
229:             * Sets the requested data array element in the first (default)
230:             * bank to the given <code>float</code>.
231:             *
232:             * @param i The desired data array element.
233:             * @param val The value to be set.
234:             */
235:            public void setElemFloat(int i, float val) {
236:                data[i + offset] = (double) val;
237:            }
238:
239:            /**
240:             * Sets the requested data array element in the specified bank to
241:             * the given <code>float</code>.
242:             *
243:             * @param bank The bank number.
244:             * @param i The desired data array element.
245:             * @param val The value to be set.
246:             */
247:            public void setElemFloat(int bank, int i, float val) {
248:                bankdata[bank][i + offsets[bank]] = (double) val;
249:            }
250:
251:            /**
252:             * Returns the requested data array element from the first
253:             * (default) bank as a <code>double</code>.
254:             *
255:             * @param i The desired data array element.
256:             *
257:             * @return The data entry as a <code>double</code>.
258:             */
259:            public double getElemDouble(int i) {
260:                return data[i + offset];
261:            }
262:
263:            /**
264:             * Returns the requested data array element from the specified
265:             * bank as a <code>double</code>.
266:             *
267:             * @param bank The bank number.
268:             * @param i The desired data array element.
269:             *
270:             * @return The data entry as a <code>double</code>.
271:             */
272:            public double getElemDouble(int bank, int i) {
273:                return bankdata[bank][i + offsets[bank]];
274:            }
275:
276:            /**
277:             * Sets the requested data array element in the first (default)
278:             * bank to the given <code>double</code>.
279:             *
280:             * @param i The desired data array element.
281:             * @param val The value to be set.
282:             */
283:            public void setElemDouble(int i, double val) {
284:                data[i + offset] = val;
285:            }
286:
287:            /**
288:             * Sets the requested data array element in the specified bank to
289:             * the given <code>double</code>.
290:             *
291:             * @param bank The bank number.
292:             * @param i The desired data array element.
293:             * @param val The value to be set.
294:             */
295:            public void setElemDouble(int bank, int i, double val) {
296:                bankdata[bank][i + offsets[bank]] = val;
297:            }
298:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.