Source Code Cross Referenced for PrimaryGridUnit.java in  » Graphic-Library » fop » org » apache » fop » layoutmgr » table » 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.table 
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: PrimaryGridUnit.java 519975 2007-03-19 15:40:31Z vhennebert $ */
019:
020:        package org.apache.fop.layoutmgr.table;
021:
022:        import java.util.LinkedList;
023:        import java.util.List;
024:
025:        import org.apache.commons.logging.Log;
026:        import org.apache.commons.logging.LogFactory;
027:        import org.apache.fop.fo.flow.TableCell;
028:        import org.apache.fop.fo.flow.TableColumn;
029:
030:        /**
031:         * This class represents a primary grid unit of a spanned cell. This is the "before-start"
032:         * (top-left, usually) grid unit of the span.
033:         */
034:        public class PrimaryGridUnit extends GridUnit {
035:
036:            private static Log log = LogFactory.getLog(PrimaryGridUnit.class);
037:
038:            /** Cell layout manager. */
039:            private TableCellLayoutManager cellLM;
040:            /** List of Knuth elements representing the contents of the cell. */
041:            private LinkedList elements;
042:            /** Index of row where this cell starts */
043:            private int startRow;
044:            /** Links to the spanned grid units. (List of GridUnit arrays, one array represents a row) */
045:            private List rows;
046:            /** The calculated size of the cell's content. (cached value) */
047:            private int contentLength = -1;
048:
049:            /**
050:             * Creates a new primary grid unit.
051:             *
052:             * @param cell table cell which occupies this grid unit
053:             * @param column table column this grid unit belongs to
054:             * @param startCol index of the column this grid unit belongs to, zero-based
055:             * @param startRow index of the row this grid unit belongs to, zero-based
056:             */
057:            public PrimaryGridUnit(TableCell cell, TableColumn column,
058:                    int startCol, int startRow) {
059:                super (cell, column, startCol, 0);
060:                this .startRow = startRow;
061:                log.trace("PrimaryGridUnit created, row " + startRow + " col "
062:                        + startCol);
063:                if (cell != null) {
064:                    cellLM = new TableCellLayoutManager(cell, this );
065:                }
066:            }
067:
068:            public TableCellLayoutManager getCellLM() {
069:                return cellLM;
070:            }
071:
072:            public boolean isPrimary() {
073:                return true;
074:            }
075:
076:            /**
077:             * Sets the Knuth elements for the table cell containing this grid unit.
078:             *
079:             * @param elements a list of ListElement (?)
080:             */
081:            public void setElements(LinkedList elements) {
082:                this .elements = elements;
083:            }
084:
085:            public LinkedList getElements() {
086:                return this .elements;
087:            }
088:
089:            /**
090:             * @return half the maximum before border width of this cell.
091:             */
092:            public int getHalfMaxBeforeBorderWidth() {
093:                int value = 0;
094:                if (getRows() != null) {
095:                    int before = 0;
096:                    //first row for before borders
097:                    GridUnit[] row = (GridUnit[]) getRows().get(0);
098:                    for (int i = 0; i < row.length; i++) {
099:                        if (row[i].hasBorders()) {
100:                            before = Math.max(before, row[i].getBorders()
101:                                    .getBorderBeforeWidth(false));
102:                        }
103:                    }
104:                    value += before / 2;
105:                } else {
106:                    if (hasBorders()) {
107:                        value += getBorders().getBorderBeforeWidth(false) / 2;
108:                    }
109:                }
110:                return value;
111:            }
112:
113:            /**
114:             * @return half the maximum after border width of this cell.
115:             */
116:            public int getHalfMaxAfterBorderWidth() {
117:                int value = 0;
118:                if (getRows() != null) {
119:                    //Last row for after borders
120:                    int after = 0;
121:                    GridUnit[] row = (GridUnit[]) getRows().get(
122:                            getRows().size() - 1);
123:                    for (int i = 0; i < row.length; i++) {
124:                        if (row[i].hasBorders()) {
125:                            after = Math.max(after, row[i].getBorders()
126:                                    .getBorderAfterWidth(false));
127:                        }
128:                    }
129:                    value += after / 2;
130:                } else {
131:                    if (hasBorders()) {
132:                        value += getBorders().getBorderAfterWidth(false) / 2;
133:                    }
134:                }
135:                return value;
136:            }
137:
138:            /**
139:             * @return the sum of half the maximum before and after border
140:             * widths of this cell.
141:             */
142:            public int getHalfMaxBorderWidth() {
143:                return getHalfMaxBeforeBorderWidth()
144:                        + getHalfMaxAfterBorderWidth();
145:            }
146:
147:            /** @param value The length of the cell content to remember. */
148:            public void setContentLength(int value) {
149:                this .contentLength = value;
150:            }
151:
152:            /** @return the length of the cell content. */
153:            public int getContentLength() {
154:                return contentLength;
155:            }
156:
157:            /** @return true if cell/row has an explicit BPD/height */
158:            public boolean hasBPD() {
159:                if (!getCell().getBlockProgressionDimension().getOptimum(null)
160:                        .isAuto()) {
161:                    return true;
162:                }
163:                if (getRow() != null
164:                        && !getRow().getBlockProgressionDimension().getOptimum(
165:                                null).isAuto()) {
166:                    return true;
167:                }
168:                return false;
169:            }
170:
171:            /**
172:             * Returns the grid units belonging to the same span as this one.
173:             *
174:             * @return a list of GridUnit[], each array corresponds to a row
175:             */
176:            public List getRows() {
177:                return this .rows;
178:            }
179:
180:            public void addRow(GridUnit[] row) {
181:                if (rows == null) {
182:                    rows = new java.util.ArrayList();
183:                }
184:                rows.add(row);
185:            }
186:
187:            /**
188:             * Returns the index of the row this grid unit belongs to.
189:             *
190:             * @return the index of the row this grid unit belongs to.
191:             */
192:            public int getStartRow() {
193:                return this .startRow;
194:            }
195:
196:            /**
197:             * Returns the widths of the start- and end-borders of the span this grid unit belongs
198:             * to.
199:             *
200:             * @return a two-element array containing the widths of the start-border then the
201:             * end-border
202:             */
203:            public int[] getStartEndBorderWidths() {
204:                int[] widths = new int[2];
205:                if (rows == null) {
206:                    widths[0] = getBorders().getBorderStartWidth(false);
207:                    widths[1] = getBorders().getBorderEndWidth(false);
208:                } else {
209:                    for (int i = 0; i < rows.size(); i++) {
210:                        GridUnit[] gridUnits = (GridUnit[]) rows.get(i);
211:                        widths[0] = Math.max(widths[0], (gridUnits[0])
212:                                .getBorders().getBorderStartWidth(false));
213:                        widths[1] = Math.max(widths[1],
214:                                (gridUnits[gridUnits.length - 1]).getBorders()
215:                                        .getBorderEndWidth(false));
216:                    }
217:                }
218:                return widths;
219:            }
220:
221:            /** @see java.lang.Object#toString() */
222:            public String toString() {
223:                StringBuffer sb = new StringBuffer(super .toString());
224:                sb.append(" startRow=").append(startRow);
225:                return sb.toString();
226:            }
227:
228:            /** @return true if this cell spans over more than one grid unit. */
229:            public boolean hasSpanning() {
230:                return (getCell().getNumberColumnsSpanned() > 1)
231:                        || (getCell().getNumberRowsSpanned() > 1);
232:            }
233:
234:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.