Class Table

java.lang.Object
net.atthegate.server.service.pdf.Table

public class Table extends Object
Used to create table objects and draw them on a page. Please see Example_08.
  • Field Details

  • Constructor Details

    • Table

      public Table()
      Create a table object.
  • Method Details

    • setPosition

      public void setPosition(double x, double y)
      Sets the position (x, y) of the top left corner of this table on the page.
      Parameters:
      x - the x coordinate of the top left point of the table.
      y - the y coordinate of the top left point of the table.
    • setPosition

      public void setPosition(float x, float y)
      Sets the position (x, y) of the top left corner of this table on the page.
      Parameters:
      x - the x coordinate of the top left point of the table.
      y - the y coordinate of the top left point of the table.
    • setLocation

      public void setLocation(float x, float y)
      Sets the location (x, y) of the top left corner of this table on the page.
      Parameters:
      x - the x coordinate of the top left point of the table.
      y - the y coordinate of the top left point of the table.
    • setBottomMargin

      public void setBottomMargin(double bottom_margin)
      Sets the bottom margin for this table.
      Parameters:
      bottom_margin - the margin.
    • setBottomMargin

      public void setBottomMargin(float bottom_margin)
      Sets the bottom margin for this table.
      Parameters:
      bottom_margin - the margin.
    • setData

      public void setData(List<List<Cell>> tableData) throws Exception
      Sets the table data. The table data is a perfect grid of cells. All cell should be an unique object and you can not reuse blank cell objects. Even if one or more cells have colspan bigger than zero the number of cells in the row will not change.
      Parameters:
      tableData - the table data.
      Throws:
      Exception
    • setData

      public void setData(List<List<Cell>> tableData, int numOfHeaderRows) throws Exception
      Sets the table data and specifies the number of header rows in this data.
      Parameters:
      tableData - the table data.
      numOfHeaderRows - the number of header rows in this data.
      Throws:
      Exception
    • autoAdjustColumnWidths

      public void autoAdjustColumnWidths()
      Auto adjusts the widths of all columns so that they are just wide enough to hold the text without truncation.
    • rightAlignNumbers

      public void rightAlignNumbers()
      Sets the alignment of the numbers to the right.
    • removeLineBetweenRows

      public void removeLineBetweenRows(int index1, int index2) throws Exception
      Removes the horizontal lines between the rows from index1 to index2.
      Throws:
      Exception
    • setTextAlignInColumn

      public void setTextAlignInColumn(int index, int alignment) throws Exception
      Sets the text alignment in the specified column.
      Parameters:
      index - the index of the specified column.
      alignment - the specified alignment. Supported values: Align.LEFT, Align.RIGHT, Align.CENTER and Align.JUSTIFY.
      Throws:
      Exception
    • setTextColorInColumn

      public void setTextColorInColumn(int index, int color) throws Exception
      Sets the color of the text in the specified column.
      Parameters:
      index - the index of the specified column.
      color - the color specified as an integer.
      Throws:
      Exception
    • setFontInColumn

      public void setFontInColumn(int index, Font font) throws Exception
      Sets the font for the specified column.
      Parameters:
      index - the column index.
      font - the font.
      Throws:
      Exception
    • setTextColorInRow

      public void setTextColorInRow(int index, int color) throws Exception
      Sets the color of the text in the specified row.
      Parameters:
      index - the index of the specified row.
      color - the color specified as an integer.
      Throws:
      Exception
    • setFontInRow

      public void setFontInRow(int index, Font font) throws Exception
      Sets the font for the specified row.
      Parameters:
      index - the row index.
      font - the font.
      Throws:
      Exception
    • setColumnWidth

      public void setColumnWidth(int index, float width) throws Exception
      Sets the width of the column with the specified index.
      Parameters:
      index - the index of specified column.
      width - the specified width.
      Throws:
      Exception
    • getColumnWidth

      public float getColumnWidth(int index) throws Exception
      Returns the column width of the column at the specified index.
      Parameters:
      index - the index of the column.
      Returns:
      the width of the column.
      Throws:
      Exception
    • getCellAt

      public Cell getCellAt(int row, int col) throws Exception
      Returns the cell at the specified row and column.
      Parameters:
      row - the specified row.
      col - the specified column.
      Returns:
      the cell at the specified row and column.
      Throws:
      Exception
    • getCellAtRowColumn

      public Cell getCellAtRowColumn(int row, int col) throws Exception
      Returns the cell at the specified row and column.
      Parameters:
      row - the specified row.
      col - the specified column.
      Returns:
      the cell at the specified row and column.
      Throws:
      Exception
    • getRow

      public List<Cell> getRow(int index) throws Exception
      Returns a list of cell for the specified row.
      Parameters:
      index - the index of the specified row.
      Returns:
      the list of cells.
      Throws:
      Exception
    • getRowAtIndex

      public List<Cell> getRowAtIndex(int index) throws Exception
      Throws:
      Exception
    • getColumn

      public List<Cell> getColumn(int index) throws Exception
      Returns a list of cell for the specified column.
      Parameters:
      index - the index of the specified column.
      Returns:
      the list of cells.
      Throws:
      Exception
    • getColumnAtIndex

      public List<Cell> getColumnAtIndex(int index) throws Exception
      Throws:
      Exception
    • getNumberOfPages

      public int getNumberOfPages(Page page) throws Exception
      Returns the total number of pages that are required to draw this table on.
      Parameters:
      page - the type of pages we are drawing this table on.
      Returns:
      the number of pages.
      Throws:
      Exception
    • drawOn

      public Point drawOn(Page page) throws Exception
      Draws this table on the specified page.
      Parameters:
      page - the page to draw this table on.
      Returns:
      Point the point on the page where to draw the next component.
      Throws:
      Exception
    • hasMoreData

      public boolean hasMoreData()
      Returns true if the table contains more data that needs to be drawn on a page.
    • getWidth

      public float getWidth()
      Returns the width of this table when drawn on a page.
      Returns:
      the widht of this table.
    • getRowsRendered

      public int getRowsRendered()
      Returns the number of data rows that have been rendered so far.
      Returns:
      the number of data rows that have been rendered so far.
    • wrapAroundCellText2

      @Deprecated public void wrapAroundCellText2()
      Deprecated.
      Just calls the wrapAroundCellText method.
    • wrapAroundCellText

      public void wrapAroundCellText()
      Wraps around the text in all cells so it fits the column width. This method should be called after all calls to setColumnWidth and autoAdjustColumnWidths.
    • setNoCellBorders

      public void setNoCellBorders()
      Sets all table cells borders to false.
    • setCellBordersColor

      public void setCellBordersColor(int color)
      Sets the color of the cell border lines.
      Parameters:
      color - the color of the cell border lines.
    • setCellBordersWidth

      public void setCellBordersWidth(float width)
      Sets the width of the cell border lines.
      Parameters:
      width - the width of the border lines.
    • resetRenderedPagesCount

      public void resetRenderedPagesCount()
      Resets the rendered pages count. Call this method if you have to draw this table more than one time.
    • mergeOverlaidBorders

      public void mergeOverlaidBorders()
      This method removes borders that have the same color and overlap 100%. The result is improved onscreen rendering of thin border lines by some PDF viewers.