public class PrintMatrixFormatEx2 extends PrintMatrixFormat
Prints a matrix in CSV format.
A matrix is printed in CSV (comma separated value) format. This is done by overriding theformat method of PrintMatrixFormat
to add commas after all but the last number in each row.BEGIN_COLUMN_LABEL, BEGIN_COLUMN_LABELS, BEGIN_ENTRY, BEGIN_MATRIX, BEGIN_ROW, BEGIN_ROW_LABEL, COLUMN_LABEL, END_COLUMN_LABEL, END_COLUMN_LABELS, END_ENTRY, END_MATRIX, END_ROW, END_ROW_LABEL, ENTRY, numberFormat, ROW_LABEL| Constructor and Description |
|---|
PrintMatrixFormatEx2(int ncols) |
| Modifier and Type | Method and Description |
|---|---|
String |
format(int type,
Object entry,
int row,
int col,
ParsePosition pos)
Returns a formatted string.
|
static void |
main(String[] args) |
getNumberFormat, setColumnLabels, setFirstColumnNumber, setFirstRowNumber, setNoColumnLabels, setNoRowLabels, setNumberFormatpublic String format(int type, Object entry, int row, int col, ParsePosition pos)
PrintMatrixFormatprint and printHTML in PrintMatrix.
This method can be overridden to gain finer control over printing.format in class PrintMatrixFormattype - is the type of string requested.
| type | return value |
| BEGIN_MATRIX | Tag for the beginning of the matrix. |
| END_MATRIX | Tag for the end of the matrix. |
| BEGIN_COLUMN_LABELS | Tag for the beginning of the column labels row. |
| END_COLUMN_LABELS | Tag for the end of the column labels row. |
| BEGIN_COLUMN_LABEL | Tag for the beginning of a column label. |
| END_COLUMN_LABEL | Tag for the end of a column label. |
| COLUMN_LABEL | The label of the specified column. |
| BEGIN_ROW | Tag for the beginning of a row. |
| END_ROW | Tag for the end of a row. |
| BEGIN_ROW_LABEL | Tag for the beginning of a row label. |
| END_ROW_LABEL | Tag for the end of a row label. |
| ROW_LABEL | The label of the specified row. |
| ENTRY | The row-col entry of the matrix |
entry - is the entry to be formatted. This is only used if type equals ENTRY.
For other values of type, this can be set to null.row - is the (0-based) row number of the element to be
formatted. This is -1 if there is no row number
associated with this request.col - is the (0-based) column number of the element to be
formatted. This is -1 if there is no column number
associated with this request.pos - is a ParsePosition object used to indicate the
alignment center of the return string. This is used
only if type==ENTRY.
If the entry is a double then the index
is the position of the decimal point.
If the entry is an int then the index
is the position of the end of the formatted integer.String to be put into the printed table.PrintMatrixFormat.BEGIN_MATRIX,
PrintMatrixFormat.END_MATRIX,
PrintMatrixFormat.BEGIN_COLUMN_LABELS,
PrintMatrixFormat.END_COLUMN_LABELS,
PrintMatrixFormat.BEGIN_COLUMN_LABEL,
PrintMatrixFormat.END_COLUMN_LABEL,
PrintMatrixFormat.COLUMN_LABEL,
PrintMatrixFormat.BEGIN_ROW,
PrintMatrixFormat.END_ROW,
PrintMatrixFormat.BEGIN_ROW_LABEL,
PrintMatrixFormat.END_ROW_LABEL,
PrintMatrixFormat.ROW_LABEL,
PrintMatrixFormat.ENTRYpublic static void main(String[] args)
Copyright © 2020 Rogue Wave Software. All rights reserved.