Source Code Cross Referenced for KnuthPenalty.java in  » Graphic-Library » fop » org » apache » fop » layoutmgr » 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.layoutmgr 
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: KnuthPenalty.java 553790 2007-07-06 08:41:46Z vhennebert $ */
019:
020:        package org.apache.fop.layoutmgr;
021:
022:        import org.apache.fop.fo.Constants;
023:
024:        /**
025:         * An instance of this class represents information about a feasible
026:         * breaking point; it does not represent any piece of content.
027:         * 
028:         * A KnuthPenalty is a feasible breaking point unless its value is infinity;
029:         * a KnuthPenalty whose value is -infinity represents a forced break.
030:         * 
031:         * A KnuthPenalty is suppressed, and its width is ignored, if it is not a
032:         * chosen breaking point; for example, a KnuthPenalty representing a
033:         * hyphenation point has a width (the "-" width), which must be ignored if
034:         * that point is not chosen as a breaking point.
035:         * 
036:         * Besides the inherited methods and attributes, this class has two more
037:         * attributes and the methods used to get them: the penalty value, which is
038:         * a kind of "aesthetic cost" (the higher the value, the more unsightly the
039:         * breaking point), and a boolean that marks KnuthPenalties which should not
040:         * be chosen as breaking points for consecutive lines.
041:         */
042:        public class KnuthPenalty extends KnuthElement {
043:
044:            /** Used for flagged penalties. See Knuth algorithm. */
045:            public static final int FLAGGED_PENALTY = 50;
046:
047:            private int penalty;
048:            private boolean bFlagged;
049:            private int breakClass = -1;
050:
051:            /**
052:             * Create a new KnuthPenalty.
053:             *
054:             * @param w the width of this penalty
055:             * @param p the penalty value of this penalty
056:             * @param f is this penalty flagged?
057:             * @param pos the Position stored in this penalty
058:             * @param bAux is this penalty auxiliary?
059:             */
060:            public KnuthPenalty(int w, int p, boolean f, Position pos,
061:                    boolean bAux) {
062:                super (w, pos, bAux);
063:                penalty = p;
064:                bFlagged = f;
065:            }
066:
067:            /**
068:             * Create a new KnuthPenalty.
069:             *
070:             * @param w the width of this penalty
071:             * @param p the penalty value of this penalty
072:             * @param f is this penalty flagged?
073:             * @param iBreakClass the break class of this penalty (one of the break-* constants)
074:             * @param pos the Position stored in this penalty
075:             * @param bAux is this penalty auxiliary?
076:             */
077:            public KnuthPenalty(int w, int p, boolean f, int iBreakClass,
078:                    Position pos, boolean bAux) {
079:                super (w, pos, bAux);
080:                penalty = p;
081:                bFlagged = f;
082:                breakClass = iBreakClass;
083:            }
084:
085:            /** @see org.apache.fop.layoutmgr.KnuthElement#isPenalty() */
086:            public boolean isPenalty() {
087:                return true;
088:            }
089:
090:            /**
091:             * @return the penalty value of this penalty.
092:             */
093:            public int getP() {
094:                return penalty;
095:            }
096:
097:            /**
098:             * Sets a new penalty value.
099:             * @param p the new penalty value
100:             */
101:            public void setP(int p) {
102:                this .penalty = p;
103:            }
104:
105:            /** @return true is this penalty is a flagged one. */
106:            public boolean isFlagged() {
107:                return bFlagged;
108:            }
109:
110:            /** @see org.apache.fop.layoutmgr.KnuthElement#isForcedBreak() */
111:            public boolean isForcedBreak() {
112:                return penalty == -KnuthElement.INFINITE;
113:            }
114:
115:            /**
116:             * @return the break class of this penalty (EN_AUTO, EN_COLUMN, EN_PAGE, EN_EVEN_PAGE,
117:             * EN_ODD_PAGE)
118:             */
119:            public int getBreakClass() {
120:                return breakClass;
121:            }
122:
123:            /**
124:             * Sets the break class for this penalty.
125:             * @param cl the break class (EN_AUTO, EN_COLUMN, EN_PAGE, EN_EVEN_PAGE, EN_ODD_PAGE)
126:             */
127:            public void setBreakClass(int cl) {
128:                this .breakClass = cl;
129:            }
130:
131:            /** @see java.lang.Object#toString() */
132:            public String toString() {
133:                StringBuffer sb = new StringBuffer(64);
134:                if (isAuxiliary()) {
135:                    sb.append("aux. ");
136:                }
137:                sb.append("penalty");
138:                sb.append(" p=");
139:                if (getP() < 0) {
140:                    sb.append("-");
141:                }
142:                if (Math.abs(getP()) == INFINITE) {
143:                    sb.append("INFINITE");
144:                } else {
145:                    sb.append(getP());
146:                }
147:                if (isFlagged()) {
148:                    sb.append(" [flagged]");
149:                }
150:                sb.append(" w=");
151:                sb.append(getW());
152:                if (isForcedBreak()) {
153:                    sb.append(" (forced break");
154:                    switch (getBreakClass()) {
155:                    case Constants.EN_PAGE:
156:                        sb.append(", page");
157:                        break;
158:                    case Constants.EN_COLUMN:
159:                        sb.append(", column");
160:                        break;
161:                    case Constants.EN_EVEN_PAGE:
162:                        sb.append(", even page");
163:                        break;
164:                    case Constants.EN_ODD_PAGE:
165:                        sb.append(", odd page");
166:                        break;
167:                    default:
168:                    }
169:                    sb.append(")");
170:                }
171:                return sb.toString();
172:            }
173:
174:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.