Package com.lowagie.text
Class SimpleTable
- java.lang.Object
-
- com.lowagie.text.Rectangle
-
- com.lowagie.text.SimpleTable
-
- All Implemented Interfaces:
Element
,PdfPTableEvent
,TextElementArray
public class SimpleTable extends Rectangle implements PdfPTableEvent, TextElementArray
Rectangle that can be used for Cells. This Rectangle is padded and knows how to draw itself in a PdfPTable or PdfPcellEvent.
-
-
Field Summary
-
Fields inherited from class com.lowagie.text.Rectangle
backgroundColor, border, borderColor, borderColorBottom, borderColorLeft, borderColorRight, borderColorTop, borderWidth, borderWidthBottom, borderWidthLeft, borderWidthRight, borderWidthTop, BOTTOM, BOX, LEFT, llx, lly, NO_BORDER, RIGHT, rotation, TOP, UNDEFINED, urx, ury, useVariableBorders
-
Fields inherited from interface 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, FOOTNOTE, HEADER, IMGRAW, IMGTEMPLATE, JBIG2, JPEG, JPEG2000, KEYWORDS, LIST, LISTITEM, MARKED, MULTI_COLUMN_TEXT, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, ROW, SECTION, SUBJECT, TABLE, TITLE, YMARK
-
-
Constructor Summary
Constructors Constructor Description SimpleTable()
A RectangleCell is always constructed without any dimensions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(Element o)
Adds an object to theTextElementArray
.void
addElement(SimpleCell element)
Adds content to this object.PdfPTable
createPdfPTable()
Creates aPdfTable
object based on this TableAttributes object.Table
createTable()
Creates a Table object based on this TableAttributes object.int
getAlignment()
float
getCellpadding()
float
getCellspacing()
float
getWidth()
Returns the width of the rectangle.float
getWidthpercentage()
boolean
isNestable()
Checks if this element is nestable.void
setAlignment(int alignment)
void
setCellpadding(float cellpadding)
void
setCellspacing(float cellspacing)
void
setWidth(float width)
void
setWidthpercentage(float widthpercentage)
void
tableLayout(PdfPTable table, float[][] widths, float[] heights, int headerRows, int rowStart, PdfContentByte[] canvases)
This method is called at the end of the table rendering.int
type()
Gets the type of the text element.-
Methods inherited from class com.lowagie.text.Rectangle
cloneNonPositionParameters, disableBorderSide, enableBorderSide, getBackgroundColor, getBorder, getBorderColor, getBorderColorBottom, getBorderColorLeft, getBorderColorRight, getBorderColorTop, getBorderWidth, getBorderWidthBottom, getBorderWidthLeft, getBorderWidthRight, getBorderWidthTop, getBottom, getBottom, getChunks, getGrayFill, getHeight, getLeft, getLeft, getRight, getRight, getRotation, getTop, getTop, hasBorder, hasBorders, isContent, isUseVariableBorders, normalize, process, rectangle, rotate, setBackgroundColor, setBorder, setBorderColor, setBorderColorBottom, setBorderColorLeft, setBorderColorRight, setBorderColorTop, setBorderWidth, setBorderWidthBottom, setBorderWidthLeft, setBorderWidthRight, setBorderWidthTop, setBottom, setGrayFill, setLeft, setRight, setRotation, setTop, setUseVariableBorders, softCloneNonPositionParameters, toString
-
-
-
-
Method Detail
-
addElement
public void addElement(SimpleCell element) throws BadElementException
Adds content to this object.- Parameters:
element
- an object of typeSimpleCell
that will be added in the table- Throws:
BadElementException
- on error
-
createTable
public Table createTable() throws BadElementException
Creates a Table object based on this TableAttributes object.- Returns:
- a
Table
object - Throws:
BadElementException
- on error
-
createPdfPTable
public PdfPTable createPdfPTable() throws DocumentException
Creates aPdfTable
object based on this TableAttributes object.- Returns:
- a
PdfTable
object - Throws:
DocumentException
- on error
-
tableLayout
public void tableLayout(PdfPTable table, float[][] widths, float[] heights, int headerRows, int rowStart, PdfContentByte[] canvases)
Description copied from interface:PdfPTableEvent
This method is called at the end of the table rendering. The text or graphics are added to one of the 4PdfContentByte
contained incanvases
.
The indexes tocanvases
are:PdfPTable.BASECANVAS
- the originalPdfContentByte
. Anything placed here will be under the table.PdfPTable.BACKGROUNDCANVAS
- the layer where the background goes to.PdfPTable.LINECANVAS
- the layer where the lines go to.PdfPTable.TEXTCANVAS
- the layer where the text go to. Anything placed here will be over the table.
The
widths
andheights
have the coordinates of the cells.
The size of thewidths
array is the number of rows. Each sub-array inwidths
corresponds to the x column border positions where the first element is the x coordinate of the left table border and the last element is the x coordinate of the right table border. If colspan is not used all the sub-arrays inwidths
are the same.
For theheights
the first element is the y coordinate of the top table border and the last element is the y coordinate of the bottom table border.- Specified by:
tableLayout
in interfacePdfPTableEvent
- Parameters:
table
- thePdfPTable
in usewidths
- an array of arrays with the cells' x positions. It has the length of the number of rowsheights
- an array with the cells' y positions. It has a length of the number of rows + 1headerRows
- the number of rows defined for the header.rowStart
- the first row number after the headercanvases
- an array ofPdfContentByte
- See Also:
PdfPTableEvent.tableLayout(com.lowagie.text.pdf.PdfPTable, float[][], float[], int, int, com.lowagie.text.pdf.PdfContentByte[])
-
getCellpadding
public float getCellpadding()
- Returns:
- Returns the cellpadding.
-
setCellpadding
public void setCellpadding(float cellpadding)
- Parameters:
cellpadding
- The cellpadding to set.
-
getCellspacing
public float getCellspacing()
- Returns:
- Returns the cellspacing.
-
setCellspacing
public void setCellspacing(float cellspacing)
- Parameters:
cellspacing
- The cellspacing to set.
-
getAlignment
public int getAlignment()
- Returns:
- Returns the alignment.
-
setAlignment
public void setAlignment(int alignment)
- Parameters:
alignment
- The alignment to set.
-
getWidth
public float getWidth()
Description copied from class:Rectangle
Returns the width of the rectangle.
-
setWidth
public void setWidth(float width)
- Parameters:
width
- The width to set.
-
getWidthpercentage
public float getWidthpercentage()
- Returns:
- Returns the widthpercentage.
-
setWidthpercentage
public void setWidthpercentage(float widthpercentage)
- Parameters:
widthpercentage
- The widthpercentage to set.
-
type
public int type()
Description copied from class:Rectangle
Gets the type of the text element.- Specified by:
type
in interfaceElement
- Overrides:
type
in classRectangle
- Returns:
- a type
- See Also:
Element.type()
-
isNestable
public boolean isNestable()
Description copied from interface:Element
Checks if this element is nestable.- Specified by:
isNestable
in interfaceElement
- Overrides:
isNestable
in classRectangle
- Returns:
- true if this element can be nested inside other elements.
- Since:
- iText 2.0.8
- See Also:
Element.isNestable()
-
add
public boolean add(Element o)
Description copied from interface:TextElementArray
Adds an object to theTextElementArray
.- Specified by:
add
in interfaceTextElementArray
- Parameters:
o
- an object that has to be added- Returns:
true
if the addition succeeded;false
otherwise- See Also:
TextElementArray.add(Element)
-
-