com.lowagie.text.pdf

Class PdfLine

public class PdfLine extends Object

PdfLine defines an array with PdfChunk-objects that fit into 1 line.
Field Summary
protected intalignment
The alignment of the line.
protected floatheight
The heigth of the line.
protected booleanisRTL
protected floatleft
The left indentation of the line.
protected ArrayListline
The arraylist containing the chunks.
protected ChunklistSymbol
The listsymbol (if necessary).
protected booleannewlineSplit
true if the chunk splitting was caused by a newline.
protected floatoriginalWidth
The original width.
protected floatsymbolIndent
The listsymbol (if necessary).
protected floatwidth
The width of the line.
Constructor Summary
PdfLine(float left, float right, int alignment, float height)
Constructs a new PdfLine-object.
PdfLine(float left, float remainingWidth, int alignment, boolean newlineSplit, ArrayList line, boolean isRTL)
Method Summary
PdfChunkadd(PdfChunk chunk)
Adds a PdfChunk to the PdfLine.
voidaddToLine(PdfChunk chunk)
floatgetAscender()
Gets the maximum size of the ascender for all the fonts used in this line.
PdfChunkgetChunk(int idx)
Gets a PdfChunk by index.
floatgetDescender()
Gets the biggest descender for all the fonts used in this line.
intgetLastStrokeChunk()
Gets the index of the last PdfChunk with metric attributes
floatgetMaxSizeSimple()
Gets the maximum size of all the fonts used in this line including images.
floatgetOriginalWidth()
Gets the original width of the line.
floatgetWidthCorrected(float charSpacing, float wordSpacing)
Gets a width corrected with a charSpacing and wordSpacing.
booleanhasToBeJustified()
Checks if this line has to be justified.
floatheight()
Returns the height of the line.
floatindentLeft()
Returns the left indentation of the line taking the alignment of the line into account.
booleanisNewlineSplit()
Checks if a newline caused the line split.
booleanisRTL()
Iteratoriterator()
Returns an iterator of PdfChunks.
floatlistIndent()
Return the indentation needed to show the listsymbol.
ChunklistSymbol()
Returns the listsymbol of this line.
intnumberOfSpaces()
Returns the number of space-characters in this line.
voidresetAlignment()
Resets the alignment of this line.
voidsetExtraIndent(float extra)
Adds extra indentation to the left (for Paragraph.setFirstLineIndent).
voidsetListItem(ListItem listItem)
Sets the listsymbol of this line.
intsize()
Returns the number of chunks in the line.
StringtoString()
Get the string representation of what is in this line.
floatwidthLeft()
Returns the width that is left, after a maximum of characters is added to the line.

Field Detail

alignment

protected int alignment
The alignment of the line.

height

protected float height
The heigth of the line.

isRTL

protected boolean isRTL

left

protected float left
The left indentation of the line.

line

protected ArrayList line
The arraylist containing the chunks.

listSymbol

protected Chunk listSymbol
The listsymbol (if necessary).

newlineSplit

protected boolean newlineSplit
true if the chunk splitting was caused by a newline.

originalWidth

protected float originalWidth
The original width.

symbolIndent

protected float symbolIndent
The listsymbol (if necessary).

width

protected float width
The width of the line.

Constructor Detail

PdfLine

PdfLine(float left, float right, int alignment, float height)
Constructs a new PdfLine-object.

Parameters: left the limit of the line at the left right the limit of the line at the right alignment the alignment of the line height the height of the line

PdfLine

PdfLine(float left, float remainingWidth, int alignment, boolean newlineSplit, ArrayList line, boolean isRTL)

Method Detail

add

PdfChunk add(PdfChunk chunk)
Adds a PdfChunk to the PdfLine.

Parameters: chunk the PdfChunk to add

Returns: null if the chunk could be added completely; if not a PdfChunk containing the part of the chunk that could not be added is returned

addToLine

private void addToLine(PdfChunk chunk)

getAscender

public float getAscender()
Gets the maximum size of the ascender for all the fonts used in this line.

Returns: maximum size of all the ascenders used in this line

getChunk

public PdfChunk getChunk(int idx)
Gets a PdfChunk by index.

Parameters: idx the index

Returns: the PdfChunk or null if beyond the array

getDescender

public float getDescender()
Gets the biggest descender for all the fonts used in this line. Note that this is a negative number.

Returns: maximum size of all the ascenders used in this line

getLastStrokeChunk

public int getLastStrokeChunk()
Gets the index of the last PdfChunk with metric attributes

Returns: the last PdfChunk with metric attributes

getMaxSizeSimple

float getMaxSizeSimple()
Gets the maximum size of all the fonts used in this line including images.

Returns: maximum size of all the fonts used in this line

getOriginalWidth

public float getOriginalWidth()
Gets the original width of the line.

Returns: the original width of the line

getWidthCorrected

public float getWidthCorrected(float charSpacing, float wordSpacing)
Gets a width corrected with a charSpacing and wordSpacing.

Parameters: charSpacing wordSpacing

Returns: a corrected width

hasToBeJustified

public boolean hasToBeJustified()
Checks if this line has to be justified.

Returns: true if the alignment equals ALIGN_JUSTIFIED and there is some width left.

height

float height()
Returns the height of the line.

Returns: a value

indentLeft

float indentLeft()
Returns the left indentation of the line taking the alignment of the line into account.

Returns: a value

isNewlineSplit

public boolean isNewlineSplit()
Checks if a newline caused the line split.

Returns: true if a newline caused the line split

isRTL

boolean isRTL()

iterator

public Iterator iterator()
Returns an iterator of PdfChunks.

Returns: an Iterator

listIndent

public float listIndent()
Return the indentation needed to show the listsymbol.

Returns: a value

listSymbol

public Chunk listSymbol()
Returns the listsymbol of this line.

Returns: a PdfChunk if the line has a listsymbol; null otherwise

numberOfSpaces

int numberOfSpaces()
Returns the number of space-characters in this line.

Returns: a value

resetAlignment

public void resetAlignment()
Resets the alignment of this line.

The alignment of the last line of for instance a Paragraph that has to be justified, has to be reset to ALIGN_LEFT.

setExtraIndent

void setExtraIndent(float extra)
Adds extra indentation to the left (for Paragraph.setFirstLineIndent).

setListItem

public void setListItem(ListItem listItem)
Sets the listsymbol of this line.

This is only necessary for the first line of a ListItem.

Parameters: listItem the list symbol

size

public int size()
Returns the number of chunks in the line.

Returns: a value

toString

public String toString()
Get the string representation of what is in this line.

Returns: a String

widthLeft

float widthLeft()
Returns the width that is left, after a maximum of characters is added to the line.

Returns: a value