public class Cell extends TableRectangle implements TextElementArray, WithHorizontalAlignment, WithVerticalAlignment
Cell is a Rectangle containing other
Elements.
A Cell must be added to a Table.
The Table will place the Cell in
a Row.
Example:
Table table = new Table(3);
table.setBorderWidth(1);
table.setBorderColor(new Color(0, 0, 255));
table.setCellpadding(5);
table.setCellspacing(5);
Cell cell = new Cell("header");
cell.setHeader(true);
cell.setColspan(3);
table.addCell(cell);
cell = new Cell("example cell with colspan 1 and rowspan 2");
cell.setRowspan(2);
cell.setBorderColor(new Color(255, 0, 0));
table.addCell(cell);
table.addCell("1.1");
table.addCell("2.1");
table.addCell("1.2");
table.addCell("2.2");
| Modifier and Type | Field and Description |
|---|---|
protected List<Element> |
arrayList
The
ArrayList of Elements
that are part of the content of the Cell. |
protected int |
colspan
The colspan of the cell.
|
protected boolean |
groupChange
Does this
Cell force a group change? |
protected boolean |
header
Is this
Cell a header? |
protected int |
horizontalAlignment
The horizontal alignment of the cell content.
|
protected int |
maxLines
Maximum number of lines allowed in the cell.
|
protected boolean |
percentage |
protected int |
rowspan
The rowspan of the cell.
|
protected boolean |
useAscender
Indicates that the largest ascender height should be used to determine the
height of the first line.
|
protected boolean |
useBorderPadding
Adjusts the cell contents to compensate for border widths.
|
protected 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).
|
protected int |
verticalAlignment
The vertical alignment of the cell content.
|
protected float |
width
The width of the cell as a String.
|
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, useVariableBordersALIGN_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 and Description |
|---|
Cell()
Constructs an empty
Cell. |
Cell(boolean dummy)
Constructs an empty
Cell (for internal use only). |
Cell(Element element)
Constructs a
Cell with a certain Element. |
Cell(String content)
Constructs a
Cell with a certain content. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(Element o)
Add an
Object to this cell. |
void |
addElement(Element element)
Adds an element to this
Cell. |
float |
bottom(int margin)
This method throws an
UnsupportedOperationException. |
void |
clear()
Clears all the
Elements of this Cell. |
PdfPCell |
createPdfPCell()
Creates a PdfPCell based on this Cell object.
|
float |
getBottom()
This method throws an
UnsupportedOperationException. |
ArrayList<Element> |
getChunks()
Gets all the chunks in this element.
|
int |
getColspan()
Gets the colspan.
|
Iterator |
getElements()
Gets an iterator of
Elements. |
boolean |
getGroupChange()
Does this
Cell force a group change? |
int |
getHorizontalAlignment()
Gets the horizontal alignment.
|
float |
getLeading()
Gets the leading.
|
float |
getLeft()
This method throws an
UnsupportedOperationException. |
int |
getMaxLines()
Getter for maxLines
|
float |
getRight()
This method throws an
UnsupportedOperationException. |
int |
getRowspan()
Gets the rowspan.
|
String |
getShowTruncation()
Getter for showTruncation
|
float |
getTop()
This method throws an
UnsupportedOperationException. |
int |
getVerticalAlignment()
Gets the vertical alignment.
|
float |
getWidth()
Gets the width.
|
String |
getWidthAsString()
Gets the width as a String.
|
boolean |
isEmpty()
Checks if the
Cell is empty. |
boolean |
isHeader()
Is this
Cell a header? |
boolean |
isTable()
Checks if this
Cell is a placeholder for a (nested) table. |
boolean |
isUseAscender()
Gets the value of useAscender
|
boolean |
isUseBorderPadding()
Gets the value of useBorderPadding.
|
boolean |
isUseDescender()
gets the value of useDescender
|
float |
left(int margin)
This method throws an
UnsupportedOperationException. |
boolean |
process(ElementListener listener)
Processes the element by adding it (or the different parts) to an
ElementListener. |
float |
right(int margin)
This method throws an
UnsupportedOperationException. |
void |
setBottom(int value)
This method throws an
UnsupportedOperationException. |
void |
setColspan(int value)
Sets the colspan.
|
void |
setGroupChange(boolean value)
Sets group change.
|
void |
setHeader(boolean value)
Sets header.
|
void |
setHorizontalAlignment(HorizontalAlignment alignment)
Sets horizontal alignment mode.
|
void |
setHorizontalAlignment(int value)
Deprecated.
Setting alignment through unconstrained types is non-obvious and error-prone,
use
setHorizontalAlignment(HorizontalAlignment) instead |
void |
setHorizontalAlignment(String alignment)
Deprecated.
Setting alignment through unconstrained types is non-obvious and error-prone,
use
setHorizontalAlignment(HorizontalAlignment) instead |
void |
setLeading(float value)
Sets the leading.
|
void |
setLeft(int value)
This method throws an
UnsupportedOperationException. |
void |
setMaxLines(int value)
Setter for maxLines
|
void |
setRight(int value)
This method throws an
UnsupportedOperationException. |
void |
setRowspan(int value)
Sets the rowspan.
|
void |
setShowTruncation(String value)
Setter for showTruncation
|
void |
setTop(int value)
This method throws an
UnsupportedOperationException. |
void |
setUseAscender(boolean use)
Sets the value of useAscender.
|
void |
setUseBorderPadding(boolean use)
Sets the value of useBorderPadding.
|
void |
setUseDescender(boolean use)
Sets the value of useDescender.
|
void |
setVerticalAlignment(int value)
Deprecated.
Setting alignment through unconstrained types is non-obvious and error-prone,
use
setVerticalAlignment(VerticalAlignment) instead |
void |
setVerticalAlignment(String alignment)
Deprecated.
Setting alignment through unconstrained types is non-obvious and error-prone,
use
setVerticalAlignment(VerticalAlignment) instead |
void |
setVerticalAlignment(VerticalAlignment alignment)
Sets vertical alignment mode.
|
void |
setWidth(float value)
Sets the width.
|
void |
setWidth(String value)
Sets the width.
|
int |
size()
Gets the number of
Elements in the Cell. |
float |
top(int margin)
This method throws an
UnsupportedOperationException. |
int |
type()
Gets the type of the text element.
|
cloneNonPositionParameters, disableBorderSide, enableBorderSide, getBackgroundColor, getBorder, getBorderColor, getBorderColorBottom, getBorderColorLeft, getBorderColorRight, getBorderColorTop, getBorderWidth, getBorderWidthBottom, getBorderWidthLeft, getBorderWidthRight, getBorderWidthTop, getBottom, getGrayFill, getHeight, getLeft, getRight, getRotation, getTop, hasBorder, hasBorders, isContent, isNestable, isUseVariableBorders, normalize, rectangle, rotate, setBackgroundColor, setBorder, setBorderColor, setBorderColorBottom, setBorderColorLeft, setBorderColorRight, setBorderColorTop, setBorderWidth, setBorderWidthBottom, setBorderWidthLeft, setBorderWidthRight, setBorderWidthTop, setBottom, setGrayFill, setLeft, setRight, setRotation, setTop, setUseVariableBorders, softCloneNonPositionParameters, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitisContent, isNestable, toStringprotected List<Element> arrayList
ArrayList of Elements
that are part of the content of the Cell.protected int horizontalAlignment
protected int verticalAlignment
protected float width
protected boolean percentage
protected int colspan
protected int rowspan
protected boolean header
Cell a header?protected int maxLines
protected boolean useAscender
protected boolean useDescender
protected boolean useBorderPadding
protected boolean groupChange
Cell force a group change?public Cell()
Cell.public Cell(boolean dummy)
Cell (for internal use only).dummy - a dummy valuepublic Cell(String content)
Cell with a certain content.
The String will be converted into a Paragraph.
content - a Stringpublic Cell(Element element) throws BadElementException
Cell with a certain Element.
if the element is a ListItem, Row or
Cell, an exception will be thrown.
element - the elementBadElementException - when the creator was called with a ListItem, Row or Cellpublic boolean process(ElementListener listener)
ElementListener.public int type()
public int getHorizontalAlignment()
public void setHorizontalAlignment(int value)
setHorizontalAlignment(HorizontalAlignment) insteadvalue - the new valuepublic void setHorizontalAlignment(String alignment)
setHorizontalAlignment(HorizontalAlignment) insteadalignment - the new alignment as a Stringpublic int getVerticalAlignment()
public void setVerticalAlignment(int value)
setVerticalAlignment(VerticalAlignment) insteadvalue - the new valuepublic void setVerticalAlignment(String alignment)
setVerticalAlignment(VerticalAlignment) insteadalignment - the new alignment as a Stringpublic void setWidth(float value)
value - the new valuepublic void setWidth(String value)
value - the new valuepublic float getWidth()
public String getWidthAsString()
public void setColspan(int value)
value - the new valuepublic int getColspan()
public void setRowspan(int value)
value - the new valuepublic int getRowspan()
public void setLeading(float value)
value - the new valuepublic float getLeading()
public void setHeader(boolean value)
value - the new valuepublic boolean isHeader()
Cell a header?public void setMaxLines(int value)
value - the maximum number of linespublic int getMaxLines()
public void setShowTruncation(String value)
value - Can be null for avoiding marking the truncation.public String getShowTruncation()
public void setUseAscender(boolean use)
use - use ascender height if truepublic boolean isUseAscender()
public void setUseDescender(boolean use)
use - use descender height if truepublic boolean isUseDescender()
public void setUseBorderPadding(boolean use)
use - adjust layout for borders if truepublic boolean isUseBorderPadding()
public boolean getGroupChange()
Cell force a group change?public void setGroupChange(boolean value)
value - the new valuepublic int size()
Elements in the Cell.size.public Iterator getElements()
Elements.Iterator.public void clear()
Elements of this Cell.public boolean isEmpty()
Cell is empty.false if there are non-empty Elements in the Cell.public boolean isTable()
Cell is a placeholder for a (nested) table.public void addElement(Element element) throws BadElementException
Cell.
Remark: you can't add ListItems, Rows, Cells,
JPEGs, GIFs or PNGs to a Cell.
element - The Element to addBadElementException - if the method was called with a ListItem, Row or Cellpublic boolean add(Element o)
Object to this cell.add in interface TextElementArrayo - the object to addtruepublic PdfPCell createPdfPCell() throws BadElementException
BadElementExceptionpublic float getTop()
UnsupportedOperationException.public float getBottom()
UnsupportedOperationException.public float getLeft()
UnsupportedOperationException.public float getRight()
UnsupportedOperationException.public float top(int margin)
UnsupportedOperationException.margin - public float bottom(int margin)
UnsupportedOperationException.margin - public float left(int margin)
UnsupportedOperationException.margin - public float right(int margin)
UnsupportedOperationException.margin - NApublic void setTop(int value)
UnsupportedOperationException.value - NApublic void setBottom(int value)
UnsupportedOperationException.value - NApublic void setLeft(int value)
UnsupportedOperationException.value - NApublic void setRight(int value)
UnsupportedOperationException.value - NApublic void setHorizontalAlignment(HorizontalAlignment alignment)
WithHorizontalAlignmentsetHorizontalAlignment in interface WithHorizontalAlignmentalignment - New alignment mode. If null, current alignment must be left unchangedpublic void setVerticalAlignment(VerticalAlignment alignment)
WithVerticalAlignmentsetVerticalAlignment in interface WithVerticalAlignmentalignment - New alignment mode. If null, current alignment must be left unchangedCopyright © 2019. All rights reserved.