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


001:        /*
002:         * $RCSfile: QuantStepSizeSpec.java,v $
003:         * $Revision: 1.1 $
004:         * $Date: 2005/02/11 05:02:17 $
005:         * $State: Exp $
006:         *
007:         * Class:                   QuantStepSizeSpec
008:         *
009:         * Description:    Quantization base normalized step size specifications
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:        package jj2000.j2k.quantization;
048:
049:        import jj2000.j2k.util.*;
050:        import jj2000.j2k.*;
051:
052:        import java.util.*;
053:
054:        import com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageWriteParamJava;
055:
056:        /**
057:         * This class extends ModuleSpec class in order to hold specifications about
058:         * the quantization base normalized step size to use in each tile-component.
059:         *
060:         * @see ModuleSpec
061:         * */
062:        public class QuantStepSizeSpec extends ModuleSpec {
063:
064:            private String defaultValue = "0.0078125";
065:
066:            /**
067:             * Constructs an empty 'QuantStepSizeSpec' with specified number of
068:             * tile and components. This constructor is called by the decoder.
069:             *
070:             * @param nt Number of tiles
071:             *
072:             * @param nc Number of components
073:             *
074:             * @param type the type of the specification module i.e. tile specific,
075:             * component specific or both.
076:             * */
077:            public QuantStepSizeSpec(int nt, int nc, byte type) {
078:                super (nt, nc, type);
079:            }
080:
081:            /**
082:             * Constructs a new 'QuantStepSizeSpec' for the specified number of
083:             * components and tiles and the arguments of "-Qstep" option.
084:             *
085:             * @param nt The number of tiles
086:             *
087:             * @param nc The number of components
088:             *
089:             * @param type the type of the specification module i.e. tile specific,
090:             * component specific or both.
091:             * */
092:            public QuantStepSizeSpec(int nt, int nc, byte type,
093:                    J2KImageWriteParamJava wp, String values) {
094:                super (nt, nc, type);
095:
096:                if (values == null) {
097:                    // XXX: setDefault
098:                    setDefault(new Float(defaultValue));
099:                    //throw new IllegalArgumentException("Qstep option not specified");
100:                }
101:                specified = values;
102:
103:                // XXX: need change
104:                String param = specified;
105:                if (param == null)
106:                    param = defaultValue;
107:
108:                // Parse argument
109:                StringTokenizer stk = new StringTokenizer(param);
110:                String word; // current word
111:                byte curSpecType = SPEC_DEF; // Specification type of the
112:                // current parameter
113:                boolean[] tileSpec = null; // Tiles concerned by the specification
114:                boolean[] compSpec = null; // Components concerned by the specification
115:                Float value; // value of the current step size
116:
117:                while (stk.hasMoreTokens()) {
118:                    word = stk.nextToken().toLowerCase();
119:
120:                    switch (word.charAt(0)) {
121:                    case 't': // Tiles specification
122:                        tileSpec = parseIdx(word, nTiles);
123:                        if (curSpecType == SPEC_COMP_DEF)
124:                            curSpecType = SPEC_TILE_COMP;
125:                        else
126:                            curSpecType = SPEC_TILE_DEF;
127:                        break;
128:                    case 'c': // Components specification
129:                        compSpec = parseIdx(word, nComp);
130:                        if (curSpecType == SPEC_TILE_DEF)
131:                            curSpecType = SPEC_TILE_COMP;
132:                        else
133:                            curSpecType = SPEC_COMP_DEF;
134:                        break;
135:                    default: // Step size value
136:                        try {
137:                            value = new Float(word);
138:                        } catch (NumberFormatException e) {
139:                            throw new IllegalArgumentException(
140:                                    "Bad parameter for " + "-Qstep option : "
141:                                            + word);
142:                        }
143:
144:                        if (value.floatValue() <= 0.0f) {
145:                            throw new IllegalArgumentException(
146:                                    "Normalized base step "
147:                                            + "must be positive : " + value);
148:                        }
149:
150:                        if (curSpecType == SPEC_DEF) {
151:                            setDefault(value);
152:                        } else if (curSpecType == SPEC_TILE_DEF) {
153:                            for (int i = tileSpec.length - 1; i >= 0; i--)
154:                                if (tileSpec[i]) {
155:                                    setTileDef(i, value);
156:                                }
157:                        } else if (curSpecType == SPEC_COMP_DEF) {
158:                            for (int i = compSpec.length - 1; i >= 0; i--)
159:                                if (compSpec[i]) {
160:                                    setCompDef(i, value);
161:                                }
162:                        } else {
163:                            for (int i = tileSpec.length - 1; i >= 0; i--) {
164:                                for (int j = compSpec.length - 1; j >= 0; j--) {
165:                                    if (tileSpec[i] && compSpec[j]) {
166:                                        setTileCompVal(i, j, value);
167:                                    }
168:                                }
169:                            }
170:                        }
171:
172:                        // Re-initialize
173:                        curSpecType = SPEC_DEF;
174:                        tileSpec = null;
175:                        compSpec = null;
176:                        break;
177:                    }
178:                }
179:
180:                // Check that default value has been specified
181:                if (getDefault() == null) {
182:                    int ndefspec = 0;
183:                    for (int t = nt - 1; t >= 0; t--) {
184:                        for (int c = nc - 1; c >= 0; c--) {
185:                            if (specValType[t][c] == SPEC_DEF) {
186:                                ndefspec++;
187:                            }
188:                        }
189:                    }
190:
191:                    // If some tile-component have received no specification, it takes
192:                    // the default value
193:                    if (ndefspec != 0) {
194:                        setDefault(new Float(defaultValue));
195:                    } else {
196:                        // All tile-component have been specified, takes the first
197:                        // tile-component value as default.
198:                        setDefault(getTileCompVal(0, 0));
199:                        switch (specValType[0][0]) {
200:                        case SPEC_TILE_DEF:
201:                            for (int c = nc - 1; c >= 0; c--) {
202:                                if (specValType[0][c] == SPEC_TILE_DEF)
203:                                    specValType[0][c] = SPEC_DEF;
204:                            }
205:                            tileDef[0] = null;
206:                            break;
207:                        case SPEC_COMP_DEF:
208:                            for (int t = nt - 1; t >= 0; t--) {
209:                                if (specValType[t][0] == SPEC_COMP_DEF)
210:                                    specValType[t][0] = SPEC_DEF;
211:                            }
212:                            compDef[0] = null;
213:                            break;
214:                        case SPEC_TILE_COMP:
215:                            specValType[0][0] = SPEC_DEF;
216:                            tileCompVal.put("t0c0", null);
217:                            break;
218:                        }
219:                    }
220:                }
221:            }
222:
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.