Source Code Cross Referenced for ImgReader.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » jj2000 » j2k » image » input » 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 » jj2000.j2k.image.input 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: ImgReader.java,v $
003:         * $Revision: 1.1 $
004:         * $Date: 2005/02/11 05:02:14 $
005:         * $State: Exp $
006:         *
007:         * Class:                   ImgReader
008:         *
009:         * Description:             Generic interface for image readers (from
010:         *                          file or other resource)
011:         *
012:         *
013:         *
014:         * COPYRIGHT:
015:         *
016:         * This software module was originally developed by Raphaël Grosbois and
017:         * Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
018:         * Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
019:         * Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
020:         * Centre France S.A) in the course of development of the JPEG2000
021:         * standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
022:         * software module is an implementation of a part of the JPEG 2000
023:         * Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
024:         * Systems AB and Canon Research Centre France S.A (collectively JJ2000
025:         * Partners) agree not to assert against ISO/IEC and users of the JPEG
026:         * 2000 Standard (Users) any of their rights under the copyright, not
027:         * including other intellectual property rights, for this software module
028:         * with respect to the usage by ISO/IEC and Users of this software module
029:         * or modifications thereof for use in hardware or software products
030:         * claiming conformance to the JPEG 2000 Standard. Those intending to use
031:         * this software module in hardware or software products are advised that
032:         * their use may infringe existing patents. The original developers of
033:         * this software module, JJ2000 Partners and ISO/IEC assume no liability
034:         * for use of this software module or modifications thereof. No license
035:         * or right to this software module is granted for non JPEG 2000 Standard
036:         * conforming products. JJ2000 Partners have full right to use this
037:         * software module for his/her own purpose, assign or donate this
038:         * software module to any third party and to inhibit third parties from
039:         * using this software module for non JPEG 2000 Standard conforming
040:         * products. This copyright notice must be included in all copies or
041:         * derivative works of this software module.
042:         *
043:         * Copyright (c) 1999/2000 JJ2000 Partners.
044:         */
045:        package jj2000.j2k.image.input;
046:
047:        import jj2000.j2k.image.*;
048:        import jj2000.j2k.*;
049:        import java.io.*;
050:
051:        import java.awt.Point;
052:
053:        /**
054:         * This is the generic interface to be implemented by all image file (or other
055:         * resource) readers for different image file formats.
056:         *
057:         * <p>An ImgReader behaves as an ImgData object. Whenever image data is
058:         * requested through the getInternCompData() or getCompData() methods, the
059:         * image data will be read (if it is not buffered) and returned. Implementing
060:         * classes should not buffer large amounts of data, so as to reduce memory
061:         * usage.</p>
062:         *
063:         * <p>This class sets the image origin to (0,0). All default implementations
064:         * of the methods assume this.</p>
065:         *
066:         * <p>This class provides default implementations of many methods. These
067:         * default implementations assume that there is no tiling (i.e., the only tile
068:         * is the entire image), that the image origin is (0,0) in the canvas system
069:         * and that there is no component subsampling (all components are the same
070:         * size), but they can be overloaded by the implementating class if need
071:         * be.</p>
072:         * */
073:        public abstract class ImgReader implements  BlkImgDataSrc {
074:
075:            /** The width of the image */
076:            protected int w;
077:
078:            /** The height of the image */
079:            protected int h;
080:
081:            /** The number of components in the image */
082:            protected int nc;
083:
084:            /**
085:             * Closes the underlying file or network connection from where the
086:             * image data is being read.
087:             *
088:             * @exception IOException If an I/O error occurs.
089:             */
090:            public abstract void close() throws IOException;
091:
092:            /**
093:             * Returns the width of the current tile in pixels, assuming there is
094:             * no-tiling. Since no-tiling is assumed this is the same as the width of
095:             * the image. The value of <tt>w</tt> is returned.
096:             *
097:             * @return The total image width in pixels.
098:             * */
099:            public int getTileWidth() {
100:                return w;
101:            }
102:
103:            /**
104:             * Returns the overall height of the current tile in pixels, assuming
105:             * there is no-tiling. Since no-tiling is assumed this is the same as the
106:             * width of the image. The value of <tt>h</tt> is returned.
107:             *
108:             * @return The total image height in pixels.  */
109:            public int getTileHeight() {
110:                return h;
111:            }
112:
113:            /** Returns the nominal tiles width */
114:            public int getNomTileWidth() {
115:                return w;
116:            }
117:
118:            /** Returns the nominal tiles height */
119:            public int getNomTileHeight() {
120:                return h;
121:            }
122:
123:            /**
124:             * Returns the overall width of the image in pixels. This is the image's
125:             * width without accounting for any component subsampling or tiling. The
126:             * value of <tt>w</tt> is returned.
127:             *
128:             * @return The total image's width in pixels.
129:             * */
130:            public int getImgWidth() {
131:                return w;
132:            }
133:
134:            /**
135:             * Returns the overall height of the image in pixels. This is the image's
136:             * height without accounting for any component subsampling or tiling. The
137:             * value of <tt>h</tt> is returned.
138:             *
139:             * @return The total image's height in pixels.
140:             * */
141:            public int getImgHeight() {
142:                return h;
143:            }
144:
145:            /**
146:             * Returns the number of components in the image. The value of <tt>nc</tt>
147:             * is returned.
148:             *
149:             * @return The number of components in the image.
150:             * */
151:            public int getNumComps() {
152:                return nc;
153:            }
154:
155:            /**
156:             * Returns the component subsampling factor in the horizontal direction,
157:             * for the specified component. This is, approximately, the ratio of
158:             * dimensions between the reference grid and the component itself, see the
159:             * 'ImgData' interface desription for details.
160:             *
161:             * @param c The index of the component (between 0 and C-1)
162:             *
163:             * @return The horizontal subsampling factor of component 'c'
164:             *
165:             * @see jj2000.j2k.image.ImgData
166:             * */
167:            public int getCompSubsX(int c) {
168:                return 1;
169:            }
170:
171:            /**
172:             * Returns the component subsampling factor in the vertical direction, for
173:             * the specified component. This is, approximately, the ratio of
174:             * dimensions between the reference grid and the component itself, see the
175:             * 'ImgData' interface desription for details.
176:             *
177:             * @param c The index of the component (between 0 and C-1)
178:             *
179:             * @return The vertical subsampling factor of component 'c'
180:             *
181:             * @see jj2000.j2k.image.ImgData
182:             * */
183:            public int getCompSubsY(int c) {
184:                return 1;
185:            }
186:
187:            /**
188:             * Returns the width in pixels of the specified tile-component. This
189:             * default implementation assumes no tiling and no component subsampling
190:             * (i.e., all components, or components, have the same dimensions in
191:             * pixels).
192:             *
193:             * @param t Tile index
194:             *
195:             * @param c The index of the component, from 0 to C-1.
196:             *
197:             * @return The width in pixels of component <tt>c</tt> in tile<tt>t</tt>.
198:             * */
199:            public int getTileCompWidth(int t, int c) {
200:                if (t != 0) {
201:                    throw new Error(
202:                            "Asking a tile-component width for a tile index"
203:                                    + " greater than 0 whereas there is only one tile");
204:                }
205:                return w;
206:            }
207:
208:            /**
209:             * Returns the height in pixels of the specified tile-component. This
210:             * default implementation assumes no tiling and no component subsampling
211:             * (i.e., all components, or components, have the same dimensions in
212:             * pixels).
213:             *
214:             * @param t The tile index
215:             *
216:             * @param c The index of the component, from 0 to C-1.
217:             *
218:             * @return The height in pixels of component <tt>c</tt> in tile
219:             * <tt>t</tt>.
220:             * */
221:            public int getTileCompHeight(int t, int c) {
222:                if (t != 0) {
223:                    throw new Error(
224:                            "Asking a tile-component width for a tile index"
225:                                    + " greater than 0 whereas there is only one tile");
226:                }
227:                return h;
228:            }
229:
230:            /**
231:             * Returns the width in pixels of the specified component in the overall
232:             * image. This default implementation assumes no component, or component,
233:             * subsampling (i.e. all components have the same dimensions in pixels).
234:             *
235:             * @param c The index of the component, from 0 to C-1.
236:             *
237:             * @return The width in pixels of component <tt>c</tt> in the overall
238:             * image.
239:             * */
240:            public int getCompImgWidth(int c) {
241:                return w;
242:            }
243:
244:            /**
245:             * Returns the height in pixels of the specified component in the overall
246:             * image. This default implementation assumes no component, or component,
247:             * subsampling (i.e. all components have the same dimensions in pixels).
248:             *
249:             * @param c The index of the component, from 0 to C-1.
250:             *
251:             * @return The height in pixels of component <tt>c</tt> in the overall
252:             * image.
253:             * */
254:            public int getCompImgHeight(int c) {
255:                return h;
256:            }
257:
258:            /**
259:             * Changes the current tile, given the new coordinates. An
260:             * IllegalArgumentException is thrown if the coordinates do not correspond
261:             * to a valid tile. This default implementation assumes no tiling so the
262:             * only valid arguments are x=0, y=0.
263:             *
264:             * @param x The horizontal coordinate of the tile.
265:             *
266:             * @param y The vertical coordinate of the new tile.
267:             * */
268:            public void setTile(int x, int y) {
269:                if (x != 0 || y != 0) {
270:                    throw new IllegalArgumentException();
271:                }
272:            }
273:
274:            /**
275:             * Advances to the next tile, in standard scan-line order (by rows then
276:             * columns). A NoNextElementException is thrown if the current tile is the
277:             * last one (i.e. there is no next tile). This default implementation
278:             * assumes no tiling, so NoNextElementException() is always thrown.
279:             * */
280:            public void nextTile() {
281:                throw new NoNextElementException();
282:            }
283:
284:            /**
285:             * Returns the coordinates of the current tile. This default
286:             * implementation assumes no-tiling, so (0,0) is returned.
287:             *
288:             * @param co If not null this object is used to return the information. If
289:             * null a new one is created and returned.
290:             *
291:             * @return The current tile's coordinates.
292:             * */
293:            public Point getTile(Point co) {
294:                if (co != null) {
295:                    co.x = 0;
296:                    co.y = 0;
297:                    return co;
298:                } else {
299:                    return new Point(0, 0);
300:                }
301:            }
302:
303:            /**
304:             * Returns the index of the current tile, relative to a standard scan-line
305:             * order. This default implementations assumes no tiling, so 0 is always
306:             * returned.
307:             *
308:             * @return The current tile's index (starts at 0).
309:             * */
310:            public int getTileIdx() {
311:                return 0;
312:            }
313:
314:            /**
315:             * Returns the horizontal coordinate of the upper-left corner of the
316:             * specified component in the current tile.
317:             *
318:             * @param c The component index.
319:             * */
320:            public int getCompULX(int c) {
321:                return 0;
322:            }
323:
324:            /**
325:             * Returns the vertical coordinate of the upper-left corner of the
326:             * specified component in the current tile.
327:             *
328:             * @param c The component index.
329:             * */
330:            public int getCompULY(int c) {
331:                return 0;
332:            }
333:
334:            /** Returns the horizontal tile partition offset in the reference grid */
335:            public int getTilePartULX() {
336:                return 0;
337:            }
338:
339:            /** Returns the vertical tile partition offset in the reference grid */
340:            public int getTilePartULY() {
341:                return 0;
342:            }
343:
344:            /**
345:             * Returns the horizontal coordinate of the image origin, the top-left
346:             * corner, in the canvas system, on the reference grid.
347:             *
348:             * @return The horizontal coordinate of the image origin in the canvas
349:             * system, on the reference grid.
350:             * */
351:            public int getImgULX() {
352:                return 0;
353:            }
354:
355:            /**
356:             * Returns the vertical coordinate of the image origin, the top-left
357:             * corner, in the canvas system, on the reference grid.
358:             *
359:             * @return The vertical coordinate of the image origin in the canvas
360:             * system, on the reference grid.
361:             * */
362:            public int getImgULY() {
363:                return 0;
364:            }
365:
366:            /**
367:             * Returns the number of tiles in the horizontal and vertical
368:             * directions. This default implementation assumes no tiling, so (1,1) is
369:             * always returned.
370:             *
371:             * @param co If not null this object is used to return the information. If
372:             * null a new one is created and returned.
373:             *
374:             * @return The number of tiles in the horizontal (Point.x) and vertical
375:             * (Point.y) directions.
376:             * */
377:            public Point getNumTiles(Point co) {
378:                if (co != null) {
379:                    co.x = 1;
380:                    co.y = 1;
381:                    return co;
382:                } else {
383:                    return new Point(1, 1);
384:                }
385:            }
386:
387:            /**
388:             * Returns the total number of tiles in the image. This default
389:             * implementation assumes no tiling, so 1 is always returned.
390:             *
391:             * @return The total number of tiles in the image.
392:             * */
393:            public int getNumTiles() {
394:                return 1;
395:            }
396:
397:            /**
398:             * Returns true if the data read was originally signed in the specified
399:             * component, false if not.
400:             *
401:             * @param c The index of the component, from 0 to C-1.
402:             *
403:             * @return true if the data was originally signed, false if not.
404:             * */
405:            public abstract boolean isOrigSigned(int c);
406:
407:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.