Class Formatter
- java.lang.Object
-
- adams.gui.visualization.core.axis.Formatter
-
- All Implemented Interfaces:
Serializable
public class Formatter extends Object implements Serializable
A wrapper class for Java formatters DecimalFormat and SimpleDateFormat.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
DecimalFormat
,SimpleDateFormat
, Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
applyPattern(String pattern)
Applies the given pattern.String
format(Double value)
Formats the given value and returns the string.static Formatter
getDateFormatter()
Returns an instance of a date formatter.static Formatter
getDateFormatter(String pattern)
Returns an instance of a date formatter with a specified pattern.static Formatter
getDecimalFormatter()
Returns an instance of a decimal formatter.static Formatter
getDecimalFormatter(String pattern)
Returns an instance of a decimal formatter with a specified pattern.Format
getFormat()
Returns in the Java formatter used internally.protected static Formatter
getFormatter(Format format, String pattern)
Returns an instance of a decimal formatter with a specified pattern.Double
parse(String s)
Parses the given string.void
setFormat(Format format)
Sets the Java formatter to use.String
toPattern()
Returns the pattern in use by the Java formatter.String
toString()
A string representation of the formatter.
-
-
-
Field Detail
-
NAN
public static final String NAN
the constant for NaN.- See Also:
- Constant Field Values
-
m_Format
protected Format m_Format
the Java formatter.
-
-
Constructor Detail
-
Formatter
public Formatter(Format format)
Initializes the formatter.- Parameters:
format
- the Java formatter to use- See Also:
setFormat(Format)
-
-
Method Detail
-
setFormat
public void setFormat(Format format)
Sets the Java formatter to use. Only DecimalFormat and SimpleDateFormat are allowed.- Parameters:
format
- the Java formatter to use
-
getFormat
public Format getFormat()
Returns in the Java formatter used internally.- Returns:
- the formatter
-
applyPattern
public void applyPattern(String pattern)
Applies the given pattern.- Parameters:
pattern
- the pattern to use
-
toPattern
public String toPattern()
Returns the pattern in use by the Java formatter.- Returns:
- the pattern in use
-
parse
public Double parse(String s)
Parses the given string. Returns Double.NaN in case of an error.- Parameters:
s
- the string to parse- Returns:
- the value or Double.NaN in case of an error
-
format
public String format(Double value)
Formats the given value and returns the string.- Parameters:
value
- the value to turn into a string- Returns:
- the generated string
-
getFormatter
protected static Formatter getFormatter(Format format, String pattern)
Returns an instance of a decimal formatter with a specified pattern.- Parameters:
format
- the Java formatter to usepattern
- the pattern to use, ignored if null- Returns:
- the formatter
-
toString
public String toString()
A string representation of the formatter.
-
getDecimalFormatter
public static Formatter getDecimalFormatter()
Returns an instance of a decimal formatter.- Returns:
- the formatter
-
getDecimalFormatter
public static Formatter getDecimalFormatter(String pattern)
Returns an instance of a decimal formatter with a specified pattern.- Parameters:
pattern
- the pattern to use, ignored if null- Returns:
- the formatter
-
getDateFormatter
public static Formatter getDateFormatter()
Returns an instance of a date formatter.- Returns:
- the formatter
-
-