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


001:        /*
002:         * $RCSfile: JPEGTileDecoderFactory.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:56:57 $
010:         * $State: Exp $
011:         */package com.sun.media.jai.tilecodec;
012:
013:        import java.io.InputStream;
014:        import java.util.Vector;
015:        import javax.media.jai.JAI;
016:        import javax.media.jai.ParameterListDescriptor;
017:        import javax.media.jai.ParameterListDescriptorImpl;
018:        import javax.media.jai.remote.NegotiableCapability;
019:        import javax.media.jai.remote.NegotiableNumericRange;
020:        import javax.media.jai.remote.NegotiableCollection;
021:        import javax.media.jai.tilecodec.TileCodecParameterList;
022:        import javax.media.jai.tilecodec.TileDecoder;
023:        import javax.media.jai.tilecodec.TileDecoderFactory;
024:
025:        /**
026:         * A factory for creating <code>JPEGTileDecoder</code>s.
027:         *
028:         * <p> This class stipulates that the capabilities of the 
029:         * <code>TileDecoder</code> be specified by implementing the
030:         * <code>getDecodingCapability()</code> method. 
031:         *
032:         * @see javax.media.jai.remote.NegotiableCapability
033:         */
034:        public class JPEGTileDecoderFactory implements  TileDecoderFactory {
035:
036:            /** 
037:             * Creates a <code>JPEGTileDecoder</code> capable of decoding the encoded 
038:             * data from the given <code>InputStream</code> using the specified
039:             * <code>TileCodecParameterList</code> containing the decoding
040:             * parameters to be used.
041:             *
042:             * <p> This method can return null if the <code>TileDecoder</code> is not
043:             * capable of producing output for the given set of parameters.  
044:             * For example, if a <code>TileDecoder</code> is only capable of dealing
045:             * with a jpeg quality factor of 0.5, and the associated
046:             * <code>TileCodecParameterList</code> specifies a quality factor of 0.75,
047:             * null should be returned.
048:             *
049:             * <p>It is recommended that the data in the supplied 
050:             * <code>InputStream</code> not be used as a factor in determining
051:             * whether this <code>InputStream</code> can be successfully decoded,
052:             * unless the supplied <code>InputStream</code> is known to be rewindable
053:             * (i.e. its <code>markSupported()</code> method returns true or it has
054:             * additional functionality that allows backward seeking). It is required
055:             * that <code>the</code> InputStream contain the same data on 
056:             * returning from this method as before this method was called.
057:             * In other words, the <code>InputStream</code> should only be used as a
058:             * discriminator if it can be rewound to its starting position
059:             * before returning from this method. Note that wrapping the
060:             * incoming <code>InputStream</code> in a <code>PushbackInputStream</code>
061:             * and then rewinding the <code>PushbackInputStream</code> before returning
062:             * does not rewind the wrapped <code>InputStream</code>.
063:             *
064:             * <p> If the supplied <code>TileCodecParameterList</code> is null,
065:             * a default <code>TileCodecParameterList</code> from the
066:             * <code>TileCodecDescriptor</code> will be used to create the decoder.
067:             *
068:             * <p> Exceptions thrown by the <code>TileDecoder</code> will be
069:             * caught by this method and will not be propagated.
070:             *
071:             * @param input The <code>InputStream</code> containing the encoded data
072:             *              to decode.
073:             * @param param The parameters to be be used in the decoding process.
074:             * @throws IllegalArgumentException if input is null.
075:             */
076:            public TileDecoder createDecoder(InputStream input,
077:                    TileCodecParameterList param) {
078:
079:                if (input == null)
080:                    throw new IllegalArgumentException(JaiI18N
081:                            .getString("TileDecoder0"));
082:
083:                return new JPEGTileDecoder(input, param);
084:            }
085:
086:            /** 
087:             * Returns the capabilities of this <code>TileDecoder</code> as a
088:             * <code>NegotiableCapability</code>.
089:             */
090:            public NegotiableCapability getDecodeCapability() {
091:
092:                Vector generators = new Vector();
093:                generators.add(JPEGTileDecoderFactory.class);
094:
095:                ParameterListDescriptor jpegPld = JAI.getDefaultInstance()
096:                        .getOperationRegistry().getDescriptor("tileDecoder",
097:                                "jpeg").getParameterListDescriptor(
098:                                "tileDecoder");
099:
100:                Class paramClasses[] = {
101:                        NegotiableNumericRange.class,
102:                        NegotiableCollection.class,
103:                        // XXX Find a way to create a negotiable representing integer
104:                        // arrays
105:                        // integer array,  horizontal subsampling
106:                        // integer array,  vertical subsampling
107:                        // integer array,  quantization table mapping
108:                        // integer array,  quantizationTable0
109:                        // integer array,  quantizationTable1
110:                        // integer array,  quantizationTable2
111:                        // integer array,  quantizationTable3
112:                        NegotiableNumericRange.class,
113:                        NegotiableCollection.class, NegotiableCollection.class,
114:                        NegotiableCollection.class };
115:
116:                String paramNames[] = { "quality", "qualitySet",
117:                        "restartInterval", "writeImageInfo", "writeTableInfo",
118:                        "writeJFIFHeader" };
119:
120:                // A collection containing the valid values for a boolean valued
121:                // parameters
122:                Vector v = new Vector();
123:                v.add(new Boolean(true));
124:                v.add(new Boolean(false));
125:                NegotiableCollection negCollection = new NegotiableCollection(v);
126:
127:                NegotiableNumericRange nnr1 = new NegotiableNumericRange(
128:                        jpegPld.getParamValueRange(paramNames[0]));
129:
130:                NegotiableNumericRange nnr2 = new NegotiableNumericRange(
131:                        jpegPld.getParamValueRange(paramNames[2]));
132:
133:                // The default values
134:                Object defaults[] = { nnr1, negCollection, nnr2, negCollection,
135:                        negCollection, negCollection };
136:
137:                NegotiableCapability decodeCap = new NegotiableCapability(
138:                        "tileCodec", "jpeg", generators,
139:                        new ParameterListDescriptorImpl(null, //descriptor
140:                                paramNames, paramClasses, defaults, null), // validValues
141:                        false); // non-preference
142:
143:                // Set the Negotiables representing the valid values on the capability
144:                decodeCap.setParameter(paramNames[0], nnr1);
145:                decodeCap.setParameter(paramNames[1], negCollection);
146:                decodeCap.setParameter(paramNames[2], nnr2);
147:                decodeCap.setParameter(paramNames[3], negCollection);
148:                decodeCap.setParameter(paramNames[4], negCollection);
149:                decodeCap.setParameter(paramNames[5], negCollection);
150:
151:                return decodeCap;
152:            }
153:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.