Source Code Cross Referenced for AbstractBaseLayoutManager.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: AbstractBaseLayoutManager.java 513970 2007-03-02 21:39:02Z adelmelle $ */
019:
020:        package org.apache.fop.layoutmgr;
021:
022:        import org.apache.commons.logging.Log;
023:        import org.apache.commons.logging.LogFactory;
024:        import org.apache.fop.datatypes.LengthBase;
025:        import org.apache.fop.datatypes.PercentBaseContext;
026:        import org.apache.fop.fo.FObj;
027:
028:        /**
029:         * The base class for nearly all LayoutManagers.
030:         * Provides the functionality for merging the {@link LayoutManager}
031:         * and the {@link org.apache.fop.datatypes.PercentBaseContext} interfaces
032:         * into a common base calls for all higher LayoutManagers.
033:         */
034:        public abstract class AbstractBaseLayoutManager implements 
035:                LayoutManager, PercentBaseContext {
036:
037:            /** Indicator if this LM generates reference areas */
038:            protected boolean generatesReferenceArea = false;
039:            /** Indicator if this LM generates block areas */
040:            protected boolean generatesBlockArea = false;
041:            /** The formatting object for this LM */
042:            protected FObj fobj = null;
043:
044:            /**
045:             * logging instance
046:             */
047:            private static Log log = LogFactory
048:                    .getLog(AbstractBaseLayoutManager.class);
049:
050:            /**
051:             * Abstract base layout manager.
052:             */
053:            public AbstractBaseLayoutManager() {
054:            }
055:
056:            /**
057:             * Abstract base layout manager.
058:             *
059:             * @param fo the formatting object for this layout manager
060:             */
061:            public AbstractBaseLayoutManager(FObj fo) {
062:                fobj = fo;
063:                setGeneratesReferenceArea(fo.generatesReferenceAreas());
064:                if (getGeneratesReferenceArea()) {
065:                    setGeneratesBlockArea(true);
066:                }
067:            }
068:
069:            // --------- Property Resolution related functions --------- //
070:
071:            /**
072:             * @see org.apache.fop.datatypes.PercentBaseContext#getBaseLength(int, FObj)
073:             */
074:            public int getBaseLength(int lengthBase, FObj fobj) {
075:                if (fobj == this .fobj) {
076:                    switch (lengthBase) {
077:                    case LengthBase.CONTAINING_BLOCK_WIDTH:
078:                        return getAncestorBlockAreaIPD();
079:                    case LengthBase.CONTAINING_BLOCK_HEIGHT:
080:                        return getAncestorBlockAreaBPD();
081:                    case LengthBase.PARENT_AREA_WIDTH:
082:                        return getParentAreaIPD();
083:                    case LengthBase.CONTAINING_REFAREA_WIDTH:
084:                        return getReferenceAreaIPD();
085:                    default:
086:                        log.error(new Exception(
087:                                "Unknown base type for LengthBase:"
088:                                        + lengthBase));
089:                        return 0;
090:                    }
091:                } else {
092:                    LayoutManager lm = getParent();
093:                    while (lm != null && fobj != lm.getFObj()) {
094:                        lm = lm.getParent();
095:                    }
096:                    if (lm != null) {
097:                        return lm.getBaseLength(lengthBase, fobj);
098:                    }
099:                }
100:                log.error("Cannot find LM to handle given FO for LengthBase. ("
101:                        + fobj.getContextInfo() + ")");
102:                return 0;
103:            }
104:
105:            /**
106:             * Find the first ancestor area that is a block area
107:             * and returns its IPD.
108:             * @return the ipd of the ancestor block area
109:             */
110:            protected int getAncestorBlockAreaIPD() {
111:                LayoutManager lm = getParent();
112:                while (lm != null) {
113:                    if (lm.getGeneratesBlockArea()
114:                            && !lm.getGeneratesLineArea()) {
115:                        return lm.getContentAreaIPD();
116:                    }
117:                    lm = lm.getParent();
118:                }
119:                if (lm == null) {
120:                    log.error("No parent LM found");
121:                }
122:                return 0;
123:            }
124:
125:            /**
126:             * Find the first ancestor area that is a block area
127:             * and returns its BPD.
128:             * @return the bpd of the ancestor block area
129:             */
130:            protected int getAncestorBlockAreaBPD() {
131:                LayoutManager lm = getParent();
132:                while (lm != null) {
133:                    if (lm.getGeneratesBlockArea()
134:                            && !lm.getGeneratesLineArea()) {
135:                        return lm.getContentAreaBPD();
136:                    }
137:                    lm = lm.getParent();
138:                }
139:                if (lm == null) {
140:                    log.error("No parent LM found");
141:                }
142:                return 0;
143:            }
144:
145:            /**
146:             * Find the parent area and returns its IPD.
147:             * @return the ipd of the parent area
148:             */
149:            protected int getParentAreaIPD() {
150:                LayoutManager lm = getParent();
151:                if (lm != null) {
152:                    return lm.getContentAreaIPD();
153:                }
154:                log.error("No parent LM found");
155:                return 0;
156:            }
157:
158:            /**
159:             * Find the parent area and returns its BPD.
160:             * @return the bpd of the parent area
161:             */
162:            protected int getParentAreaBPD() {
163:                LayoutManager lm = getParent();
164:                if (lm != null) {
165:                    return lm.getContentAreaBPD();
166:                }
167:                log.error("No parent LM found");
168:                return 0;
169:            }
170:
171:            /**
172:             * Find the first ancestor area that is a reference area
173:             * and returns its IPD.
174:             * @return the ipd of the ancestor reference area
175:             */
176:            public int getReferenceAreaIPD() {
177:                LayoutManager lm = getParent();
178:                while (lm != null) {
179:                    if (lm.getGeneratesReferenceArea()) {
180:                        return lm.getContentAreaIPD();
181:                    }
182:                    lm = lm.getParent();
183:                }
184:                if (lm == null) {
185:                    log.error("No parent LM found");
186:                }
187:                return 0;
188:            }
189:
190:            /**
191:             * Find the first ancestor area that is a reference area
192:             * and returns its BPD.
193:             * @return the bpd of the ancestor reference area
194:             */
195:            protected int getReferenceAreaBPD() {
196:                LayoutManager lm = getParent();
197:                while (lm != null) {
198:                    if (lm.getGeneratesReferenceArea()) {
199:                        return lm.getContentAreaBPD();
200:                    }
201:                    lm = lm.getParent();
202:                }
203:                if (lm == null) {
204:                    log.error("No parent LM found");
205:                }
206:                return 0;
207:            }
208:
209:            /**
210:             * Returns the IPD of the content area
211:             * @return the IPD of the content area
212:             * @see LayoutManager#getContentAreaIPD
213:             */
214:            public int getContentAreaIPD() {
215:                log
216:                        .error("getContentAreaIPD called when it should have been overwritten");
217:                return 0;
218:            }
219:
220:            /**
221:             * Returns the BPD of the content area
222:             * @return the BPD of the content area
223:             * @see LayoutManager#getContentAreaBPD
224:             */
225:            public int getContentAreaBPD() {
226:                log
227:                        .error("getContentAreaBPD called when it should have been overwritten");
228:                return 0;
229:            }
230:
231:            /**
232:             * @see LayoutManager#getGeneratesReferenceArea
233:             */
234:            public boolean getGeneratesReferenceArea() {
235:                return generatesReferenceArea;
236:            }
237:
238:            /**
239:             * Lets implementing LM set the flag indicating if they
240:             * generate reference areas.
241:             * @param generatesReferenceArea if true the areas generates by this LM are 
242:             * reference areas.
243:             */
244:            protected void setGeneratesReferenceArea(
245:                    boolean generatesReferenceArea) {
246:                this .generatesReferenceArea = generatesReferenceArea;
247:            }
248:
249:            /**
250:             * @see LayoutManager#getGeneratesBlockArea
251:             */
252:            public boolean getGeneratesBlockArea() {
253:                return generatesBlockArea;
254:            }
255:
256:            /**
257:             * Lets implementing LM set the flag indicating if they
258:             * generate block areas.
259:             * @param generatesBlockArea if true the areas generates by this LM are block areas.
260:             */
261:            protected void setGeneratesBlockArea(boolean generatesBlockArea) {
262:                this .generatesBlockArea = generatesBlockArea;
263:            }
264:
265:            /**
266:             * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesLineArea
267:             */
268:            public boolean getGeneratesLineArea() {
269:                return false;
270:            }
271:
272:            /**
273:             * @see org.apache.fop.layoutmgr.LayoutManager#getFObj
274:             */
275:            public FObj getFObj() {
276:                return fobj;
277:            }
278:
279:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.