Class OrdinateFormat


  • public class OrdinateFormat
    extends java.lang.Object
    Formats numeric values for ordinates in a consistent, accurate way.

    The format has the following characteristics:

    • It is consistent in all locales (in particular, the decimal separator is always a period)
    • Scientific notation is never output, even for very large numbers. This means that it is possible that output can contain a large number of digits.
    • The maximum number of decimal places reflects the available precision
    • NaN values are represented as "NaN"
    • Inf values are represented as "Inf" or "-Inf"
    Author:
    mdavis
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static OrdinateFormat DEFAULT
      The default formatter using the maximum number of digits in the fraction portion of a number.
      static int MAX_FRACTION_DIGITS
      The maximum number of fraction digits to support output of reasonable ordinate values.
      static java.lang.String REP_NAN
      The output representation of Double.NaN
      static java.lang.String REP_NEG_INF
      The output representation of Double.NEGATIVE_INFINITY
      static java.lang.String REP_POS_INF
      The output representation of Double.POSITIVE_INFINITY
    • Constructor Summary

      Constructors 
      Constructor Description
      OrdinateFormat()
      Creates an OrdinateFormat using the default maximum number of fraction digits.
      OrdinateFormat​(int maximumFractionDigits)
      Creates an OrdinateFormat using the given maximum number of fraction digits.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static OrdinateFormat create​(int maximumFractionDigits)
      Creates a new formatter with the given maximum number of digits in the fraction portion of a number.
      java.lang.String format​(double ord)
      Returns a string representation of the given ordinate numeric value.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • REP_POS_INF

        public static final java.lang.String REP_POS_INF
        The output representation of Double.POSITIVE_INFINITY
        See Also:
        Constant Field Values
      • REP_NEG_INF

        public static final java.lang.String REP_NEG_INF
        The output representation of Double.NEGATIVE_INFINITY
        See Also:
        Constant Field Values
      • REP_NAN

        public static final java.lang.String REP_NAN
        The output representation of Double.NaN
        See Also:
        Constant Field Values
      • MAX_FRACTION_DIGITS

        public static final int MAX_FRACTION_DIGITS
        The maximum number of fraction digits to support output of reasonable ordinate values. The default is chosen to allow representing the smallest possible IEEE-754 double-precision value, although this is not expected to occur (and is not supported by other areas of the JTS code).
        See Also:
        Constant Field Values
      • DEFAULT

        public static OrdinateFormat DEFAULT
        The default formatter using the maximum number of digits in the fraction portion of a number.
    • Constructor Detail

      • OrdinateFormat

        public OrdinateFormat()
        Creates an OrdinateFormat using the default maximum number of fraction digits.
      • OrdinateFormat

        public OrdinateFormat​(int maximumFractionDigits)
        Creates an OrdinateFormat using the given maximum number of fraction digits.
        Parameters:
        maximumFractionDigits - the maximum number of fraction digits to output
    • Method Detail

      • create

        public static OrdinateFormat create​(int maximumFractionDigits)
        Creates a new formatter with the given maximum number of digits in the fraction portion of a number.
        Parameters:
        maximumFractionDigits - the maximum number of fraction digits to output
        Returns:
        a formatter
      • format

        public java.lang.String format​(double ord)
        Returns a string representation of the given ordinate numeric value.
        Parameters:
        ord - the ordinate value
        Returns:
        the formatted number string