Source Code Cross Referenced for TileDecoderImpl.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » javax » media » jai » tilecodec » 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.tilecodec 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: TileDecoderImpl.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:56 $
010:         * $State: Exp $
011:         */package javax.media.jai.tilecodec;
012:
013:        import java.awt.Point;
014:        import java.awt.image.Raster;
015:        import java.awt.image.SampleModel;
016:        import java.io.InputStream;
017:        import java.io.IOException;
018:        import javax.media.jai.JAI;
019:        import javax.media.jai.ParameterListDescriptor;
020:        import javax.media.jai.tilecodec.TileCodecDescriptor;
021:        import com.sun.media.jai.tilecodec.TileCodecUtils;
022:
023:        /**
024:         * A partial implementation of the <code>TileDecoder</code> interface
025:         * useful for subclassing.
026:         *
027:         * @since JAI 1.1
028:         */
029:        public abstract class TileDecoderImpl implements  TileDecoder {
030:
031:            /**
032:             * The name of the format.
033:             */
034:            protected String formatName;
035:
036:            /**
037:             * The <code>InputStream</code> containing the encoded data to decode.
038:             */
039:            protected InputStream inputStream;
040:
041:            /**
042:             * The <code>TileCodecParameterList</code> object containing the
043:             * decoding parameters. 
044:             */
045:            protected TileCodecParameterList paramList;
046:
047:            /**
048:             * Constructs a <code>TileDecoderImpl</code>. An
049:             * <code>IllegalArgumentException</code> will be thrown if
050:             * <code>param</code>'s <code>getParameterListDescriptor()</code> 
051:             * method does not return the same descriptor as that from
052:             * the associated <code>TileCodecDescriptor</code>'s 
053:             * <code>getParameterListDescriptor</code> method for the "tileDecoder" 
054:             * registry mode. 
055:             *
056:             * <p> If param is null, then the default parameter list for decoding
057:             * as defined by the associated <code>TileCodecDescriptor</code>'s 
058:             * <code>getDefaultParameters()</code> method will be used for decoding.
059:             * If this too is null, an <code>IllegalArgumentException</code> will
060:             * be thrown if the <code>ParameterListDescriptor</code> associated
061:             * with the associated <code>TileCodecDescriptor</code> for the
062:             * "tileDecoder" registry mode, reports that the number of parameters
063:             * for this format is non-zero.
064:             *
065:             * @param formatName The name of the format.
066:             * @param input The <code>InputStream</code> to decode data from.
067:             * @param param  The object containing the tile decoding parameters.
068:             *
069:             * @throws IllegalArgumentException if formatName is null.
070:             * @throws IllegalArgumentException if input is null.
071:             * @throws IllegalArgumentException if param's getFormatName() method does
072:             * not return the same formatName as the one specified to this method.
073:             * @throws IllegalArgumentException if the ParameterListDescriptor 
074:             * associated with the param and the associated TileCodecDescriptor are
075:             * not equal.
076:             * @throws IllegalArgumentException if param does not have "tileDecoder"
077:             * as one of the valid modes that it supports.
078:             * @throws IllegalArgumentException if the associated TileCodecDescriptor's
079:             * includesSampleModelInfo() returns false and a non-null value for the
080:             * "sampleModel" parameter is not supplied in the supplied parameter list.
081:             */
082:            public TileDecoderImpl(String formatName, InputStream input,
083:                    TileCodecParameterList param) {
084:
085:                // Cause IllegalArgumentException to be thrown if formatName,
086:                // input is null
087:                if (formatName == null) {
088:                    throw new IllegalArgumentException(JaiI18N
089:                            .getString("TileCodecDescriptorImpl0"));
090:                }
091:
092:                if (input == null) {
093:                    throw new IllegalArgumentException(JaiI18N
094:                            .getString("TileDecoderImpl0"));
095:                }
096:
097:                TileCodecDescriptor tcd = TileCodecUtils
098:                        .getTileCodecDescriptor("tileDecoder", formatName);
099:
100:                // If param is null, get the default parameter list.
101:                if (param == null)
102:                    param = tcd.getDefaultParameters("tileDecoder");
103:
104:                if (param != null) {
105:
106:                    // Check whether the formatName from the param is the same as the
107:                    // one supplied to this method.
108:                    if (param.getFormatName().equalsIgnoreCase(formatName) == false) {
109:                        throw new IllegalArgumentException(JaiI18N
110:                                .getString("TileDecoderImpl1"));
111:                    }
112:
113:                    // Check whether the supplied parameterList supports the 
114:                    // "tileDecoder" mode.
115:                    if (param.isValidForMode("tileDecoder") == false) {
116:                        throw new IllegalArgumentException(JaiI18N
117:                                .getString("TileDecoderImpl2"));
118:                    }
119:
120:                    // Check whether the ParameterListDescriptors are the same.
121:                    if (param.getParameterListDescriptor().equals(
122:                            tcd.getParameterListDescriptor("tileDecoder")) == false)
123:                        throw new IllegalArgumentException(JaiI18N
124:                                .getString("TileCodec0"));
125:
126:                    SampleModel sm = null;
127:
128:                    // Check whether a non-null samplemodel value is needed
129:                    if (tcd.includesSampleModelInfo() == false) {
130:                        try {
131:                            sm = (SampleModel) param
132:                                    .getObjectParameter("sampleModel");
133:                        } catch (IllegalArgumentException iae) {
134:                            // There is no parameter named sampleModel defined on the
135:                            // supplied parameter list
136:                            throw new IllegalArgumentException(JaiI18N
137:                                    .getString("TileDecoderImpl3"));
138:                        }
139:
140:                        if (sm == null
141:                                || sm == ParameterListDescriptor.NO_PARAMETER_DEFAULT) {
142:
143:                            if (tcd.getParameterListDescriptor("tileDecoder")
144:                                    .getParamDefaultValue("sampleModel") == null) {
145:                                // If a non-null value was not set on the parameter list
146:                                // and wasn't available thru the descriptor either 
147:                                throw new IllegalArgumentException(JaiI18N
148:                                        .getString("TileDecoderImpl4"));
149:                            }
150:                        }
151:                    }
152:
153:                } else {
154:
155:                    // If the supplied parameterList is null and the default one is 
156:                    // null too, then check whether this format supports no parameters
157:                    ParameterListDescriptor pld = tcd
158:                            .getParameterListDescriptor("tileDecoder");
159:
160:                    // Check whether a non-null samplemodel value is needed
161:                    if (tcd.includesSampleModelInfo() == false) {
162:                        // SampleModel must be specified via the parameter list
163:                        throw new IllegalArgumentException(JaiI18N
164:                                .getString("TileDecoderImpl5"));
165:                    }
166:
167:                    // If the PLD is not null and says that there are supposed to 
168:                    // be some parameters (numParameters returns non-zero value)
169:                    // throw an IllegalArgumentException
170:                    if (pld != null && pld.getNumParameters() != 0) {
171:                        throw new IllegalArgumentException(JaiI18N
172:                                .getString("TileDecoderImpl6"));
173:                    }
174:                }
175:
176:                this .formatName = formatName;
177:                this .inputStream = input;
178:                this .paramList = param;
179:            }
180:
181:            /**
182:             * Returns the format name.
183:             */
184:            public String getFormatName() {
185:                return formatName;
186:            }
187:
188:            /**
189:             * Returns the current parameters as an instance of the
190:             * <code>TileCodecParameterList</code> interface.
191:             */
192:            public TileCodecParameterList getDecodeParameterList() {
193:                return paramList;
194:            }
195:
196:            /**
197:             * Returns the <code>InputStream</code> associated with this 
198:             * <code>TileDecoder</code>.
199:             */
200:            public InputStream getInputStream() {
201:                return inputStream;
202:            }
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.