Source Code Cross Referenced for CommonTextDecoration.java in  » Graphic-Library » fop » org » apache » fop » fo » properties » 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.fo.properties 
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: CommonTextDecoration.java 474225 2006-11-13 10:08:19Z jeremias $ */
019:
020:        package org.apache.fop.fo.properties;
021:
022:        import java.util.Iterator;
023:        import java.util.List;
024:
025:        import java.awt.Color;
026:
027:        import org.apache.fop.apps.FOUserAgent;
028:        import org.apache.fop.fo.Constants;
029:        import org.apache.fop.fo.PropertyList;
030:        import org.apache.fop.fo.expr.PropertyException;
031:
032:        /**
033:         * Stores all information concerning text-decoration.
034:         */
035:        public class CommonTextDecoration {
036:
037:            //using a bit-mask here
038:            private static final int UNDERLINE = 1;
039:            private static final int OVERLINE = 2;
040:            private static final int LINE_THROUGH = 4;
041:            private static final int BLINK = 8;
042:
043:            private int decoration;
044:            private Color underColor;
045:            private Color overColor;
046:            private Color throughColor;
047:
048:            /**
049:             * Creates a new CommonTextDecoration object with default values.
050:             */
051:            public CommonTextDecoration() {
052:            }
053:
054:            /**
055:             * Creates a CommonTextDecoration object from a property list.
056:             * @param pList the property list to build the object for
057:             * @return a CommonTextDecoration object or null if the obj would only have default values
058:             * @throws PropertyException if there's a problem while processing the property
059:             */
060:            public static CommonTextDecoration createFromPropertyList(
061:                    PropertyList pList) throws PropertyException {
062:                return calcTextDecoration(pList);
063:            }
064:
065:            private static CommonTextDecoration calcTextDecoration(
066:                    PropertyList pList) throws PropertyException {
067:                CommonTextDecoration deco = null;
068:                PropertyList parentList = pList.getParentPropertyList();
069:                if (parentList != null) {
070:                    //Parent is checked first
071:                    deco = calcTextDecoration(parentList);
072:                }
073:                //For rules, see XSL 1.0, chapters 5.5.6 and 7.16.4
074:                Property textDecoProp = pList
075:                        .getExplicit(Constants.PR_TEXT_DECORATION);
076:                if (textDecoProp != null) {
077:                    List list = textDecoProp.getList();
078:                    Iterator i = list.iterator();
079:                    while (i.hasNext()) {
080:                        Property prop = (Property) i.next();
081:                        int propEnum = prop.getEnum();
082:                        FOUserAgent ua = (pList == null) ? null : (pList
083:                                .getFObj() == null ? null : pList.getFObj()
084:                                .getUserAgent());
085:                        if (propEnum == Constants.EN_NONE) {
086:                            if (deco != null) {
087:                                deco.decoration = 0;
088:                            }
089:                            return deco;
090:                        } else if (propEnum == Constants.EN_UNDERLINE) {
091:                            if (deco == null) {
092:                                deco = new CommonTextDecoration();
093:                            }
094:                            deco.decoration |= UNDERLINE;
095:                            deco.underColor = pList.get(Constants.PR_COLOR)
096:                                    .getColor(ua);
097:                        } else if (propEnum == Constants.EN_NO_UNDERLINE) {
098:                            if (deco != null) {
099:                                deco.decoration &= OVERLINE | LINE_THROUGH
100:                                        | BLINK;
101:                                deco.underColor = pList.get(Constants.PR_COLOR)
102:                                        .getColor(ua);
103:                            }
104:                        } else if (propEnum == Constants.EN_OVERLINE) {
105:                            if (deco == null) {
106:                                deco = new CommonTextDecoration();
107:                            }
108:                            deco.decoration |= OVERLINE;
109:                            deco.overColor = pList.get(Constants.PR_COLOR)
110:                                    .getColor(ua);
111:                        } else if (propEnum == Constants.EN_NO_OVERLINE) {
112:                            if (deco != null) {
113:                                deco.decoration &= UNDERLINE | LINE_THROUGH
114:                                        | BLINK;
115:                                deco.overColor = pList.get(Constants.PR_COLOR)
116:                                        .getColor(ua);
117:                            }
118:                        } else if (propEnum == Constants.EN_LINE_THROUGH) {
119:                            if (deco == null) {
120:                                deco = new CommonTextDecoration();
121:                            }
122:                            deco.decoration |= LINE_THROUGH;
123:                            deco.throughColor = pList.get(Constants.PR_COLOR)
124:                                    .getColor(ua);
125:                        } else if (propEnum == Constants.EN_NO_LINE_THROUGH) {
126:                            if (deco != null) {
127:                                deco.decoration &= UNDERLINE | OVERLINE | BLINK;
128:                                deco.throughColor = pList.get(
129:                                        Constants.PR_COLOR).getColor(ua);
130:                            }
131:                        } else if (propEnum == Constants.EN_BLINK) {
132:                            if (deco == null) {
133:                                deco = new CommonTextDecoration();
134:                            }
135:                            deco.decoration |= BLINK;
136:                        } else if (propEnum == Constants.EN_NO_BLINK) {
137:                            if (deco != null) {
138:                                deco.decoration &= UNDERLINE | OVERLINE
139:                                        | LINE_THROUGH;
140:                            }
141:                        } else {
142:                            throw new PropertyException(
143:                                    "Illegal value encountered: "
144:                                            + prop.getString());
145:                        }
146:                    }
147:                }
148:                return deco;
149:            }
150:
151:            /** @return true if underline is active */
152:            public boolean hasUnderline() {
153:                return (this .decoration & UNDERLINE) != 0;
154:            }
155:
156:            /** @return true if overline is active */
157:            public boolean hasOverline() {
158:                return (this .decoration & OVERLINE) != 0;
159:            }
160:
161:            /** @return true if line-through is active */
162:            public boolean hasLineThrough() {
163:                return (this .decoration & LINE_THROUGH) != 0;
164:            }
165:
166:            /** @return true if blink is active */
167:            public boolean isBlinking() {
168:                return (this .decoration & BLINK) != 0;
169:            }
170:
171:            /** @return the color of the underline mark */
172:            public Color getUnderlineColor() {
173:                return this .underColor;
174:            }
175:
176:            /** @return the color of the overline mark */
177:            public Color getOverlineColor() {
178:                return this .overColor;
179:            }
180:
181:            /** @return the color of the line-through mark */
182:            public Color getLineThroughColor() {
183:                return this.throughColor;
184:            }
185:
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.