com.lowagie.text

## Class SimpleCell

- java.lang.Object
- - com.lowagie.text.Rectangle
  - - com.lowagie.text.SimpleCell

- All Implemented Interfaces:
    Element, PdfPCellEvent, TextElementArray

      public class SimpleCell
      extends Rectangle
      implements PdfPCellEvent, TextElementArray

  Rectangle that can be used for Cells. This Rectangle is padded and knows how to draw itself in a PdfPTable or PdfPcellEvent.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static boolean` | `CELL` the CellAttributes object represents a cell.
    `private boolean` | `cellgroup` indicates if these are the attributes of a single Cell (false) or a group of Cells (true).
    `private int` | `colspan` the colspan of a Cell
    `private java.util.ArrayList` | `content` the content of the Cell.
    `private int` | `horizontalAlignment` horizontal alignment inside the Cell.
    `private float` | `padding_bottom` an extra padding variable
    `private float` | `padding_left` an extra padding variable
    `private float` | `padding_right` an extra padding variable
    `private float` | `padding_top` an extra padding variable
    `static boolean` | `ROW` the CellAttributes object represents a row.
    `private float` | `spacing_bottom` an extra spacing variable
    `private float` | `spacing_left` an extra spacing variable
    `private float` | `spacing_right` an extra spacing variable
    `private float` | `spacing_top` an extra spacing variable
    `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).
    `private int` | `verticalAlignment` vertical alignment inside the Cell.
    `private float` | `width` the width of the Cell.
    `private float` | `widthpercentage` the widthpercentage of the Cell.

    - ### 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, useVariableBorders`

    - ### Fields 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, CHAPTER, CHUNK, CREATIONDATE, CREATOR, HEADER, IMGRAW, IMGTEMPLATE, JBIG2, JPEG, JPEG2000, KEYWORDS, LIST, LISTITEM, MARKED, MULTI_COLUMN_TEXT, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, SECTION, SUBJECT, TABLE, TITLE, YMARK`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleCell(boolean row)` A CellAttributes object is always constructed without any dimensions.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `add(java.lang.Object o)` Adds an object to the `TextElementArray`.
    `void` | `addElement(Element element)` Adds content to this object.
    `void` | `cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases)` This method is called at the end of the cell rendering.
    `Cell` | `createCell(SimpleCell rowAttributes)` Creates a Cell with these attributes.
    `PdfPCell` | `createPdfPCell(SimpleCell rowAttributes)` Creates a PdfPCell with these attributes.
    `int` | `getColspan()`
    `(package private) java.util.ArrayList` | `getContent()`
    `int` | `getHorizontalAlignment()`
    `float` | `getPadding_bottom()`
    `float` | `getPadding_left()`
    `float` | `getPadding_right()`
    `float` | `getPadding_top()`
    `float` | `getSpacing_bottom()`
    `float` | `getSpacing_left()`
    `float` | `getSpacing_right()`
    `float` | `getSpacing_top()`
    `int` | `getVerticalAlignment()`
    `float` | `getWidth()` Returns the width of the rectangle.
    `float` | `getWidthpercentage()`
    `boolean` | `isCellgroup()`
    `boolean` | `isUseAscender()`
    `boolean` | `isUseBorderPadding()`
    `boolean` | `isUseDescender()`
    `void` | `setCellgroup(boolean cellgroup)`
    `void` | `setColspan(int colspan)`
    `void` | `setHorizontalAlignment(int horizontalAlignment)`
    `void` | `setPadding_bottom(float padding_bottom)`
    `void` | `setPadding_left(float padding_left)`
    `void` | `setPadding_right(float padding_right)`
    `void` | `setPadding_top(float padding_top)`
    `void` | `setPadding(float padding)` Sets the padding parameters if they are undefined.
    `void` | `setSpacing_bottom(float spacing)`
    `void` | `setSpacing_left(float spacing)`
    `void` | `setSpacing_right(float spacing)`
    `void` | `setSpacing_top(float spacing)`
    `void` | `setSpacing(float spacing)`
    `void` | `setUseAscender(boolean useAscender)`
    `void` | `setUseBorderPadding(boolean useBorderPadding)`
    `void` | `setUseDescender(boolean useDescender)`
    `void` | `setVerticalAlignment(int verticalAlignment)`
    `void` | `setWidth(float width)`
    `void` | `setWidthpercentage(float widthpercentage)`
    `int` | `type()` 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, getBottom, getChunks, getGrayFill, getHeight, getLeft, getLeft, getRight, getRight, getRotation, getTop, getTop, hasBorder, hasBorders, isContent, isNestable, isUseVariableBorders, normalize, process, rectangle, rotate, setBackgroundColor, setBorder, setBorderColor, setBorderColorBottom, setBorderColorLeft, setBorderColorRight, setBorderColorTop, setBorderWidth, setBorderWidthBottom, setBorderWidthLeft, setBorderWidthRight, setBorderWidthTop, setBottom, setGrayFill, setLeft, setRight, setTop, setUseVariableBorders, softCloneNonPositionParameters, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface com.lowagie.text.Element

      `getChunks, isContent, isNestable, process, toString`

