Class Cell

All Implemented Interfaces:
Element, TextElementArray

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

    • Cell

      public Cell()
      Constructs an empty Cell.
  • Method Details

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

      public void setHorizontalAlignment(String alignment)
      Sets the alignment of this cell. This methods allows you to set the alignment as a String.
      Parameters:
      alignment - the new alignment as a String
    • 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

      public void setVerticalAlignment(String alignment)
      Sets the alignment of this paragraph.
      Parameters:
      alignment - the new alignment as a String
    • setWidth

      public void setWidth(float value)
      Sets the width.
      Parameters:
      value - the new value
    • setWidth

      public void setWidth(String value)
      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.
      Overrides:
      getWidth in class Rectangle
      Returns:
      the width
    • getWidthAsString

      public String 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 this Cell a 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

      public void setShowTruncation(String value)
      Setter for showTruncation
      Parameters:
      value - Can be null for avoiding marking the truncation.
    • getShowTruncation

      public String 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 this Cell force a group change?
      Returns:
      a value
    • setGroupChange

      public void setGroupChange(boolean value)
      Sets group change.
      Parameters:
      value - the new value
    • getElements

      public Iterator getElements()
      Gets an iterator of Elements.
      Returns:
      an Iterator.
    • 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 this Cell is a placeholder for a (nested) table.
      Returns:
      true if the only element in this cell is a table
    • 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
    • getTop

      public float getTop()
      This method throws an UnsupportedOperationException.
      Overrides:
      getTop in class Rectangle
      Returns:
      NA
    • getBottom

      public float getBottom()
      This method throws an UnsupportedOperationException.
      Overrides:
      getBottom in class Rectangle
      Returns:
      NA
    • getLeft

      public float getLeft()
      This method throws an UnsupportedOperationException.
      Overrides:
      getLeft in class Rectangle
      Returns:
      NA
    • getRight

      public float getRight()
      This method throws an UnsupportedOperationException.
      Overrides:
      getRight in class Rectangle
      Returns:
      NA
    • setTop

      public void setTop(int value)
      This method throws an UnsupportedOperationException.
      Parameters:
      value - NA
    • setBottom

      public void setBottom(int value)
      This method throws an UnsupportedOperationException.
      Parameters:
      value - NA
    • setLeft

      public void setLeft(int value)
      This method throws an UnsupportedOperationException.
      Parameters:
      value - NA
    • setRight

      public void setRight(int value)
      This method throws an UnsupportedOperationException.
      Parameters:
      value - NA