Source Code Cross Referenced for TileEncoderImpl.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: TileEncoderImpl.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.image.Raster;
014:        import java.awt.image.SampleModel;
015:        import java.io.IOException;
016:        import java.io.OutputStream;
017:        import javax.media.jai.JAI;
018:        import javax.media.jai.ParameterListDescriptor;
019:        import javax.media.jai.tilecodec.TileCodecDescriptor;
020:        import com.sun.media.jai.tilecodec.TileCodecUtils;
021:
022:        /**
023:         * A partial implementation of the <code>TileEncoder</code> interface
024:         * useful for subclassing.
025:         *
026:         * @since JAI 1.1
027:         */
028:        public abstract class TileEncoderImpl implements  TileEncoder {
029:
030:            /**
031:             * The name of the format.
032:             */
033:            protected String formatName;
034:
035:            /** 
036:             * The <code>OutputStream</code>  to write the encoded data to.
037:             */
038:            protected OutputStream outputStream;
039:
040:            /**
041:             * The <code>TileCodecParameterList</code> object containing the
042:             * encoding parameters.
043:             */
044:            protected TileCodecParameterList paramList;
045:
046:            /**
047:             * Constructs an <code>TileEncoderImpl</code>. An
048:             * <code>IllegalArgumentException</code> will be thrown if
049:             * <code>param</code>'s <code>getParameterListDescriptor()</code> method
050:             * does not return the same descriptor as that from the associated
051:             * <code>TileCodecDescriptor</code>'s 
052:             * <code>getParameterListDescriptor</code> method for the "tileEncoder" 
053:             * registry mode. 
054:             *
055:             * <p> If param is null, then the default parameter list for encoding
056:             * as defined by the associated <code>TileCodecDescriptor</code>'s 
057:             * <code>getDefaultParameters()</code> method will be used for encoding.
058:             * If this too is null, an <code>IllegalArgumentException</code> will
059:             * be thrown if the <code>ParameterListDescriptor</code> associated
060:             * with the associated <code>TileCodecDescriptor</code> for the
061:             * "tileEncoder" registry mode, reports that the number of parameters 
062:             * for this format is non-zero.
063:             *
064:             * @param formatName The name of the format.
065:             * @param output The <code>OutputStream</code> to write encoded data to.
066:             * @param param  The object containing the tile encoding parameters.
067:             *
068:             * @throws IllegalArgumentException if formatName is null.
069:             * @throws IllegalArgumentException if output is null.
070:             * @throws IllegalArgumentException if param's getFormatName() method does
071:             * not return the same formatName as the one specified to this method.
072:             * @throws IllegalArgumentException if the ParameterListDescriptors 
073:             * associated with the param and the associated TileCodecDescriptor are
074:             * not equal.
075:             * @throws IllegalArgumentException if param does not have "tileEncoder"
076:             * as one of the valid modes that it supports. 
077:             */
078:            public TileEncoderImpl(String formatName, OutputStream output,
079:                    TileCodecParameterList param) {
080:
081:                // Cause a IllegalArgumentException to be thrown if formatName, output
082:                // is null
083:                if (formatName == null) {
084:                    throw new IllegalArgumentException(JaiI18N
085:                            .getString("TileCodecDescriptorImpl0"));
086:                }
087:
088:                if (output == null) {
089:                    throw new IllegalArgumentException(JaiI18N
090:                            .getString("TileEncoderImpl0"));
091:                }
092:
093:                TileCodecDescriptor tcd = TileCodecUtils
094:                        .getTileCodecDescriptor("tileEncoder", formatName);
095:
096:                // If param is null, get the default parameter list.
097:                if (param == null)
098:                    param = tcd.getDefaultParameters("tileEncoder");
099:
100:                if (param != null) {
101:
102:                    // Check whether the formatName from the param is the same as the
103:                    // one supplied to this method.
104:                    if (param.getFormatName().equalsIgnoreCase(formatName) == false) {
105:                        throw new IllegalArgumentException(JaiI18N
106:                                .getString("TileEncoderImpl1"));
107:                    }
108:
109:                    // Check whether the supplied parameterList supports the 
110:                    // "tileDecoder" mode.
111:                    if (param.isValidForMode("tileEncoder") == false) {
112:                        throw new IllegalArgumentException(JaiI18N
113:                                .getString("TileEncoderImpl2"));
114:                    }
115:
116:                    // Check whether the ParameterListDescriptors are the same.
117:                    if (param.getParameterListDescriptor().equals(
118:                            tcd.getParameterListDescriptor("tileEncoder")) == false)
119:                        throw new IllegalArgumentException(JaiI18N
120:                                .getString("TileCodec0"));
121:
122:                } else {
123:
124:                    // If the supplied parameterList is null and the default one is 
125:                    // null too, then check whether this format supports no parameters
126:                    ParameterListDescriptor pld = tcd
127:                            .getParameterListDescriptor("tileEncoder");
128:
129:                    // If the PLD is not null and says that there are supposed to 
130:                    // be some parameters (numParameters returns non-zero value)
131:                    // throw an IllegalArgumentException
132:                    if (pld != null && pld.getNumParameters() != 0) {
133:                        throw new IllegalArgumentException(JaiI18N
134:                                .getString("TileDecoderImpl6"));
135:                    }
136:                }
137:
138:                this .formatName = formatName;
139:                this .outputStream = output;
140:                this .paramList = param;
141:            }
142:
143:            /**
144:             * Returns the format name of the encoding scheme.
145:             */
146:            public String getFormatName() {
147:                return formatName;
148:            }
149:
150:            /**
151:             * Returns the current parameters as an instance of the
152:             * <code>TileCodecParameterList</code> interface.
153:             */
154:            public TileCodecParameterList getEncodeParameterList() {
155:                return paramList;
156:            }
157:
158:            /** 
159:             * Returns the <code>OutputStream</code> to which the encoded data will
160:             * be written.
161:             */
162:            public OutputStream getOutputStream() {
163:                return outputStream;
164:            }
165:
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.