com.lowagie.text
Class Cell

java.lang.Object
  |
  +--com.lowagie.text.Rectangle
        |
        +--com.lowagie.text.Cell
All Implemented Interfaces:
Element, MarkupAttributes, TextElementArray
Direct Known Subclasses:
RtfTableCell

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  ArrayList arrayList
          This is the ArrayList of Elements.
protected  int colspan
          This is the colspan.
static Cell DUMMY_CELL
          This constant can be used as empty cell.
static Cell EMPTY_CELL
          This constant can be used as empty cell.
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  boolean noWrap
          Will the element have to be wrapped?
protected  int rowspan
          This is the rowspan.
protected  int verticalAlignment
          This is the vertical alignment.
protected  String width
          This is the vertical alignment.
 
Fields inherited from class com.lowagie.text.Rectangle
background, border, borderWidth, BOTTOM, BOX, color, grayFill, LEFT, llx, lly, markupAttributes, NO_BORDER, RIGHT, rotation, TOP, UNDEFINED, urx, ury
 
Fields inherited from interface com.lowagie.text.Element
ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_JUSTIFIED, 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, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, ROW, SECTION, SUBJECT, TABLE, TITLE
 
Constructor Summary
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(Properties attributes)
          Returns a Cell that has been constructed taking in account the value of some attributes.
Cell(String content)
          Constructs a Cell with a certain content.
 
Method Summary
 boolean add(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.
 String cellWidth()
          Gets the width.
 void clear()
          Clears all the Elements of this Cell.
 int colspan()
          Gets the colspan.
(package private)  void fill()
          Makes sure there is at least 1 object in the Cell.
 ArrayList getChunks()
          Gets all the chunks in this element.
 Iterator getElements()
          Gets an iterator of Elements.
 boolean getGroupChange()
          Does this Cell force a group change?
 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(String tag)
          Checks if a given tag corresponds with this object.
 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(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 setNoWrap(boolean value)
          Set nowrap.
 void setRight(int value)
          This method throws an UnsupportedOperationException.
 void setRowspan(int value)
          Sets the rowspan.
 void setTop(int value)
          This method throws an UnsupportedOperationException.
 void setVerticalAlignment(int value)
          Sets the vertical alignment.
 void setVerticalAlignment(String alignment)
          Sets the alignment of this paragraph.
 void setWidth(String value)
          Sets the width.
 int size()
          Gets the number of Elements 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.
 
Methods inherited from class com.lowagie.text.Rectangle
backgroundColor, border, borderColor, borderWidth, bottom, getMarkupAttribute, getMarkupAttributeNames, getMarkupAttributes, getRotation, grayFill, hasBorder, hasBorders, height, left, rectangle, right, rotate, setBackgroundColor, setBorder, setBorderColor, setBorderWidth, setBottom, setGrayFill, setLeft, setMarkupAttribute, setMarkupAttributes, setRight, setTop, top, width
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.lowagie.text.Element
toString
 

Field Detail

EMPTY_CELL

public static final Cell EMPTY_CELL
This constant can be used as empty cell.


DUMMY_CELL

public static final Cell DUMMY_CELL
This constant can be used as empty cell.


arrayList

protected ArrayList arrayList
This is the ArrayList of Elements.


horizontalAlignment

protected int horizontalAlignment
This is the horizontal alignment.


verticalAlignment

protected int verticalAlignment
This is the vertical alignment.


width

protected String width
This is the vertical alignment.


colspan

protected int colspan
This is the colspan.


rowspan

protected int rowspan
This is the rowspan.


leading

float leading
This is the leading.


header

protected boolean header
Is this Cell a header?


noWrap

protected boolean noWrap
Will the element have to be wrapped?


groupChange

protected boolean groupChange
Does this Cell force a group change?

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)
     throws BadElementException
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

process

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

Specified by:
process in interface Element
Overrides:
process in class Rectangle
Parameters:
listener - an ElementListener
Returns:
true if the element was processed successfully

type

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

Specified by:
type in interface Element
Overrides:
type in class Rectangle
Returns:
a type

getChunks

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

Specified by:
getChunks in interface Element
Overrides:
getChunks in class Rectangle
Returns:
an ArrayList

addElement

public void addElement(Element element)
                throws BadElementException
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

add

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

Specified by:
add in interface TextElementArray
Parameters:
o - the object to add
Returns:
always true

setLeading

public void setLeading(float value)
Sets the leading.

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

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

setColspan

public void setColspan(int value)
Sets the colspan.

Parameters:
value - the new value

setRowspan

public void setRowspan(int value)
Sets the rowspan.

Parameters:
value - the new value

setHeader

public void setHeader(boolean value)
Sets header.

Parameters:
value - the new value

setNoWrap

public void setNoWrap(boolean value)
Set nowrap.

Parameters:
value - the new value

size

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

Returns:
a size.

isEmpty

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

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

fill

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


isTable

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

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

getElements

public Iterator getElements()
Gets an iterator of Elements.

Returns:
an Iterator.

horizontalAlignment

public int horizontalAlignment()
Gets the horizontal alignment.

Returns:
a value

verticalAlignment

public int verticalAlignment()
Gets the vertical alignment.

Returns:
a value

cellWidth

public String cellWidth()
Gets the width.

Returns:
a value

colspan

public int colspan()
Gets the colspan.

Returns:
a value

rowspan

public int rowspan()
Gets the rowspan.

Returns:
a value

leading

public float leading()
Gets the leading.

Returns:
a value

header

public boolean header()
Is this Cell a header?

Returns:
a value

noWrap

public boolean noWrap()
Get nowrap.

Returns:
a value

clear

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


top

public float top()
This method throws an UnsupportedOperationException.

Overrides:
top in class Rectangle
Returns:
the upper right y-coordinate

bottom

public float bottom()
This method throws an UnsupportedOperationException.

Overrides:
bottom in class Rectangle
Returns:
the lower left y-coordinate

left

public float left()
This method throws an UnsupportedOperationException.

Overrides:
left in class Rectangle
Returns:
the lower left x-coordinate

right

public float right()
This method throws an UnsupportedOperationException.

Overrides:
right in class Rectangle
Returns:
the upper right x-coordinate

top

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


bottom

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


left

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


right

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


setTop

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


setBottom

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


setLeft

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


setRight

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


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

getGroupChange

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

Returns:
a value

setGroupChange

public void setGroupChange(boolean value)
Sets group change.

Parameters:
value - the new value