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


001:        /*
002:         * $RCSfile: DataBlk.java,v $
003:         * $Revision: 1.1 $
004:         * $Date: 2005/02/11 05:02:12 $
005:         * $State: Exp $
006:         *
007:         * Interface:           DataBlk
008:         *
009:         * Description:         A generic interface to hold 2D blocks of data.
010:         *
011:         *
012:         *
013:         * COPYRIGHT:
014:         *
015:         * This software module was originally developed by Raphaël Grosbois and
016:         * Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
017:         * Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
018:         * Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
019:         * Centre France S.A) in the course of development of the JPEG2000
020:         * standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
021:         * software module is an implementation of a part of the JPEG 2000
022:         * Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
023:         * Systems AB and Canon Research Centre France S.A (collectively JJ2000
024:         * Partners) agree not to assert against ISO/IEC and users of the JPEG
025:         * 2000 Standard (Users) any of their rights under the copyright, not
026:         * including other intellectual property rights, for this software module
027:         * with respect to the usage by ISO/IEC and Users of this software module
028:         * or modifications thereof for use in hardware or software products
029:         * claiming conformance to the JPEG 2000 Standard. Those intending to use
030:         * this software module in hardware or software products are advised that
031:         * their use may infringe existing patents. The original developers of
032:         * this software module, JJ2000 Partners and ISO/IEC assume no liability
033:         * for use of this software module or modifications thereof. No license
034:         * or right to this software module is granted for non JPEG 2000 Standard
035:         * conforming products. JJ2000 Partners have full right to use this
036:         * software module for his/her own purpose, assign or donate this
037:         * software module to any third party and to inhibit third parties from
038:         * using this software module for non JPEG 2000 Standard conforming
039:         * products. This copyright notice must be included in all copies or
040:         * derivative works of this software module.
041:         *
042:         * Copyright (c) 1999/2000 JJ2000 Partners.
043:         *
044:         *
045:         *
046:         */
047:
048:        package jj2000.j2k.image;
049:
050:        /**
051:         * This is a generic abstract class to store data from a block of an
052:         * image. This class does not have the notion of components. Therefore, it
053:         * should be used for data from a single component. Subclasses should
054:         * implement the different types of storage (<tt>int</tt>,
055:         * <tt>float</tt>, etc.).
056:         *
057:         * <P>The data is always stored in one array, of the type matching the data
058:         * type (i.e. for 'int' it's an 'int[]'). The data should be stored in the
059:         * array in standard scan-line order. That is the samples go from the top-left
060:         * corner of the code-block to the lower-right corner by line and then column.
061:         *
062:         * <P>The member variable 'offset' gives the index in the array of the first
063:         * data element (i.e. the top-left coefficient (ulx,uly)). The member variable
064:         * 'scanw' gives the width of the scan that is used to store the data, that
065:         * can be different from the width of the block. Element '(x,y)' of the
066:         * code-block (i.e. '(ulx,uly)' is the top-left coefficient), will appear at
067:         * position 'offset+(y-uly)*scanw+(x-ulx)' in the array of data.
068:         *
069:         * <P>A block of data can have the <i>progressive</i> attribute
070:         * set. Data is progressive when it is obtained by successive
071:         * refinement and the values in this block are approximations of the
072:         * "final" values. When the final values are returned the progressive
073:         * attribute must be turned off.
074:         *
075:         * <P>The classes <tt>DataBlkInt</tt> and <tt>DataBlkFloat</tt>
076:         * provide implementations for <tt>int</tt> and <tt>float</tt> types
077:         * respectively.
078:         *
079:         * @see DataBlkInt
080:         *
081:         * @see DataBlkFloat
082:         * */
083:        public abstract class DataBlk {
084:
085:            /** The identifier for the <tt>byte</tt> data type, as signed 8
086:                bits. */
087:            public final static int TYPE_BYTE = 0;
088:
089:            /** The identifier for the <tt>short</tt> data type, as signed 16
090:                bits. */
091:            public final static int TYPE_SHORT = 1;
092:
093:            /** The identifier for the <tt>int</tt> data type, as signed 32
094:                bits. */
095:            public final static int TYPE_INT = 3;
096:
097:            /** The identifier for the <tt>float</tt> data type */
098:            public final static int TYPE_FLOAT = 4;
099:
100:            /** The horizontal coordinate (in pixels) of the upper-left corner
101:             *  of the block of data. This is relative to the component of the
102:             *  image from where this block was filled or is to be filled.
103:             */
104:            public int ulx;
105:
106:            /** The vertical coordinate of the upper-left corner of the block
107:             *  of data. This is relative to the component of the image from where
108:             *  this block was filled or is to be filled.
109:             */
110:            public int uly;
111:
112:            /** The width of the block, in pixels. */
113:            public int w;
114:
115:            /** The height of the block, in pixels. */
116:            public int h;
117:
118:            /** The offset in the array of the top-left coefficient */
119:            public int offset;
120:
121:            /** The width of the scanlines used to store the data in the array */
122:            public int scanw;
123:
124:            /** The progressive attribute (<tt>false</tt> by default) */
125:            public boolean progressive;
126:
127:            /**
128:             * Returns the size in bits, given the data type. The data type
129:             * must be one defined in this class. An
130:             * <tt>IllegalArgumentException</tt> is thrown if <tt>type</tt> is
131:             * not defined in this class.
132:             *
133:             * @param type The data type.
134:             *
135:             * @return The size in bits of the data type.
136:             *
137:             *
138:             *
139:             */
140:            public static int getSize(int type) {
141:                switch (type) {
142:                case TYPE_BYTE:
143:                    return 8;
144:                case TYPE_SHORT:
145:                    return 16;
146:                case TYPE_INT:
147:                case TYPE_FLOAT:
148:                    return 32;
149:                default:
150:                    throw new IllegalArgumentException();
151:                }
152:            }
153:
154:            /**
155:             * Returns the data type of the <tt>DataBlk</tt> object, as
156:             * defined in this class.
157:             *
158:             * @return The data type of the object, as defined in thsi class.
159:             *
160:             *
161:             *
162:             */
163:            public abstract int getDataType();
164:
165:            /**
166:             * Returns the array containing the data, or null if there is no
167:             * data. The returned array is of the type returned by
168:             * <tt>getDataType()</tt> (e.g., for <tt>TYPE_INT</tt>, it is a
169:             * <tt>int[]</tt>).
170:             *
171:             * <P>Each implementing class should provide a type specific
172:             * equivalent method (e.g., <tt>getDataInt()</tt> in
173:             * <tt>DataBlkInt</tt>) which returns an array of the correct
174:             * type explicetely and not through an <tt>Object</tt>.
175:             *
176:             * @return The array containing the data, or <tt>null</tt> if
177:             *         there is no data.
178:             *
179:             *
180:             *
181:             * @see #getDataType
182:             *
183:             */
184:            public abstract Object getData();
185:
186:            /**
187:             * Sets the data array to the specified one. The type of the
188:             * specified data array must match the one returned by
189:             * <tt>getDataType()</tt> (e.g., for <tt>TYPE_INT</tt>, it should
190:             * be a <tt>int[]</tt>). If the wrong type of array is given a
191:             * <tt>ClassCastException</tt> will be thrown.
192:             *
193:             * <P>The size of the array is not necessarily checked for
194:             * consistency with <tt>w</tt> and <tt>h</tt> or any other fields.
195:             *
196:             * <P>Each implementing class should provide a type specific
197:             * equivalent method (e.g., <tt>setDataInt()</tt> in
198:             * <tt>DataBlkInt</tt>) which takes an array of the correct
199:             * type explicetely and not through an <tt>Object</tt>.
200:             *
201:             * @param arr The new data array to use
202:             *
203:             *
204:             *
205:             * @see #getDataType
206:             * */
207:            public abstract void setData(Object arr);
208:
209:            /**
210:             * Returns a string of informations about the DataBlk
211:             *
212:             * @return Block dimensions and progressiveness in a string
213:             *
214:             *
215:             */
216:            public String toString() {
217:                String typeString = "";
218:                switch (getDataType()) {
219:                case TYPE_BYTE:
220:                    typeString = "Unsigned Byte";
221:                    break;
222:                case TYPE_SHORT:
223:                    typeString = "Short";
224:                    break;
225:                case TYPE_INT:
226:                    typeString = "Integer";
227:                    break;
228:                case TYPE_FLOAT:
229:                    typeString = "Float";
230:                    break;
231:                }
232:
233:                return "DataBlk: " + "upper-left(" + ulx + "," + uly
234:                        + "), width= " + w + ", height= " + h
235:                        + ", progressive= " + progressive + ", offset= "
236:                        + offset + ", scanw= " + scanw + ", type= "
237:                        + typeString;
238:            }
239:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.