Package pal.io

Class FormattedOutput

  • All Implemented Interfaces:
    java.io.Serializable

    public class FormattedOutput
    extends java.lang.Object
    implements java.io.Serializable
    tools to simplify formatted output to a stream
    Version:
    $Id: FormattedOutput.java,v 1.17 2003/04/03 05:55:53 matt Exp $
    Author:
    Korbinian Strimmer, Alexei Drummond
    See Also:
    Serialized Form
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int displayDecimal​(java.io.PrintWriter out, double number, int width)
      print decimal number with a prespecified number of digits after the point
      void displayInteger​(java.io.PrintWriter out, int num, int maxNum)
      print integer, aligned to a reference number, (introducing space at the left side)
      void displayIntegerWhite​(java.io.PrintWriter out, int maxNum)
      print whitespace of length of a string displaying a given integer
      void displayLabel​(java.io.PrintWriter out, java.lang.String label, int width)
      print label with a prespecified length (label will be shortened or spaces will introduced, if necessary)
      java.lang.String getDecimalString​(double number, int width)
      Returns a decimal string representation of a number with constrained width.
      static FormattedOutput getInstance()
      create instance of this class (note that there is no public constructor as this class is a singleton)
      java.lang.String getSFString​(double[] numbers, int sf, java.lang.String delimiter)  
      java.lang.String getSFString​(double number, int sf)  
      void multiplePrint​(java.io.PrintWriter out, char c, int num)
      repeatedly print a character
      static java.lang.String space​(int size, char c)
      returns of string of a given length of a single character.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInstance

        public static FormattedOutput getInstance()
        create instance of this class (note that there is no public constructor as this class is a singleton)
      • displayDecimal

        public int displayDecimal​(java.io.PrintWriter out,
                                  double number,
                                  int width)
        print decimal number with a prespecified number of digits after the point
        Parameters:
        out - output stream
        number - to be printed
        width - number of fraction digits
        Returns:
        length of the string printed
      • getDecimalString

        public java.lang.String getDecimalString​(double number,
                                                 int width)
        Returns a decimal string representation of a number with constrained width.
      • getSFString

        public java.lang.String getSFString​(double[] numbers,
                                            int sf,
                                            java.lang.String delimiter)
      • getSFString

        public java.lang.String getSFString​(double number,
                                            int sf)
      • displayLabel

        public void displayLabel​(java.io.PrintWriter out,
                                 java.lang.String label,
                                 int width)
        print label with a prespecified length (label will be shortened or spaces will introduced, if necessary)
        Parameters:
        out - output stream
        label - label to be printed
        width - desired length
      • displayInteger

        public void displayInteger​(java.io.PrintWriter out,
                                   int num,
                                   int maxNum)
        print integer, aligned to a reference number, (introducing space at the left side)
        Parameters:
        out - output stream
        num - number to be printed
        maxNum - reference number
      • displayIntegerWhite

        public void displayIntegerWhite​(java.io.PrintWriter out,
                                        int maxNum)
        print whitespace of length of a string displaying a given integer
        Parameters:
        output - stream
        maxNum - number
      • multiplePrint

        public void multiplePrint​(java.io.PrintWriter out,
                                  char c,
                                  int num)
        repeatedly print a character
        Parameters:
        out - output stream
        c - character
        num - number of repeats
      • space

        public static java.lang.String space​(int size,
                                             char c)
        returns of string of a given length of a single character.
        Parameters:
        size - length of the string required
        c - character