Source Code Cross Referenced for GuardBitsSpec.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: GuardBitsSpec.java,v $
003:         * $Revision: 1.1 $
004:         * $Date: 2005/02/11 05:02:17 $
005:         * $State: Exp $
006:         *
007:         * Class:                   GuardBitsSpec
008:         *
009:         * Description:             Guard bits specifications
010:         *
011:         * COPYRIGHT:
012:         *
013:         * This software module was originally developed by Raphaël Grosbois and
014:         * Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
015:         * Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
016:         * Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
017:         * Centre France S.A) in the course of development of the JPEG2000
018:         * standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
019:         * software module is an implementation of a part of the JPEG 2000
020:         * Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
021:         * Systems AB and Canon Research Centre France S.A (collectively JJ2000
022:         * Partners) agree not to assert against ISO/IEC and users of the JPEG
023:         * 2000 Standard (Users) any of their rights under the copyright, not
024:         * including other intellectual property rights, for this software module
025:         * with respect to the usage by ISO/IEC and Users of this software module
026:         * or modifications thereof for use in hardware or software products
027:         * claiming conformance to the JPEG 2000 Standard. Those intending to use
028:         * this software module in hardware or software products are advised that
029:         * their use may infringe existing patents. The original developers of
030:         * this software module, JJ2000 Partners and ISO/IEC assume no liability
031:         * for use of this software module or modifications thereof. No license
032:         * or right to this software module is granted for non JPEG 2000 Standard
033:         * conforming products. JJ2000 Partners have full right to use this
034:         * software module for his/her own purpose, assign or donate this
035:         * software module to any third party and to inhibit third parties from
036:         * using this software module for non JPEG 2000 Standard conforming
037:         * products. This copyright notice must be included in all copies or
038:         * derivative works of this software module.
039:         *
040:         * Copyright (c) 1999/2000 JJ2000 Partners.
041:         *
042:         *
043:         *
044:         */
045:        package jj2000.j2k.quantization;
046:
047:        import jj2000.j2k.util.*;
048:        import jj2000.j2k.*;
049:
050:        import java.util.*;
051:
052:        import com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageWriteParamJava;
053:
054:        /**
055:         * This class extends ModuleSpec class in order to hold specifications about
056:         * number of guard bits in each tile-component.
057:         *
058:         * @see ModuleSpec
059:         * */
060:        public class GuardBitsSpec extends ModuleSpec {
061:
062:            private String defaultValue = "2";
063:
064:            /**
065:             * Constructs an empty 'GuardBitsSpec' with specified number of tile and
066:             * components. This constructor is called by the decoder.
067:             *
068:             * @param nt Number of tiles
069:             *
070:             * @param nc Number of components
071:             *
072:             * @param type the type of the specification module i.e. tile specific,
073:             * component specific or both.
074:             * */
075:            public GuardBitsSpec(int nt, int nc, byte type) {
076:                super (nt, nc, type);
077:            }
078:
079:            /**
080:             * Constructs a new 'GuardBitsSpec' for the specified number of components
081:             * and tiles and the arguments of "-Qguard_bits" option.
082:             *
083:             * @param nt The number of tiles
084:             *
085:             * @param nc The number of components
086:             *
087:             * @param type the type of the specification module i.e. tile specific,
088:             * component specific or both.
089:             * */
090:            public GuardBitsSpec(int nt, int nc, byte type,
091:                    J2KImageWriteParamJava wp, String values) {
092:                super (nt, nc, type);
093:
094:                if (values == null) {
095:                    setDefault(new Integer(defaultValue));
096:                    return;
097:                    //throw new IllegalArgumentException("Qguard_bits option not "+
098:                    //                                 "specified");
099:                }
100:
101:                String param = values;
102:                // Parse argument
103:                StringTokenizer stk = new StringTokenizer(param);
104:                String word; // current word
105:                byte curSpecType = SPEC_DEF; // Specification type of the
106:                // current parameter
107:                boolean[] tileSpec = null; // Tiles concerned by the specification
108:                boolean[] compSpec = null; // Components concerned by the specification
109:                Integer value; // value of the guard bits
110:
111:                while (stk.hasMoreTokens()) {
112:                    word = stk.nextToken().toLowerCase();
113:
114:                    switch (word.charAt(0)) {
115:                    case 't': // Tiles specification
116:                        tileSpec = parseIdx(word, nTiles);
117:                        if (curSpecType == SPEC_COMP_DEF)
118:                            curSpecType = SPEC_TILE_COMP;
119:                        else
120:                            curSpecType = SPEC_TILE_DEF;
121:                        break;
122:                    case 'c': // Components specification
123:                        compSpec = parseIdx(word, nComp);
124:                        if (curSpecType == SPEC_TILE_DEF)
125:                            curSpecType = SPEC_TILE_COMP;
126:                        else
127:                            curSpecType = SPEC_COMP_DEF;
128:                        break;
129:                    default: // Step size value
130:                        try {
131:                            value = new Integer(word);
132:                        } catch (NumberFormatException e) {
133:                            throw new IllegalArgumentException(
134:                                    "Bad parameter for "
135:                                            + "-Qguard_bits option" + " : "
136:                                            + word);
137:                        }
138:
139:                        if (value.floatValue() <= 0.0f) {
140:                            throw new IllegalArgumentException(
141:                                    "Guard bits value " + "must be positive : "
142:                                            + value);
143:                        }
144:
145:                        if (curSpecType == SPEC_DEF) {
146:                            setDefault(value);
147:                        } else if (curSpecType == SPEC_TILE_DEF) {
148:                            for (int i = tileSpec.length - 1; i >= 0; i--)
149:                                if (tileSpec[i]) {
150:                                    setTileDef(i, value);
151:                                }
152:                        } else if (curSpecType == SPEC_COMP_DEF) {
153:                            for (int i = compSpec.length - 1; i >= 0; i--)
154:                                if (compSpec[i]) {
155:                                    setCompDef(i, value);
156:                                }
157:                        } else {
158:                            for (int i = tileSpec.length - 1; i >= 0; i--) {
159:                                for (int j = compSpec.length - 1; j >= 0; j--) {
160:                                    if (tileSpec[i] && compSpec[j]) {
161:                                        setTileCompVal(i, j, value);
162:                                    }
163:                                }
164:                            }
165:                        }
166:
167:                        // Re-initialize
168:                        curSpecType = SPEC_DEF;
169:                        tileSpec = null;
170:                        compSpec = null;
171:                        break;
172:                    }
173:                }
174:
175:                // Check that default value has been specified
176:                if (getDefault() == null) {
177:                    int ndefspec = 0;
178:                    for (int t = nt - 1; t >= 0; t--) {
179:                        for (int c = nc - 1; c >= 0; c--) {
180:                            if (specValType[t][c] == SPEC_DEF) {
181:                                ndefspec++;
182:                            }
183:                        }
184:                    }
185:
186:                    // If some tile-component have received no specification, it takes
187:                    // the default value
188:                    if (ndefspec != 0) {
189:                        setDefault(new Integer(defaultValue));
190:                    } else {
191:                        // All tile-component have been specified, takes the first
192:                        // tile-component value as default.
193:                        setDefault(getTileCompVal(0, 0));
194:                        switch (specValType[0][0]) {
195:                        case SPEC_TILE_DEF:
196:                            for (int c = nc - 1; c >= 0; c--) {
197:                                if (specValType[0][c] == SPEC_TILE_DEF)
198:                                    specValType[0][c] = SPEC_DEF;
199:                            }
200:                            tileDef[0] = null;
201:                            break;
202:                        case SPEC_COMP_DEF:
203:                            for (int t = nt - 1; t >= 0; t--) {
204:                                if (specValType[t][0] == SPEC_COMP_DEF)
205:                                    specValType[t][0] = SPEC_DEF;
206:                            }
207:                            compDef[0] = null;
208:                            break;
209:                        case SPEC_TILE_COMP:
210:                            specValType[0][0] = SPEC_DEF;
211:                            tileCompVal.put("t0c0", null);
212:                            break;
213:                        }
214:                    }
215:                }
216:            }
217:
218:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.