public class TableFormat extends Object
Constructor and Description |
---|
TableFormat() |
Modifier and Type | Method and Description |
---|---|
protected static String[] |
asciiTableFormat(int columns,
int dataColumns,
int rows,
int dataRows,
String[] columnLabels,
String[] rowLabels,
Double[][] data,
int[] sigDigits,
int[] dashRows)
Formats the given data into an ASCII table.
|
protected static String |
center(String original,
int width)
Returns a space-padded string of at least the specified width such that the argument string
is centered within the returned string.
|
protected static String |
format(double f,
int d)
Formats a floating point number so that it is rounded and zero-padded to the given number of
significant digits after the decimal point.
|
protected static String |
ljust(String original,
int width)
Returns a space-padded string of at least the specified width such that the argument string
is left-justified within the returned string.
|
static void |
printTable(PrintStream out,
String[] table)
Simply prints each element of the given array of strings to the given stream in its own line.
|
static void |
printTableFormat(PrintStream out,
double[][] data)
Formats the given data into an ASCII table and prints it to the given stream.
|
static void |
printTableFormat(PrintStream out,
Double[][] data)
Formats the given data into an ASCII table and prints it to the given stream.
|
static void |
printTableFormat(PrintStream out,
String[] columnLabels,
String[] rowLabels,
double[][] data)
Formats the given data into an ASCII table and prints it to the given stream.
|
static void |
printTableFormat(PrintStream out,
String[] columnLabels,
String[] rowLabels,
Double[][] data)
Formats the given data into an ASCII table and prints it to the given stream.
|
static void |
printTableFormat(PrintStream out,
String[] columnLabels,
String[] rowLabels,
double[][] data,
int[] sigDigits)
Formats the given data into an ASCII table and prints it to the given stream.
|
static void |
printTableFormat(PrintStream out,
String[] columnLabels,
String[] rowLabels,
Double[][] data,
int[] sigDigits)
Formats the given data into an ASCII table and prints it to the given stream.
|
static void |
printTableFormat(PrintStream out,
String[] columnLabels,
String[] rowLabels,
double[][] data,
int[] sigDigits,
int[] dashRows)
Formats the given data into an ASCII table and prints it to the given stream.
|
static void |
printTableFormat(PrintStream out,
String[] columnLabels,
String[] rowLabels,
Double[][] data,
int[] sigDigits,
int[] dashRows)
Formats the given data into an ASCII table and prints it to the given stream.
|
protected static String |
rjust(String original,
int width)
Returns a space-padded string of at least the specified width such that the argument string
is right-justified within the returned string.
|
static String[] |
tableFormat(double[][] data)
Formats the given data into an ASCII table.
|
static String[] |
tableFormat(Double[][] data)
Formats the given data into an ASCII table.
|
static String[] |
tableFormat(String[] columnLabels,
String[] rowLabels,
double[][] data)
Formats the given data into an ASCII table.
|
static String[] |
tableFormat(String[] columnLabels,
String[] rowLabels,
Double[][] data)
Formats the given data into an ASCII table.
|
static String[] |
tableFormat(String[] columnLabels,
String[] rowLabels,
double[][] data,
int[] sigDigits)
Formats the given data into an ASCII table.
|
static String[] |
tableFormat(String[] columnLabels,
String[] rowLabels,
Double[][] data,
int[] sigDigits)
Formats the given data into an ASCII table.
|
static String[] |
tableFormat(String[] columnLabels,
String[] rowLabels,
double[][] data,
int[] sigDigits,
int[] dashRows)
Formats the given data into an ASCII table.
|
static String[] |
tableFormat(String[] columnLabels,
String[] rowLabels,
Double[][] data,
int[] sigDigits,
int[] dashRows)
Formats the given data into an ASCII table.
|
static double[][] |
transpose(double[][] m)
Transposes the given matrix so that the rows become the columns and the columns become the
rows.
|
static Double[][] |
transpose(Double[][] m)
Transposes the given matrix so that the rows become the columns and the columns become the
rows.
|
static Double[][] |
wrapDouble(double[][] m)
Simply converts the type of the given matrix from
double to Double . |
public static Double[][] wrapDouble(double[][] m)
double
to Double
.m
- The matrix.public static void printTable(PrintStream out, String[] table)
out
- The stream.table
- The strings.public static void printTableFormat(PrintStream out, double[][] data)
null
entries will be rounded to three significant digits after the decimal
place.out
- The stream.data
- The numerical data.public static String[] tableFormat(double[][] data)
null
entries will be rounded
to three significant digits after the decimal place.data
- The numerical data.public static void printTableFormat(PrintStream out, Double[][] data)
null
entries will be rounded to three significant digits after the decimal
place.out
- The stream.data
- The numerical data.public static String[] tableFormat(Double[][] data)
null
entries will be rounded
to three significant digits after the decimal place.data
- The numerical data.public static void printTableFormat(PrintStream out, String[] columnLabels, String[] rowLabels, double[][] data)
null
entries will be rounded to three significant digits after the decimal
place.out
- The stream.columnLabels
- One label for each column in the output, starting with the column of row
labels if one exists. If null
, no column label row will be returned.rowLabels
- One label for each non-null
row in data
. If
null
, no row label column will be returned.data
- The numerical data.public static String[] tableFormat(String[] columnLabels, String[] rowLabels, double[][] data)
null
entries will be rounded
to three significant digits after the decimal place.columnLabels
- One label for each column in the output, starting with the column of row
labels if one exists. If null
, no column label row will be returned.rowLabels
- One label for each non-null
row in data
. If
null
, no row label column will be returned.data
- The numerical data.public static void printTableFormat(PrintStream out, String[] columnLabels, String[] rowLabels, Double[][] data)
data
set to null
will become a single dash in the
output. All non-null
entries will be rounded to three significant digits after
the decimal place.out
- The stream.columnLabels
- One label for each column in the output, starting with the column of row
labels if one exists. If null
, no column label row will be returned.rowLabels
- One label for each non-null
row in data
. If
null
, no row label column will be returned.data
- The numerical data.public static String[] tableFormat(String[] columnLabels, String[] rowLabels, Double[][] data)
data
set to
null
will become a single dash in the output. All non-null
entries
will be rounded to three significant digits after the decimal place.columnLabels
- One label for each column in the output, starting with the column of row
labels if one exists. If null
, no column label row will be returned.rowLabels
- One label for each non-null
row in data
. If
null
, no row label column will be returned.data
- The numerical data.public static void printTableFormat(PrintStream out, String[] columnLabels, String[] rowLabels, double[][] data, int[] sigDigits)
data
set to null
will become a single dash in the
output.out
- The stream.columnLabels
- One label for each column in the output, starting with the column of row
labels if one exists. If null
, no column label row will be returned.rowLabels
- One label for each non-null
row in data
. If
null
, no row label column will be returned.data
- The numerical data.sigDigits
- Significant digits specified on a column by column basis, only for
data
columns.public static String[] tableFormat(String[] columnLabels, String[] rowLabels, double[][] data, int[] sigDigits)
data
set to
null
will become a single dash in the output.columnLabels
- One label for each column in the output, starting with the column of row
labels if one exists. If null
, no column label row will be returned.rowLabels
- One label for each non-null
row in data
. If
null
, no row label column will be returned.data
- The numerical data.sigDigits
- Significant digits specified on a column by column basis, only for
data
columns.public static void printTableFormat(PrintStream out, String[] columnLabels, String[] rowLabels, Double[][] data, int[] sigDigits)
data
set to null
will become a single dash in the
output.out
- The stream.columnLabels
- One label for each column in the output, starting with the column of row
labels if one exists. If null
, no column label row will be returned.rowLabels
- One label for each non-null
row in data
. If
null
, no row label column will be returned.data
- The numerical data.sigDigits
- Significant digits specified on a column by column basis, only for
data
columns.public static String[] tableFormat(String[] columnLabels, String[] rowLabels, Double[][] data, int[] sigDigits)
data
set to
null
will become a single dash in the output.columnLabels
- One label for each column in the output, starting with the column of row
labels if one exists. If null
, no column label row will be returned.rowLabels
- One label for each non-null
row in data
. If
null
, no row label column will be returned.data
- The numerical data.sigDigits
- Significant digits specified on a column by column basis, only for
data
columns.public static void printTableFormat(PrintStream out, String[] columnLabels, String[] rowLabels, double[][] data, int[] sigDigits, int[] dashRows)
data
set to null
will become a single dash in the
output.out
- The stream.columnLabels
- One label for each column in the output, starting with the column of row
labels if one exists. If null
, no column label row will be returned.rowLabels
- One label for each non-null
row in data
. If
null
, no row label column will be returned.data
- The numerical data.sigDigits
- Significant digits specified on a column by column basis, only for
data
columns.dashRows
- The indexes of rows in data
which should be preceded by a row of
dashes in the output.public static String[] tableFormat(String[] columnLabels, String[] rowLabels, double[][] data, int[] sigDigits, int[] dashRows)
data
set to
null
will become a single dash in the output.columnLabels
- One label for each column in the output, starting with the column of row
labels if one exists. If null
, no column label row will be returned.rowLabels
- One label for each non-null
row in data
. If
null
, no row label column will be returned.data
- The numerical data.sigDigits
- Significant digits specified on a column by column basis, only for
data
columns.dashRows
- The indexes of rows in data
which should be preceded by a row of
dashes in the output.public static void printTableFormat(PrintStream out, String[] columnLabels, String[] rowLabels, Double[][] data, int[] sigDigits, int[] dashRows)
data
set to null
will become a single dash in the
output.out
- The stream.columnLabels
- One label for each column in the output, starting with the column of row
labels if one exists. If null
, no column label row will be returned.rowLabels
- One label for each non-null
row in data
. If
null
, no row label column will be returned.data
- The numerical data.sigDigits
- Significant digits specified on a column by column basis, only for
data
columns.dashRows
- The indexes of rows in data
which should be preceded by a row of
dashes in the output.public static String[] tableFormat(String[] columnLabels, String[] rowLabels, Double[][] data, int[] sigDigits, int[] dashRows)
data
set to
null
will become a single dash in the output.columnLabels
- One label for each column in the output, starting with the column of row
labels if one exists. If null
, no column label row will be returned.rowLabels
- One label for each non-null
row in data
. If
null
, no row label column will be returned.data
- The numerical data.sigDigits
- Significant digits specified on a column by column basis, only for
data
columns.dashRows
- The indexes of rows in data
which should be preceded by a row of
dashes in the output.protected static String[] asciiTableFormat(int columns, int dataColumns, int rows, int dataRows, String[] columnLabels, String[] rowLabels, Double[][] data, int[] sigDigits, int[] dashRows)
data
set to
null
will become a row with one dash in each cell of the output table's row. Any
entry in any row of data
set to null
will also become a single dash
in the output.columns
- The total number of columns in the table.dataColumns
- The number of columns containing data in the table.rows
- The total number of rows in the table.dataRows
- The number of rows containing data in the table.columnLabels
- One label for each column in the output, starting with the column of row
labels if one exists. If null
, no column label row will be returned.rowLabels
- One label for each non-null row in data
. If null
,
no row label column will be returned.data
- The numerical data.sigDigits
- Significant digits specified on a column by column basis, only for
data
columns.dashRows
- The indexes of rows in data
which should be preceded by a row of
dashes in the output.public static double[][] transpose(double[][] m)
m
- The matrix to transpose.public static Double[][] transpose(Double[][] m)
m
- The matrix to transpose.protected static String format(double f, int d)
f
- The floating point value to format.d
- The number of significant digits to round to. If less than 0, this method assumes 0;
if greater than 18, this method assumes 18.protected static String ljust(String original, int width)
original
- The string to justify.width
- The width within which the original string should be padded.protected static String rjust(String original, int width)
original
- The string to justify.width
- The width within which the original string should be padded.protected static String center(String original, int width)
original
- The string to justify.width
- The width within which the original string should be padded.Copyright © 2016. All rights reserved.