cern.colt.matrix.impl

## Class AbstractFormatter

- java.lang.Object
- - cern.colt.PersistentObject
  - - cern.colt.matrix.impl.AbstractFormatter

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable
  Direct Known Subclasses:
    Formatter, Formatter

      public abstract class AbstractFormatter
      extends PersistentObject

  Abstract base class for flexible, well human readable matrix print formatting. Value type independent. A single cell is formatted via a format string. Columns can be aligned left, centered, right and by decimal point.

  A column can be broader than specified by the parameter `minColumnWidth` (because a cell may not fit into that width) but a column is never smaller than `minColumnWidth`. Normally one does not need to specify `minColumnWidth`. Cells in a row are separated by a separator string, similar separators can be set for rows and slices. For more info, see the concrete subclasses.

  Version:
    1.0, 09/24/99
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `CENTER` The alignment string aligning the cells of a column to its center.
    `static java.lang.String` | `DECIMAL` The alignment string aligning the cells of a column to the decimal point.
    `static java.lang.String` | `DEFAULT_COLUMN_SEPARATOR` The default string separating any two columns from another; currently `" "`.
    `static int` | `DEFAULT_MIN_COLUMN_WIDTH` The default minimum number of characters a column may have; currently `1`.
    `static java.lang.String` | `DEFAULT_ROW_SEPARATOR` The default string separating any two rows from another; currently `"\n"`.
    `static java.lang.String` | `DEFAULT_SLICE_SEPARATOR` The default string separating any two slices from another; currently `"\n\n"`.
    `static java.lang.String` | `LEFT` The alignment string aligning the cells of a column to the left.
    `static java.lang.String` | `RIGHT` The alignment string aligning the cells of a column to the right.

    - ### Fields inherited from class cern.colt.PersistentObject

      `serialVersionUID`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `demo1()` Demonstrates how to use this class.
    `static void` | `demo2()` Demonstrates how to use this class.
    `static void` | `demo3(int size, java.lang.Object value)` Demonstrates how to use this class.
    `void` | `setAlignment(java.lang.String alignment)` Sets the column alignment (left,center,right,decimal).
    `void` | `setColumnSeparator(java.lang.String columnSeparator)` Sets the string separating any two columns from another.
    `void` | `setFormat(java.lang.String format)` Sets the way a single cell value is to be formatted.
    `void` | `setMinColumnWidth(int minColumnWidth)` Sets the minimum number of characters a column may have.
    `void` | `setPrintShape(boolean printShape)` Specifies whether a string representation of a matrix is to be preceded with a summary of its shape.
    `void` | `setRowSeparator(java.lang.String rowSeparator)` Sets the string separating any two rows from another.
    `void` | `setSliceSeparator(java.lang.String sliceSeparator)` Sets the string separating any two slices from another.
    `static java.lang.String` | `shape(AbstractMatrix1D matrix)` Returns a short string representation describing the shape of the matrix.
    `static java.lang.String` | `shape(AbstractMatrix2D matrix)` Returns a short string representation describing the shape of the matrix.
    `static java.lang.String` | `shape(AbstractMatrix3D matrix)` Returns a short string representation describing the shape of the matrix.

    - ### Methods inherited from class cern.colt.PersistentObject

      `clone`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### LEFT

          public static final java.lang.String LEFT

      The alignment string aligning the cells of a column to the left.
      See Also:
        Constant Field Values

    - #### CENTER

          public static final java.lang.String CENTER

      The alignment string aligning the cells of a column to its center.
      See Also:
        Constant Field Values

    - #### RIGHT

          public static final java.lang.String RIGHT

      The alignment string aligning the cells of a column to the right.
      See Also:
        Constant Field Values

    - #### DECIMAL

          public static final java.lang.String DECIMAL

      The alignment string aligning the cells of a column to the decimal point.
      See Also:
        Constant Field Values

    - #### DEFAULT_MIN_COLUMN_WIDTH

          public static final int DEFAULT_MIN_COLUMN_WIDTH

      The default minimum number of characters a column may have; currently `1`.
      See Also:
        Constant Field Values

    - #### DEFAULT_COLUMN_SEPARATOR

          public static final java.lang.String DEFAULT_COLUMN_SEPARATOR

      The default string separating any two columns from another; currently `" "`.
      See Also:
        Constant Field Values

    - #### DEFAULT_ROW_SEPARATOR

          public static final java.lang.String DEFAULT_ROW_SEPARATOR

      The default string separating any two rows from another; currently `"\n"`.
      See Also:
        Constant Field Values

    - #### DEFAULT_SLICE_SEPARATOR

          public static final java.lang.String DEFAULT_SLICE_SEPARATOR

      The default string separating any two slices from another; currently `"\n\n"`.
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### demo1

          public static void demo1()

      Demonstrates how to use this class.

    - #### demo2

          public static void demo2()

      Demonstrates how to use this class.

    - #### demo3

          public static void demo3(int size,
                   java.lang.Object value)

      Demonstrates how to use this class.

    - #### setAlignment

          public void setAlignment(java.lang.String alignment)

      Sets the column alignment (left,center,right,decimal).
      Parameters:
        `alignment` - the new alignment to be used; must be one of `{LEFT,CENTER,RIGHT,DECIMAL}`.

    - #### setColumnSeparator

          public void setColumnSeparator(java.lang.String columnSeparator)

      Sets the string separating any two columns from another.
      Parameters:
        `columnSeparator` - the new columnSeparator to be used.

    - #### setFormat

          public void setFormat(java.lang.String format)

      Sets the way a single cell value is to be formatted.
      Parameters:
        `format` - the new format to be used.

    - #### setMinColumnWidth

          public void setMinColumnWidth(int minColumnWidth)

      Sets the minimum number of characters a column may have.
      Parameters:
        `minColumnWidth` - the new minColumnWidth to be used.

    - #### setPrintShape

          public void setPrintShape(boolean printShape)

      Specifies whether a string representation of a matrix is to be preceded with a summary of its shape.
      Parameters:
        `printShape` - `true` shape summary is printed, otherwise not printed.

    - #### setRowSeparator

          public void setRowSeparator(java.lang.String rowSeparator)

      Sets the string separating any two rows from another.
      Parameters:
        `rowSeparator` - the new rowSeparator to be used.

    - #### setSliceSeparator

          public void setSliceSeparator(java.lang.String sliceSeparator)

      Sets the string separating any two slices from another.
      Parameters:
        `sliceSeparator` - the new sliceSeparator to be used.

    - #### shape

          public static java.lang.String shape(AbstractMatrix1D matrix)

      Returns a short string representation describing the shape of the matrix.

    - #### shape

          public static java.lang.String shape(AbstractMatrix2D matrix)

      Returns a short string representation describing the shape of the matrix.

    - #### shape

          public static java.lang.String shape(AbstractMatrix3D matrix)

      Returns a short string representation describing the shape of the matrix.

Jump to the Colt Homepage