JMSLTM Numerical Library 5.0.1

com.imsl.math
Class PrintMatrixFormat

java.lang.Object
  extended by com.imsl.math.PrintMatrixFormat

public class PrintMatrixFormat
extends Object

This class can be used to customize the actions of PrintMatrix. By default, entries are formatted using the default NumberFormat for the current default locale. As of JDK1.3, none of these NumberFormat objects support scientific notation. To enable scientific notation, set the NumberFormat property to null. There is no way to simultaneously support scientific notation and locale-correct formatting.

See Also:
PrintMatrix, NumberFormat, Simple Example, Example overriding format method.

Field Summary
static int BEGIN_COLUMN_LABEL
          This flag as the type argument to format, indicates that the formatting string for ending a column label is to be returned.
static int BEGIN_COLUMN_LABELS
          This flag as the type argument to format, indicates that the formatting string for beginning a column label row is to be returned.
static int BEGIN_ENTRY
          This flag as the type argument to format, indicates that the formatted string for beginning an entry is to be returned.
static int BEGIN_MATRIX
          This flag as the type argument to format, indicates that the formatting string for beginning a matrix is to be returned.
static int BEGIN_ROW
          This flag as the type argument to format, indicates that the formatting string for beginning a row is to be returned.
static int BEGIN_ROW_LABEL
          This flag as the type argument to format, indicates that the formatting string for beginning a row label is to be returned.
static int COLUMN_LABEL
          This flag as the type argument to format, indicates that the formatted string for a given column label is to be returned.
static int END_COLUMN_LABEL
          This flag as the type argument to format, indicates that the formatting string for ending a column label is to be returned.
static int END_COLUMN_LABELS
          This flag as the type argument to format, indicates that the formatting string for ending a column label row is to be returned.
static int END_ENTRY
          This flag as the type argument to format, indicates that the formatted string for ending an entry is to be returned.
static int END_MATRIX
          This flag as the type argument to format, indicates that the formatting string for ending a matrix is to be returned.
static int END_ROW
          This flag as the type argument to format, indicates that the formatting string for ending a row is to be returned.
static int END_ROW_LABEL
          This flag as the type argument to format, indicates that the formatting string for ending a row label is to be returned.
static int ENTRY
          This flag as the type argument to format, indicates that the formatted string for a given entry is to be returned.
protected  NumberFormat numberFormat
          The NumberFormat to be used in formatting double and Complex entries.
static int ROW_LABEL
          This flag as the type argument to format, indicates that the formatted string for a given row label is to be returned.
 
Constructor Summary
PrintMatrixFormat()
          Constructs a PrintMatrixFormat object.
 
Method Summary
 String format(int type, Object entry, int row, int col, ParsePosition pos)
          Returns a formatted string.
 NumberFormat getNumberFormat()
          Returns the NumberFormat to be used in formatting double and Complex entries.
 void setColumnLabels(String[] columnLabels)
          Turns on column labeling using the given labels.
 void setFirstColumnNumber(int firstColumnNumber)
          Turns on column labeling with index numbers and sets the index for the label of the first column.
 void setFirstRowNumber(int firstRowNumber)
          Turns on row labeling with index numbers and sets the index for the label of the first row.
 void setNoColumnLabels()
          Turns off column labels.
 void setNoRowLabels()
          Turns off row labels.
 void setNumberFormat(NumberFormat numberFormat)
          Sets the NumberFormat to be used in formatting double and Complex entries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEGIN_COLUMN_LABEL

public static final int BEGIN_COLUMN_LABEL
This flag as the type argument to format, indicates that the formatting string for ending a column label is to be returned.

See Also:
format(int type, Object entry, int row, int col, ParsePosition pos), Constant Field Values

BEGIN_COLUMN_LABELS

public static final int BEGIN_COLUMN_LABELS
This flag as the type argument to format, indicates that the formatting string for beginning a column label row is to be returned.

See Also:
format(int type, Object entry, int row, int col, ParsePosition pos), Constant Field Values

BEGIN_ENTRY

public static final int BEGIN_ENTRY
This flag as the type argument to format, indicates that the formatted string for beginning an entry is to be returned.

See Also:
format(int type, Object entry, int row, int col, ParsePosition pos), Constant Field Values

BEGIN_MATRIX

public static final int BEGIN_MATRIX
This flag as the type argument to format, indicates that the formatting string for beginning a matrix is to be returned.

See Also:
format(int type, Object entry, int row, int col, ParsePosition pos), Constant Field Values

BEGIN_ROW

public static final int BEGIN_ROW
This flag as the type argument to format, indicates that the formatting string for beginning a row is to be returned.

See Also:
format(int type, Object entry, int row, int col, ParsePosition pos), Constant Field Values

BEGIN_ROW_LABEL

public static final int BEGIN_ROW_LABEL
This flag as the type argument to format, indicates that the formatting string for beginning a row label is to be returned.

See Also:
format(int type, Object entry, int row, int col, ParsePosition pos), Constant Field Values

COLUMN_LABEL

public static final int COLUMN_LABEL
This flag as the type argument to format, indicates that the formatted string for a given column label is to be returned.

