Method from com.lowagie.text.Section Detail: |
public boolean add(Object o) {
if (isAddedCompletely()) {
throw new IllegalStateException("This LargeElement has already been added to the Document.");
}
try {
Element element = (Element) o;
if (element.type() == Element.SECTION) {
Section section = (Section) o;
section.setNumbers(++subsections, numbers);
return super.add(section);
}
else if (o instanceof MarkedSection && ((MarkedObject)o).element.type() == Element.SECTION) {
MarkedSection mo = (MarkedSection)o;
Section section = (Section)mo.element;
section.setNumbers(++subsections, numbers);
return super.add(mo);
}
else if (element.isNestable()) {
return super.add(o);
}
else {
throw new ClassCastException("You can't add a " + element.getClass().getName() + " to a Section.");
}
}
catch(ClassCastException cce) {
throw new ClassCastException("Insertion of illegal Element: " + cce.getMessage());
}
}
Adds a Paragraph , List , Table or another Section
to this Section . |
public void add(int index,
Object o) {
if (isAddedCompletely()) {
throw new IllegalStateException("This LargeElement has already been added to the Document.");
}
try {
Element element = (Element) o;
if (element.isNestable()) {
super.add(index, element);
}
else {
throw new ClassCastException("You can't add a " + element.getClass().getName() + " to a Section.");
}
}
catch(ClassCastException cce) {
throw new ClassCastException("Insertion of illegal Element: " + cce.getMessage());
}
}
Adds a Paragraph , List or Table
to this Section . |
public boolean addAll(Collection collection) {
for (Iterator iterator = collection.iterator(); iterator.hasNext(); ) {
this.add(iterator.next());
}
return true;
}
Adds a collection of Element s
to this Section . |
public MarkedSection addMarkedSection() {
MarkedSection section = new MarkedSection(new Section(null, numberDepth + 1));
add(section);
return section;
}
Adds a marked section. For use in class MarkedSection only! |
public Section addSection(Paragraph title) {
return addSection(0, title, numberDepth + 1);
}
Creates a Section , adds it to this Section and returns it. |
public Section addSection(String title) {
return addSection(new Paragraph(title));
}
Adds a Section to this Section and returns it. |
public Section addSection(float indentation,
Paragraph title) {
return addSection(indentation, title, numberDepth + 1);
}
Creates a Section , adds it to this Section and returns it. |
public Section addSection(Paragraph title,
int numberDepth) {
return addSection(0, title, numberDepth);
}
Creates a Section , add it to this Section and returns it. |
public Section addSection(String title,
int numberDepth) {
return addSection(new Paragraph(title), numberDepth);
}
Adds a Section to this Section and returns it. |
public Section addSection(float indentation,
String title) {
return addSection(indentation, new Paragraph(title));
}
Adds a Section to this Section and returns it. |
public Section addSection(float indentation,
Paragraph title,
int numberDepth) {
if (isAddedCompletely()) {
throw new IllegalStateException("This LargeElement has already been added to the Document.");
}
Section section = new Section(title, numberDepth);
section.setIndentation(indentation);
add(section);
return section;
}
Creates a Section , adds it to this Section and returns it. |
public Section addSection(float indentation,
String title,
int numberDepth) {
return addSection(indentation, new Paragraph(title), numberDepth);
}
Adds a Section to this Section and returns it. |
public static Paragraph constructTitle(Paragraph title,
ArrayList numbers,
int numberDepth,
int numberStyle) {
if (title == null) {
return null;
}
int depth = Math.min(numbers.size(), numberDepth);
if (depth < 1) {
return title;
}
StringBuffer buf = new StringBuffer(" ");
for (int i = 0; i < depth; i++) {
buf.insert(0, ".");
buf.insert(0, ((Integer) numbers.get(i)).intValue());
}
if (numberStyle == NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT) {
buf.deleteCharAt(buf.length() - 2);
}
Paragraph result = new Paragraph(title);
result.add(0, new Chunk(buf.toString(), title.getFont()));
return result;
}
Constructs a Paragraph that will be used as title for a Section or Chapter. |
public void flushContent() {
setNotAddedYet(false);
title = null;
Element element;
for (Iterator i = iterator(); i.hasNext(); ) {
element = (Element)i.next();
if (element instanceof Section) {
Section s = (Section)element;
if (!s.isComplete() && size() == 1) {
s.flushContent();
return;
}
else {
s.setAddedCompletely(true);
}
}
i.remove();
}
}
|
public Paragraph getBookmarkTitle() {
if (bookmarkTitle == null)
return getTitle();
else
return new Paragraph(bookmarkTitle);
}
|
public ArrayList getChunks() {
ArrayList tmp = new ArrayList();
for (Iterator i = iterator(); i.hasNext(); ) {
tmp.addAll(((Element) i.next()).getChunks());
}
return tmp;
}
Gets all the chunks in this element. |
public int getDepth() {
return numbers.size();
}
Returns the depth of this section. |
public float getIndentation() {
return indentation;
}
Returns the indentation of the content of this Section . |
public float getIndentationLeft() {
return indentationLeft;
}
Returns the indentation of this Section on the left side. |
public float getIndentationRight() {
return indentationRight;
}
Returns the indentation of this Section on the right side. |
public int getNumberDepth() {
return numberDepth;
}
Returns the numberdepth of this Section . |
public int getNumberStyle() {
return numberStyle;
}
Gets the style used for numbering sections. |
public Paragraph getTitle() {
return constructTitle(title, numbers, numberDepth, numberStyle);
}
Returns the title, preceded by a certain number of sectionnumbers. |
protected boolean isAddedCompletely() {
return addedCompletely;
}
|
public boolean isBookmarkOpen() {
return bookmarkOpen;
}
Getter for property bookmarkOpen. |
public boolean isChapter() {
return type() == Element.CHAPTER;
}
Checks if this object is a Chapter . |
public boolean isComplete() {
return complete;
}
|
public boolean isContent() {
return true;
}
|
public boolean isNestable() {
return false;
}
|
public boolean isNotAddedYet() {
return notAddedYet;
}
Indicates if this is the first time the section is added. |
public boolean isSection() {
return type() == Element.SECTION;
}
Checks if this object is a Section . |
public boolean isTriggerNewPage() {
return triggerNewPage && notAddedYet;
}
Getter for property bookmarkOpen. |
public void newPage() {
this.add(Chunk.NEXTPAGE);
}
Adds a new page to the section. |
public boolean process(ElementListener listener) {
try {
Element element;
for (Iterator i = iterator(); i.hasNext(); ) {
element = (Element)i.next();
listener.add(element);
}
return true;
}
catch(DocumentException de) {
return false;
}
}
Processes the element by adding it (or the different parts) to an
ElementListener . |
protected void setAddedCompletely(boolean addedCompletely) {
this.addedCompletely = addedCompletely;
}
|
public void setBookmarkOpen(boolean bookmarkOpen) {
this.bookmarkOpen = bookmarkOpen;
}
Setter for property bookmarkOpen. |
public void setBookmarkTitle(String bookmarkTitle) {
this.bookmarkTitle = bookmarkTitle;
}
Sets the bookmark title. The bookmark title is the same as the section title but
can be changed with this method. |
public void setChapterNumber(int number) {
numbers.set(numbers.size() - 1, new Integer(number));
Object s;
for (Iterator i = iterator(); i.hasNext(); ) {
s = i.next();
if (s instanceof Section) {
((Section)s).setChapterNumber(number);
}
}
}
Changes the Chapter number. |
public void setComplete(boolean complete) {
this.complete = complete;
}
|
public void setIndentation(float indentation) {
this.indentation = indentation;
}
Sets the indentation of the content of this Section . |
public void setIndentationLeft(float indentation) {
indentationLeft = indentation;
}
Sets the indentation of this Section on the left side. |
public void setIndentationRight(float indentation) {
indentationRight = indentation;
}
Sets the indentation of this Section on the right side. |
public void setNotAddedYet(boolean notAddedYet) {
this.notAddedYet = notAddedYet;
}
Sets the indication if the section was already added to
the document. |
public void setNumberDepth(int numberDepth) {
this.numberDepth = 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. |
public void setNumberStyle(int numberStyle) {
this.numberStyle = 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 |
public void setTitle(Paragraph title) {
this.title = title;
}
Sets the title of this section. |
public void setTriggerNewPage(boolean triggerNewPage) {
this.triggerNewPage = triggerNewPage;
}
Setter for property triggerNewPage. |
public int type() {
return Element.SECTION;
}
Gets the type of the text element. |