Class TablePrinter.PrintConfig

java.lang.Object
fc.io.TablePrinter.PrintConfig
Enclosing class:
TablePrinter

public static class TablePrinter.PrintConfig extends Object
Configuration object containing for table printing object. Some methods in this class return this object for method chaining convenience.

Note: Alas ! TablePrinter does not support cellspans across columns or rows. That would make things too complicated for this implementation.

  • Constructor Details

    • PrintConfig

      public PrintConfig()
      Constructs a new PrintConfig with the following default options.
      • cell corner: the + character
      • horizontal cell border: the - character
      • vertical cell border, the | character
      • width of each column: 20 chars
      • horizontal alignment of each cell: HAlign.LEFT
      • The character used for cellpadding and cellspacing is a blank space.
  • Method Details

    • setHeader

      public void setHeader(String[] header)
      Optionally sets the header row for the table
    • getHeader

      public String[] getHeader()
      Gets the header row for the table if set. If not set, return null
    • setPageSize

      Sets the number of lines on each page. A page is a logical unit that typically shows some number of lines on the screen without the need to scroll the page. This value is useful in conjunction with other page specific settings like
      invalid reference
      showPageHeading()
      Parameters:
      lines - number of lines on the page, specify a zero or negative quantity for a single page. (number of lines not including lines occupied by the table header itself, if the header is printed).
    • headerEveryPage

      Specifies that page heading (if set) on each separate page. This may be ignored if no heading has been set. true by default, although headers will still not be printed until the setPageSize(int) method is invoked.
    • setAlign

      Sets the alignment of each cell. By default: left
    • setCellCorner

      Sets the string (typically a single character) that makes up a cell corner. Defaults to +
    • setCellBorderHorizontal

      Sets the string (typically a single character) that makes up a horizontal cell border. Defaults to -
    • setCellBorderVertical

      Sets the string (typically a single character) that makes up a vertical cell border. Defaults to |
    • setCellPaddingGlyph

      Sets the string (typically a single character) that makes up the cellpadding. Defaults to " "
    • setCellSpacingGlyph

      Sets the string (typically a single character) that makes up the cellspacing. Defaults to " "
    • setCellWidth

      Sets the width of each cell. Defaults to 20. This width is common to all cells.
      Parameters:
      width - the width of each cell
    • setCellWidthForColumn

      public TablePrinter.PrintConfig setCellWidthForColumn(int column, int width)
      Sets the cell width of the the specified column. cells are numbered starting from 0
      Parameters:
      column - the cell number
      width - the desired character width
    • setCellWrap

      public TablePrinter.PrintConfig setCellWrap(boolean wrap)
      Cell wrapping is on by default and the contents of any column that exceed the width are wrapped within each cell (using the current platforms line seperator for newlines within the cell).
      Parameters:
      wrap - true To turn cell wrapping on, false to turn cell wrapping off and show fixed width contents only.
    • setAutoFit

      public TablePrinter.PrintConfig setAutoFit(boolean autofit)
      Sets each cell to expand to the size needed for the maximum sized cell in that column. By default, this is false. Setting this to true automatically turns off cell wrapping.

      Note: using autofit may result in slower performance because the table almost always has to be rendered in two passes.

      Parameters:
      autofit - true to turn autofit on, false otherwise.
    • setPrintBorders

      public TablePrinter.PrintConfig setPrintBorders(boolean print)
      Specifies whether table and cell borders are printed. By default this is true.
      Parameters:
      print - true to print borders, false otherwise
    • setCellSpacing

      Specifies the cell spacing between cells. This is useful for tables with no borders. By default, this value is zero.
    • setCellPadding

      Specifies the cell padding for each cell. This is useful for tables with no borders. By default, this value is zero.
    • toString

      public String toString()
      Prints a short description of this object.
      Overrides:
      toString in class Object