Package com.lowagie.text
Class Section
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList
com.lowagie.text.Section
- All Implemented Interfaces:
Element,LargeElement,TextElementArray,Serializable,Cloneable,Iterable,Collection,List,RandomAccess
- Direct Known Subclasses:
Chapter
A
Section is a part of a Document containing
other Sections, Paragraphs, List
and/or Tables.
Remark: you can not construct a Section yourself.
You will have to ask an instance of Section to the
Chapter or Section to which you want to
add the new Section.
Example:
Paragraph title2 = new Paragraph("This is Chapter 2", FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC, new Color(0, 0, 255)));
Chapter chapter2 = new Chapter(title2, 2);
Paragraph someText = new Paragraph("This is some text");
chapter2.add(someText);
Paragraph title21 = new Paragraph("This is Section 1 in Chapter 2", FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD, new Color(255, 0, 0)));
Section section1 = chapter2.addSection(title21);
Paragraph someSectionText = new Paragraph("This is some silly paragraph in a chapter and/or section. It contains some text to test the functionality of Chapters and Section.");
section1.add(someSectionText);
Paragraph title211 = new Paragraph("This is SubSection 1 in Section 1 in Chapter 2", FontFactory.getFont(FontFactory.HELVETICA, 14, Font.BOLD, new Color(255, 0, 0)));
Section section11 = section1.addSection(40, title211, 2);
section11.add(someSectionText);
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanIndicates if the Section was added completely to the document.protected booleanfalse if the bookmark children are not visibleprotected StringThe bookmark title if different from the content titleprotected booleanIndicates if the Section will be complete once added to the document.protected floatThe additional indentation of the content of this section.protected floatThe indentation of this section on the left side.protected floatThe indentation of this section on the right side.protected booleanIndicates if this is the first time the section was added.protected intThe number of sectionnumbers that has to be shown before the section title.protected ArrayListThis is the complete list of sectionnumbers of this section and the parents of this section.protected intThe style for sectionnumbers.static final intA possible number style.static final intA possible number style.protected intThis is the number of subsections.protected ParagraphThe title of this section.protected booleantrue if the section has to trigger a new pageFields inherited from class java.util.AbstractList
modCountFields inherited from interface com.lowagie.text.Element
ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_JUSTIFIED, ALIGN_JUSTIFIED_ALL, ALIGN_LEFT, ALIGN_MIDDLE, ALIGN_RIGHT, ALIGN_TOP, ALIGN_UNDEFINED, ANCHOR, ANNOTATION, AUTHOR, CCITT_BLACKIS1, CCITT_ENCODEDBYTEALIGN, CCITT_ENDOFBLOCK, CCITT_ENDOFLINE, CCITTG3_1D, CCITTG3_2D, CCITTG4, CELL, CHAPTER, CHUNK, CREATIONDATE, CREATOR, HEADER, IMGRAW, IMGTEMPLATE, JBIG2, JPEG, JPEG2000, KEYWORDS, LIST, LISTITEM, MARKED, MULTI_COLUMN_TEXT, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, ROW, SECTION, SUBJECT, TABLE, TITLE, YMARK -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds aParagraph,ListorTableto thisSection.booleanAdds aParagraph,List,Tableor anotherSectionto thisSection.booleanaddAll(Collection collection) Adds a collection ofElements to thisSection.Adds a marked section.addSection(float indentation, Paragraph title) Creates aSection, adds it to thisSectionand returns it.addSection(float indentation, Paragraph title, int numberDepth) Creates aSection, adds it to thisSectionand returns it.addSection(float indentation, String title) Adds aSectionto thisSectionand returns it.addSection(float indentation, String title, int numberDepth) Adds aSectionto thisSectionand returns it.addSection(Paragraph title) Creates aSection, adds it to thisSectionand returns it.addSection(Paragraph title, int numberDepth) Creates aSection, add it to thisSectionand returns it.addSection(String title) Adds aSectionto thisSectionand returns it.addSection(String title, int numberDepth) Adds aSectionto thisSectionand returns it.static ParagraphconstructTitle(Paragraph title, ArrayList numbers, int numberDepth, int numberStyle) Constructs a Paragraph that will be used as title for a Section or Chapter.voidFlushes the content that has been added.Gets the bookmark title.Gets all the chunks in this element.intgetDepth()Returns the depth of this section.floatReturns the indentation of the content of thisSection.floatReturns the indentation of thisSectionon the left side.floatReturns the indentation of thisSectionon the right side.intReturns the numberdepth of thisSection.intGets the style used for numbering sections.getTitle()Returns the title, preceded by a certain number of sectionnumbers.protected booleanbooleanGetter for property bookmarkOpen.booleanChecks if this object is aChapter.booleanIndicates if the element is complete or not.booleanChecks if this element is a content object.booleanChecks if this element is nestable.booleanIndicates if this is the first time the section is added.booleanChecks if this object is aSection.booleanGetter for property bookmarkOpen.voidnewPage()Adds a new page to the section.booleanprocess(ElementListener listener) Processes the element by adding it (or the different parts) to anElementListener.protected voidsetAddedCompletely(boolean addedCompletely) voidsetBookmarkOpen(boolean bookmarkOpen) Setter for property bookmarkOpen.voidsetBookmarkTitle(String bookmarkTitle) Sets the bookmark title.voidsetChapterNumber(int number) Changes the Chapter number.voidsetComplete(boolean complete) If you invoke setComplete(false), you indicate that the content of the object isn't complete yet; it can be added to the document partially, but more will follow.voidsetIndentation(float indentation) Sets the indentation of the content of thisSection.voidsetIndentationLeft(float indentation) Sets the indentation of thisSectionon the left side.voidsetIndentationRight(float indentation) Sets the indentation of thisSectionon the right side.voidsetNotAddedYet(boolean notAddedYet) Sets the indication if the section was already added to the document.voidsetNumberDepth(int numberDepth) Sets the depth of the sectionnumbers that will be shown preceding the title.voidsetNumberStyle(int numberStyle) Sets the style for numbering sections.voidSets the title of this section.voidsetTriggerNewPage(boolean triggerNewPage) Setter for property triggerNewPage.inttype()Gets the type of the text element.Methods inherited from class java.util.ArrayList
addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class java.util.AbstractCollection
containsAll, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface java.util.List
containsAll
-
Field Details
-
NUMBERSTYLE_DOTTED
public static final int NUMBERSTYLE_DOTTEDA possible number style. The default number style: "1.2.3."- Since:
- iText 2.0.8
- See Also:
-
NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT
public static final int NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOTA possible number style. For instance: "1.2.3"- Since:
- iText 2.0.8
- See Also:
-
title
The title of this section. -
bookmarkTitle
The bookmark title if different from the content title -
numberDepth
protected int numberDepthThe number of sectionnumbers that has to be shown before the section title. -
numberStyle
protected int numberStyleThe style for sectionnumbers.- Since:
- iText 2.0.8
-
indentationLeft
protected float indentationLeftThe indentation of this section on the left side. -
indentationRight
protected float indentationRightThe indentation of this section on the right side. -
indentation
protected float indentationThe additional indentation of the content of this section. -
bookmarkOpen
protected boolean bookmarkOpenfalse if the bookmark children are not visible -
triggerNewPage
protected boolean triggerNewPagetrue if the section has to trigger a new page -
subsections
protected int subsectionsThis is the number of subsections. -
numbers
This is the complete list of sectionnumbers of this section and the parents of this section. -
complete
protected boolean completeIndicates if the Section will be complete once added to the document.- Since:
- iText 2.0.8
-
addedCompletely
protected boolean addedCompletelyIndicates if the Section was added completely to the document.- Since:
- iText 2.0.8
-
notAddedYet
protected boolean notAddedYetIndicates if this is the first time the section was added.- Since:
- iText 2.0.8
-
-
Constructor Details
-
Section
protected Section()Constructs a newSection. -
Section
Constructs a newSection.- Parameters:
title- aParagraphnumberDepth- the numberDepth
-
-
Method Details
-
process
Processes the element by adding it (or the different parts) to anElementListener. -
type
public int type()Gets the type of the text element. -
isChapter
public boolean isChapter()Checks if this object is aChapter.- Returns:
trueif it is aChapter,falseif it is aSection.
-
isSection
public boolean isSection()Checks if this object is aSection.- Returns:
trueif it is aSection,falseif it is aChapter.
-
getChunks
Gets all the chunks in this element. -
isContent
public boolean isContent()Description copied from interface:ElementChecks if this element is a content object. If not, it's a metadata object. -
isNestable
public boolean isNestable()Description copied from interface:ElementChecks if this element is nestable.- Specified by:
isNestablein interfaceElement- Returns:
- true if this element can be nested inside other elements.
- Since:
- iText 2.0.8
- See Also:
-
add
Adds aParagraph,ListorTableto thisSection.- Specified by:
addin interfaceList- Overrides:
addin classArrayList- Parameters:
index- index at which the specified element is to be insertedo- an object of typeParagraph,ListorTable=- Throws:
ClassCastException- if the object is not aParagraph,ListorTable
-
add
Adds aParagraph,List,Tableor anotherSectionto thisSection.- Specified by:
addin interfaceCollection- Specified by:
addin interfaceList- Specified by:
addin interfaceTextElementArray- Overrides:
addin classArrayList- Parameters:
o- an object of typeParagraph,List,Tableor anotherSection- Returns:
- a boolean
- Throws:
ClassCastException- if the object is not aParagraph,List,TableorSection
-
addAll
Adds a collection ofElements to thisSection.- Specified by:
addAllin interfaceCollection- Specified by:
addAllin interfaceList- Overrides:
addAllin classArrayList- Parameters:
collection- a collection ofParagraphs,Lists and/orTables- Returns:
trueif the action succeeded,falseif not.- Throws:
ClassCastException- if one of the objects isn't aParagraph,List,Table
-
addSection
Creates aSection, adds it to thisSectionand returns it.- Parameters:
indentation- the indentation of the new sectiontitle- the title of the new sectionnumberDepth- the numberDepth of the section- Returns:
- a new Section object
-
addSection
Creates aSection, adds it to thisSectionand returns it.- Parameters:
indentation- the indentation of the new sectiontitle- the title of the new section- Returns:
- a new Section object
-
addSection
Creates aSection, add it to thisSectionand returns it.- Parameters:
title- the title of the new sectionnumberDepth- the numberDepth of the section- Returns:
- a new Section object
-
addMarkedSection
Adds a marked section. For use in class MarkedSection only! -
addSection
Creates aSection, adds it to thisSectionand returns it.- Parameters:
title- the title of the new section- Returns:
- a new Section object
-
addSection
Adds aSectionto thisSectionand returns it.- Parameters:
indentation- the indentation of the new sectiontitle- the title of the new sectionnumberDepth- the numberDepth of the section- Returns:
- a new Section object
-
addSection
Adds aSectionto thisSectionand returns it.- Parameters:
title- the title of the new sectionnumberDepth- the numberDepth of the section- Returns:
- a new Section object
-
addSection
Adds aSectionto thisSectionand returns it.- Parameters:
indentation- the indentation of the new sectiontitle- the title of the new section- Returns:
- a new Section object
-
addSection
Adds aSectionto thisSectionand returns it.- Parameters:
title- the title of the new section- Returns:
- a new Section object
-
setTitle
Sets the title of this section.- Parameters:
title- the new title
-
getTitle
Returns the title, preceded by a certain number of sectionnumbers.- Returns:
- a
Paragraph
-
constructTitle
public static Paragraph constructTitle(Paragraph title, ArrayList numbers, int numberDepth, int numberStyle) Constructs a Paragraph that will be used as title for a Section or Chapter.- Parameters:
title- the title of the sectionnumbers- a list of sectionnumbersnumberDepth- how many numbers have to be shownnumberStyle- the numbering style- Returns:
- a Paragraph object
- Since:
- iText 2.0.8
-
setNumberDepth
public void setNumberDepth(int numberDepth) Sets the depth of the sectionnumbers that will be shown preceding the title.If the numberdepth is 0, the sections will not be numbered. If the numberdepth is 1, the section will be numbered with their own number. If the numberdepth is higher (for instance x > 1), the numbers of x - 1 parents will be shown.
- Parameters:
numberDepth- the new numberDepth
-
getNumberDepth
public int getNumberDepth()Returns the numberdepth of thisSection.- Returns:
- the numberdepth
-
setNumberStyle
public void setNumberStyle(int numberStyle) Sets the style for numbering sections. Possible values are NUMBERSTYLE_DOTTED: 1.2.3. (the default) or NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT: 1.2.3- Since:
- iText 2.0.8
-
getNumberStyle
public int getNumberStyle()Gets the style used for numbering sections.- Returns:
- a value corresponding with a numbering style
- Since:
- iText 2.0.8
-
setIndentationLeft
public void setIndentationLeft(float indentation) Sets the indentation of thisSectionon the left side.- Parameters:
indentation- the indentation
-
getIndentationLeft
public float getIndentationLeft()Returns the indentation of thisSectionon the left side.- Returns:
- the indentation
-
setIndentationRight
public void setIndentationRight(float indentation) Sets the indentation of thisSectionon the right side.- Parameters:
indentation- the indentation
-
getIndentationRight
public float getIndentationRight()Returns the indentation of thisSectionon the right side.- Returns:
- the indentation
-
setIndentation
public void setIndentation(float indentation) Sets the indentation of the content of thisSection.- Parameters:
indentation- the indentation
-
getIndentation
public float getIndentation()Returns the indentation of the content of thisSection.- Returns:
- the indentation
-
setBookmarkOpen
public void setBookmarkOpen(boolean bookmarkOpen) Setter for property bookmarkOpen.- Parameters:
bookmarkOpen- false if the bookmark children are not visible.
-
isBookmarkOpen
public boolean isBookmarkOpen()Getter for property bookmarkOpen.- Returns:
- Value of property bookmarkOpen.
-
setTriggerNewPage
public void setTriggerNewPage(boolean triggerNewPage) Setter for property triggerNewPage.- Parameters:
triggerNewPage- true if a new page has to be triggered.
-
isTriggerNewPage
public boolean isTriggerNewPage()Getter for property bookmarkOpen.- Returns:
- Value of property triggerNewPage.
-
setBookmarkTitle
Sets the bookmark title. The bookmark title is the same as the section title but can be changed with this method.- Parameters:
bookmarkTitle- the bookmark title
-
getBookmarkTitle
Gets the bookmark title.- Returns:
- the bookmark title
-
setChapterNumber
public void setChapterNumber(int number) Changes the Chapter number. -
getDepth
public int getDepth()Returns the depth of this section.- Returns:
- the depth
-
isNotAddedYet
public boolean isNotAddedYet()Indicates if this is the first time the section is added.- Returns:
- true if the section wasn't added yet
- Since:
- iText2.0.8
-
setNotAddedYet
public void setNotAddedYet(boolean notAddedYet) Sets the indication if the section was already added to the document.- Parameters:
notAddedYet-- Since:
- iText2.0.8
-
isAddedCompletely
protected boolean isAddedCompletely()- Since:
- iText 2.0.8
-
setAddedCompletely
protected void setAddedCompletely(boolean addedCompletely) - Since:
- iText 2.0.8
-
flushContent
public void flushContent()Description copied from interface:LargeElementFlushes the content that has been added.- Specified by:
flushContentin interfaceLargeElement- Since:
- iText 2.0.8
- See Also:
-
isComplete
public boolean isComplete()Description copied from interface:LargeElementIndicates if the element is complete or not.- Specified by:
isCompletein interfaceLargeElement- Returns:
- indicates if the element is complete according to the user.
- Since:
- iText 2.0.8
- See Also:
-
setComplete
public void setComplete(boolean complete) Description copied from interface:LargeElementIf you invoke setComplete(false), you indicate that the content of the object isn't complete yet; it can be added to the document partially, but more will follow. If you invoke setComplete(true), you indicate that you won't add any more data to the object.- Specified by:
setCompletein interfaceLargeElement- Parameters:
complete- false if you'll be adding more data after adding the object to the document.- Since:
- iText 2.0.8
- See Also:
-
newPage
public void newPage()Adds a new page to the section.- Since:
- 2.1.1
-