com.lowagie.text

Class Section

public class Section extends ArrayList implements TextElementArray, LargeElement

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);
 
Field Summary
protected booleanaddedCompletely
Indicates if the Section was added completely to the document.
protected booleanbookmarkOpen
false if the bookmark children are not visible
protected StringbookmarkTitle
The bookmark title if different from the content title
protected booleancomplete
Indicates if the Section will be complete once added to the document.
protected floatindentation
The additional indentation of the content of this section.
protected floatindentationLeft
The indentation of this section on the left side.
protected floatindentationRight
The indentation of this section on the right side.
protected booleannotAddedYet
Indicates if this is the first time the section was added.
protected intnumberDepth
The number of sectionnumbers that has to be shown before the section title.
protected ArrayListnumbers
This is the complete list of sectionnumbers of this section and the parents of this section.
protected intnumberStyle
The style for sectionnumbers.
static intNUMBERSTYLE_DOTTED
A possible number style.
static intNUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT
A possible number style.
static longserialVersionUID
A serial version uid.
protected intsubsections
This is the number of subsections.
protected Paragraphtitle
The title of this section.
protected booleantriggerNewPage
true if the section has to trigger a new page
Constructor Summary
protected Section()
Constructs a new Section.
protected Section(Paragraph title, int numberDepth)
Constructs a new Section.
Method Summary
voidadd(int index, Object o)
Adds a Paragraph, List or Table to this Section.
booleanadd(Object o)
Adds a Paragraph, List, Table or another Section to this Section.
booleanaddAll(Collection collection)
Adds a collection of Elements to this Section.
MarkedSectionaddMarkedSection()
Adds a marked section.
SectionaddSection(float indentation, Paragraph title, int numberDepth)
Creates a Section, adds it to this Section and returns it.
SectionaddSection(float indentation, Paragraph title)
Creates a Section, adds it to this Section and returns it.
SectionaddSection(Paragraph title, int numberDepth)
Creates a Section, add it to this Section and returns it.
SectionaddSection(Paragraph title)
Creates a Section, adds it to this Section and returns it.
SectionaddSection(float indentation, String title, int numberDepth)
Adds a Section to this Section and returns it.
SectionaddSection(String title, int numberDepth)
Adds a Section to this Section and returns it.
SectionaddSection(float indentation, String title)
Adds a Section to this Section and returns it.
SectionaddSection(String title)
Adds a Section to this Section and 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.
voidflushContent()
ParagraphgetBookmarkTitle()
Gets the bookmark title.
ArrayListgetChunks()
Gets all the chunks in this element.
intgetDepth()
Returns the depth of this section.
floatgetIndentation()
Returns the indentation of the content of this Section.
floatgetIndentationLeft()
Returns the indentation of this Section on the left side.
floatgetIndentationRight()
Returns the indentation of this Section on the right side.
intgetNumberDepth()
Returns the numberdepth of this Section.
intgetNumberStyle()
Gets the style used for numbering sections.
ParagraphgetTitle()
Returns the title, preceded by a certain number of sectionnumbers.
protected booleanisAddedCompletely()
booleanisBookmarkOpen()
Getter for property bookmarkOpen.
booleanisChapter()
Checks if this object is a Chapter.
booleanisComplete()
booleanisContent()
booleanisNestable()
booleanisNotAddedYet()
Indicates if this is the first time the section is added.
booleanisSection()
Checks if this object is a Section.
booleanisTriggerNewPage()
Getter 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 an ElementListener.
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)
voidsetIndentation(float indentation)
Sets the indentation of the content of this Section.
voidsetIndentationLeft(float indentation)
Sets the indentation of this Section on the left side.
voidsetIndentationRight(float indentation)
Sets the indentation of this Section on 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.
voidsetNumbers(int number, ArrayList numbers)
Sets the number of this section.
voidsetNumberStyle(int numberStyle)
Sets the style for numbering sections.
voidsetTitle(Paragraph title)
Sets the title of this section.
voidsetTriggerNewPage(boolean triggerNewPage)
Setter for property triggerNewPage.
inttype()
Gets the type of the text element.

Field Detail

addedCompletely

