com.lowagie.text

Class Cell

public class Cell extends Rectangle implements TextElementArray

A 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");
 

See Also: Rectangle Element Table Row

Field Summary
protected ArrayListarrayList
This is the ArrayList of Elements.
protected intcolspan
This is the colspan.
protected booleangroupChange
Does this Cell force a group change?
protected booleanheader
Is this Cell a header?
protected inthorizontalAlignment
This is the horizontal alignment.
floatleading
This is the leading.
protected intmaxLines
Maximum number of lines allowed in the cell.
protected introwspan
This is the rowspan.
StringshowTruncation
If a truncation happens due to the maxLines property, then this text will be added to indicate a truncation has happened.
protected booleanuseAscender
Indicates that the largest ascender height should be used to determine the height of the first line.
protected booleanuseBorderPadding
Adjusts the cell contents to compensate for border widths.
protected booleanuseDescender
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 intverticalAlignment
This is the vertical alignment.
protected Stringwidth
This is the vertical alignment.
Constructor Summary
Cell()
Constructs an empty Cell.
Cell(boolean dummy)
Constructs an empty Cell (for internal use only).
Cell(String content)
Constructs a Cell with a certain content.
Cell(Element element)
Constructs a Cell with a certain Element.
Cell(Properties attributes)
Returns a Cell that has been constructed taking in account the value of some attributes.
Method Summary
booleanadd(Object o)
Add an Object to this cell.
voidaddElement(Element element)
Adds an element to this Cell.
floatbottom()
This method throws an UnsupportedOperationException.
floatbottom(int margin)
This method throws an UnsupportedOperationException.
StringcellWidth()
Gets the width.
voidclear()
Clears all the Elements of this Cell.
intcolspan()
Gets the colspan.
PdfPCellcreatePdfPCell()
Creates a PdfPCell based on this Cell object.
voidfill()
Makes sure there is at least 1 object in the Cell.
ArrayListgetChunks()
Gets all the chunks in this element.
static CellgetDummyCell()
Get dummy cell used when merging inner tables.
IteratorgetElements()
Gets an iterator of Elements.
booleangetGroupChange()
Does this Cell force a group change?
intgetMaxLines()
Getter for
StringgetShowTruncation()
Getter for
booleanheader()
Is this Cell a header?
inthorizontalAlignment()
Gets the horizontal alignment.
booleanisEmpty()
Checks if the Cell is empty.
booleanisTable()
Checks if the Cell is empty.
static booleanisTag(String tag)
Checks if a given tag corresponds with this object.
booleanisUseAscender()
Gets the value of
booleanisUseBorderPadding()
Gets the value of useBorderPadding.
booleanisUseDescender()
gets the value of
floatleading()
Gets the leading.
floatleft()
This method throws an UnsupportedOperationException.
floatleft(int margin)
This method throws an UnsupportedOperationException.
booleannoWrap()
Get nowrap.
booleanprocess(ElementListener listener)
Processes the element by adding it (or the different parts) to an ElementListener.
floatright()
This method throws an UnsupportedOperationException.
floatright(int margin)
This method throws an UnsupportedOperationException.
introwspan()
Gets the rowspan.
voidsetBottom(int value)
This method throws an UnsupportedOperationException.
voidsetColspan(int value)
Sets the colspan.
voidsetGroupChange(boolean value)
Sets group change.
voidsetHeader(boolean value)
Sets header.
voidsetHorizontalAlignment(int value)
Sets the horizontal alignment.
voidsetHorizontalAlignment(String alignment)
Sets the alignment of this cell.
voidsetLeading(float value)
Sets the leading.
voidsetLeft(int value)
This method throws an UnsupportedOperationException.
voidsetMaxLines(int value)
Setter for
voidsetNoWrap(boolean value)
Set nowrap.
voidsetRight(int value)
This method throws an UnsupportedOperationException.
voidsetRowspan(int value)
Sets the rowspan.
voidsetShowTruncation(String value)
Setter for
voidsetTop(int value)
This method throws an UnsupportedOperationException.
voidsetUseAscender(boolean use)
Sets the value of useAscender.
voidsetUseBorderPadding(boolean use)
Sets the value of useBorderPadding.
voidsetUseDescender(boolean use)
Sets the value of useDescender.
voidsetVerticalAlignment(int value)
Sets the vertical alignment.
voidsetVerticalAlignment(String alignment)
Sets the alignment of this paragraph.
voidsetWidth(String value)
Sets the width.
intsize()
Gets the number of Elements in the Cell.
floattop()
This method throws an UnsupportedOperationException.
floattop(int margin)
This method throws an UnsupportedOperationException.
inttype()
Gets the type of the text element.
intverticalAlignment()
Gets the vertical alignment.

