Home » iText-2.1.7 » com.lowagie » text » [javadoc | source]
com.lowagie.text
public class: Phrase [javadoc | source]
java.lang.Object
   java.util.AbstractCollection
      java.util.AbstractList
         java.util.ArrayList
            com.lowagie.text.Phrase

All Implemented Interfaces:
    TextElementArray, List, Serializable, RandomAccess, Cloneable, Collection

Direct Known Subclasses:
    Anchor, Paragraph, ListItem

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)));
Field Summary
protected  float leading    This is the leading of this phrase. 
protected  Font font    This is the font of this phrase. 
protected  HyphenationEvent hyphenation    Null, unless the Phrase has to be hyphenated.
    since: 2.1.2 -
 
Fields inherited from java.util.AbstractList:
modCount
Constructor:
 public Phrase() 
 public Phrase(Phrase phrase) 
    Copy constructor for Phrase.
 public Phrase(float leading) 
 public Phrase(Chunk chunk) 
    Constructs a Phrase with a certain Chunk.
    Parameters:
    chunk - a Chunk
 public Phrase(String string) 
    Constructs a Phrase with a certain String.
    Parameters:
    string - a String
 public Phrase(float leading,
    Chunk chunk) 
    Constructs a Phrase with a certain Chunk and a certain leading.
    Parameters:
    leading - the leading
    chunk - a Chunk
 public Phrase(String string,
    Font font) 
    Constructs a Phrase with a certain String and a certain Font.
    Parameters:
    string - a String
    font - a Font
 public Phrase(float leading,
    String string) 
    Constructs a Phrase with a certain leading and a certain String.
    Parameters:
    leading - the leading
    string - a String
 public Phrase(float leading,
    String string,
    Font font) 
    Constructs a Phrase with a certain leading, a certain String and a certain Font.
    Parameters:
    leading - the leading
    string - a String
    font - a Font
Method from com.lowagie.text.Phrase Summary:
add,   add,   addAll,   addChunk,   addSpecial,   getChunks,   getContent,   getFont,   getHyphenation,   getInstance,   getInstance,   getInstance,   getLeading,   hasLeading,   isContent,   isEmpty,   isNestable,   process,   setFont,   setHyphenation,   setLeading,   type
Methods from java.util.ArrayList:
add,   add,   addAll,   addAll,   clear,   clone,   contains,   ensureCapacity,   get,   indexOf,   isEmpty,   lastIndexOf,   remove,   remove,   removeRange,   set,   size,   toArray,   toArray,   trimToSize
Methods from java.util.AbstractList:
add,   add,   addAll,   clear,   equals,   get,   hashCode,   indexOf,   iterator,   lastIndexOf,   listIterator,   listIterator,   remove,   removeRange,   set,   subList
Methods from java.util.AbstractCollection:
add,   addAll,   clear,   contains,   containsAll,   isEmpty,   iterator,   remove,   removeAll,   retainAll,   size,   toArray,   toArray,   toString
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.lowagie.text.Phrase Detail:
 public boolean add(Object o) 
    Adds a Chunk, Anchor or another Phrase to this Phrase.
 public  void add(int index,
    Object o) 
    Adds a Chunk, an Anchor or another Phrase to this Phrase.
 public boolean addAll(Collection collection) 
    Adds a collection of Chunks to this Phrase.
 protected boolean addChunk(Chunk chunk) 
    Adds a Chunk.

    This method is a hack to solve a problem I had with phrases that were split between chunks in the wrong place.

 protected  void addSpecial(Object object) 
    Adds a Object to the Paragraph.
 public ArrayList getChunks() 
    Gets all the chunks in this element.
 public String getContent() 
    Returns the content as a String object. This method differs from toString because toString will return an ArrayList with the toString value of the Chunks in this Phrase.
 public Font getFont() 
    Gets the font of the first Chunk that appears in this Phrase.
 public HyphenationEvent getHyphenation() 
    Getter for the hyphenation settings.
 public static final Phrase getInstance(String string) 
    Gets a special kind of Phrase that changes some characters into corresponding symbols.
 public static final Phrase getInstance(int leading,
    String string) 
    Gets a special kind of Phrase that changes some characters into corresponding symbols.
 public static final Phrase getInstance(int leading,
    String string,
    Font font) 
    Gets a special kind of Phrase that changes some characters into corresponding symbols.
 public float getLeading() 
    Gets the leading of this phrase.
 public boolean hasLeading() 
    Checks you if the leading of this phrase is defined.
 public boolean isContent() 
 public boolean isEmpty() 
    Checks is this Phrase contains no or 1 empty Chunk.
 public boolean isNestable() 
 public boolean process(ElementListener listener) 
    Processes the element by adding it (or the different parts) to an ElementListener.
 public  void setFont(Font font) 
    Sets the main font of this phrase.
 public  void setHyphenation(HyphenationEvent hyphenation) 
    Setter for the hyphenation.
 public  void setLeading(float leading) 
    Sets the leading of this phrase.
 public int type() 
    Gets the type of the text element.