Package com.lowagie.text
Class Cell
java.lang.Object
com.lowagie.text.Rectangle
com.lowagie.text.Cell
- All Implemented Interfaces:
Element,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");
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ArrayListTheArrayListofElements that are part of the content of the Cell.protected intThe colspan of the cell.protected booleanDoes thisCellforce a group change?protected booleanIs thisCella header?protected intThe horizontal alignment of the cell content.protected intMaximum number of lines allowed in the cell.protected booleanprotected intThe rowspan of the cell.protected booleanIndicates that the largest ascender height should be used to determine the height of the first line.protected booleanAdjusts the cell contents to compensate for border widths.protected booleanIndicates 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 intThe vertical alignment of the cell content.protected floatThe width of the cell as a String.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, useVariableBordersFields 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, 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 -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdd anObjectto this cell.voidaddElement(Element element) Adds an element to thisCell.floatbottom(int margin) This method throws anUnsupportedOperationException.voidclear()Clears all theElements of thisCell.Creates a PdfPCell based on this Cell object.floatThis method throws anUnsupportedOperationException.Gets all the chunks in this element.intGets the colspan.Gets an iterator ofElements.booleanDoes thisCellforce a group change?intGets the horizontal alignment.floatGets the leading.floatgetLeft()This method throws anUnsupportedOperationException.intGetter for maxLinesfloatgetRight()This method throws anUnsupportedOperationException.intGets the rowspan.Getter for showTruncationfloatgetTop()This method throws anUnsupportedOperationException.intGets the vertical alignment.floatgetWidth()Gets the width.Gets the width as a String.booleanisEmpty()Checks if theCellis empty.booleanisHeader()Is thisCella header?booleanisTable()Checks if thisCellis a placeholder for a (nested) table.booleanGets the value of useAscenderbooleanGets the value of useBorderPadding.booleangets the value of useDescenderfloatleft(int margin) This method throws anUnsupportedOperationException.booleanprocess(ElementListener listener) Processes the element by adding it (or the different parts) to anElementListener.floatright(int margin) This method throws anUnsupportedOperationException.voidsetBottom(int value) This method throws anUnsupportedOperationException.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 anUnsupportedOperationException.voidsetMaxLines(int value) Setter for maxLinesvoidsetRight(int value) This method throws anUnsupportedOperationException.voidsetRowspan(int value) Sets the rowspan.voidsetShowTruncation(String value) Setter for showTruncationvoidsetTop(int value) This method throws anUnsupportedOperationException.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(float value) Sets the width.voidSets the width.intsize()Gets the number ofElements in the Cell.floattop(int margin) This method throws anUnsupportedOperationException.inttype()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, 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, setTop, setUseVariableBorders, softCloneNonPositionParameters, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.lowagie.text.Element
isContent, isNestable, toString
-
Field Details
-
arrayList
TheArrayListofElements that are part of the content of the Cell. -
horizontalAlignment
protected int horizontalAlignmentThe horizontal alignment of the cell content. -
verticalAlignment
protected int verticalAlignmentThe vertical alignment of the cell content. -
width
protected float widthThe width of the cell as a String. It can be an absolute value "100" or a percentage "20%". -
percentage
protected boolean percentage -
colspan
protected int colspanThe colspan of the cell. -
rowspan
protected int rowspanThe rowspan of the cell. -
header
protected boolean headerIs thisCella header? -
maxLines
protected int maxLinesMaximum 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) -
useAscender
protected boolean useAscenderIndicates 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. -
useDescender
protected boolean useDescenderIndicates 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. -
useBorderPadding
protected boolean useBorderPaddingAdjusts the cell contents to compensate for border widths. Note that this only has an effect when rendered to PDF. -
groupChange
protected boolean groupChangeDoes thisCellforce a group change?
-
-
Constructor Details
-
Cell
public Cell()Constructs an emptyCell. -
Cell
public Cell(boolean dummy) Constructs an emptyCell(for internal use only).- Parameters:
dummy- a dummy value
-
Cell
Constructs aCellwith a certain content.The
Stringwill be converted into aParagraph.- Parameters:
content- aString
-
Cell
Constructs aCellwith a certainElement.if the element is a
ListItem,RoworCell, an exception will be thrown.- Parameters:
element- the element- Throws:
BadElementException- when the creator was called with aListItem,RoworCell
-
-
Method Details
-
process
Processes the element by adding it (or the different parts) to anElementListener. -
type
public int type()Gets the type of the text element. -
getChunks
Gets all the chunks in this element. -
getHorizontalAlignment
public int getHorizontalAlignment()Gets the horizontal alignment.- Returns:
- a value
-
setHorizontalAlignment
public void setHorizontalAlignment(int value) Sets the horizontal alignment.- Parameters:
value- the new value
-
setHorizontalAlignment
Sets the alignment of this cell. This methods allows you to set the alignment as a String.- Parameters:
alignment- the new alignment as aString
-
getVerticalAlignment
public int getVerticalAlignment()Gets the vertical alignment.- Returns:
- a value
-
setVerticalAlignment
public void setVerticalAlignment(int value) Sets the vertical alignment.- Parameters:
value- the new value
-
setVerticalAlignment
Sets the alignment of this paragraph.- Parameters:
alignment- the new alignment as aString
-
setWidth
public void setWidth(float value) Sets the width.- Parameters:
value- the new value
-
setWidth
Sets the width. It can be an absolute value "100" or a percentage "20%"- Parameters:
value- the new value
-
getWidth
public float getWidth()Gets the width. -
getWidthAsString
Gets the width as a String.- Returns:
- a value
-
setColspan
public void setColspan(int value) Sets the colspan.- Parameters:
value- the new value
-
getColspan
public int getColspan()Gets the colspan.- Returns:
- a value
-
setRowspan
public void setRowspan(int value) Sets the rowspan.- Parameters:
value- the new value
-
getRowspan
public int getRowspan()Gets the rowspan.- Returns:
- a value
-
setLeading
public void setLeading(float value) Sets the leading.- Parameters:
value- the new value
-
getLeading
public float getLeading()Gets the leading.- Returns:
- a value
-
setHeader
public void setHeader(boolean value) Sets header.- Parameters:
value- the new value
-
isHeader
public boolean isHeader()Is thisCella header?- Returns:
- a value
-
setMaxLines
public void setMaxLines(int value) Setter for maxLines- Parameters:
value- the maximum number of lines
-
getMaxLines
public int getMaxLines()Getter for maxLines- Returns:
- the maxLines value
-
setShowTruncation
Setter for showTruncation- Parameters:
value- Can be null for avoiding marking the truncation.
-
getShowTruncation
Getter for showTruncation- Returns:
- the showTruncation value
-
setUseAscender
public void setUseAscender(boolean use) Sets the value of useAscender.- Parameters:
use- use ascender height if true
-
isUseAscender
public boolean isUseAscender()Gets the value of useAscender- Returns:
- useAscender
-
setUseDescender
public void setUseDescender(boolean use) Sets the value of useDescender.- Parameters:
use- use descender height if true
-
isUseDescender
public boolean isUseDescender()gets the value of useDescender- Returns:
- useDescender
-
setUseBorderPadding
public void setUseBorderPadding(boolean use) Sets the value of useBorderPadding.- Parameters:
use- adjust layout for borders if true
-
isUseBorderPadding
public boolean isUseBorderPadding()Gets the value of useBorderPadding.- Returns:
- useBorderPadding
-
getGroupChange
public boolean getGroupChange()Does thisCellforce a group change?- Returns:
- a value
-
setGroupChange
public void setGroupChange(boolean value) Sets group change.- Parameters:
value- the new value
-
size
public int size()Gets the number ofElements in the Cell.- Returns:
- a
size.
-
getElements
Gets an iterator ofElements.- Returns:
- an
Iterator.
-
clear
public void clear()Clears all theElements of thisCell. -
isEmpty
public boolean isEmpty()Checks if theCellis empty.- Returns:
falseif there are non-emptyElements in theCell.
-
isTable
public boolean isTable()Checks if thisCellis a placeholder for a (nested) table.- Returns:
- true if the only element in this cell is a table
-
addElement
Adds an element to thisCell.Remark: you can't add
ListItems,Rows,Cells,JPEGs,GIFs orPNGs to aCell.- Parameters:
element- TheElementto add- Throws:
BadElementException- if the method was called with aListItem,RoworCell
-
add
Add anObjectto this cell.- Specified by:
addin interfaceTextElementArray- Parameters:
o- the object to add- Returns:
- always
true
-
createPdfPCell
Creates a PdfPCell based on this Cell object.- Returns:
- a PdfPCell
- Throws:
BadElementException
-
getTop
public float getTop()This method throws anUnsupportedOperationException. -
getBottom
public float getBottom()This method throws anUnsupportedOperationException. -
getLeft
public float getLeft()This method throws anUnsupportedOperationException. -
getRight
public float getRight()This method throws anUnsupportedOperationException. -
top
public float top(int margin) This method throws anUnsupportedOperationException.- Parameters:
margin-- Returns:
- NA
-
bottom
public float bottom(int margin) This method throws anUnsupportedOperationException.- Parameters:
margin-- Returns:
- NA
-
left
public float left(int margin) This method throws anUnsupportedOperationException.- Parameters:
margin-- Returns:
- NA
-
right
public float right(int margin) This method throws anUnsupportedOperationException.- Parameters:
margin- NA- Returns:
- NA
-
setTop
public void setTop(int value) This method throws anUnsupportedOperationException.- Parameters:
value- NA
-
setBottom
public void setBottom(int value) This method throws anUnsupportedOperationException.- Parameters:
value- NA
-
setLeft
public void setLeft(int value) This method throws anUnsupportedOperationException.- Parameters:
value- NA
-
setRight
public void setRight(int value) This method throws anUnsupportedOperationException.- Parameters:
value- NA
-