java.lang.Object
org.strassburger.tui4j.formatting.layout.table.Table
All Implemented Interfaces:
Renderable

public class Table extends Object implements Renderable
A table layout component that arranges data in rows and columns with customizable styles and alignments.
  • Constructor Details

    • Table

      public Table()
  • Method Details

    • setRows

      public Table setRows(List<List<StyledText>> rows)
      Sets the rows of the table
      Parameters:
      rows - the list of rows, each row is a list of StyledText cells
      Returns:
      the Table instance for chaining
    • addRow

      public Table addRow(List<StyledText> row)
      Adds a row to the table
      Parameters:
      row - the row to add
      Returns:
      the Table instance for chaining
    • hasHeader

      public boolean hasHeader()
    • setHasHeader

      public Table setHasHeader(boolean hasHeader)
      Sets whether the table has a header row
      Parameters:
      hasHeader - true if the first row is a header
      Returns:
      the Table instance for chaining
    • setColumnAlignment

      public Table setColumnAlignment(int col, ColumnAlign columnAlignments)
      Sets the alignment for a specific column
      Parameters:
      col - the column index
      columnAlignments - the alignment to set
      Returns:
      the Table instance for chaining
    • setColumnGrow

      public Table setColumnGrow(int col, int grow)
      Sets the grow factor for a specific column
      Parameters:
      col - the column index
      grow - the grow factor (must be >= 0)
      Returns:
      the Table instance for chaining
    • setDefaultGrow

      public Table setDefaultGrow(int grow)
      Sets the default grow factor for all columns
      Parameters:
      grow - the default grow factor (must be >= 0)
      Returns:
      the Table instance for chaining
    • setStyle

      public Table setStyle(TableStyle style)
      Sets the style of the table
      Parameters:
      style - the TableStyle to use (e.g. TableStyles.DEFAULT)
      Returns:
      the Table instance for chaining
    • render

      public void render(Printer printer, int width, int height)
      Description copied from interface: Renderable
      Render the element using the given printer and dimensions
      Specified by:
      render in interface Renderable
      Parameters:
      printer - the printer to use
      width - the available width
      height - the available height