Package pal.io

Class FormattedOutput

java.lang.Object
pal.io.FormattedOutput
All Implemented Interfaces:
Serializable

public class FormattedOutput extends Object implements 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:
  • Method Details

    • 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(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 String getDecimalString(double number, int width)
      Returns a decimal string representation of a number with constrained width.
    • getSFString

      public String getSFString(double[] numbers, int sf, String delimiter)
    • getSFString

      public String getSFString(double number, int sf)
    • displayLabel

      public void displayLabel(PrintWriter out, 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(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(PrintWriter out, int maxNum)
      print whitespace of length of a string displaying a given integer
      Parameters:
      output - stream
      maxNum - number
    • multiplePrint

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

      public static 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