org.odftoolkit.simple.draw
Class Textbox

java.lang.Object
  extended by org.odftoolkit.simple.Component
      extended by org.odftoolkit.simple.draw.Frame
          extended by org.odftoolkit.simple.draw.Textbox
All Implemented Interfaces:
ListContainer, ParagraphContainer

public class Textbox
extends Frame
implements ListContainer, ParagraphContainer

This class provides method to set the content, properties and style of text box.

Since:
0.5

Field Summary
 
Fields inherited from class org.odftoolkit.simple.draw.Frame
mElement, mFrameContainer, mOwnerDocument, mStyleHandler
 
Method Summary
 List addList()
          Add a new List to this container.
 List addList(ListDecorator decorator)
          Add a List with specified ListDecorator to this container.
 Paragraph addParagraph(String textContent)
          Add paragraph at the end of the container with specified text content.
 void clearContent()
          Remove all the content of this text box.
 void clearList()
          Remove all Lists from this container.
static Textbox getInstanceof(DrawTextBoxElement element)
          Get a text box instance by an instance of DrawTextBoxElement .
 OdfElement getListContainerElement()
          Get the ODF element which can have as child element directly according to ODF specification.
 Iterator<List> getListIterator()
          Return an Iterator of the Lists in this ListContainer.
 DrawTextBoxElement getOdfElement()
          Get the instance of DrawTextBoxElement which represents this frame.
 Paragraph getParagraphByIndex(int index, boolean isEmptyParagraphSkipped)
          Return a paragraph with a given index.
 Paragraph getParagraphByReverseIndex(int reverseIndex, boolean isEmptyParagraphSkipped)
          Return a paragraph with a given index.
 OdfElement getParagraphContainerElement()
          Get the ODF element which can have as child element directly.
 Iterator<Paragraph> getParagraphIterator()
          Return an Iterator of the paragraph in this container.
 String getTextContent()
          Get the text content of this text box.
static Textbox newTextbox(TextboxContainer container)
          Create an instance of frame
 boolean removeList(List list)
          Remove the existing List from this container.
 boolean removeParagraph(Paragraph para)
          Remove paragraph from the container
 void setTextContent(String content)
          Set the text content of this text box.
 
Methods inherited from class org.odftoolkit.simple.draw.Frame
getDesciption, getDrawFrameElement, getHyperlink, getInstanceof, getName, getRectangle, getStyleHandler, getTitle, newFrame, setBackgroundColor, setDescription, setHyperlink, setImage, setName, setRectangle, setTitle
 
Methods inherited from class org.odftoolkit.simple.Component
getComponentByElement, getOwnerDocument, registerComponent, unregisterComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstanceof

public static Textbox getInstanceof(DrawTextBoxElement element)
Get a text box instance by an instance of DrawTextBoxElement .

Parameters:
element - - the instance of DrawTextBoxElement
Returns:
an instance of text box

newTextbox

public static Textbox newTextbox(TextboxContainer container)
Create an instance of frame

The frame will be added at the end of this container.

Parameters:
container - - the frame container that contains this frame.

setTextContent

public void setTextContent(String content)
Set the text content of this text box.

This method will clear the content at first, and then create a paragraph with the given content.

Parameters:
content - - the text content
See Also:
clearContent(), addParagraph(String textContent)

clearContent

public void clearContent()
Remove all the content of this text box.


getTextContent

public String getTextContent()
Get the text content of this text box.

Returns:
- the text content
See Also:
TextExtractor.getText(OdfElement)

getOdfElement

public DrawTextBoxElement getOdfElement()
Get the instance of DrawTextBoxElement which represents this frame.

Overrides:
getOdfElement in class Frame
Returns:
the instance of DrawTextBoxElement

addList

public List addList()
Description copied from interface: ListContainer
Add a new List to this container.

Specified by:
addList in interface ListContainer
Returns:
added list.

addList

public List addList(ListDecorator decorator)
Description copied from interface: ListContainer
Add a List with specified ListDecorator to this container.

Specified by:
addList in interface ListContainer
Parameters:
decorator - the specified ListDecorator
Returns:
added list.

clearList

public void clearList()
Description copied from interface: ListContainer
Remove all Lists from this container.

Specified by:
clearList in interface ListContainer

getListContainerElement

public OdfElement getListContainerElement()
Description copied from interface: ListContainer
Get the ODF element which can have as child element directly according to ODF specification. This Element will help to find the position to insert a new List. For example, element is usable with element, so TextDocument will return OfficeTextElement. While Presentation Notes is an indirectly ListContainer, which holds List with the help of its grand-child element , so for Notes, DrawTextBoxElement should be return.

Specified by:
getListContainerElement in interface ListContainer
Returns:
container element which can hold .

getListIterator

public Iterator<List> getListIterator()
Description copied from interface: ListContainer
Return an Iterator of the Lists in this ListContainer. The Lists are iterated in the same order that they occur in the ListContainer.

Specified by:
getListIterator in interface ListContainer
Returns:
an Iterator of the Lists in this ListContainer
See Also:
Iterator

removeList

public boolean removeList(List list)
Description copied from interface: ListContainer
Remove the existing List from this container.

Specified by:
removeList in interface ListContainer
Returns:
true, if the container contains this List.

addParagraph

public Paragraph addParagraph(String textContent)
Description copied from interface: ParagraphContainer
Add paragraph at the end of the container with specified text content.

Specified by:
addParagraph in interface ParagraphContainer
Parameters:
textContent - - the text content
Returns:
an instance of paragraph

getParagraphContainerElement

public OdfElement getParagraphContainerElement()
Description copied from interface: ParagraphContainer
Get the ODF element which can have as child element directly.

Specified by:
getParagraphContainerElement in interface ParagraphContainer
Returns:
- an ODF element which can have paragraph as child

removeParagraph

public boolean removeParagraph(Paragraph para)
Description copied from interface: ParagraphContainer
Remove paragraph from the container

Specified by:
removeParagraph in interface ParagraphContainer
Parameters:
para - - the instance of paragraph
Returns:
true if the paragraph is removed successfully, false if errors happen.

getParagraphByIndex

public Paragraph getParagraphByIndex(int index,
                                     boolean isEmptyParagraphSkipped)
Description copied from interface: ParagraphContainer
Return a paragraph with a given index.

An index of zero represents the first paragraph.

If empty paragraph is skipped, the empty paragraph won't be counted.

Specified by:
getParagraphByIndex in interface ParagraphContainer
Parameters:
index - - the index started from 0.
isEmptyParagraphSkipped - - whether the empty paragraph is skipped or not
Returns:
the paragraph with a given index

getParagraphByReverseIndex

public Paragraph getParagraphByReverseIndex(int reverseIndex,
                                            boolean isEmptyParagraphSkipped)
Description copied from interface: ParagraphContainer
Return a paragraph with a given index. The index is in reverse order.

An index of zero represents the last paragraph.

If empty paragraph is skipped, the empty paragraph won't be counted.

Specified by:
getParagraphByReverseIndex in interface ParagraphContainer
Parameters:
reverseIndex - - the index started from 0 in reverse order.
isEmptyParagraphSkipped - - whether the empty paragraph is skipped or not
Returns:
the paragraph with a given index

getParagraphIterator

public Iterator<Paragraph> getParagraphIterator()
Description copied from interface: ParagraphContainer
Return an Iterator of the paragraph in this container.

Specified by:
getParagraphIterator in interface ParagraphContainer
Returns:
an Iterator of the paragraph in this container


Copyright © 2010-2017 The Apache Software Foundation. All Rights Reserved.