- - ### Field Detail

    - #### ROW

          public static final boolean ROW

      the CellAttributes object represents a row.
      See Also:
        Constant Field Values

    - #### CELL

          public static final boolean CELL

      the CellAttributes object represents a cell.
      See Also:
        Constant Field Values

    - #### content

          private java.util.ArrayList content

      the content of the Cell.

    - #### width

          private float width

      the width of the Cell.

    - #### widthpercentage

          private float widthpercentage

      the widthpercentage of the Cell.

    - #### spacing_left

          private float spacing_left

      an extra spacing variable

    - #### spacing_right

          private float spacing_right

      an extra spacing variable

    - #### spacing_top

          private float spacing_top

      an extra spacing variable

    - #### spacing_bottom

          private float spacing_bottom

      an extra spacing variable

    - #### padding_left

          private float padding_left

      an extra padding variable

    - #### padding_right

          private float padding_right

      an extra padding variable

    - #### padding_top

          private float padding_top

      an extra padding variable

    - #### padding_bottom

          private float padding_bottom

      an extra padding variable

    - #### colspan

          private int colspan

      the colspan of a Cell

    - #### horizontalAlignment

          private int horizontalAlignment

      horizontal alignment inside the Cell.

    - #### verticalAlignment

          private int verticalAlignment

      vertical alignment inside the Cell.

    - #### cellgroup

          private boolean cellgroup

      indicates if these are the attributes of a single Cell (false) or a group of Cells (true).

    - #### 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.

    - #### 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.

    - #### useBorderPadding

          protected boolean useBorderPadding

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

  - ### Constructor Detail

    - #### SimpleCell

          public SimpleCell(boolean row)

      A CellAttributes object is always constructed without any dimensions. Dimensions are defined after creation.
      Parameters:
        `row` - only true if the CellAttributes object represents a row.

  - ### Method Detail

    - #### addElement

          public void addElement(Element element)
                          throws BadElementException

      Adds content to this object.
      Parameters:
        `element` -
      Throws:
        `BadElementException`

    - #### createCell

          public Cell createCell(SimpleCell rowAttributes)
                          throws BadElementException

      Creates a Cell with these attributes.
      Parameters:
        `rowAttributes` -
      Returns:
        a cell based on these attributes.
      Throws:
        `BadElementException`

    - #### createPdfPCell

          public PdfPCell createPdfPCell(SimpleCell rowAttributes)

      Creates a PdfPCell with these attributes.
      Parameters:
        `rowAttributes` -
      Returns:
        a PdfPCell based on these attributes.

    - #### cellLayout

          public void cellLayout(PdfPCell cell,
                        Rectangle position,
                        PdfContentByte[] canvases)

      Description copied from interface: `PdfPCellEvent`
      This method is called at the end of the cell rendering. The text or graphics are added to one of the 4 `PdfContentByte` contained in `canvases`.
      The indexes to `canvases` are:

      - `PdfPTable.BASECANVAS` - the original `PdfContentByte`. Anything placed here will be under the cell.
      - `PdfPTable.BACKGROUNDCANVAS` - the layer where the background goes to.
      - `PdfPTable.LINECANVAS` - the layer where the lines go to.
      - `PdfPTable.TEXTCANVAS` - the layer where the text go to. Anything placed here will be over the cell.
      The layers are placed in sequence on top of each other.

      Specified by:
        `cellLayout` in interface `PdfPCellEvent`
      Parameters:
        `cell` - the cell
        `position` - the coordinates of the cell
        `canvases` - an array of `PdfContentByte`
      See Also:
        `PdfPCellEvent.cellLayout(com.lowagie.text.pdf.PdfPCell, com.lowagie.text.Rectangle, com.lowagie.text.pdf.PdfContentByte[])`

    - #### setPadding

          public void setPadding(float padding)

      Sets the padding parameters if they are undefined.
      Parameters:
        `padding` -

    - #### getColspan

          public int getColspan()

      Returns:
        Returns the colspan.

    - #### setColspan

          public void setColspan(int colspan)

      Parameters:
        `colspan` - The colspan to set.

    - #### getPadding_bottom

          public float getPadding_bottom()

      Returns:
        Returns the padding_bottom.

    - #### setPadding_bottom

          public void setPadding_bottom(float padding_bottom)

      Parameters:
        `padding_bottom` - The padding_bottom to set.

    - #### getPadding_left

          public float getPadding_left()

      Returns:
        Returns the padding_left.

    - #### setPadding_left

          public void setPadding_left(float padding_left)

      Parameters:
        `padding_left` - The padding_left to set.

    - #### getPadding_right

          public float getPadding_right()

      Returns:
        Returns the padding_right.

    - #### setPadding_right

          public void setPadding_right(float padding_right)

      Parameters:
        `padding_right` - The padding_right to set.

    - #### getPadding_top

          public float getPadding_top()

      Returns:
        Returns the padding_top.

    - #### setPadding_top

          public void setPadding_top(float padding_top)

      Parameters:
        `padding_top` - The padding_top to set.

    - #### getSpacing_left

          public float getSpacing_left()

      Returns:
        Returns the spacing.

    - #### getSpacing_right

          public float getSpacing_right()

      Returns:
        Returns the spacing.

    - #### getSpacing_top

          public float getSpacing_top()

      Returns:
        Returns the spacing.

    - #### getSpacing_bottom

          public float getSpacing_bottom()

      Returns:
        Returns the spacing.

    - #### setSpacing

          public void setSpacing(float spacing)

      Parameters:
        `spacing` - The spacing to set.

    - #### setSpacing_left

          public void setSpacing_left(float spacing)

      Parameters:
        `spacing` - The spacing to set.

    - #### setSpacing_right

          public void setSpacing_right(float spacing)

      Parameters:
        `spacing` - The spacing to set.

    - #### setSpacing_top

          public void setSpacing_top(float spacing)

      Parameters:
        `spacing` - The spacing to set.

    - #### setSpacing_bottom

          public void setSpacing_bottom(float spacing)

      Parameters:
        `spacing` - The spacing to set.

    - #### isCellgroup

          public boolean isCellgroup()

      Returns:
        Returns the cellgroup.

    - #### setCellgroup

          public void setCellgroup(boolean cellgroup)

      Parameters:
        `cellgroup` - The cellgroup to set.

    - #### getHorizontalAlignment

          public int getHorizontalAlignment()

      Returns:
        Returns the horizontal alignment.

    - #### setHorizontalAlignment

          public void setHorizontalAlignment(int horizontalAlignment)

      Parameters:
        `horizontalAlignment` - The horizontalAlignment to set.

    - #### getVerticalAlignment

          public int getVerticalAlignment()

      Returns:
        Returns the vertical alignment.

    - #### setVerticalAlignment

          public void setVerticalAlignment(int verticalAlignment)

      Parameters:
        `verticalAlignment` - The verticalAligment to set.

    - #### getWidth

          public float getWidth()

      Description copied from class: `Rectangle`
      Returns the width of the rectangle.
      Overrides:
        `getWidth` in class `Rectangle`
      Returns:
        Returns the width.

    - #### setWidth

          public void setWidth(float width)

      Parameters:
        `width` - The width to set.

    - #### getWidthpercentage

          public float getWidthpercentage()

      Returns:
        Returns the widthpercentage.

    - #### setWidthpercentage

          public void setWidthpercentage(float widthpercentage)

      Parameters:
        `widthpercentage` - The widthpercentage to set.

    - #### isUseAscender

          public boolean isUseAscender()

      Returns:
        Returns the useAscender.

    - #### setUseAscender

          public void setUseAscender(boolean useAscender)

      Parameters:
        `useAscender` - The useAscender to set.

    - #### isUseBorderPadding

          public boolean isUseBorderPadding()

      Returns:
        Returns the useBorderPadding.

    - #### setUseBorderPadding

          public void setUseBorderPadding(boolean useBorderPadding)

      Parameters:
        `useBorderPadding` - The useBorderPadding to set.

    - #### isUseDescender

          public boolean isUseDescender()

      Returns:
        Returns the useDescender.

    - #### setUseDescender

          public void setUseDescender(boolean useDescender)

      Parameters:
        `useDescender` - The useDescender to set.

    - #### getContent

          java.util.ArrayList getContent()

      Returns:
        Returns the content.

    - #### add

          public boolean add(java.lang.Object o)

      Description copied from interface: `TextElementArray`
      Adds an object to the `TextElementArray`.
      Specified by:
        `add` in interface `TextElementArray`
      Parameters:
        `o` - an object that has to be added
      Returns:
        `true` if the addition succeeded; `false` otherwise
      See Also:
        `TextElementArray.add(java.lang.Object)`

    - #### type

          public int type()

      Description copied from class: `Rectangle`
      Gets the type of the text element.
      Specified by:
        `type` in interface `Element`
      Overrides:
        `type` in class `Rectangle`
      Returns:
        a type
      See Also:
        `Element.type()`