public class Section extends ArrayList<Element> implements TextElementArray, LargeElement, Indentable, IAccessibleElement
Section
is a part of a Document
containing other Section
s, Paragraph
s, List
and/or Table
s.
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);
Modifier and Type | Field and Description |
---|---|
protected boolean |
addedCompletely
Indicates if the Section was added completely to the document.
|
protected boolean |
bookmarkOpen
false if the bookmark children are not visible
|
protected String |
bookmarkTitle
The bookmark title if different from the content title
|
protected boolean |
complete
Indicates if the Section will be complete once added to the document.
|
protected float |
indentation
The additional indentation of the content of this section.
|
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 boolean |
notAddedYet
Indicates if this is the first time the section was added.
|
protected int |
numberDepth
The number of sectionnumbers that has to be shown before the section title.
|
protected ArrayList<Integer> |
numbers
This is the complete list of sectionnumbers of this section and the parents of this section.
|
protected int |
numberStyle
The style for sectionnumbers.
|
static int |
NUMBERSTYLE_DOTTED
A possible number style.
|
static int |
NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT
A possible number style.
|
protected int |
subsections
This is the number of subsections.
|
protected Paragraph |
title
The title of this section.
|
protected boolean |
triggerNewPage
true if the section has to trigger a new page
|
modCount
ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_JUSTIFIED, ALIGN_JUSTIFIED_ALL, ALIGN_LEFT, ALIGN_MIDDLE, ALIGN_RIGHT, ALIGN_TOP, ALIGN_UNDEFINED, ANCHOR, ANNOTATION, AUTHOR, BODY, CCITT_BLACKIS1, CCITT_ENCODEDBYTEALIGN, CCITT_ENDOFBLOCK, CCITT_ENDOFLINE, CCITTG3_1D, CCITTG3_2D, CCITTG4, CHAPTER, CHUNK, CREATIONDATE, CREATOR, DIV, HEADER, IMGRAW, IMGTEMPLATE, JBIG2, JPEG, JPEG2000, KEYWORDS, LANGUAGE, LIST, LISTITEM, MARKED, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, SECTION, SUBJECT, TITLE, WRITABLE_DIRECT, YMARK
Modifier | Constructor and Description |
---|---|
protected |
Section()
Constructs a new Section .
|
protected |
Section(Paragraph title, int numberDepth)
Constructs a new Section .
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(Element element)
Adds a Paragraph , List , Table or another Section to this Section .
|
void |
add(int index, Element element)
Adds a Paragraph , List or Table to this Section .
|
boolean |
addAll(Collection extends Element> collection)
Adds a collection of Element s to this Section .
|
protected MarkedSection |
addMarkedSection()
Adds a marked section.
|
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.
|
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(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(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.
|
static Paragraph |
constructTitle(Paragraph title, ArrayList<Integer> numbers, int numberDepth, int numberStyle)
Constructs a Paragraph that will be used as title for a Section or Chapter.
|
void |
flushContent()
Flushes the content that has been added.
|
PdfObject |
getAccessibleAttribute(PdfName key)
Get the attribute of accessible element (everything in A dictionary + Lang , Alt , ActualText , E ).
|
HashMap<PdfName,PdfObject> |
getAccessibleAttributes()
Gets all the properties of accessible element.
|
Paragraph |
getBookmarkTitle()
Gets the bookmark title.
|
List<Chunk> |
getChunks()
Gets all the chunks in this element.
|
int |
getDepth()
Returns the depth of this section.
|
AccessibleElementId |
getId() |
float |
getIndentation()
Returns the indentation of the content of this Section .
|
float |
getIndentationLeft()
Returns the indentation of this Section on the left side.
|
float |
getIndentationRight()
Returns the indentation of this Section on the right side.
|
int |
getNumberDepth()
Returns the numberdepth of this Section .
|
int |
getNumberStyle()
Gets the style used for numbering sections.
|
PdfName |
getRole()
Gets the role of the accessible element.
|
Paragraph |
getTitle()
Returns the title, preceded by a certain number of sectionnumbers.
|
protected boolean |
isAddedCompletely() |
boolean |
isBookmarkOpen()
Getter for property bookmarkOpen.
|
boolean |
isChapter()
Checks if this object is a Chapter .
|
boolean |
isComplete()
Indicates if the element is complete or not.
|
boolean |
isContent()
Checks if this element is a content object.
|
boolean |
isInline() |
boolean |
isNestable()
Checks if this element is nestable.
|
boolean |
isNotAddedYet()
Indicates if this is the first time the section is added.
|
boolean |
isSection()
Checks if this object is a Section .
|
boolean |
isTriggerNewPage()
Getter for property bookmarkOpen.
|
void |
newPage()
Adds a new page to the section.
|
boolean |
process(ElementListener listener)
Processes the element by adding it (or the different parts) to an ElementListener .
|
void |
setAccessibleAttribute(PdfName key, PdfObject value)
Set the attribute of accessible element (everything in A dictionary + Lang , Alt , ActualText , E ).
|
protected void |
setAddedCompletely(boolean addedCompletely) |
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 |
setComplete(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.
|
void |
setId(AccessibleElementId id) |
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 |
setNotAddedYet(boolean notAddedYet)
Sets the indication if the section was already added to the document.
|
void |
setNumberDepth(int numberDepth)
Sets the depth of the sectionnumbers that will be shown preceding the title.
|
void |
setNumberStyle(int numberStyle)
Sets the style for numbering sections.
|
void |
setRole(PdfName role)
Sets the role of the accessiblee element.
|
void |
setTitle(Paragraph title)
Sets the title of this section.
|
void |
setTriggerNewPage(boolean triggerNewPage)
Setter for property triggerNewPage.
|
int |
type()
Gets the type of the text element.
|
addAll, clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
equals, hashCode
containsAll, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
containsAll, equals, hashCode
parallelStream, stream
public static final int NUMBERSTYLE_DOTTED
public static final int NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT
protected Paragraph title
protected String bookmarkTitle
protected int numberDepth
protected int numberStyle
protected float indentationLeft
protected float indentationRight
protected float indentation
protected boolean bookmarkOpen
protected boolean triggerNewPage
protected int subsections
protected ArrayList<Integer> numbers
protected boolean complete
protected boolean addedCompletely
protected boolean notAddedYet
protected Section()
Section
.
protected Section(Paragraph title, int numberDepth)
Section
.
title
- a Paragraph
numberDepth
- the numberDepth
public boolean process(ElementListener listener)
ElementListener
.
public int type()
public boolean isChapter()
Chapter
.
true
if it is a Chapter
, false
if it is a Section
.
public boolean isSection()
Section
.
true
if it is a Section
, false
if it is a Chapter
.
public boolean isContent()
Element
isContent
in interface Element
Element.isContent()
public boolean isNestable()
Element
isNestable
in interface Element
Element.isNestable()
public void add(int index, Element element)
Paragraph
, List
or Table
to this Section
.
add
in interface List<Element>
add
in class ArrayList<Element>
index
- index at which the specified element is to be inserted
element
- an element of type Paragraph
, List
or Table
=
ClassCastException
- if the object is not a Paragraph
, List
or Table
public boolean add(Element element)
Paragraph
, List
, Table
or another Section
to this Section
.
add
in interface TextElementArray
add
in interface Collection<Element>
add
in interface List<Element>
add
in class ArrayList<Element>
element
- an element of type Paragraph
, List
, Table
or another Section
ClassCastException
- if the object is not a Paragraph
, List
, Table
or Section
public boolean addAll(Collection extends Element> collection)
Element
s to this Section
.
addAll
in interface Collection<Element>
addAll
in interface List<Element>
addAll
in class ArrayList<Element>
collection
- a collection of Paragraph
s, List
s and/or Table
s
true
if the action succeeded, false
if not.
ClassCastException
- if one of the objects isn't a Paragraph
, List
, Table
public Section addSection(float indentation, Paragraph title, int numberDepth)
Section
, adds it to this Section
and returns it.
indentation
- the indentation of the new section
title
- the title of the new section
numberDepth
- the numberDepth of the section
public Section addSection(float indentation, Paragraph title)
Section
, adds it to this Section
and returns it.
indentation
- the indentation of the new section
title
- the title of the new section
public Section addSection(Paragraph title, int numberDepth)
Section
, add it to this Section
and returns it.
title
- the title of the new section
numberDepth
- the numberDepth of the section
protected MarkedSection addMarkedSection()
public Section addSection(Paragraph title)
Section
, adds it to this Section
and returns it.
title
- the title of the new section
public Section addSection(float indentation, String title, int numberDepth)
Section
to this Section
and returns it.
indentation
- the indentation of the new section
title
- the title of the new section
numberDepth
- the numberDepth of the section
public Section addSection(String title, int numberDepth)
Section
to this Section
and returns it.
title
- the title of the new section
numberDepth
- the numberDepth of the section
public Section addSection(float indentation, String title)
Section
to this Section
and returns it.
indentation
- the indentation of the new section
title
- the title of the new section
public Section addSection(String title)
Section
to this Section
and returns it.
title
- the title of the new section
public void setTitle(Paragraph title)
title
- the new title
public Paragraph getTitle()
Paragraph
public static Paragraph constructTitle(Paragraph title, ArrayList<Integer> numbers, int numberDepth, int numberStyle)
title
- the title of the section
numbers
- a list of sectionnumbers
numberDepth
- how many numbers have to be shown
numberStyle
- the numbering style
public void setNumberDepth(int numberDepth)
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.
numberDepth
- the new numberDepth
public int getNumberDepth()
Section
.
public void setNumberStyle(int numberStyle)
NUMBERSTYLE_DOTTED
: 1.2.3. (the default) or NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT
: 1.2.3
numberStyle
- the style to use
public int getNumberStyle()
public void setIndentationLeft(float indentation)
Section
on the left side.
setIndentationLeft
in interface Indentable
indentation
- the indentation
public float getIndentationLeft()
Section
on the left side.
getIndentationLeft
in interface Indentable
public void setIndentationRight(float indentation)
Section
on the right side.
setIndentationRight
in interface Indentable
indentation
- the indentation
public float getIndentationRight()
Section
on the right side.
getIndentationRight
in interface Indentable
public void setIndentation(float indentation)
Section
.
indentation
- the indentation
public float getIndentation()
Section
.
public void setBookmarkOpen(boolean bookmarkOpen)
bookmarkOpen
- false if the bookmark children are not visible.
public boolean isBookmarkOpen()
public void setTriggerNewPage(boolean triggerNewPage)
triggerNewPage
- true if a new page has to be triggered.
public boolean isTriggerNewPage()
public void setBookmarkTitle(String bookmarkTitle)
bookmarkTitle
- the bookmark title
public Paragraph getBookmarkTitle()
public void setChapterNumber(int number)
number
- the new number
public int getDepth()
public boolean isNotAddedYet()
public void setNotAddedYet(boolean notAddedYet)
notAddedYet
-
protected boolean isAddedCompletely()
protected void setAddedCompletely(boolean addedCompletely)
addedCompletely
- true if section was completely added, false otherwise
public void flushContent()
LargeElement
flushContent
in interface LargeElement
LargeElement.flushContent()
public boolean isComplete()
LargeElement
isComplete
in interface LargeElement
LargeElement.isComplete()
public void setComplete(boolean complete)
LargeElement
setComplete
in interface LargeElement
complete
- false if you'll be adding more data after adding the object to the document.
LargeElement.setComplete(boolean)
public void newPage()
public PdfObject getAccessibleAttribute(PdfName key)
IAccessibleElement
A
dictionary + Lang
, Alt
, ActualText
, E
).
getAccessibleAttribute
in interface IAccessibleElement
public void setAccessibleAttribute(PdfName key, PdfObject value)
IAccessibleElement
A
dictionary + Lang
, Alt
, ActualText
, E
).
setAccessibleAttribute
in interface IAccessibleElement
public HashMap<PdfName,PdfObject> getAccessibleAttributes()
IAccessibleElement
getAccessibleAttributes
in interface IAccessibleElement
public PdfName getRole()
IAccessibleElement
getRole
in interface IAccessibleElement
public void setRole(PdfName role)
IAccessibleElement
null
if you don't want to tag this element. Note that all child elements won't also be tagged.
setRole
in interface IAccessibleElement
public AccessibleElementId getId()
getId
in interface IAccessibleElement
public void setId(AccessibleElementId id)
setId
in interface IAccessibleElement
public boolean isInline()
isInline
in interface IAccessibleElement
Copyright © 1998–2022. All rights reserved.