Package org.jfree.chart.util
Class LogFormat
- java.lang.Object
-
- java.text.Format
-
- java.text.NumberFormat
-
- org.jfree.chart.util.LogFormat
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
public class LogFormat extends java.text.NumberFormatA number formatter for logarithmic values. This formatter does not support parsing.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private doublebaseThe log base value.private java.lang.StringbaseLabelThe label for the log base (for example, "e").private doublebaseLogThe natural logarithm of the base value.private java.text.NumberFormatformatterThe number formatter for the exponent.private java.lang.StringpowerLabelThe label for the power symbol.private booleanshowBaseA flag that controls whether or not the base is shown.
-
Constructor Summary
Constructors Constructor Description LogFormat()Creates a new instance using base 10.LogFormat(double base, java.lang.String baseLabel, boolean showBase)Creates a new instance.LogFormat(double base, java.lang.String baseLabel, java.lang.String powerLabel, boolean showBase)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private doublecalculateLog(double value)Calculates the log of a given value.java.lang.Objectclone()Returns a clone of this instance.booleanequals(java.lang.Object obj)Tests this formatter for equality with an arbitrary object.java.lang.StringBufferformat(double number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)Returns a formatted representation of the specified number.java.lang.StringBufferformat(long number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)Formats the specified number as a hexadecimal string.java.text.NumberFormatgetExponentFormat()Returns the number format used for the exponent.java.lang.Numberparse(java.lang.String source, java.text.ParsePosition parsePosition)Parsing is not implemented, so this method always returnsnull.voidsetExponentFormat(java.text.NumberFormat format)Sets the number format used for the exponent.-
Methods inherited from class java.text.NumberFormat
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
-
-
-
-
Field Detail
-
base
private double base
The log base value.
-
baseLog
private double baseLog
The natural logarithm of the base value.
-
baseLabel
private java.lang.String baseLabel
The label for the log base (for example, "e").
-
powerLabel
private java.lang.String powerLabel
The label for the power symbol.
-
showBase
private boolean showBase
A flag that controls whether or not the base is shown.
-
formatter
private java.text.NumberFormat formatter
The number formatter for the exponent.
-
-
Constructor Detail
-
LogFormat
public LogFormat()
Creates a new instance using base 10.
-
LogFormat
public LogFormat(double base, java.lang.String baseLabel, boolean showBase)Creates a new instance.- Parameters:
base- the base.baseLabel- the base label (nullnot permitted).showBase- a flag that controls whether or not the base value is shown.
-
LogFormat
public LogFormat(double base, java.lang.String baseLabel, java.lang.String powerLabel, boolean showBase)Creates a new instance.- Parameters:
base- the base.baseLabel- the base label (nullnot permitted).powerLabel- the power label (nullnot permitted).showBase- a flag that controls whether or not the base value is shown.
-
-
Method Detail
-
getExponentFormat
public java.text.NumberFormat getExponentFormat()
Returns the number format used for the exponent.- Returns:
- The number format (never
null).
-
setExponentFormat
public void setExponentFormat(java.text.NumberFormat format)
Sets the number format used for the exponent.- Parameters:
format- the formatter (nullnot permitted).
-
calculateLog
private double calculateLog(double value)
Calculates the log of a given value.- Parameters:
value- the value.- Returns:
- The log of the value.
-
format
public java.lang.StringBuffer format(double number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)Returns a formatted representation of the specified number.- Specified by:
formatin classjava.text.NumberFormat- Parameters:
number- the number.toAppendTo- the string buffer to append to.pos- the position.- Returns:
- A string buffer containing the formatted value.
-
format
public java.lang.StringBuffer format(long number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)Formats the specified number as a hexadecimal string. The decimal fraction is ignored.- Specified by:
formatin classjava.text.NumberFormat- Parameters:
number- the number to format.toAppendTo- the buffer to append to (ignored here).pos- the field position (ignored here).- Returns:
- The string buffer.
-
parse
public java.lang.Number parse(java.lang.String source, java.text.ParsePosition parsePosition)Parsing is not implemented, so this method always returnsnull.- Specified by:
parsein classjava.text.NumberFormat- Parameters:
source- ignored.parsePosition- ignored.- Returns:
- Always
null.
-
equals
public boolean equals(java.lang.Object obj)
Tests this formatter for equality with an arbitrary object.- Overrides:
equalsin classjava.text.NumberFormat- Parameters:
obj- the object (nullpermitted).- Returns:
- A boolean.
-
clone
public java.lang.Object clone()
Returns a clone of this instance.- Overrides:
clonein classjava.text.NumberFormat- Returns:
- A clone.
-
-