protected boolean addedCompletely
Indicates if the Section was added completely to the document.

Since: iText 2.0.8

bookmarkOpen

protected boolean bookmarkOpen
false if the bookmark children are not visible

bookmarkTitle

protected String bookmarkTitle
The bookmark title if different from the content title

complete

protected boolean complete
Indicates if the Section will be complete once added to the document.

Since: iText 2.0.8

indentation

protected float indentation
The additional indentation of the content of this section.

indentationLeft

protected float indentationLeft
The indentation of this section on the left side.

indentationRight

protected float indentationRight
The indentation of this section on the right side.

notAddedYet

protected boolean notAddedYet
Indicates if this is the first time the section was added.

Since: iText 2.0.8

numberDepth

protected int numberDepth
The number of sectionnumbers that has to be shown before the section title.

numbers

protected ArrayList numbers
This is the complete list of sectionnumbers of this section and the parents of this section.

numberStyle

protected int numberStyle
The style for sectionnumbers.

Since: iText 2.0.8

NUMBERSTYLE_DOTTED

public static final int NUMBERSTYLE_DOTTED
A possible number style. The default number style: "1.2.3."

Since: iText 2.0.8

NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT

public static final int NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT
A possible number style. For instance: "1.2.3"

Since: iText 2.0.8

serialVersionUID

private static final long serialVersionUID
A serial version uid.

subsections

protected int subsections
This is the number of subsections.

title

protected Paragraph title
The title of this section.

triggerNewPage

protected boolean triggerNewPage
true if the section has to trigger a new page

Constructor Detail

Section

protected Section()
Constructs a new Section.

Section

protected Section(Paragraph title, int numberDepth)
Constructs a new Section.

Parameters: title a Paragraph numberDepth the numberDepth

Method Detail

add

public void add(int index, Object o)
Adds a Paragraph, List or Table to this Section.

Parameters: index index at which the specified element is to be inserted o an object of type Paragraph, List or Table=

Throws: ClassCastException if the object is not a Paragraph, List or Table

add

public boolean add(Object o)
Adds a Paragraph, List, Table or another Section to this Section.

Parameters: o an object of type Paragraph, List, Table or another Section

Returns: a boolean

Throws: ClassCastException if the object is not a Paragraph, List, Table or Section

addAll

public boolean addAll(Collection collection)
Adds a collection of Elements to this Section.

Parameters: collection a collection of Paragraphs, Lists and/or Tables

Returns: true if the action succeeded, false if not.

Throws: ClassCastException if one of the objects isn't a Paragraph, List, Table

addMarkedSection

public MarkedSection addMarkedSection()
Adds a marked section. For use in class MarkedSection only!

addSection

public Section addSection(float indentation, Paragraph title, int numberDepth)
Creates a Section, adds it to this Section and returns it.

Parameters: indentation the indentation of the new section title the title of the new section numberDepth the numberDepth of the section

Returns: a new Section object

addSection

public Section addSection(float indentation, Paragraph title)
Creates a Section, adds it to this Section and returns it.

Parameters: indentation the indentation of the new section title the title of the new section

Returns: a new Section object

addSection

public Section addSection(Paragraph title, int numberDepth)
Creates a Section, add it to this Section and returns it.

Parameters: title the title of the new section numberDepth the numberDepth of the section

Returns: a new Section object

addSection

public Section addSection(Paragraph title)
Creates a Section, adds it to this Section and returns it.

Parameters: title the title of the new section

Returns: a new Section object

addSection

public Section addSection(float indentation, String title, int numberDepth)
Adds a Section to this Section and returns it.

Parameters: indentation the indentation of the new section title the title of the new section numberDepth the numberDepth of the section

Returns: a new Section object

addSection

public Section addSection(String title, int numberDepth)
Adds a Section to this Section and returns it.

Parameters: title the title of the new section numberDepth the numberDepth of the section

Returns: a new Section object

addSection

public Section addSection(float indentation, String title)
Adds a Section to this Section and returns it.

Parameters: indentation the indentation of the new section title the title of the new section

Returns: a new Section object

addSection

public Section addSection(String title)
Adds a Section to this Section and returns it.

Parameters: title the title of the new section