Field Detail

arrayList

protected ArrayList arrayList
This is the ArrayList of Elements.

colspan

protected int colspan
This is the colspan.

groupChange

protected boolean groupChange
Does this Cell force a group change?

header

protected boolean header
Is this Cell a header?

horizontalAlignment

protected int horizontalAlignment
This is the horizontal alignment.

leading

float leading
This is the leading.

maxLines

protected int maxLines
Maximum number of lines allowed in the cell. The default value of this property is not to limit the maximum number of lines (contributed by dperezcar@fcc.es)

rowspan

protected int rowspan
This is the rowspan.

showTruncation

String showTruncation
If a truncation happens due to the 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)

useAscender

protected boolean useAscender
Indicates that the largest ascender height should be used to determine the height of the first line. Note that this only has an effect when rendered to PDF. Setting this to true can help with vertical alignment problems.

useBorderPadding

protected boolean useBorderPadding
Adjusts the cell contents to compensate for border widths. Note that this only has an effect when rendered to PDF.

useDescender

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). Note that this only has an effect when rendered to PDF.

verticalAlignment

protected int verticalAlignment
This is the vertical alignment.

width

protected String width
This is the vertical alignment.

Constructor Detail

Cell

public Cell()
Constructs an empty Cell.

Cell

public Cell(boolean dummy)
Constructs an empty Cell (for internal use only).

Parameters: dummy a dummy value

Cell

public Cell(String content)
Constructs a Cell with a certain content.

The String will be converted into a Paragraph.

Parameters: content a String

Cell

public Cell(Element element)
Constructs a Cell with a certain Element.

if the element is a ListItem, Row or Cell, an exception will be thrown.

Parameters: element the element

Throws: BadElementException when the creator was called with a ListItem, Row or Cell

Cell

public Cell(Properties attributes)
Returns a Cell that has been constructed taking in account the value of some attributes.

Parameters: attributes Some attributes

Method Detail

add

public boolean add(Object o)
Add an Object to this cell.

Parameters: o the object to add

Returns: always true

addElement

public void addElement(Element element)
Adds an element to this Cell.

Remark: you can't add ListItems, Rows, Cells, JPEGs, GIFs or PNGs to a Cell.

Parameters: element The Element to add

Throws: BadElementException if the method was called with a ListItem, Row or Cell

bottom

public float bottom()
This method throws an UnsupportedOperationException.

Returns: NA

bottom

public float bottom(int margin)
This method throws an UnsupportedOperationException.

Parameters: margin

Returns: NA

cellWidth

public String cellWidth()
Gets the width.

Returns: a value

clear

public void clear()
Clears all the Elements of this Cell.

colspan

public int colspan()
Gets the colspan.

Returns: a value

createPdfPCell

public PdfPCell createPdfPCell()
Creates a PdfPCell based on this Cell object.

Returns: a PdfPCell

Throws: BadElementException

fill

void fill()
Makes sure there is at least 1 object in the Cell. Otherwise it might not be shown in the table.

getChunks

public ArrayList getChunks()
Gets all the chunks in this element.

Returns: an ArrayList

getDummyCell

public static Cell getDummyCell()
Get dummy cell used when merging inner tables.

Returns: a cell with colspan 3 and no border

getElements

public Iterator getElements()
Gets an iterator of Elements.

Returns: an Iterator.

getGroupChange

public boolean getGroupChange()
Does this Cell force a group change?

Returns: a value

getMaxLines

public int getMaxLines()
Getter for maxLines

Returns: the maxLines value

getShowTruncation

public String getShowTruncation()
Getter for showTruncation

Returns: the showTruncation value

header

public boolean header()
Is this Cell a header?

Returns: a value

horizontalAlignment

