Source Code Cross Referenced for MarkedSection.java in  » PDF » pdf-itext » com » lowagie » text » 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 » PDF » pdf itext » com.lowagie.text 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: MarkedSection.java 2748 2007-05-12 15:11:48Z blowagie $
003:         * $Name$
004:         *
005:         * Copyright 2007 by Bruno Lowagie.
006:         *
007:         * The contents of this file are subject to the Mozilla Public License Version 1.1
008:         * (the "License"); you may not use this file except in compliance with the License.
009:         * You may obtain a copy of the License at http://www.mozilla.org/MPL/
010:         *
011:         * Software distributed under the License is distributed on an "AS IS" basis,
012:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
013:         * for the specific language governing rights and limitations under the License.
014:         *
015:         * The Original Code is 'iText, a free JAVA-PDF library'.
016:         *
017:         * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
018:         * the Initial Developer are Copyright (C) 1999-2007 by Bruno Lowagie.
019:         * All Rights Reserved.
020:         * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
021:         * are Copyright (C) 2000-2007 by Paulo Soares. All Rights Reserved.
022:         *
023:         * Contributor(s): all the names of the contributors are added in the source code
024:         * where applicable.
025:         *
026:         * Alternatively, the contents of this file may be used under the terms of the
027:         * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
028:         * provisions of LGPL are applicable instead of those above.  If you wish to
029:         * allow use of your version of this file only under the terms of the LGPL
030:         * License and not to allow others to use your version of this file under
031:         * the MPL, indicate your decision by deleting the provisions above and
032:         * replace them with the notice and other provisions required by the LGPL.
033:         * If you do not delete the provisions above, a recipient may use your version
034:         * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
035:         *
036:         * This library is free software; you can redistribute it and/or modify it
037:         * under the terms of the MPL as stated above or under the terms of the GNU
038:         * Library General Public License as published by the Free Software Foundation;
039:         * either version 2 of the License, or any later version.
040:         *
041:         * This library is distributed in the hope that it will be useful, but WITHOUT
042:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
043:         * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
044:         * details.
045:         *
046:         * If you didn't download this code from the following link, you should check if
047:         * you aren't using an obsolete version:
048:         * http://www.lowagie.com/iText/
049:         */
050:
051:        package com.lowagie.text;
052:
053:        import java.util.Collection;
054:        import java.util.Iterator;
055:
056:        /**
057:         * Wrapper that allows to add properties to a Chapter/Section object.
058:         * Before iText 1.5 every 'basic building block' implemented the MarkupAttributes interface.
059:         * By setting attributes, you could add markup to the corresponding XML and/or HTML tag.
060:         * This functionality was hardly used by anyone, so it was removed, and replaced by
061:         * the MarkedObject functionality.
062:         */
063:
064:        public class MarkedSection extends MarkedObject {
065:
066:            /** This is the title of this section. */
067:            protected MarkedObject title = null;
068:
069:            /**
070:             * Creates a MarkedObject with a Section or Chapter object.
071:             * @param section	the marked section
072:             */
073:            public MarkedSection(Section section) {
074:                super ();
075:                if (section.title != null) {
076:                    title = new MarkedObject(section.title);
077:                    section.setTitle(null);
078:                }
079:                this .element = section;
080:            }
081:
082:            /**
083:             * Adds a <CODE>Paragraph</CODE>, <CODE>List</CODE> or <CODE>Table</CODE>
084:             * to this <CODE>Section</CODE>.
085:             *
086:             * @param	index	index at which the specified element is to be inserted
087:             * @param	o   	an object of type <CODE>Paragraph</CODE>, <CODE>List</CODE> or <CODE>Table</CODE>=
088:             * @throws	ClassCastException if the object is not a <CODE>Paragraph</CODE>, <CODE>List</CODE> or <CODE>Table</CODE>
089:             */
090:            public void add(int index, Object o) {
091:                ((Section) element).add(index, o);
092:            }
093:
094:            /**
095:             * Adds a <CODE>Paragraph</CODE>, <CODE>List</CODE>, <CODE>Table</CODE> or another <CODE>Section</CODE>
096:             * to this <CODE>Section</CODE>.
097:             *
098:             * @param	o   	an object of type <CODE>Paragraph</CODE>, <CODE>List</CODE>, <CODE>Table</CODE> or another <CODE>Section</CODE>
099:             * @return	a boolean
100:             * @throws	ClassCastException if the object is not a <CODE>Paragraph</CODE>, <CODE>List</CODE>, <CODE>Table</CODE> or <CODE>Section</CODE>
101:             */
102:            public boolean add(Object o) {
103:                return ((Section) element).add(o);
104:            }
105:
106:            /**
107:             * Processes the element by adding it (or the different parts) to an
108:             * <CODE>ElementListener</CODE>.
109:             *
110:             * @param       listener        an <CODE>ElementListener</CODE>
111:             * @return <CODE>true</CODE> if the element was processed successfully
112:             */
113:            public boolean process(ElementListener listener) {
114:                try {
115:                    Element element;
116:                    for (Iterator i = ((Section) this .element).iterator(); i
117:                            .hasNext();) {
118:                        element = (Element) i.next();
119:                        listener.add(element);
120:                    }
121:                    return true;
122:                } catch (DocumentException de) {
123:                    return false;
124:                }
125:            }
126:
127:            /**
128:             * Adds a collection of <CODE>Element</CODE>s
129:             * to this <CODE>Section</CODE>.
130:             *
131:             * @param	collection	a collection of <CODE>Paragraph</CODE>s, <CODE>List</CODE>s and/or <CODE>Table</CODE>s
132:             * @return	<CODE>true</CODE> if the action succeeded, <CODE>false</CODE> if not.
133:             * @throws	ClassCastException if one of the objects isn't a <CODE>Paragraph</CODE>, <CODE>List</CODE>, <CODE>Table</CODE>
134:             */
135:            public boolean addAll(Collection collection) {
136:                return ((Section) element).addAll(collection);
137:            }
138:
139:            /**
140:             * Creates a <CODE>Section</CODE>, adds it to this <CODE>Section</CODE> and returns it.
141:             *
142:             * @param	indentation	the indentation of the new section
143:             * @param	numberDepth	the numberDepth of the section
144:             * @return  a new Section object
145:             */
146:            public MarkedSection addSection(float indentation, int numberDepth) {
147:                MarkedSection section = ((Section) element).addMarkedSection();
148:                section.setIndentation(indentation);
149:                section.setNumberDepth(numberDepth);
150:                return section;
151:            }
152:
153:            /**
154:             * Creates a <CODE>Section</CODE>, adds it to this <CODE>Section</CODE> and returns it.
155:             *
156:             * @param	indentation	the indentation of the new section
157:             * @return  a new Section object
158:             */
159:            public MarkedSection addSection(float indentation) {
160:                MarkedSection section = ((Section) element).addMarkedSection();
161:                section.setIndentation(indentation);
162:                return section;
163:            }
164:
165:            /**
166:             * Creates a <CODE>Section</CODE>, add it to this <CODE>Section</CODE> and returns it.
167:             *
168:             * @param	numberDepth	the numberDepth of the section
169:             * @return  a new Section object
170:             */
171:            public MarkedSection addSection(int numberDepth) {
172:                MarkedSection section = ((Section) element).addMarkedSection();
173:                section.setNumberDepth(numberDepth);
174:                return section;
175:            }
176:
177:            /**
178:             * Creates a <CODE>Section</CODE>, adds it to this <CODE>Section</CODE> and returns it.
179:             *
180:             * @return  a new Section object
181:             */
182:            public MarkedSection addSection() {
183:                return ((Section) element).addMarkedSection();
184:            }
185:
186:            // public methods
187:
188:            /**
189:             * Sets the title of this section.
190:             *
191:             * @param	title	the new title
192:             */
193:            public void setTitle(MarkedObject title) {
194:                if (title.element instanceof  Paragraph)
195:                    this .title = title;
196:            }
197:
198:            /**
199:             * Gets the title of this MarkedSection.
200:             */
201:            public MarkedObject title() {
202:                if (title == null) {
203:                    return null;
204:                }
205:                int depth = Math.min(((Section) element).numbers.size(),
206:                        ((Section) element).numberDepth);
207:                if (depth < 1) {
208:                    return title;
209:                }
210:                StringBuffer buf = new StringBuffer();
211:                for (int i = 0; i < depth; i++) {
212:                    buf.insert(0, ".");
213:                    buf.insert(0,
214:                            ((Integer) ((Section) element).numbers.get(i))
215:                                    .intValue());
216:                }
217:                if (buf.length() > 0)
218:                    buf.append(' ');
219:                Paragraph result = new Paragraph((Paragraph) title.element);
220:                result.add(0, new Chunk(buf.toString(),
221:                        ((Paragraph) title.element).getFont()));
222:                MarkedObject mo = new MarkedObject(result);
223:                mo.markupAttributes = title.markupAttributes;
224:                return mo;
225:            }
226:
227:            /**
228:             * Sets the depth of the sectionnumbers that will be shown preceding the title.
229:             * <P>
230:             * If the numberdepth is 0, the sections will not be numbered. If the numberdepth
231:             * is 1, the section will be numbered with their own number. If the numberdepth is
232:             * higher (for instance x > 1), the numbers of x - 1 parents will be shown.
233:             *
234:             * @param	numberDepth		the new numberDepth
235:             */
236:            public void setNumberDepth(int numberDepth) {
237:                ((Section) element).setNumberDepth(numberDepth);
238:            }
239:
240:            /**
241:             * Sets the indentation of this <CODE>Section</CODE> on the left side.
242:             *
243:             * @param	indentation		the indentation
244:             */
245:            public void setIndentationLeft(float indentation) {
246:                ((Section) element).setIndentationLeft(indentation);
247:            }
248:
249:            /**
250:             * Sets the indentation of this <CODE>Section</CODE> on the right side.
251:             *
252:             * @param	indentation		the indentation
253:             */
254:            public void setIndentationRight(float indentation) {
255:                ((Section) element).setIndentationRight(indentation);
256:            }
257:
258:            /**
259:             * Sets the indentation of the content of this <CODE>Section</CODE>.
260:             *
261:             * @param	indentation		the indentation
262:             */
263:            public void setIndentation(float indentation) {
264:                ((Section) element).setIndentation(indentation);
265:            }
266:
267:            /** Setter for property bookmarkOpen.
268:             * @param bookmarkOpen false if the bookmark children are not
269:             * visible.
270:             */
271:            public void setBookmarkOpen(boolean bookmarkOpen) {
272:                ((Section) element).setBookmarkOpen(bookmarkOpen);
273:            }
274:
275:            /**
276:             * Setter for property triggerNewPage.
277:             * @param triggerNewPage true if a new page has to be triggered.
278:             */
279:            public void setTriggerNewPage(boolean triggerNewPage) {
280:                ((Section) element).setTriggerNewPage(triggerNewPage);
281:            }
282:
283:            /**
284:             * Sets the bookmark title. The bookmark title is the same as the section title but
285:             * can be changed with this method.
286:             * @param bookmarkTitle the bookmark title
287:             */
288:            public void setBookmarkTitle(String bookmarkTitle) {
289:                ((Section) element).setBookmarkTitle(bookmarkTitle);
290:            }
291:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.