Class TablePrinter
java.lang.Object
neqsim.thermo.util.readwrite.TablePrinter
- All Implemented Interfaces:
Serializable
A utility class for pretty printing a 2D string table.
- Author:
- Even Solbraa
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final longSerialization version UID. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String[][]convertDoubleToString(double[][] doubleArray) Returns a 2D string table in a formatted and visually appealing way.private static int[]getColumnWidths(String[][] table) Calculates the maximum width of each column in the table.private static voidprintHorizontalLine(int[] columnWidths) Prints a horizontal line separator based on the column widths.private static voidPrints a row of the table with appropriate padding based on column widths.static voidprintTable(double[][] table) Prints a 2D string table in a formatted and visually appealing way.static voidprintTable(String[][] table) Prints a 2D string table in a formatted and visually appealing way.
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerialization version UID.- See Also:
-
-
Constructor Details
-
TablePrinter
public TablePrinter()
-
-
Method Details
-
printTable
Prints a 2D string table in a formatted and visually appealing way.- Parameters:
table- The 2D string table to be printed.
-
getColumnWidths
Calculates the maximum width of each column in the table.- Parameters:
table- The 2D string table.- Returns:
- An array containing the maximum width of each column.
-
printHorizontalLine
private static void printHorizontalLine(int[] columnWidths) Prints a horizontal line separator based on the column widths.- Parameters:
columnWidths- An array containing the maximum width of each column.
-
printRow
Prints a row of the table with appropriate padding based on column widths.- Parameters:
row- The row of data to be printed.columnWidths- An array containing the maximum width of each column.
-
printTable
public static void printTable(double[][] table) Prints a 2D string table in a formatted and visually appealing way.- Parameters:
table- The 2D double table to be printed.
-
convertDoubleToString
Returns a 2D string table in a formatted and visually appealing way.- Parameters:
doubleArray- The 2D double table to be printed.- Returns:
- 2d string table
-