public int horizontalAlignment()
Gets the horizontal alignment.

Returns: a value

isEmpty

public boolean isEmpty()
Checks if the Cell is empty.

Returns: false if there are non-empty Elements in the Cell.

isTable

public boolean isTable()
Checks if the Cell is empty.

Returns: false if there are non-empty Elements in the Cell.

isTag

public static boolean isTag(String tag)
Checks if a given tag corresponds with this object.

Parameters: tag the given tag

Returns: true if the tag corresponds

isUseAscender

public boolean isUseAscender()
Gets the value of useAscender

Returns: useAscender

isUseBorderPadding

public boolean isUseBorderPadding()
Gets the value of useBorderPadding.

Returns: useBorderPadding

isUseDescender

public boolean isUseDescender()
gets the value of useDescender

Returns: useDescender

leading

public float leading()
Gets the leading.

Returns: a value

left

public float left()
This method throws an UnsupportedOperationException.

Returns: NA

left

public float left(int margin)
This method throws an UnsupportedOperationException.

Parameters: margin

Returns: NA

noWrap

public boolean noWrap()
Get nowrap.

Returns: a value

process

public boolean process(ElementListener listener)
Processes the element by adding it (or the different parts) to an ElementListener.

Parameters: listener an ElementListener

Returns: true if the element was processed successfully

right

public float right()
This method throws an UnsupportedOperationException.

Returns: NA

right

public float right(int margin)
This method throws an UnsupportedOperationException.

Parameters: margin NA

Returns: NA

rowspan

public int rowspan()
Gets the rowspan.

Returns: a value

setBottom

public void setBottom(int value)
This method throws an UnsupportedOperationException.

Parameters: value NA

setColspan

public void setColspan(int value)
Sets the colspan.

Parameters: value the new value

setGroupChange

public void setGroupChange(boolean value)
Sets group change.

Parameters: value the new value

setHeader

public void setHeader(boolean value)
Sets header.

Parameters: value the new value

setHorizontalAlignment

public void setHorizontalAlignment(int value)
Sets the horizontal alignment.

Parameters: value the new value

setHorizontalAlignment

public void setHorizontalAlignment(String alignment)
Sets the alignment of this cell.

Parameters: alignment the new alignment as a String

setLeading

public void setLeading(float value)
Sets the leading.

Parameters: value the new value

setLeft

public void setLeft(int value)
This method throws an UnsupportedOperationException.

Parameters: value NA

setMaxLines

public void setMaxLines(int value)
Setter for maxLines

Parameters: value the maximum number of lines

setNoWrap

public void setNoWrap(boolean value)
Set nowrap.

Parameters: value the new value

setRight

public void setRight(int value)
This method throws an UnsupportedOperationException.

Parameters: value NA

setRowspan

public void setRowspan(int value)
Sets the rowspan.

Parameters: value the new value

setShowTruncation

public void setShowTruncation(String value)
Setter for showTruncation

Parameters: value Can be null for avoiding marking the truncation.

setTop

public void setTop(int value)
This method throws an UnsupportedOperationException.

Parameters: value NA

setUseAscender

public void setUseAscender(boolean use)
Sets the value of useAscender.

Parameters: use use ascender height if true

setUseBorderPadding

public void setUseBorderPadding(boolean use)
Sets the value of useBorderPadding.

Parameters: use adjust layour for borders if true

setUseDescender

public void setUseDescender(boolean use)
Sets the value of useDescender.

Parameters: use use descender height if true

setVerticalAlignment

public void setVerticalAlignment(int value)
Sets the vertical alignment.

Parameters: value the new value

setVerticalAlignment

public void setVerticalAlignment(String alignment)
Sets the alignment of this paragraph.

Parameters: alignment the new alignment as a String

setWidth

public void setWidth(String value)
Sets the width.

Parameters: value the new value

size

public int size()
Gets the number of Elements in the Cell.

Returns: a size.

top

public float top()
This method throws an UnsupportedOperationException.

Returns: NA

top

public float top(int margin)
This method throws an UnsupportedOperationException.

Parameters: margin

Returns: NA

type

public int type()
Gets the type of the text element.

Returns: a type

verticalAlignment

public int verticalAlignment()
Gets the vertical alignment.

Returns: a value