Returns: a new Section object

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 section numbers a list of sectionnumbers numberDepth how many numbers have to be shown numberStyle the numbering style

Returns: a Paragraph object

Since: iText 2.0.8

flushContent

public void flushContent()

Since: iText 2.0.8

See Also: flushContent

getBookmarkTitle

public Paragraph getBookmarkTitle()
Gets the bookmark title.

Returns: the bookmark title

getChunks

public ArrayList getChunks()
Gets all the chunks in this element.

Returns: an ArrayList

getDepth

public int getDepth()
Returns the depth of this section.

Returns: the depth

getIndentation

public float getIndentation()
Returns the indentation of the content of this Section.

Returns: the indentation

getIndentationLeft

public float getIndentationLeft()
Returns the indentation of this Section on the left side.

Returns: the indentation

getIndentationRight

public float getIndentationRight()
Returns the indentation of this Section on the right side.

Returns: the indentation

getNumberDepth

public int getNumberDepth()
Returns the numberdepth of this Section.

Returns: the numberdepth

getNumberStyle

public int getNumberStyle()
Gets the style used for numbering sections.

Returns: a value corresponding with a numbering style

Since: iText 2.0.8

getTitle

public Paragraph getTitle()
Returns the title, preceded by a certain number of sectionnumbers.

Returns: a Paragraph

isAddedCompletely

protected boolean isAddedCompletely()

Since: iText 2.0.8

isBookmarkOpen

public boolean isBookmarkOpen()
Getter for property bookmarkOpen.

Returns: Value of property bookmarkOpen.

isChapter

public boolean isChapter()
Checks if this object is a Chapter.

Returns: true if it is a Chapter, false if it is a Section.

isComplete

public boolean isComplete()

Since: iText 2.0.8

See Also: isComplete

isContent

public boolean isContent()

Since: iText 2.0.8

See Also: isContent

isNestable

public boolean isNestable()

Since: iText 2.0.8

See Also: isNestable

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

isSection

public boolean isSection()
Checks if this object is a Section.

Returns: true if it is a Section, false if it is a Chapter.

isTriggerNewPage

public boolean isTriggerNewPage()
Getter for property bookmarkOpen.

Returns: Value of property triggerNewPage.

newPage

public void newPage()
Adds a new page to the section.

Since: 2.1.1

process

public boolean process(ElementListener listener)
Processes the element by adding it (or the different parts) to an ElementListener.

Parameters: listener the ElementListener

Returns: true if the element was processed successfully

setAddedCompletely

protected void setAddedCompletely(boolean addedCompletely)

Since: iText 2.0.8

setBookmarkOpen

public void setBookmarkOpen(boolean bookmarkOpen)
Setter for property bookmarkOpen.

Parameters: bookmarkOpen false if the bookmark children are not visible.

setBookmarkTitle

public void setBookmarkTitle(String bookmarkTitle)
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

setChapterNumber

public void setChapterNumber(int number)
Changes the Chapter number.

setComplete

public void setComplete(boolean complete)

Since: iText 2.0.8

See Also: LargeElement

setIndentation

public void setIndentation(float indentation)
Sets the indentation of the content of this Section.

Parameters: indentation the indentation

setIndentationLeft

public void setIndentationLeft(float indentation)
Sets the indentation of this Section on the left side.

Parameters: indentation the indentation

setIndentationRight

public void setIndentationRight(float indentation)
Sets the indentation of this Section on the right side.

Parameters: indentation the indentation

setNotAddedYet

public void setNotAddedYet(boolean notAddedYet)
Sets the indication if the section was already added to the document.

Parameters: notAddedYet

Since: iText2.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

setNumbers

private void setNumbers(int number, ArrayList numbers)
Sets the number of this section.

Parameters: number the number of this section numbers an ArrayList, containing the numbers of the Parent

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

setTitle

public void setTitle(Paragraph title)
Sets the title of this section.

Parameters: title the new title

setTriggerNewPage

public void setTriggerNewPage(boolean triggerNewPage)
Setter for property triggerNewPage.

Parameters: triggerNewPage true if a new page has to be triggered.

type

public int type()
Gets the type of the text element.

Returns: a type