Class TextTable

java.lang.Object
edu.cmu.tetrad.util.TextTable

public class TextTable extends Object
Stores a 2D array of Strings for printing out tables. The table can print out columns either left justified or right justified, with a given number of spaces between columns.
Author:
josephramsey
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Set justification to this if the columns should be left justified.
    static final int
    Set justification to this if the columns should be right justified.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TextTable(int rows, int columns)
    Construct the text table; the table has a fixed number of rows and columns, each greater than zero.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    int
     
    getTokenAt(int row, int column)
     
    void
    setColumnSpacing(int numSpaces)
    Sets the number of spaces between columns, to some number >= 0.
    void
     
    void
    setJustification(int justification)
    Sets the justification, either LEFT_JUSTIFIED or RIGHT_JUSTIFIED.
    void
    setToken(int row, int column, String token)
    Sets the token at the given row and column, each of which must be >= 0 and less than the number of rows or columns, respectively.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • LEFT_JUSTIFIED

      public static final int LEFT_JUSTIFIED
      Set justification to this if the columns should be left justified.
      See Also:
    • RIGHT_JUSTIFIED

      public static final int RIGHT_JUSTIFIED
      Set justification to this if the columns should be right justified.
      See Also:
  • Constructor Details

    • TextTable

      public TextTable(int rows, int columns)
      Construct the text table; the table has a fixed number of rows and columns, each greater than zero.
  • Method Details

    • setToken

      public void setToken(int row, int column, String token)
      Sets the token at the given row and column, each of which must be >= 0 and less than the number of rows or columns, respectively.
    • getTokenAt

      public String getTokenAt(int row, int column)
      Returns:
      the token at the given row and column.
    • getNumRows

      public int getNumRows()
      Returns:
      the number of rows, as set in the constructor.
    • getNumColumns

      public int getNumColumns()
      Returns:
      the number of rows, as set in the constructor.
    • setColumnSpacing

      public void setColumnSpacing(int numSpaces)
      Sets the number of spaces between columns, to some number >= 0.
    • setJustification

      public void setJustification(int justification)
      Sets the justification, either LEFT_JUSTIFIED or RIGHT_JUSTIFIED.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setDelimiter

      public void setDelimiter(TextTable.Delimiter delimiter)