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 Details

    • ROW

      public static final boolean ROW
      the CellAttributes object represents a row.
      See Also:
    • CELL

      public static final boolean CELL
      the CellAttributes object represents a cell.
      See Also:
    • 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.
    • content

      private List<Element> 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).
  • Constructor Details

    • 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 Details

    • addElement

      public void addElement(Element element) throws BadElementException
      Adds content to this object.
      Parameters:
      element - an object of type Element that you want to add to the cell
      Throws:
      BadElementException - on error
    • createCell

      public Cell createCell(SimpleCell rowAttributes) throws BadElementException
      Creates a Cell with these attributes.
      Parameters:
      rowAttributes - an object of type SimpleCell whose attributes are to be used to create new cell
      Returns:
      a cell based on these attributes.
      Throws:
      BadElementException - on error
    • createPdfPCell

      public PdfPCell createPdfPCell(SimpleCell rowAttributes)
      Creates a PdfPCell with these attributes.
      Parameters:
      rowAttributes - an object of type SimpleCell whose attributes are to be used to create new cell
      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:
    • setPadding

      public void setPadding(float padding)
      Sets the padding parameters if they are undefined.
      Parameters:
      padding - padding that will be set
    • 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.
    • setSpacing_left

      public void setSpacing_left(float spacing)
      Parameters:
      spacing - The spacing to set.
    • getSpacing_right

      public float getSpacing_right()
      Returns:
      Returns the spacing.
    • setSpacing_right

      public void setSpacing_right(float spacing)
      Parameters:
      spacing - The spacing to set.
    • getSpacing_top

      public float getSpacing_top()
      Returns:
      Returns the spacing.
    • setSpacing_top

      public void setSpacing_top(float spacing)
      Parameters:
      spacing - The spacing to set.
    • getSpacing_bottom

      public float getSpacing_bottom()
      Returns:
      Returns the spacing.
    • setSpacing_bottom

      public void setSpacing_bottom(float spacing)
      Parameters:
      spacing - The spacing to set.
    • setSpacing

      public void setSpacing(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

      List<Element> getContent()
      Returns:
      Returns the content.
    • add

      public boolean add(Element 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:
    • 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: