Package com.aowagie.text.pdf
Class PdfCell
- java.lang.Object
-
- com.aowagie.text.Rectangle
-
- com.aowagie.text.pdf.PdfCell
-
- All Implemented Interfaces:
Element
class PdfCell extends Rectangle
APdfCellis the PDF translation of aCell.A
PdfCellis anArrayListofPdfLines.When using variable borders (
isUseVariableBorders()== true), the borders are drawn completely inside the cell Rectangle so that adjacent cell borders will not overlap. Otherwise, the borders are drawn on top of the edges of the cell Rectangle and will overlap the borders of adjacent cells.
-
-
Field Summary
Fields Modifier and Type Field Description private floatcellpaddingThis is the cellpadding of the cell.private floatcellspacingThis is the cellspacing of the cell.private floatcontentHeightThis is the total height of the content of the cell.private PdfLinefirstLineprivate intgroupNumberThis is the number of the group the cell is in.private booleanheaderIndicates if this cell belongs to the header of aPdfTableprivate java.util.ArrayListimagesThese are the Images in the Cell.private PdfLinelastLineprivate floatleadingThis is the leading of the lines.private PdfLinelineThese are the PdfLines in the Cell.private java.util.ArrayListlinesThese are the PdfLines in the Cell.private intrownumberThis is the number of the row the cell is in.private introwspanThis is the rowspan of the cell.private booleanuseAscenderIndicates that the largest ascender height should be used to determine the height of the first line.private booleanuseBorderPaddingAdjusts the cell contents to compensate for border widths.private booleanuseDescenderIndicates that the largest descender height should be added to the height of the last line (so characters like y don't dip into the border).private intverticalAlignment-
Fields inherited from class com.aowagie.text.Rectangle
border, borderWidth, BOTTOM, BOX, LEFT, llx, lly, NO_BORDER, RIGHT, rotation, TOP, UNDEFINED, urx, ury
-
Fields inherited from interface com.aowagie.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, HEADER, IMGRAW, IMGTEMPLATE, JBIG2, JPEG, JPEG2000, KEYWORDS, LIST, LISTITEM, MARKED, MULTI_COLUMN_TEXT, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, ROW, SECTION, SUBJECT, TABLE, TITLE, YMARK
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private floataddImage(Image i, float left, float right, float extraHeight, int alignment)Adds an image to this Cell.private voidaddLine(PdfLine line)private voidaddList(List list, float left, float right, int alignment)private floatcellpadding()Gets the cellpadding of a cell..private floatcellspacing()Gets the cellspacing of a cell.private floatfirstLineRealHeight()Calculates what the height of the first line should be so that the content will be flush with the top.private voidflushCurrentLine()private floatgetBorderWidthInside(int side)Gets the amount of the border for the specified side that is inside the Rectangle.floatgetBottom()Returns the lower left y-coordinate.intgetGroupNumber()Gets the number of the group this cell is in..java.util.ArrayListgetImages(float top, float bottom)Gets the images of a cell that can be drawn between certain limits.floatgetLeft()Returns the lower left x-coordinate.java.util.ArrayListgetLines(float top, float bottom)Gets the lines of a cell that can be drawn between certain limits.floatgetRight()Returns the upper right x-coordinate.floatgetTop()Returns the upper right y-coordinate.(package private) booleanisHeader()Checks if this cell belongs to the header of aPdfTable.booleanisUseAscender()Gets the value of useAscenderbooleanisUseBorderPadding()Gets the value of useBorderPadding.booleanisUseDescender()gets the value of useDescender(package private) booleanmayBeRemoved()Checks if the cell may be removed.private voidprocessActions(Element element, PdfAction action, java.util.ArrayList allActions)Processes all actions contained in the cell.Rectanglerectangle(float top, float bottom)Gets a Rectangle that is altered to fit on the page.floatremainingHeight()Returns the height needed to draw the remaining text.private floatremainingLinesHeight()Returns the total height of all the lines in the cell.private PdfLineremoveLine(int index)(package private) intrownumber()Gets the number of the row this cell is in..introwspan()Gets the rowspan of a cell.voidsetBottom(float value)Sets the bottom of the Rectangle and determines the proper {link #verticalOffset} to appropriately align the contents vertically.(package private) voidsetGroupNumber(int number)Sets the group number.(package private) voidsetHeader()Indicates that this cell belongs to the header of aPdfTable.voidsetUseAscender(boolean use)Sets the value of useAscender.voidsetUseBorderPadding(boolean use)Sets the value of useBorderPadding.voidsetUseDescender(boolean use)Sets the value of useDescender.-
Methods inherited from class com.aowagie.text.Rectangle
cloneNonPositionParameters, disableBorderSide, enableBorderSide, getBackgroundColor, getBorder, getBorderColor, getBorderColorBottom, getBorderColorLeft, getBorderColorRight, getBorderColorTop, getBorderWidth, getBorderWidthBottom, getBorderWidthLeft, getBorderWidthRight, getBorderWidthTop, getBottom, getChunks, getGrayFill, getHeight, getLeft, getRight, getRotation, getTop, getWidth, hasBorder, hasBorders, isContent, isNestable, isUseVariableBorders, normalize, process, rotate, setBackgroundColor, setBorder, setBorderColor, setBorderColorBottom, setBorderColorLeft, setBorderColorRight, setBorderColorTop, setBorderWidth, setBorderWidthBottom, setBorderWidthLeft, setBorderWidthRight, setBorderWidthTop, setGrayFill, setLeft, setRight, setTop, setUseVariableBorders, softCloneNonPositionParameters, toString, type
-
-
-
-
Field Detail
-
lines
private java.util.ArrayList lines
These are the PdfLines in the Cell.
-
line
private PdfLine line
These are the PdfLines in the Cell.
-
images
private final java.util.ArrayList images
These are the Images in the Cell.
-
leading
private final float leading
This is the leading of the lines.
-
rownumber
private final int rownumber
This is the number of the row the cell is in.
-
rowspan
private final int rowspan
This is the rowspan of the cell.
-
cellspacing
private final float cellspacing
This is the cellspacing of the cell.
-
cellpadding
private final float cellpadding
This is the cellpadding of the cell.
-
header
private boolean header
Indicates if this cell belongs to the header of aPdfTable
-
contentHeight
private float contentHeight
This is the total height of the content of the cell. Note that the actual cell height may be larger due to another cell on the row *
-
useAscender
private boolean useAscender
Indicates that the largest ascender height should be used to determine the height of the first line. Setting this to true can help with vertical alignment problems.
-
useDescender
private boolean useDescender
Indicates that the largest descender height should be added to the height of the last line (so characters like y don't dip into the border).
-
useBorderPadding
private boolean useBorderPadding
Adjusts the cell contents to compensate for border widths.
-
verticalAlignment
private final int verticalAlignment
-
firstLine
private PdfLine firstLine
-
lastLine
private PdfLine lastLine
-
groupNumber
private int groupNumber
This is the number of the group the cell is in.
-
-
Constructor Detail
-
PdfCell
public PdfCell(Cell cell, int rownumber, float left, float right, float top, float cellspacing, float cellpadding)
Constructs aPdfCell-object.- Parameters:
cell- the originalCellrownumber- the number of theRowtheCellwas in.left- the left border of thePdfCellright- the right border of thePdfCelltop- the top border of thePdfCellcellspacing- the cellspacing of theTablecellpadding- the cellpadding of theTable
-
-
Method Detail
-
addList
private void addList(List list, float left, float right, int alignment)
-
setBottom
public void setBottom(float value)
Sets the bottom of the Rectangle and determines the proper {link #verticalOffset} to appropriately align the contents vertically.
-
getLeft
public float getLeft()
Returns the lower left x-coordinate.
-
getRight
public float getRight()
Returns the upper right x-coordinate.
-
getTop
public float getTop()
Returns the upper right y-coordinate.
-
getBottom
public float getBottom()
Returns the lower left y-coordinate.
-
addLine
private void addLine(PdfLine line)
-
removeLine
private PdfLine removeLine(int index)
-
flushCurrentLine
private void flushCurrentLine()
-
firstLineRealHeight
private float firstLineRealHeight()
Calculates what the height of the first line should be so that the content will be flush with the top. For text, this is the height of the ascender. For an image, it is the actual height of the image.- Returns:
- the real height of the first line
-
getBorderWidthInside
private float getBorderWidthInside(int side)
Gets the amount of the border for the specified side that is inside the Rectangle. For non-variable width borders this is only 1/2 the border width on that side. This always returns 0 ifuseBorderPaddingis false;- Parameters:
side- the side to check. One of the side constants inRectangle- Returns:
- the borderwidth inside the cell
-
addImage
private float addImage(Image i, float left, float right, float extraHeight, int alignment)
Adds an image to this Cell.- Parameters:
i- the image to addleft- the left borderright- the right borderextraHeight- extra height to add above imagealignment- horizontal alignment (constant from Element class)- Returns:
- the height of the image
-
getLines
public java.util.ArrayList getLines(float top, float bottom)Gets the lines of a cell that can be drawn between certain limits.Remark: all the lines that can be drawn are removed from the object!
- Parameters:
top- the top of the part of the table that can be drawnbottom- the bottom of the part of the table that can be drawn- Returns:
- an
ArrayListofPdfLines
-
getImages
public java.util.ArrayList getImages(float top, float bottom)Gets the images of a cell that can be drawn between certain limits.Remark: all the lines that can be drawn are removed from the object!
- Parameters:
top- the top of the part of the table that can be drawnbottom- the bottom of the part of the table that can be drawn- Returns:
- an
ArrayListofImages
-
isHeader
boolean isHeader()
Checks if this cell belongs to the header of aPdfTable.- Returns:
void
-
setHeader
void setHeader()
Indicates that this cell belongs to the header of aPdfTable.
-
mayBeRemoved
boolean mayBeRemoved()
Checks if the cell may be removed.Headers may always be removed, even if they are drawn only partially: they will be repeated on each following page anyway!
- Returns:
trueif all the lines are already drawn;falseotherwise.
-
remainingLinesHeight
private float remainingLinesHeight()
Returns the total height of all the lines in the cell.- Returns:
- a value
-
remainingHeight
public float remainingHeight()
Returns the height needed to draw the remaining text.- Returns:
- a height
-
rownumber
int rownumber()
Gets the number of the row this cell is in..- Returns:
- a number
-
rowspan
public int rowspan()
Gets the rowspan of a cell.- Returns:
- the rowspan of the cell
-
cellspacing
private float cellspacing()
Gets the cellspacing of a cell.- Returns:
- a value
-
cellpadding
private float cellpadding()
Gets the cellpadding of a cell..- Returns:
- a value
-
processActions
private void processActions(Element element, PdfAction action, java.util.ArrayList allActions)
Processes all actions contained in the cell.- Parameters:
element- an element in the cellaction- an action that should be coupled to the cellallActions-
-
getGroupNumber
public int getGroupNumber()
Gets the number of the group this cell is in..- Returns:
- a number
-
setGroupNumber
void setGroupNumber(int number)
Sets the group number.- Parameters:
number-
-
rectangle
public Rectangle rectangle(float top, float bottom)
Gets a Rectangle that is altered to fit on the page.
-
setUseAscender
public void setUseAscender(boolean use)
Sets the value of useAscender.- Parameters:
use- use ascender height if true
-
isUseAscender
public boolean isUseAscender()
Gets the value of useAscender- Returns:
- useAscender
-
setUseDescender
public void setUseDescender(boolean use)
Sets the value of useDescender.- Parameters:
use- use descender height if true
-
isUseDescender
public boolean isUseDescender()
gets the value of useDescender- Returns:
- useDescender
-
setUseBorderPadding
public void setUseBorderPadding(boolean use)
Sets the value of useBorderPadding.- Parameters:
use- adjust layout for borders if true
-
isUseBorderPadding
public boolean isUseBorderPadding()
Gets the value of useBorderPadding.- Returns:
- useBorderPadding
-
-