Source Code Cross Referenced for SpaceVal.java in  » Graphic-Library » fop » org » apache » fop » traits » 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.traits 
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: SpaceVal.java 426576 2006-07-28 15:44:37Z jeremias $ */
019:
020:        package org.apache.fop.traits;
021:
022:        import org.apache.fop.datatypes.PercentBaseContext;
023:        import org.apache.fop.fo.Constants;
024:        import org.apache.fop.fo.properties.Property;
025:        import org.apache.fop.fo.properties.SpaceProperty;
026:        import org.apache.fop.fonts.Font;
027:
028:        /**
029:         * Store a single Space property value in simplified form, with all
030:         * Length values resolved. See section 4.3 in the specs.
031:         */
032:        public class SpaceVal {
033:
034:            private final MinOptMax space;
035:            private final boolean bConditional;
036:            private final boolean bForcing;
037:            private final int iPrecedence; //  Numeric only, if forcing, set to 0
038:
039:            /**
040:             * Constructor for SpaceVal objects based on Space objects.
041:             * @param spaceprop Space object to use
042:             * @param context Percentage evaluation context
043:             */
044:            public SpaceVal(SpaceProperty spaceprop, PercentBaseContext context) {
045:                space = new MinOptMax(spaceprop.getMinimum(context).getLength()
046:                        .getValue(context), spaceprop.getOptimum(context)
047:                        .getLength().getValue(context), spaceprop.getMaximum(
048:                        context).getLength().getValue(context));
049:                bConditional = (spaceprop.getConditionality().getEnum() == Constants.EN_DISCARD);
050:                Property precProp = spaceprop.getPrecedence();
051:                if (precProp.getNumber() != null) {
052:                    iPrecedence = precProp.getNumber().intValue();
053:                    bForcing = false;
054:                } else {
055:                    bForcing = (precProp.getEnum() == Constants.EN_FORCE);
056:                    iPrecedence = 0;
057:                }
058:            }
059:
060:            /**
061:             * Constructor for SpaceVal objects based on the full set of properties.
062:             * @param space space to use
063:             * @param bConditional Conditionality value
064:             * @param bForcing Forcing value
065:             * @param iPrecedence Precedence value
066:             */
067:            public SpaceVal(MinOptMax space, boolean bConditional,
068:                    boolean bForcing, int iPrecedence) {
069:                this .space = space;
070:                this .bConditional = bConditional;
071:                this .bForcing = bForcing;
072:                this .iPrecedence = iPrecedence;
073:            }
074:
075:            static public SpaceVal makeWordSpacing(Property wordSpacing,
076:                    SpaceVal letterSpacing, Font fs) {
077:                if (wordSpacing.getEnum() == Constants.EN_NORMAL) {
078:                    // give word spaces the possibility to shrink by a third,
079:                    // and stretch by a half;
080:                    int spaceCharIPD = fs.getCharWidth(' ');
081:                    MinOptMax space = new MinOptMax(-spaceCharIPD / 3, 0,
082:                            spaceCharIPD / 2);
083:                    //TODO Adding 2 letter spaces here is not 100% correct. Spaces don't have letter spacing
084:                    return new SpaceVal(MinOptMax.add(space, MinOptMax
085:                            .multiply(letterSpacing.getSpace(), 2)), true,
086:                            true, 0);
087:                } else {
088:                    return new SpaceVal(wordSpacing.getSpace(), null);
089:                }
090:            }
091:
092:            static public SpaceVal makeLetterSpacing(Property letterSpacing) {
093:                if (letterSpacing.getEnum() == Constants.EN_NORMAL) {
094:                    // letter spaces are set to zero (or use different values?)
095:                    return new SpaceVal(new MinOptMax(0), true, true, 0);
096:                } else {
097:                    return new SpaceVal(letterSpacing.getSpace(), null);
098:                }
099:            }
100:
101:            /**
102:             * Returns the Conditionality value.
103:             * @return the Conditionality value
104:             */
105:            public boolean isConditional() {
106:                return bConditional;
107:            }
108:
109:            /**
110:             * Returns the Forcing value.
111:             * @return the Forcing value
112:             */
113:            public boolean isForcing() {
114:                return bForcing;
115:            }
116:
117:            /**
118:             * Returns the Precedence value.
119:             * @return the Precedence value
120:             */
121:            public int getPrecedence() {
122:                return iPrecedence;
123:            }
124:
125:            /**
126:             * Returns the Space value.
127:             * @return the Space value
128:             */
129:            public MinOptMax getSpace() {
130:                return space;
131:            }
132:
133:            public String toString() {
134:                return "SpaceVal: " + getSpace().toString();
135:            }
136:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.