See Also:
format(int type, Object entry, int row, int col, ParsePosition pos), Constant Field Values

END_COLUMN_LABEL

public static final int END_COLUMN_LABEL
This flag as the type argument to format, indicates that the formatting string for ending a column label is to be returned.

See Also:
format(int type, Object entry, int row, int col, ParsePosition pos), Constant Field Values

END_COLUMN_LABELS

public static final int END_COLUMN_LABELS
This flag as the type argument to format, indicates that the formatting string for ending a column label row is to be returned.

See Also:
format(int type, Object entry, int row, int col, ParsePosition pos), Constant Field Values

END_ENTRY

public static final int END_ENTRY
This flag as the type argument to format, indicates that the formatted string for ending an entry is to be returned.

See Also:
format(int type, Object entry, int row, int col, ParsePosition pos), Constant Field Values

END_MATRIX

public static final int END_MATRIX
This flag as the type argument to format, indicates that the formatting string for ending a matrix is to be returned.

See Also:
format(int type, Object entry, int row, int col, ParsePosition pos), Constant Field Values

END_ROW

public static final int END_ROW
This flag as the type argument to format, indicates that the formatting string for ending a row is to be returned.

See Also:
format(int type, Object entry, int row, int col, ParsePosition pos), Constant Field Values

END_ROW_LABEL

public static final int END_ROW_LABEL
This flag as the type argument to format, indicates that the formatting string for ending a row label is to be returned.

See Also:
format(int type, Object entry, int row, int col, ParsePosition pos), Constant Field Values

ENTRY

public static final int ENTRY
This flag as the type argument to format, indicates that the formatted string for a given entry is to be returned.

See Also:
format(int type, Object entry, int row, int col, ParsePosition pos), Constant Field Values

numberFormat

protected NumberFormat numberFormat
The NumberFormat to be used in formatting double and Complex entries.

See Also:
Complex

ROW_LABEL

public static final int ROW_LABEL
This flag as the type argument to format, indicates that the formatted string for a given row label is to be returned.

See Also:
format(int type, Object entry, int row, int col, ParsePosition pos), Constant Field Values
Constructor Detail

PrintMatrixFormat

public PrintMatrixFormat()
Constructs a PrintMatrixFormat object.

Method Detail

format

public String format(int type,
                     Object entry,
                     int row,
                     int col,
                     ParsePosition pos)
Returns a formatted string. This method is used by the methods print and printHTML in PrintMatrix. This method can be overridden to gain finer control over printing.

Parameters:
type - is the type of string requested.

typereturn value
BEGIN_MATRIXTag for the beginning of the matrix.
END_MATRIXTag for the end of the matrix.
BEGIN_COLUMN_LABELSTag for the beginning of the column labels row.
END_COLUMN_LABELSTag for the end of the column labels row.
BEGIN_COLUMN_LABELTag for the beginning of a column label.
END_COLUMN_LABELTag for the end of a column label.
COLUMN_LABELThe label of the specified column.
BEGIN_ROWTag for the beginning of a row.
END_ROWTag for the end of a row.
BEGIN_ROW_LABELTag for the beginning of a row label.
END_ROW_LABELTag for the end of a row label.
ROW_LABELThe label of the specified row.
ENTRYThe 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.
Returns:
is the String to be put into the printed table.
See Also:
BEGIN_MATRIX, END_MATRIX, BEGIN_COLUMN_LABELS, END_COLUMN_LABELS, BEGIN_COLUMN_LABEL, END_COLUMN_LABEL, COLUMN_LABEL, BEGIN_ROW, END_ROW, BEGIN_ROW_LABEL, END_ROW_LABEL, ROW_LABEL, ENTRY

getNumberFormat

public NumberFormat getNumberFormat()
Returns the NumberFormat to be used in formatting double and Complex entries.


setColumnLabels

public void setColumnLabels(String[] columnLabels)
Turns on column labeling using the given labels.

Parameters:
columnLabels - is an array of Strings to be used as column labels. If there are more columns than labels, the labels are reused.

setFirstColumnNumber

public void setFirstColumnNumber(int firstColumnNumber)
Turns on column labeling with index numbers and sets the index for the label of the first column.

Parameters:
firstColumnNumber - is the number for the first column label. This is usually 0 or 1. The default is 0.

setFirstRowNumber

public void setFirstRowNumber(int firstRowNumber)
Turns on row labeling with index numbers and sets the index for the label of the first row.

Parameters:
firstRowNumber - is the number for the first row label. This is usually 0 or 1. The default is 0.

setNoColumnLabels

public void setNoColumnLabels()
Turns off column labels.


setNoRowLabels

public void setNoRowLabels()
Turns off row labels.


setNumberFormat

public void setNumberFormat(NumberFormat numberFormat)
Sets the NumberFormat to be used in formatting double and Complex entries.

Parameters:
numberFormat - a NumberFormat or null. If null then numbers will be formatted using Integer.toString(int), or Object.toString().

JMSLTM Numerical Library 5.0.1

Copyright © 1970-2008 Visual Numerics, Inc.
Built July 8 2008.