|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<Element>
com.itextpdf.text.Phrase
public class Phrase
A Phrase is a series of Chunks.
A Phrase has a main Font, but some chunks
within the phrase can have a Font that differs from the
main Font. All the Chunks in a Phrase
have the same leading.
Example:
// When no parameters are passed, the default leading = 16
Phrase phrase0 = new Phrase();
Phrase phrase1 = new Phrase("this is a phrase");
// In this example the leading is passed as a parameter
Phrase phrase2 = new Phrase(16, "this is a phrase with leading 16");
// When a Font is passed (explicitly or embedded in a chunk), the default leading = 1.5 * size of the font
Phrase phrase3 = new Phrase("this is a phrase with a red, normal font Courier, size 12", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, new Color(255, 0, 0)));
Phrase phrase4 = new Phrase(new Chunk("this is a phrase"));
Phrase phrase5 = new Phrase(18, new Chunk("this is a phrase", FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD, new Color(255, 0, 0)));
Element,
Chunk,
Paragraph,
Anchor,
Serialized Form| Field Summary | |
|---|---|
protected Font |
font
This is the font of this phrase. |
protected HyphenationEvent |
hyphenation
Null, unless the Phrase has to be hyphenated. |
protected float |
leading
This is the leading of this phrase. |
| Fields inherited from class java.util.AbstractList |
|---|
modCount |
| Fields inherited from interface com.itextpdf.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, CCITT_BLACKIS1, CCITT_ENCODEDBYTEALIGN, CCITT_ENDOFBLOCK, CCITT_ENDOFLINE, CCITTG3_1D, CCITTG3_2D, CCITTG4, CHAPTER, CHUNK, CREATIONDATE, CREATOR, HEADER, IMGRAW, IMGTEMPLATE, JBIG2, JPEG, JPEG2000, KEYWORDS, LIST, LISTITEM, MARKED, MULTI_COLUMN_TEXT, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, SECTION, SUBJECT, TITLE, WRITABLE_DIRECT, YMARK |
| Constructor Summary | |
|---|---|
Phrase()
Constructs a Phrase without specifying a leading. |
|
Phrase(Chunk chunk)
Constructs a Phrase with a certain Chunk. |
|
Phrase(float leading)
Constructs a Phrase with a certain leading. |
|
Phrase(float leading,
Chunk chunk)
Constructs a Phrase with a certain Chunk
and a certain leading. |
|
Phrase(float leading,
java.lang.String string)
Constructs a Phrase with a certain leading and a certain String. |
|
Phrase(float leading,
java.lang.String string,
Font font)
Constructs a Phrase with a certain leading, a certain String
and a certain Font. |
|
Phrase(Phrase phrase)
Copy constructor for Phrase. |
|
Phrase(java.lang.String string)
Constructs a Phrase with a certain String. |
|
Phrase(java.lang.String string,
Font font)
Constructs a Phrase with a certain String and a certain Font. |
|
| Method Summary | |
|---|---|
boolean |
add(Element element)
Adds a Chunk, Anchor or another Phrase
to this Phrase. |
void |
add(int index,
Element element)
Adds a Chunk, an Anchor or another Phrase
to this Phrase. |
boolean |
add(java.lang.String s)
Adds a String to this Phrase. |
boolean |
addAll(java.util.Collection<? extends Element> collection)
Adds a collection of Chunks
to this Phrase. |
protected boolean |
addChunk(Chunk chunk)
Adds a Chunk. |
protected void |
addSpecial(Element object)
Adds an Element to the Paragraph. |
java.util.List<Chunk> |
getChunks()
Gets all the chunks in this element. |
java.lang.String |
getContent()
Returns the content as a String object. |
Font |
getFont()
Gets the font of the first Chunk that appears in this Phrase. |
HyphenationEvent |
getHyphenation()
Getter for the hyphenation settings. |
static Phrase |
getInstance(int leading,
java.lang.String string)
Gets a special kind of Phrase that changes some characters into corresponding symbols. |
static Phrase |
getInstance(int leading,
java.lang.String string,
Font font)
Gets a special kind of Phrase that changes some characters into corresponding symbols. |
static Phrase |
getInstance(java.lang.String string)
Gets a special kind of Phrase that changes some characters into corresponding symbols. |
float |
getLeading()
Gets the leading of this phrase. |
boolean |
hasLeading()
Checks you if the leading of this phrase is defined. |
boolean |
isContent()
Checks if this element is a content object. |
boolean |
isEmpty()
Checks is this Phrase contains no or 1 empty Chunk. |
boolean |
isNestable()
Checks if this element is nestable. |
boolean |
process(ElementListener listener)
Processes the element by adding it (or the different parts) to an ElementListener. |
void |
setFont(Font font)
Sets the main font of this phrase. |
void |
setHyphenation(HyphenationEvent hyphenation)
Setter for the hyphenation. |
void |
setLeading(float leading)
Sets the leading of this phrase. |
int |
type()
Gets the type of the text element. |
| Methods inherited from class java.util.ArrayList |
|---|
addAll, clear, clone, contains, ensureCapacity, get, indexOf, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize |
| Methods inherited from class java.util.AbstractList |
|---|
equals, hashCode, iterator, listIterator, listIterator, subList |
| Methods inherited from class java.util.AbstractCollection |
|---|
containsAll, removeAll, retainAll, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.itextpdf.text.Element |
|---|
toString |
| Methods inherited from interface java.util.List |
|---|
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList |
| Field Detail |
|---|
protected float leading
protected Font font
protected HyphenationEvent hyphenation
| Constructor Detail |
|---|
public Phrase()
Phrase without specifying a leading.
public Phrase(Phrase phrase)
Phrase.
phrase - the Phrase to copypublic Phrase(float leading)
Phrase with a certain leading.
leading - the leadingpublic Phrase(Chunk chunk)
Phrase with a certain Chunk.
chunk - a Chunk
public Phrase(float leading,
Chunk chunk)
Phrase with a certain Chunk
and a certain leading.
leading - the leadingchunk - a Chunkpublic Phrase(java.lang.String string)
Phrase with a certain String.
string - a String
public Phrase(java.lang.String string,
Font font)
Phrase with a certain String and a certain Font.
string - a Stringfont - a Font
public Phrase(float leading,
java.lang.String string)
Phrase with a certain leading and a certain String.
leading - the leadingstring - a String
public Phrase(float leading,
java.lang.String string,
Font font)
Phrase with a certain leading, a certain String
and a certain Font.
leading - the leadingstring - a Stringfont - a Font| Method Detail |
|---|
public boolean process(ElementListener listener)
ElementListener.
process in interface Elementlistener - an ElementListener
true if the element was processed successfullypublic int type()
type in interface Elementpublic java.util.List<Chunk> getChunks()
getChunks in interface ElementArrayListpublic boolean isContent()
Element
isContent in interface ElementElement.isContent()public boolean isNestable()
Element
isNestable in interface ElementElement.isNestable()
public void add(int index,
Element element)
Chunk, an Anchor or another Phrase
to this Phrase.
add in interface java.util.List<Element>add in class java.util.ArrayList<Element>index - index at which the specified element is to be insertedelement - an object of type Chunk, Anchor or Phrase
java.lang.ClassCastException - when you try to add something that isn't a Chunk, Anchor or Phrasepublic boolean add(java.lang.String s)
String to this Phrase.
s - a string
public boolean add(Element element)
Chunk, Anchor or another Phrase
to this Phrase.
add in interface TextElementArrayadd in interface java.util.Collection<Element>add in interface java.util.List<Element>add in class java.util.ArrayList<Element>element - an object of type Chunk, Anchor or Phrase
java.lang.ClassCastException - when you try to add something that isn't a Chunk, Anchor or Phrasepublic boolean addAll(java.util.Collection<? extends Element> collection)
Chunks
to this Phrase.
addAll in interface java.util.Collection<Element>addAll in interface java.util.List<Element>addAll in class java.util.ArrayList<Element>collection - a collection of Chunks, Anchors and Phrases.
true if the action succeeded, false if not.
java.lang.ClassCastException - when you try to add something that isn't a Chunk, Anchor or Phraseprotected boolean addChunk(Chunk chunk)
This method is a hack to solve a problem I had with phrases that were split between chunks in the wrong place.
chunk - a Chunk to add to the Phrase
protected void addSpecial(Element object)
Element to the Paragraph.
object - the object to add.public void setLeading(float leading)
leading - the new leadingpublic void setFont(Font font)
font - the new fontpublic float getLeading()
public boolean hasLeading()
public Font getFont()
Chunk that appears in this Phrase.
Fontpublic java.lang.String getContent()
public boolean isEmpty()
Phrase contains no or 1 empty Chunk.
isEmpty in interface java.util.Collection<Element>isEmpty in interface java.util.List<Element>isEmpty in class java.util.ArrayList<Element>false if the Phrase
contains more than one or more non-emptyChunks.public HyphenationEvent getHyphenation()
public void setHyphenation(HyphenationEvent hyphenation)
hyphenation - a HyphenationEvent instancepublic static final Phrase getInstance(java.lang.String string)
string -
public static final Phrase getInstance(int leading,
java.lang.String string)
leading - string -
public static final Phrase getInstance(int leading,
java.lang.String string,
Font font)
leading - string - font -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||