public class Cell extends Rectangle implements TextElementArray
Cell
is a Rectangle
containing other
Element
s.
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 java.util.ArrayList |
arrayList
This is the
ArrayList of Element s. |
protected int |
colspan
This is the colspan.
|
protected boolean |
groupChange
Does this
Cell force a group change? |
protected boolean |
header
Is this
Cell a header? |
protected int |
horizontalAlignment
This is the horizontal alignment.
|
(package private) float |
leading
This is the leading.
|
protected int |
maxLines
Maximum number of lines allowed in the cell.
|
protected int |
rowspan
This is the rowspan.
|
(package private) java.lang.String |
showTruncation
If a truncation happens due to the
maxLines property, then this text will
be added to indicate a truncation has happened. |
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
This is the vertical alignment.
|
protected java.lang.String |
width
This is the vertical alignment.
|
background, border, borderColorBottom, borderColorLeft, borderColorRight, borderColorTop, borderWidth, borderWidthBottom, borderWidthLeft, borderWidthRight, borderWidthTop, BOTTOM, BOX, color, LEFT, llx, lly, markupAttributes, NO_BORDER, RIGHT, rotation, TOP, UNDEFINED, urx, ury, useVariableBorders
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 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(java.util.Properties attributes)
Returns a
Cell that has been constructed taking in account
the value of some attributes. |
Cell(java.lang.String content)
Constructs a
Cell with a certain content. |
Modifier and Type | Method and Description |
---|---|
boolean |
add(java.lang.Object o)
Add an
Object to this cell. |
void |
addElement(Element element)
Adds an element to this
Cell . |
float |
bottom()
This method throws an
UnsupportedOperationException . |
float |
bottom(int margin)
This method throws an
UnsupportedOperationException . |
java.lang.String |
cellWidth()
Gets the width.
|
void |
clear()
Clears all the
Element s of this Cell . |
int |
colspan()
Gets the colspan.
|
PdfPCell |
createPdfPCell()
Creates a PdfPCell based on this Cell object.
|
(package private) void |
fill()
Makes sure there is at least 1 object in the Cell.
|
java.util.ArrayList |
getChunks()
Gets all the chunks in this element.
|
static Cell |
getDummyCell()
Get dummy cell used when merging inner tables.
|
java.util.Iterator |
getElements()
Gets an iterator of
Element s. |
boolean |
getGroupChange()
Does this
Cell force a group change? |
int |
getMaxLines()
Getter for
maxLines |
java.lang.String |
getShowTruncation()
Getter for
showTruncation |
boolean |
header()
Is this
Cell a header? |
int |
horizontalAlignment()
Gets the horizontal alignment.
|
boolean |
isEmpty()
Checks if the
Cell is empty. |
boolean |
isTable()
Checks if the
Cell is empty. |
static boolean |
isTag(java.lang.String tag)
Checks if a given tag corresponds with this object.
|
boolean |
isUseAscender()
Gets the value of
useAscender |
boolean |
isUseBorderPadding()
Gets the value of
useBorderPadding . |
boolean |
isUseDescender()
gets the value of
useDescender |
float |
leading()
Gets the leading.
|
float |
left()
This method throws an
UnsupportedOperationException . |
float |
left(int margin)
This method throws an
UnsupportedOperationException . |
boolean |
noWrap()
Get nowrap.
|
boolean |
process(ElementListener listener)
Processes the element by adding it (or the different parts) to an
ElementListener . |
float |
right()
This method throws an
UnsupportedOperationException . |
float |
right(int margin)
This method throws an
UnsupportedOperationException . |
int |
rowspan()
Gets the rowspan.
|
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(int value)
Sets the horizontal alignment.
|
void |
setHorizontalAlignment(java.lang.String alignment)
Sets the alignment of this cell.
|
void |
setLeading(float value)
Sets the leading.
|
void |
setLeft(int value)
This method throws an
UnsupportedOperationException . |
void |
setMaxLines(int value)
Setter for
maxLines |
void |
setNoWrap(boolean value)
Set nowrap.
|
void |
setRight(int value)
This method throws an
UnsupportedOperationException . |
void |
setRowspan(int value)
Sets the rowspan.
|
void |
setShowTruncation(java.lang.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)
Sets the vertical alignment.
|
void |
setVerticalAlignment(java.lang.String alignment)
Sets the alignment of this paragraph.
|
void |
setWidth(java.lang.String value)
Sets the width.
|
int |
size()
Gets the number of
Element s in the Cell. |
float |
top()
This method throws an
UnsupportedOperationException . |
float |
top(int margin)
This method throws an
UnsupportedOperationException . |
int |
type()
Gets the type of the text element.
|
int |
verticalAlignment()
Gets the vertical alignment.
|
backgroundColor, border, borderColor, borderWidth, bottom, cloneNonPositionParameters, disableBorderSide, enableBorderSide, getBorderColorBottom, getBorderColorLeft, getBorderColorRight, getBorderColorTop, getBorderWidthBottom, getBorderWidthLeft, getBorderWidthRight, getBorderWidthTop, getMarkupAttribute, getMarkupAttributeNames, getMarkupAttributes, getRotation, grayFill, hasBorder, hasBorders, height, isUseVariableBorders, left, normalize, rectangle, right, rotate, setBackgroundColor, setBorder, setBorderColor, setBorderColorBottom, setBorderColorLeft, setBorderColorRight, setBorderColorTop, setBorderWidth, setBorderWidthBottom, setBorderWidthLeft, setBorderWidthRight, setBorderWidthTop, setBottom, setGrayFill, setLeft, setMarkupAttribute, setMarkupAttributes, setRight, setTop, setUseVariableBorders, softCloneNonPositionParameters, top, toString, width
protected java.util.ArrayList arrayList
ArrayList
of Element
s.protected int horizontalAlignment
protected int verticalAlignment
protected java.lang.String width
protected int colspan
protected int rowspan
float leading
protected boolean header
Cell
a header?protected boolean useAscender
protected boolean useDescender
protected boolean useBorderPadding
protected boolean groupChange
Cell
force a group change?protected int maxLines
java.lang.String showTruncation
maxLines
property, then this text will
be added to indicate a truncation has happened.
Default value is null, and means avoiding marking the truncation.
A useful value of this property could be e.g. "..."
(contributed by dperezcar@fcc.es)public Cell()
Cell
.public Cell(boolean dummy)
Cell
(for internal use only).dummy
- a dummy valuepublic Cell(java.lang.String content)
Cell
with a certain content.
The String
will be converted into a Paragraph
.
content
- a String
public 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 Cell
public Cell(java.util.Properties attributes)
Cell
that has been constructed taking in account
the value of some attributes.attributes
- Some attributespublic static Cell getDummyCell()
public boolean process(ElementListener listener)
ElementListener
.public int type()
public java.util.ArrayList getChunks()
public void addElement(Element element) throws BadElementException
Cell
.
Remark: you can't add ListItem
s, Row
s, Cell
s,
JPEG
s, GIF
s or PNG
s to a Cell
.
element
- The Element
to addBadElementException
- if the method was called with a ListItem
, Row
or Cell
public boolean add(java.lang.Object o)
Object
to this cell.add
in interface TextElementArray
o
- the object to addtrue
public void setLeading(float value)
value
- the new valuepublic void setHorizontalAlignment(int value)
value
- the new valuepublic void setHorizontalAlignment(java.lang.String alignment)
alignment
- the new alignment as a String
public void setVerticalAlignment(int value)
value
- the new valuepublic void setVerticalAlignment(java.lang.String alignment)
alignment
- the new alignment as a String
public void setWidth(java.lang.String value)
value
- the new valuepublic void setColspan(int value)
value
- the new valuepublic void setRowspan(int value)
value
- the new valuepublic void setHeader(boolean value)
value
- the new valuepublic void setNoWrap(boolean value)
value
- the new valuepublic int size()
Element
s in the Cell.size
.public boolean isEmpty()
Cell
is empty.false
if there are non-empty Element
s in the Cell
.void fill()
public boolean isTable()
Cell
is empty.false
if there are non-empty Element
s in the Cell
.public java.util.Iterator getElements()
Element
s.Iterator
.public int horizontalAlignment()
public int verticalAlignment()
public java.lang.String cellWidth()
public int colspan()
public int rowspan()
public float leading()
public boolean header()
Cell
a header?public boolean noWrap()
public void clear()
Element
s of this Cell
.public float top()
UnsupportedOperationException
.public float bottom()
UnsupportedOperationException
.public float left()
UnsupportedOperationException
.public float right()
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 static boolean isTag(java.lang.String tag)
tag
- the given tagpublic boolean getGroupChange()
Cell
force a group change?public void setGroupChange(boolean value)
value
- the new valuepublic int getMaxLines()
maxLines
public void setMaxLines(int value)
maxLines
value
- the maximum number of linespublic void setShowTruncation(java.lang.String value)
showTruncation
value
- Can be null for avoiding marking the truncation.public java.lang.String getShowTruncation()
showTruncation
public void setUseAscender(boolean use)
useAscender
.use
- use ascender height if truepublic boolean isUseAscender()
useAscender
public void setUseDescender(boolean use)
useDescender
.use
- use descender height if truepublic boolean isUseDescender()
useDescender
public void setUseBorderPadding(boolean use)
useBorderPadding
.use
- adjust layour for borders if truepublic boolean isUseBorderPadding()
useBorderPadding
.public PdfPCell createPdfPCell() throws BadElementException
BadElementException