Source Code Cross Referenced for ImageEncoderFactory.java in  » Chart » jfreechart » org » jfree » chart » encoders » 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 » Chart » jfreechart » org.jfree.chart.encoders 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ===========================================================
002:         * JFreeChart : a free chart library for the Java(tm) platform
003:         * ===========================================================
004:         *
005:         * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
006:         *
007:         * Project Info:  http://www.jfree.org/jfreechart/index.html
008:         *
009:         * This library is free software; you can redistribute it and/or modify it 
010:         * under the terms of the GNU Lesser General Public License as published by 
011:         * the Free Software Foundation; either version 2.1 of the License, or 
012:         * (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful, but 
015:         * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
016:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
017:         * License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library; if not, write to the Free Software
021:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
022:         * USA.  
023:         *
024:         * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
025:         * in the United States and other countries.]
026:         *
027:         * ------------------------
028:         * ImageEncoderFactory.java
029:         * ------------------------
030:         * (C) Copyright 2004-2007, by Richard Atkinson and Contributors.
031:         *
032:         * Original Author:  Richard Atkinson;
033:         * Contributor(s):   David Gilbert (for Object Refinery Limited);
034:         *
035:         * $Id: ImageEncoderFactory.java,v 1.3.2.3 2007/02/02 14:51:22 mungady Exp $
036:         *
037:         * Changes
038:         * -------
039:         * 01-Aug-2004 : Initial version (RA);
040:         * 01-Nov-2005 : Now using ImageIO for JPEG encoding, so we no longer have a
041:         *               dependency on com.sun.* which isn't available on all 
042:         *               implementations (DG);
043:         * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG);
044:         *
045:         */
046:
047:        package org.jfree.chart.encoders;
048:
049:        import java.util.Hashtable;
050:
051:        /**
052:         * Factory class for returning {@link ImageEncoder}s for different 
053:         * {@link ImageFormat}s.
054:         */
055:        public class ImageEncoderFactory {
056:            private static Hashtable encoders = null;
057:
058:            static {
059:                init();
060:            }
061:
062:            /**
063:             * Sets up default encoders (uses Sun PNG Encoder if JDK 1.4+ and the
064:             * SunPNGEncoderAdapter class is available).
065:             */
066:            private static void init() {
067:                encoders = new Hashtable();
068:                encoders.put("jpeg",
069:                        "org.jfree.chart.encoders.SunJPEGEncoderAdapter");
070:                try {
071:                    //  Test for being run under JDK 1.4+
072:                    Class.forName("javax.imageio.ImageIO");
073:                    //  Test for JFreeChart being compiled under JDK 1.4+
074:                    Class
075:                            .forName("org.jfree.chart.encoders.SunPNGEncoderAdapter");
076:                    encoders.put("png",
077:                            "org.jfree.chart.encoders.SunPNGEncoderAdapter");
078:                    encoders.put("jpeg",
079:                            "org.jfree.chart.encoders.SunJPEGEncoderAdapter");
080:                } catch (ClassNotFoundException e) {
081:                    encoders
082:                            .put("png",
083:                                    "org.jfree.chart.encoders.KeypointPNGEncoderAdapter");
084:                }
085:            }
086:
087:            /**
088:             * Used to set additional encoders or replace default ones.
089:             *
090:             * @param format  The image format name.
091:             * @param imageEncoderClassName  The name of the ImageEncoder class.
092:             */
093:            public static void setImageEncoder(String format,
094:                    String imageEncoderClassName) {
095:                encoders.put(format, imageEncoderClassName);
096:            }
097:
098:            /**
099:             * Used to retrieve an ImageEncoder for a specific image format.
100:             *
101:             * @param format  The image format required.
102:             * 
103:             * @return The ImageEncoder or <code>null</code> if none available.
104:             */
105:            public static ImageEncoder newInstance(String format) {
106:                ImageEncoder imageEncoder = null;
107:                String className = (String) encoders.get(format);
108:                if (className == null) {
109:                    throw new IllegalArgumentException(
110:                            "Unsupported image format - " + format);
111:                }
112:                try {
113:                    Class imageEncoderClass = Class.forName(className);
114:                    imageEncoder = (ImageEncoder) imageEncoderClass
115:                            .newInstance();
116:                } catch (Exception e) {
117:                    throw new IllegalArgumentException(e.toString());
118:                }
119:                return imageEncoder;
120:            }
121:
122:            /**
123:             * Used to retrieve an ImageEncoder for a specific image format.
124:             *
125:             * @param format  The image format required.
126:             * @param quality  The quality to be set before returning.
127:             * 
128:             * @return The ImageEncoder or <code>null</code> if none available.
129:             */
130:            public static ImageEncoder newInstance(String format, float quality) {
131:                ImageEncoder imageEncoder = newInstance(format);
132:                imageEncoder.setQuality(quality);
133:                return imageEncoder;
134:            }
135:
136:            /**
137:             * Used to retrieve an ImageEncoder for a specific image format.
138:             *
139:             * @param format  The image format required.
140:             * @param encodingAlpha  Sets whether alpha transparency should be encoded.
141:             * 
142:             * @return The ImageEncoder or <code>null</code> if none available.
143:             */
144:            public static ImageEncoder newInstance(String format,
145:                    boolean encodingAlpha) {
146:                ImageEncoder imageEncoder = newInstance(format);
147:                imageEncoder.setEncodingAlpha(encodingAlpha);
148:                return imageEncoder;
149:            }
150:
151:            /**
152:             * Used to retrieve an ImageEncoder for a specific image format.
153:             *
154:             * @param format  The image format required.
155:             * @param quality  The quality to be set before returning.
156:             * @param encodingAlpha  Sets whether alpha transparency should be encoded.
157:             * 
158:             * @return The ImageEncoder or <code>null</code> if none available.
159:             */
160:            public static ImageEncoder newInstance(String format,
161:                    float quality, boolean encodingAlpha) {
162:                ImageEncoder imageEncoder = newInstance(format);
163:                imageEncoder.setQuality(quality);
164:                imageEncoder.setEncodingAlpha(encodingAlpha);
165:                return imageEncoder;
166:            }
167:
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.