ExpFormatter

public class ExpFormatter
implements NumberFormatter
Hierarchy:
Object ⯈ ExpFormatter
All implemented interfaces:
NumberFormatter, ValueFormatter<T>

Summary

Constants
static final NumberFormatter percent
Inherited from NumberFormatter.
Instance Fields
final int base
Exponent base.
protected final String formatString
protected final boolean showMantissa
Constructors
protected ExpFormatter (int base, String mantissaFmt, String mulSign, String baseExpFmt)
Instance Methods
String format (Double x)
Formats value x according to the formatter rules.
Show all inherited methods (11 more)
protected native Object clone ()
Inherited from Object.
boolean equals (Object)
Inherited from Object.
protected void finalize ()
Inherited from Object.
final native Class<?> getClass ()
Inherited from Object.
native int hashCode ()
Inherited from Object.
final native void notify ()
Inherited from Object.
final native void notifyAll ()
Inherited from Object.
String toString ()
Inherited from Object.
final void wait ()
Inherited from Object.
final native void wait (long)
Inherited from Object.
final void wait (long, int)
Inherited from Object.
Static Methods
static ExpFormatter plainExp (int base)
Plain text format as an integer power of a specific base written as "B^X", where B is the base and X is the power (exponent).
static ExpFormatter plainExp (int base, String mantissaFmt)
Plain text format as mantissa and exponent in a specific base written as "M*B^X", where M is mantissa, B is the base, and X is the power (exponent).
static NumberFormatter simple (String fmt)
Inherited from NumberFormatter.
static ExpFormatter svgExp (int base, double dy)
SVG-compatible format as an integer power of a specific base written in superscript form using <tspan> tag.
static ExpFormatter svgExp (int base, String mantissaFmt, double dy)
SVG-compatible format as mantissa and exponent in a specific base written in superscript form using <tspan> tag.

formatString

protected final String formatString;

showMantissa

protected final boolean showMantissa;

base

public final int base;

Exponent base.

ExpFormatter

protected ExpFormatter (
	int base,
	String mantissaFmt,
	String mulSign,
	String baseExpFmt
);

format

@Override
public String format (
	Double x
);

Implements ValueFormatter.format(T). Copied description:

Formats value x according to the formatter rules.

Parameters
x
value to format
Returns

formatted string

plainExp

public static ExpFormatter plainExp (
	int base
);

Plain text format as an integer power of a specific base written as "B^X", where B is the base and X is the power (exponent).

Note that the number is rounded to the nearest integer power of base. If you need precise expression, use mantissa version instead.

Parameters
base
the base of exponent; for example, in 2^X, 2 is the base
Returns

number formatter object encapsulating the rule

See also

plainExp(int, String)

plainExp

public static ExpFormatter plainExp (
	int base,
	String mantissaFmt
);

Plain text format as mantissa and exponent in a specific base written as "M*B^X", where M is mantissa, B is the base, and X is the power (exponent).

Parameters
base
the base of exponent; for example, in 2^X, 2 is the base
mantissaFmt
mantissa format string compatible with simple number format.

Format string should expect mantissa to be a floating point number. Valid examples are: "%f", "%.1f", "%+.3f", and so on. Using "%e" is not recommended as it would not make sense in the final result.

Returns

number formatter object encapsulating the rule

See also

plainExp(int)

svgExp

public static ExpFormatter svgExp (
	int base,
	double dy
);

SVG-compatible format as an integer power of a specific base written in superscript form using <tspan> tag. The exact format is:

 B<tspan dy="dy" style="font-size:smaller">X</tspan>
where B is the base and X is the power (exponent); dy is the superscript offset. The formatted string can be used within SVG tag <text> and should appear as:
BX

Note that the number is rounded to the nearest integer power of base. If you need precise expression, use mantissa version of instead.

Parameters
base
the base of exponent; for example, in 2X, 2 is the base
dy
superscript offset in pixels
Returns

number formatter object encapsulating the rule

See also

svgExp(int, String, double), plainExp(int)

svgExp

public static ExpFormatter svgExp (
	int base,
	String mantissaFmt,
	double dy
);

SVG-compatible format as mantissa and exponent in a specific base written in superscript form using <tspan> tag. The exact format is:

 M&#x00b7;B<tspan dy="dy" style="font-size:smaller">X</tspan>
where M is mantissa, B is the base, and X is the power (exponent); dy is the superscript offset. The formatted string can be used within SVG tag <text> and should appear as:
M·BX
Parameters
base
the base of exponent; for example, in 2X, 2 is the base
mantissaFmt
mantissaFmt mantissa format string compatible with simple number format.

Format string should expect mantissa to be a floating point number. Valid examples are: "%f", "%.1f", "%+.3f", and so on. Using "%e" is not recommended as it would not make sense in the final result.

dy
superscript offset in pixels
Returns

number formatter object encapsulating the rule

See also

svgExp(int, double), plainExp(int, String)