A
Phrase
is a series of
Chunk
s.
A
Phrase
has a main
Font
, but some chunks
within the phrase can have a
Font
that differs from the
main
Font
. All the
Chunk
s 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 (explicitely 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)));
Phrase
public Phrase()
Constructs a Phrase
without specifying a leading.
Phrase
public Phrase(Properties attributes)
Returns a Phrase
that has been constructed taking in account
the value of some attributes.
attributes
- Some attributes
Phrase
public Phrase(String string)
Constructs a Phrase
with a certain String
.
Phrase
public Phrase(String string,
Font font)
Constructs a Phrase
with a certain String
and a certain Font
.
string
- a String
font
- a Font
Phrase
private Phrase(boolean dummy)
Constructs a Phrase that can be used in the static getInstance() method.
dummy
- a dummy parameter
Phrase
public Phrase(Chunk chunk)
Constructs a Phrase
with a certain Chunk
.
Phrase
public Phrase(float leading)
Constructs a Phrase
with a certain leading.
Phrase
public Phrase(float leading,
String string)
Constructs a Phrase
with a certain leading and a certain String
.
leading
- the leadingstring
- a String
Phrase
public Phrase(float leading,
String string,
Font font)
Constructs a Phrase
with a certain leading, a certain String
and a certain Font
.
leading
- the leadingstring
- a String
font
- a Font
Phrase
public Phrase(float leading,
Chunk chunk)
Constructs a Phrase
with a certain Chunk
and a certain leading.
leading
- the leadingchunk
- a Chunk
add
public boolean add(Object o)
Adds a Chunk
, Anchor
or another Phrase
to this Phrase
.
- add in interface TextElementArray
o
- an object of type Chunk
, Anchor
or Phrase
add
public void add(int index,
Object o)
Adds a Chunk
, an Anchor
or another Phrase
to this Phrase
.
index
- index at which the specified element is to be insertedo
- an object of type Chunk
, Anchor
or Phrase
addAll
public boolean addAll(Collection collection)
Adds a collection of Chunk
s
to this Phrase
.
collection
- a collection of Chunk
s, Anchor
s and Phrase
s.
true
if the action succeeded, false
if not.
addChunk
private 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.
chunk
- a Chunk to add to the Phrase
- true if adding the Chunk succeeded
addSpecial
protected void addSpecial(Object object)
Adds a Object
to the Paragraph
.
object
- the object to add.
font
public Font font()
Gets the font of the first Chunk
that appears in this Phrase
.
getChunks
public ArrayList getChunks()
Gets all the chunks in this element.
- getChunks in interface Element
getInstance
public static final Phrase getInstance(String string)
Gets a special kind of Phrase that changes some characters into corresponding symbols.
- a newly constructed Phrase
getInstance
public static final Phrase getInstance(int leading,
String string)
Gets a special kind of Phrase that changes some characters into corresponding symbols.
- a newly constructed Phrase
getInstance
public static final Phrase getInstance(int leading,
String string,
Font font)
Gets a special kind of Phrase that changes some characters into corresponding symbols.
leading
- string
- font
-
- a newly constructed Phrase
getMarkupAttribute
public String getMarkupAttribute(String name)
- getMarkupAttribute in interface MarkupAttributes
com.lowagie.text.MarkupAttributes.getMarkupAttribute(java.lang.String)
isEmpty
public boolean isEmpty()
Checks is this Phrase
contains no or 1 empty Chunk
.
false
if the Phrase
contains more than one or more non-emptyChunk
s.
isTag
public static boolean isTag(String tag)
Checks if a given tag corresponds with this object.
- true if the tag corresponds
leading
public float leading()
Gets the leading of this phrase.
leadingDefined
public boolean leadingDefined()
Checks you if the leading of this phrase is defined.
- true if the leading is defined
process
public boolean process(ElementListener listener)
Processes the element by adding it (or the different parts) to an
ElementListener
.
- process in interface Element
listener
- an ElementListener
true
if the element was processed successfully
setLeading
public void setLeading(float leading)
Sets the leading of this phrase.
leading
- the new leading
setMarkupAttribute
public void setMarkupAttribute(String name,
String value)
- setMarkupAttribute in interface MarkupAttributes
com.lowagie.text.MarkupAttributes.setMarkupAttribute(java.lang.String, java.lang.String)
setMarkupAttributes
public void setMarkupAttributes(Properties markupAttributes)
- setMarkupAttributes in interface MarkupAttributes
com.lowagie.text.MarkupAttributes.setMarkupAttributes(java.util.Properties)
type
public int type()
Gets the type of the text element.
- type in interface Element