com.lowagie.text

Class Section

Implemented Interfaces:
Element, TextElementArray
Known Direct Subclasses:
Chapter

public class Section
extends ArrayList
implements TextElementArray

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 boolean
bookmarkOpen
false if the bookmark children are not visible
protected String
bookmarkTitle
The bookmark title if different from the content title
protected float
indentationLeft
The indentation of this section on the left side.
protected float
indentationRight
The indentation of this section on the right side.
protected int
numberDepth
This is the number of sectionnumbers that has to be shown before the section title.
protected ArrayList
numbers
This is the complete list of sectionnumbers of this section and the parents of this section.
protected float
sectionIndent
The additional indentation of the content of this section.
private static long
serialVersionUID
protected int
subsections
This is the number of subsections.
protected Paragraph
title
This is the title of this section.
protected boolean
triggerNewPage
true if the section has to trigger a new page

Fields 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, CCITTG3_1D, CCITTG3_2D, CCITTG4, CCITT_BLACKIS1, CCITT_ENCODEDBYTEALIGN, CCITT_ENDOFBLOCK, CCITT_ENDOFLINE, CELL, CHAPTER, CHUNK, CREATIONDATE, CREATOR, HEADER, IMGRAW, IMGTEMPLATE, JPEG, KEYWORDS, LIST, LISTITEM, MARKED, MULTI_COLUMN_TEXT, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, ROW, SECTION, SUBJECT, TABLE, TITLE

Constructor Summary

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

Method Summary

boolean
add(Object o)
Adds a Paragraph, List, Table or another Section to this Section.
void
add(int index, Object o)
Adds a Paragraph, List or Table to this Section.
boolean
addAll(Collection collection)
Adds a collection of Elements to this Section.
MarkedSection
addMarkedSection()
Adds a marked section.
Section
addSection(Properties attributes)
Creates a given Section following a set of attributes and adds it to this one.
Section
addSection(String title)
Adds a Section to this Section and returns it.
Section
addSection(String title, int numberDepth)
Adds a Section to this Section and returns it.
Section
addSection(Paragraph title)
Creates a Section, adds it to this Section and returns it.
Section
addSection(Paragraph title, int numberDepth)
Creates a Section, add it to this Section and returns it.
Section
addSection(float indentation, String title)
Adds a Section to this Section and returns it.
Section
addSection(float indentation, String title, int numberDepth)
Adds a Section to this Section and returns it.
Section
addSection(float indentation, Paragraph title)
Creates a Section, adds it to this Section and returns it.
Section
addSection(float indentation, Paragraph title, int numberDepth)
Creates a Section, adds it to this Section and returns it.
int
depth()
Returns the depth of this section.
Paragraph
getBookmarkTitle()
Gets the bookmark title.
ArrayList
getChunks()
Gets all the chunks in this element.
float
indentation()
Returns the indentation of the content of this Section.
float
indentationLeft()
Returns the indentation of this Section on the left side.
float
indentationRight()
Returns the indentation of this Section on the right side.
boolean
isBookmarkOpen()
Getter for property bookmarkOpen.
boolean
isChapter()
Checks if this object is a Chapter.
boolean
isSection()
Checks if this object is a Section.
static boolean
isTag(String tag)
Checks if a given tag corresponds with this object.
static boolean
isTitle(String tag)
Checks if a given tag corresponds with a title tag for this object.
boolean
isTriggerNewPage()
Getter for property bookmarkOpen.
int
numberDepth()
Returns the numberdepth of this Section.
boolean
process(ElementListener listener)
Processes the element by adding it (or the different parts) to an ElementListener.
void
set(Properties attributes)
Alters the attributes of this Section.
void
setBookmarkOpen(boolean bookmarkOpen)
Setter for property bookmarkOpen.
void
setBookmarkTitle(String bookmarkTitle)
Sets the bookmark title.
void
setChapterNumber(int number)
Changes the Chapter number.
void
setIndentation(float indentation)
Sets the indentation of the content of this Section.
void
setIndentationLeft(float indentation)
Sets the indentation of this Section on the left side.
void
setIndentationRight(float indentation)
Sets the indentation of this Section on the right side.
void
setNumberDepth(int numberDepth)
Sets the depth of the sectionnumbers that will be shown preceding the title.
private void
setNumbers(int number, ArrayList numbers)
Sets the number of this section.
void
setTitle(Paragraph title)
Sets the title of this section.
void
setTriggerNewPage(boolean triggerNewPage)
Setter for property triggerNewPage.
Paragraph
title()
Returns the title, preceeded by a certain number of sectionnumbers.
int
type()
Gets the type of the text element.

Field Details

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

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.

numberDepth

protected int numberDepth
This is 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.

sectionIndent

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

serialVersionUID

private static final long serialVersionUID
Field Value:
3324172577544748043L

subsections

protected int subsections
This is the number of subsections.

title

protected Paragraph title
This is the title of this section.

triggerNewPage

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

Constructor Details

Section

protected Section()
Constructs a new Section.

Section

(package private)  Section(Paragraph title,
                           int numberDepth)
Constructs a new Section.
Parameters:
title - a Paragraph
numberDepth - the numberDepth

Method Details

add

public boolean add(Object o)
Adds a Paragraph, List, Table or another Section to this Section.
Specified by:
add in interface TextElementArray
Parameters:
o - an object of type Paragraph, List, Table or another Section
Returns:
a boolean

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=

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.

addMarkedSection

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

addSection

public Section addSection(Properties attributes)
Creates a given Section following a set of attributes and adds it to this one.
Parameters:
attributes - the attributes
Returns:
a Section

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

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(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(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(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(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(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(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

depth

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

getBookmarkTitle

public Paragraph getBookmarkTitle()
Gets the bookmark title.
Returns:
the bookmark title

getChunks

public ArrayList getChunks()
Gets all the chunks in this element.
Specified by:
getChunks in interface Element
Returns:
an ArrayList

indentation

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

indentationLeft

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

indentationRight

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

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.

isSection

public boolean isSection()
Checks if this object is a Section.
Returns:
true if it is a Section, false if it is a Chapter.

isTag

public static boolean isTag(String tag)
Checks if a given tag corresponds with this object.
Parameters:
tag - the given tag
Returns:
true if the tag corresponds

isTitle

public static boolean isTitle(String tag)
Checks if a given tag corresponds with a title tag for this object.
Parameters:
tag - the given tag
Returns:
true if the tag corresponds

isTriggerNewPage

public boolean isTriggerNewPage()
Getter for property bookmarkOpen.
Returns:
Value of property triggerNewPage.

numberDepth

public int numberDepth()
Returns the numberdepth of this Section.
Returns:
the numberdepth

process

public boolean process(ElementListener listener)
Processes the element by adding it (or the different parts) to an ElementListener.
Specified by:
process in interface Element
Parameters:
listener - the ElementListener
Returns:
true if the element was processed successfully

set

public void set(Properties attributes)
Alters the attributes of this Section.
Parameters:
attributes - the attributes

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.

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

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

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.

title

public Paragraph title()
Returns the title, preceeded by a certain number of sectionnumbers.
Returns:
a Paragraph

type

public int type()
Gets the type of the text element.
Specified by:
type in interface Element
Returns:
a type