Class Phrase
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList
-
- com.gitlab.pdftk_java.com.lowagie.text.Phrase
-
- All Implemented Interfaces:
Element,MarkupAttributes,TextElementArray,Serializable,Cloneable,Iterable,Collection,List,RandomAccess
public class Phrase extends ArrayList implements TextElementArray, MarkupAttributes
APhraseis a series ofChunks.A
Phrasehas a mainFont, but some chunks within the phrase can have aFontthat differs from the mainFont. All theChunks in aPhrasehave the sameleading.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)));- See Also:
Element,Chunk,Paragraph,Anchor, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected FontfontThis is the font of this phrase.protected floatleadingThis is the leading of this phrase.protected PropertiesmarkupAttributesContains extra markupAttributes-
Fields inherited from class java.util.AbstractList
modCount
-
Fields inherited from interface com.gitlab.pdftk_java.com.lowagie.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, CELL, CHAPTER, CHUNK, CREATIONDATE, CREATOR, GRAPHIC, HEADER, IMGRAW, IMGTEMPLATE, JPEG, KEYWORDS, LIST, LISTITEM, MULTI_COLUMN_TEXT, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, ROW, SECTION, SUBJECT, TABLE, TITLE
-
-
Constructor Summary
Constructors Constructor Description Phrase()Constructs aPhrasewithout specifying a leading.Phrase(float leading)Constructs aPhrasewith a certain leading.Phrase(float leading, Chunk chunk)Constructs aPhrasewith a certainChunkand a certain leading.Phrase(float leading, String string)Constructs aPhrasewith a certain leading and a certainString.Phrase(float leading, String string, Font font)Constructs aPhrasewith a certain leading, a certainStringand a certainFont.Phrase(Chunk chunk)Constructs aPhrasewith a certainChunk.Phrase(String string)Constructs aPhrasewith a certainString.Phrase(String string, Font font)Constructs aPhrasewith a certainStringand a certainFont.Phrase(Properties attributes)Returns aPhrasethat has been constructed taking in account the value of some attributes.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, Object o)Adds aChunk, anAnchoror anotherPhraseto thisPhrase.booleanadd(Object o)Adds aChunk,Anchoror anotherPhraseto thisPhrase.booleanaddAll(Collection collection)Adds a collection ofChunks to thisPhrase.protected voidaddSpecial(Object object)Adds aObjectto theParagraph.Fontfont()Gets the font of the firstChunkthat appears in thisPhrase.ArrayListgetChunks()Gets all the chunks in this element.static PhrasegetInstance(int leading, String string)Gets a special kind of Phrase that changes some characters into corresponding symbols.static PhrasegetInstance(int leading, String string, Font font)Gets a special kind of Phrase that changes some characters into corresponding symbols.static PhrasegetInstance(String string)Gets a special kind of Phrase that changes some characters into corresponding symbols.StringgetMarkupAttribute(String name)Returns the value of the specified attribute.SetgetMarkupAttributeNames()Returns aSetofStringattribute names for theMarkupAttributesimplementor.PropertiesgetMarkupAttributes()Return aProperties-object containing all the markupAttributes.booleanisEmpty()Checks is thisPhrasecontains no or 1 emptyChunk.static booleanisTag(String tag)Checks if a given tag corresponds with this object.floatleading()Gets the leading of this phrase.booleanleadingDefined()Checks you if the leading of this phrase is defined.booleanprocess(ElementListener listener)Processes the element by adding it (or the different parts) to anElementListener.voidsetLeading(float leading)Sets the leading of this phrase.voidsetMarkupAttribute(String name, String value)Sets the specified attribute.voidsetMarkupAttributes(Properties markupAttributes)Sets the markupAttributes.inttype()Gets the type of the text element.-
Methods inherited from class java.util.ArrayList
addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
Methods inherited from class java.util.AbstractCollection
containsAll, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
Methods inherited from interface java.util.List
containsAll
-
-
-
-
Field Detail
-
leading
protected float leading
This is the leading of this phrase.
-
font
protected Font font
This is the font of this phrase.
-
markupAttributes
protected Properties markupAttributes
Contains extra markupAttributes
-
-
Constructor Detail
-
Phrase
public Phrase()
Constructs aPhrasewithout specifying a leading.
-
Phrase
public Phrase(float leading)
Constructs aPhrasewith a certain leading.- Parameters:
leading- the leading
-
Phrase
public Phrase(Chunk chunk)
Constructs aPhrasewith a certainChunk.- Parameters:
chunk- aChunk
-
Phrase
public Phrase(float leading, Chunk chunk)Constructs aPhrasewith a certainChunkand a certain leading.- Parameters:
leading- the leadingchunk- aChunk
-
Phrase
public Phrase(String string)
Constructs aPhrasewith a certainString.- Parameters:
string- aString
-
Phrase
public Phrase(String string, Font font)
Constructs aPhrasewith a certainStringand a certainFont.- Parameters:
string- aStringfont- aFont
-
Phrase
public Phrase(float leading, String string)Constructs aPhrasewith a certain leading and a certainString.- Parameters:
leading- the leadingstring- aString
-
Phrase
public Phrase(float leading, String string, Font font)Constructs aPhrasewith a certain leading, a certainStringand a certainFont.- Parameters:
leading- the leadingstring- aStringfont- aFont
-
Phrase
public Phrase(Properties attributes)
Returns aPhrasethat has been constructed taking in account the value of some attributes.- Parameters:
attributes- Some attributes
-
-
Method Detail
-
getInstance
public static final Phrase getInstance(String string)
Gets a special kind of Phrase that changes some characters into corresponding symbols.- Parameters:
string-- Returns:
- 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.- Parameters:
leading-string-- Returns:
- 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.- Parameters:
leading-string-font-- Returns:
- a newly constructed Phrase
-
process
public boolean process(ElementListener listener)
Processes the element by adding it (or the different parts) to anElementListener.
-
type
public int type()
Gets the type of the text element.
-
getChunks
public ArrayList getChunks()
Gets all the chunks in this element.
-
add
public void add(int index, Object o)Adds aChunk, anAnchoror anotherPhraseto thisPhrase.- Specified by:
addin interfaceList- Overrides:
addin classArrayList- Parameters:
index- index at which the specified element is to be insertedo- an object of typeChunk,AnchororPhrase- Throws:
ClassCastException- when you try to add something that isn't aChunk,AnchororPhrase
-
add
public boolean add(Object o)
Adds aChunk,Anchoror anotherPhraseto thisPhrase.- Specified by:
addin interfaceCollection- Specified by:
addin interfaceList- Specified by:
addin interfaceTextElementArray- Overrides:
addin classArrayList- Parameters:
o- an object of typeChunk,AnchororPhrase- Returns:
- a boolean
- Throws:
ClassCastException- when you try to add something that isn't aChunk,AnchororPhrase
-
addAll
public boolean addAll(Collection collection)
Adds a collection ofChunks to thisPhrase.- Specified by:
addAllin interfaceCollection- Specified by:
addAllin interfaceList- Overrides:
addAllin classArrayList- Parameters:
collection- a collection ofChunks,Anchors andPhrases.- Returns:
trueif the action succeeded,falseif not.- Throws:
ClassCastException- when you try to add something that isn't aChunk,AnchororPhrase
-
addSpecial
protected void addSpecial(Object object)
Adds aObjectto theParagraph.- Parameters:
object- the object to add.
-
setLeading
public void setLeading(float leading)
Sets the leading of this phrase.- Parameters:
leading- the new leading
-
isEmpty
public boolean isEmpty()
Checks is thisPhrasecontains no or 1 emptyChunk.
-
leadingDefined
public boolean leadingDefined()
Checks you if the leading of this phrase is defined.- Returns:
- true if the leading is defined
-
leading
public float leading()
Gets the leading of this phrase.- Returns:
- the linespacing
-
font
public Font font()
Gets the font of the firstChunkthat appears in thisPhrase.- Returns:
- a
Font
-
isTag
public static boolean isTag(String tag)
Checks if a given tag corresponds with this object.- Parameters:
tag- the given tag- Returns:
- true if the tag corresponds
-
setMarkupAttribute
public void setMarkupAttribute(String name, String value)
Description copied from interface:MarkupAttributesSets the specified attribute.- Specified by:
setMarkupAttributein interfaceMarkupAttributes- Parameters:
name-Stringattribute name.value-Stringattribute value.- See Also:
MarkupAttributes.setMarkupAttribute(java.lang.String, java.lang.String)
-
setMarkupAttributes
public void setMarkupAttributes(Properties markupAttributes)
Description copied from interface:MarkupAttributesSets the markupAttributes.- Specified by:
setMarkupAttributesin interfaceMarkupAttributes- Parameters:
markupAttributes- aProperties-object containing markupattributes- See Also:
MarkupAttributes.setMarkupAttributes(java.util.Properties)
-
getMarkupAttribute
public String getMarkupAttribute(String name)
Description copied from interface:MarkupAttributesReturns the value of the specified attribute.- Specified by:
getMarkupAttributein interfaceMarkupAttributes- Parameters:
name-Stringattribute name.- Returns:
String.- See Also:
MarkupAttributes.getMarkupAttribute(java.lang.String)
-
getMarkupAttributeNames
public Set getMarkupAttributeNames()
Description copied from interface:MarkupAttributesReturns aSetofStringattribute names for theMarkupAttributesimplementor.- Specified by:
getMarkupAttributeNamesin interfaceMarkupAttributes- Returns:
Set.- See Also:
MarkupAttributes.getMarkupAttributeNames()
-
getMarkupAttributes
public Properties getMarkupAttributes()
Description copied from interface:MarkupAttributesReturn aProperties-object containing all the markupAttributes.- Specified by:
getMarkupAttributesin interfaceMarkupAttributes- Returns:
Properties- See Also:
MarkupAttributes.getMarkupAttributes()
-
-