Class ScientificNumberFormat

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public class ScientificNumberFormat
    extends java.text.NumberFormat
    A number format that will switch between a "small" and "large" format depending on the magnitude of the value. If the magnitude of the to-be-formatted value is below a settable threshold, then the small format will be used. Otherwise, and if the value is exactly equal to 0.0, the large format will be used.
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.text.NumberFormat

        java.text.NumberFormat.Field
    • Field Summary

      • Fields inherited from class java.text.NumberFormat

        FRACTION_FIELD, INTEGER_FIELD
    • Constructor Summary

      Constructors 
      Constructor Description
      ScientificNumberFormat()
      Creates a Scientific number format with 10 significant digits and a threshold of 0.0001
      ScientificNumberFormat​(int significantDigits, double threshold)
      Creates a scientific number format with any number of significant digits and a custom threshold
      ScientificNumberFormat​(java.lang.String largeFormat, java.lang.String smallFormat, double threshold)
      Creates a scientific number format with custom large and small formats
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      javax.swing.JFormattedTextField createEditor()
      Creates an editor that uses this formatter as its decimal format
      java.lang.StringBuffer format​(double number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)  
      java.lang.StringBuffer format​(long number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)  
      static ScientificNumberFormat getShared()  
      java.lang.Number parse​(java.lang.String source, java.text.ParsePosition parsePosition)  
      • Methods inherited from class java.text.NumberFormat

        clone, equals, format, format, format, getAvailableLocales, getCurrency, getCurrencyInstance, getCurrencyInstance, getInstance, getInstance, getIntegerInstance, getIntegerInstance, getMaximumFractionDigits, getMaximumIntegerDigits, getMinimumFractionDigits, getMinimumIntegerDigits, getNumberInstance, getNumberInstance, getPercentInstance, getPercentInstance, getRoundingMode, hashCode, isGroupingUsed, isParseIntegerOnly, parse, parseObject, setCurrency, setGroupingUsed, setMaximumFractionDigits, setMaximumIntegerDigits, setMinimumFractionDigits, setMinimumIntegerDigits, setParseIntegerOnly, setRoundingMode
      • Methods inherited from class java.text.Format

        format, formatToCharacterIterator, parseObject
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ScientificNumberFormat

        public ScientificNumberFormat()
        Creates a Scientific number format with 10 significant digits and a threshold of 0.0001
      • ScientificNumberFormat

        public ScientificNumberFormat​(int significantDigits,
                                      double threshold)
        Creates a scientific number format with any number of significant digits and a custom threshold
      • ScientificNumberFormat

        public ScientificNumberFormat​(java.lang.String largeFormat,
                                      java.lang.String smallFormat,
                                      double threshold)
        Creates a scientific number format with custom large and small formats
    • Method Detail

      • format

        public java.lang.StringBuffer format​(double number,
                                             java.lang.StringBuffer toAppendTo,
                                             java.text.FieldPosition pos)
        Specified by:
        format in class java.text.NumberFormat
      • format

        public java.lang.StringBuffer format​(long number,
                                             java.lang.StringBuffer toAppendTo,
                                             java.text.FieldPosition pos)
        Specified by:
        format in class java.text.NumberFormat
      • parse

        public java.lang.Number parse​(java.lang.String source,
                                      java.text.ParsePosition parsePosition)
        Specified by:
        parse in class java.text.NumberFormat
      • createEditor

        public javax.swing.JFormattedTextField createEditor()
        Creates an editor that uses this formatter as its decimal format