Source Code Cross Referenced for ColorExt.java in  » Graphic-Library » fop » org » apache » fop » util » 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 » Graphic Library » fop » org.apache.fop.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        /* $Id$ */
019:
020:        package org.apache.fop.util;
021:
022:        import java.awt.Color;
023:        import java.awt.color.ColorSpace;
024:
025:        /**
026:         * Color helper class.
027:         * <p>
028:         * This class extends java.awt.Color class keeping track of the original color
029:         * property values specified by the fo user in a rgb-icc call.
030:         */
031:        public final class ColorExt extends Color {
032:            //
033:            private static final long serialVersionUID = 1L;
034:
035:            // Values of fop-rgb-icc arguments
036:            private float rgbReplacementRed;
037:            private float rgbReplacementGreen;
038:            private float rgbReplacementBlue;
039:
040:            private String iccProfileName;
041:            private String iccProfileSrc;
042:            private ColorSpace colorSpace;
043:
044:            private float[] colorValues;
045:
046:            /*
047:             * Helper for createFromFoRgbIcc
048:             */
049:            private ColorExt(ColorSpace colorSpace, float[] colorValues,
050:                    float opacity) {
051:                super (colorSpace, colorValues, opacity);
052:            }
053:
054:            /*
055:             * Helper for createFromSvgIccColor
056:             */
057:            private ColorExt(float red, float green, float blue, float opacity) {
058:                super (red, green, blue, opacity);
059:            }
060:
061:            /**
062:             * Create ColorExt object backup up FO's rgb-icc color function
063:             * 
064:             * @param redReplacement
065:             *            Red part of RGB replacement color that will be used when ICC
066:             *            profile can not be loaded
067:             * @param greenReplacement
068:             *            Green part of RGB replacement color that will be used when ICC
069:             *            profile can not be loaded
070:             * @param blueReplacement
071:             *            Blue part of RGB replacement color that will be used when ICC
072:             *            profile can not be loaded
073:             * @param profileName
074:             *            Name of ICC profile
075:             * @param profileSrc
076:             *            Source of ICC profile
077:             * @param colorSpace
078:             *            ICC ColorSpace for the ICC profile
079:             * @param iccValues
080:             *            color values
081:             * @return the requested color object
082:             */
083:            public static ColorExt createFromFoRgbIcc(float redReplacement,
084:                    float greenReplacement, float blueReplacement,
085:                    String profileName, String profileSrc,
086:                    ColorSpace colorSpace, float[] iccValues) {
087:                ColorExt ce = new ColorExt(colorSpace, iccValues, 1.0f);
088:                ce.rgbReplacementRed = redReplacement;
089:                ce.rgbReplacementGreen = greenReplacement;
090:                ce.rgbReplacementBlue = blueReplacement;
091:                ce.iccProfileName = profileName;
092:                ce.iccProfileSrc = profileSrc;
093:                ce.colorSpace = colorSpace;
094:                ce.colorValues = iccValues;
095:                return ce;
096:            }
097:
098:            /**
099:             * Create ColorExt object backing up SVG's icc-color function.
100:             * 
101:             * @param red
102:             *            Red value resulting from the conversion from the user provided
103:             *            (icc) color values to the batik (rgb) color space
104:             * @param green
105:             *            Green value resulting from the conversion from the user
106:             *            provided (icc) color values to the batik (rgb) color space
107:             * @param blue
108:             *            Blue value resulting from the conversion from the user
109:             *            provided (icc) color values to the batik (rgb) color space
110:             * @param opacity
111:             *            Opacity
112:             * @param profileName
113:             *            ICC profile name
114:             * @param profileHref
115:             *            the URI to the color profile
116:             * @param profileCS
117:             *            ICC ColorSpace profile
118:             * @param colorValues
119:             *            ICC color values
120:             * @return the requested color object
121:             */
122:            public static ColorExt createFromSvgIccColor(float red,
123:                    float green, float blue, float opacity, String profileName,
124:                    String profileHref, ColorSpace profileCS,
125:                    float[] colorValues) {
126:                ColorExt ce = new ColorExt(red, green, blue, opacity);
127:                ce.rgbReplacementRed = -1;
128:                ce.rgbReplacementGreen = -1;
129:                ce.rgbReplacementBlue = -1;
130:                ce.iccProfileName = profileName;
131:                ce.iccProfileSrc = profileHref;
132:                ce.colorSpace = profileCS;
133:                ce.colorValues = colorValues;
134:                return ce;
135:
136:            }
137:
138:            /**
139:             * Get ICC profile name
140:             * 
141:             * @return ICC profile name
142:             */
143:            public String getIccProfileName() {
144:                return this .iccProfileName;
145:            }
146:
147:            /**
148:             * Get ICC profile source
149:             * 
150:             * @return ICC profile source
151:             */
152:            public String getIccProfileSrc() {
153:                return this .iccProfileSrc;
154:            }
155:
156:            /**
157:             * @return the original ColorSpace
158:             */
159:            public ColorSpace getOrigColorSpace() {
160:                return this .colorSpace;
161:            }
162:
163:            /**
164:             * @return the original color values
165:             */
166:            public float[] getOriginalColorComponents() {
167:                return this .colorValues;
168:            }
169:
170:            /**
171:             * Create string representation of fop-rgb-icc function call to map this
172:             * ColorExt settings
173:             * @return the string representing the internal fop-rgb-icc() function call
174:             */
175:            public String toFunctionCall() {
176:                StringBuffer sb = new StringBuffer(40);
177:                sb.append("fop-rgb-icc(");
178:                sb.append(this .rgbReplacementRed + ",");
179:                sb.append(this .rgbReplacementGreen + ",");
180:                sb.append(this .rgbReplacementBlue + ",");
181:                sb.append(this .iccProfileName + ",");
182:                sb.append("\"" + this .iccProfileSrc + "\"");
183:                float[] colorComponents = this .getColorComponents(null);
184:                for (int ix = 0; ix < colorComponents.length; ix++) {
185:                    sb.append(",");
186:                    sb.append(colorComponents[ix]);
187:                }
188:                sb.append(")");
189:                return sb.toString();
190:            }
191:
192:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.