Source Code Cross Referenced for PDColorSpace.java in  » PDF » jPod » de » intarsys » pdf » pd » 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 » PDF » jPod » de.intarsys.pdf.pd 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2007, intarsys consulting GmbH
003:         *
004:         * Redistribution and use in source and binary forms, with or without
005:         * modification, are permitted provided that the following conditions are met:
006:         *
007:         * - Redistributions of source code must retain the above copyright notice,
008:         *   this list of conditions and the following disclaimer.
009:         *
010:         * - Redistributions in binary form must reproduce the above copyright notice,
011:         *   this list of conditions and the following disclaimer in the documentation
012:         *   and/or other materials provided with the distribution.
013:         *
014:         * - Neither the name of intarsys nor the names of its contributors may be used
015:         *   to endorse or promote products derived from this software without specific
016:         *   prior written permission.
017:         *
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
021:         * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
022:         * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
023:         * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
024:         * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
025:         * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
026:         * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
027:         * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
028:         * POSSIBILITY OF SUCH DAMAGE.
029:         */
030:        package de.intarsys.pdf.pd;
031:
032:        import de.intarsys.pdf.cos.COSArray;
033:        import de.intarsys.pdf.cos.COSBasedObject;
034:        import de.intarsys.pdf.cos.COSName;
035:        import de.intarsys.pdf.cos.COSObject;
036:
037:        /**
038:         * An abstract superclass for all color spaces.
039:         * 
040:         */
041:        public abstract class PDColorSpace extends PDObject {
042:            /**
043:             * The meta class implementation
044:             */
045:            public static class MetaClass extends PDObject.MetaClass {
046:                protected MetaClass(Class paramInstanceClass) {
047:                    super (paramInstanceClass);
048:                }
049:
050:                public Class getRootClass() {
051:                    return PDColorSpace.class;
052:                }
053:
054:                /*
055:                 * (non-Javadoc)
056:                 * 
057:                 * @see de.intarsys.pdf.cos.COSBasedObject.MetaClass#doCreateCOSBasedObject(de.intarsys.pdf.cos.COSObject)
058:                 */
059:                protected COSBasedObject doCreateCOSBasedObject(COSObject object) {
060:                    COSArray array;
061:                    COSName type;
062:
063:                    if (object instanceof  COSName) {
064:                        return getNamed((COSName) object);
065:                    }
066:
067:                    if (object instanceof  COSArray) {
068:                        array = (COSArray) object;
069:                        type = array.get(0).asName();
070:                        if (type == null) {
071:                            throw new IllegalArgumentException(
072:                                    "ColorSpace array has no type");
073:                        }
074:                        if (type.equals(CN_CS_DeviceCMYK)
075:                                || type.equals(CN_CS_CMYK)) {
076:                            return PDCSDeviceCMYK.SINGLETON;
077:                        }
078:                        if (type.equals(CN_CS_DeviceRGB)
079:                                || type.equals(CN_CS_RGB)) {
080:                            return PDCSDeviceRGB.SINGLETON;
081:                        }
082:                        if (type.equals(CN_CS_DeviceGray)
083:                                || type.equals(CN_CS_G)) {
084:                            return PDCSDeviceGray.SINGLETON;
085:                        }
086:                    }
087:                    return super .doCreateCOSBasedObject(object);
088:                }
089:
090:                protected COSBasedObject.MetaClass doDetermineClass(
091:                        COSObject object) {
092:                    if (object instanceof  COSArray) {
093:                        COSName type = ((COSArray) object).get(0).asName();
094:                        if (type == null) {
095:                            throw new IllegalArgumentException(
096:                                    "ColorSpace array has no type");
097:                        }
098:                        if (type.equals(CN_CS_CalGray)) {
099:                            return PDCSCalGray.META;
100:                        }
101:                        if (type.equals(CN_CS_CalRGB)) {
102:                            return PDCSCalRGB.META;
103:                        }
104:                        if (type.equals(CN_CS_Lab)) {
105:                            return PDCSLab.META;
106:                        }
107:                        if (type.equals(CN_CS_ICCBased)) {
108:                            return PDCSICCBased.META;
109:                        }
110:                        if (type.equals(CN_CS_Indexed) || type.equals(CN_CS_I)) {
111:                            return PDCSIndexed.META;
112:                        }
113:                        if (type.equals(CN_CS_Pattern)) {
114:                            return PDCSPattern.META;
115:                        }
116:                        if (type.equals(CN_CS_Separation)) {
117:                            return PDCSSeparation.META;
118:                        }
119:                        if (type.equals(CN_CS_DeviceN)) {
120:                            return PDCSDeviceN.META;
121:                        }
122:                    }
123:                    return super .doDetermineClass(object);
124:                }
125:            }
126:
127:            public static final COSName CN_CS_CalGray = COSName
128:                    .constant("CalGray");
129:
130:            public static final COSName CN_CS_CalRGB = COSName
131:                    .constant("CalRGB");
132:
133:            public static final COSName CN_CS_CMYK = COSName.constant("CMYK");
134:
135:            public static final COSName CN_CS_DeviceCMYK = COSName
136:                    .constant("DeviceCMYK");
137:
138:            public static final COSName CN_CS_DeviceGray = COSName
139:                    .constant("DeviceGray");
140:
141:            public static final COSName CN_CS_DeviceN = COSName
142:                    .constant("DeviceN");
143:
144:            public static final COSName CN_CS_DeviceRGB = COSName
145:                    .constant("DeviceRGB");
146:
147:            public static final COSName CN_CS_G = COSName.constant("G");
148:
149:            public static final COSName CN_CS_ICCBased = COSName
150:                    .constant("ICCBased");
151:
152:            public static final COSName CN_CS_Indexed = COSName
153:                    .constant("Indexed");
154:
155:            public static final COSName CN_CS_I = COSName.constant("I");
156:
157:            public static final COSName CN_CS_Lab = COSName.constant("Lab");
158:
159:            public static final COSName CN_CS_Pattern = COSName
160:                    .constant("Pattern");
161:
162:            public static final COSName CN_CS_RGB = COSName.constant("RGB");
163:
164:            public static final COSName CN_CS_Separation = COSName
165:                    .constant("Separation");
166:
167:            /** The meta class instance */
168:            public static final MetaClass META = new MetaClass(MetaClass.class
169:                    .getDeclaringClass());
170:
171:            public static PDColorSpace getNamed(COSName name) {
172:                if (name.equals(CN_CS_Pattern)) {
173:                    return new PDCSPattern(name);
174:                }
175:                return getSingleton(name);
176:            }
177:
178:            /**
179:             * return the singleton color space instance corresponding to the given name
180:             * 
181:             * @param name
182:             *            must be one of the predefined color space names
183:             * 
184:             * @return return the singleton color space instance corresponding to the
185:             *         given name
186:             */
187:            public static PDColorSpace getSingleton(COSName name) {
188:                if (CN_CS_DeviceGray.equals(name)) {
189:                    return PDCSDeviceGray.SINGLETON;
190:                } else if (CN_CS_G.equals(name)) {
191:                    return PDCSDeviceGray.SINGLETON;
192:                } else if (CN_CS_DeviceRGB.equals(name)) {
193:                    return PDCSDeviceRGB.SINGLETON;
194:                } else if (CN_CS_RGB.equals(name)) {
195:                    return PDCSDeviceRGB.SINGLETON;
196:                } else if (CN_CS_DeviceCMYK.equals(name)) {
197:                    return PDCSDeviceCMYK.SINGLETON;
198:                } else if (CN_CS_CMYK.equals(name)) {
199:                    return PDCSDeviceCMYK.SINGLETON;
200:                } else {
201:                    return null;
202:                }
203:            }
204:
205:            /**
206:             * This attribute is stored here to ease invalidating, should be in
207:             * PlatformColorSpace
208:             */
209:            private Object cachedColorSpace;
210:
211:            protected PDColorSpace(COSObject object) {
212:                super (object);
213:            }
214:
215:            public Object getCachedColorSpace() {
216:                // todo 1 review, maybe move to platform.
217:                return cachedColorSpace;
218:            }
219:
220:            public void invalidateCaches() {
221:                super .invalidateCaches();
222:                cachedColorSpace = null;
223:            }
224:
225:            public void setCachedColorSpace(Object paramColorSpace) {
226:                cachedColorSpace = paramColorSpace;
227:            }
228:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.