Package com.inet.report.chart.format
Class FixedNumberFormat
- java.lang.Object
-
- java.text.Format
-
- java.text.NumberFormat
-
- com.inet.report.chart.format.FixedNumberFormat
-
- All Implemented Interfaces:
ChartFormat
,java.io.Serializable
,java.lang.Cloneable
public class FixedNumberFormat extends java.text.NumberFormat implements ChartFormat
This is a "fixed" number format.
There are three format styles available: number, percent and currency. The number style format shows the value as is.
The percent style format multiplies the values with 100 and shows the percent symbol. The currency style format shows the currency symbol.
The percent and currency symbol position is decided from locale to locale.- Since:
- 8.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static Abbreviation
DEFAULT_ABBREVIATION
The default abbreviation.static int
DEFAULT_NUMBER_OF_DECIMAL_PLACES
Default number of decimal places.static boolean
DEFAULT_USE_THOUSANDS_SEPARATOR
Default using of thousands separator.static int
FORMAT_CURRENCY
The currency format stylestatic int
FORMAT_NUMBER
The number format stylestatic int
FORMAT_PERCENT
The percent format stylestatic int
MINUS_SIGN_AFTER
Minus symbol is placed after number.static int
MINUS_SIGN_BEFORE
Minus symbol is placed before number.static int
MINUS_SIGN_BRACKETS
Use brackets instead of minus.static int
MINUS_SIGN_SYSTEM_DEFAULT
Use system default pattern for negative values.
-
Constructor Summary
Constructors Constructor Description FixedNumberFormat()
Creates a new instance of format with typeFORMAT_NUMBER
and default properties.FixedNumberFormat(int type)
Creates a new instance of format with default properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FixedNumberFormat
clone()
Overrides Cloneablejava.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)
Abbreviation
getAbbreviation()
Returns the abbreviation of formatted values.int
getMinusSymbol()
Returns the flag that control the placing and form of the minus symbol.protected java.lang.String
getName()
FOR INTERNAL USE ONLY Returns the XML attribute name for this dataset.int
getNumberOfDecimalPlaces()
Returns the number of decimal places of this number format.int
getType()
Returns the formating type: number, currency or percent.boolean
isUseThousandSeparator()
Returns the flag that controls the showing of thousands separator.java.lang.Number
parse(java.lang.String source, java.text.ParsePosition parsePosition)
void
readProperties(org.w3c.dom.Element element)
Reads the XML properties of a chart format.void
saveProperties(java.lang.StringBuilder buffer, int depth)
Writes the format properties to output.void
setAbbreviation(Abbreviation abbreviation)
Sets the abbreviation of formatted values.void
setFormatingProperties(com.inet.report.chart.format.FormatingProperties properties)
Sets the location specific formating properties, e.g. locale, time zone, first day of week.void
setMinusSymbol(int minusSymbol)
Sets the flag that control the placing and form of the minus symbol.void
setNumberOfDecimalPlaces(int numberOfDecimalPlaces)
Sets the number of decimal places of this number format.void
setUseThousandSeparator(boolean useThousandSeparator)
Sets the flag that controls the showing of thousands separator.-
Methods inherited from class java.text.NumberFormat
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
-
-
-
-
Field Detail
-
DEFAULT_NUMBER_OF_DECIMAL_PLACES
public static final int DEFAULT_NUMBER_OF_DECIMAL_PLACES
Default number of decimal places.- See Also:
- Constant Field Values
-
DEFAULT_USE_THOUSANDS_SEPARATOR
public static final boolean DEFAULT_USE_THOUSANDS_SEPARATOR
Default using of thousands separator.- See Also:
- Constant Field Values
-
DEFAULT_ABBREVIATION
public static final Abbreviation DEFAULT_ABBREVIATION
The default abbreviation.
-
MINUS_SIGN_BEFORE
public static final int MINUS_SIGN_BEFORE
Minus symbol is placed before number.- See Also:
- Constant Field Values
-
MINUS_SIGN_AFTER
public static final int MINUS_SIGN_AFTER
Minus symbol is placed after number.- See Also:
- Constant Field Values
-
MINUS_SIGN_BRACKETS
public static final int MINUS_SIGN_BRACKETS
Use brackets instead of minus.- See Also:
- Constant Field Values
-
MINUS_SIGN_SYSTEM_DEFAULT
public static final int MINUS_SIGN_SYSTEM_DEFAULT
Use system default pattern for negative values.- See Also:
- Constant Field Values
-
FORMAT_NUMBER
public static final int FORMAT_NUMBER
The number format style- See Also:
- Constant Field Values
-
FORMAT_PERCENT
public static final int FORMAT_PERCENT
The percent format style- See Also:
- Constant Field Values
-
FORMAT_CURRENCY
public static final int FORMAT_CURRENCY
The currency format style- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FixedNumberFormat
public FixedNumberFormat()
Creates a new instance of format with typeFORMAT_NUMBER
and default properties.- Since:
- 8.0
- See Also:
FORMAT_NUMBER
,FORMAT_PERCENT
,FORMAT_CURRENCY
-
FixedNumberFormat
public FixedNumberFormat(int type)
Creates a new instance of format with default properties.- Parameters:
type
- the formating type- Throws:
java.lang.IllegalArgumentException
- by illegal type.- Since:
- 8.0
- See Also:
FORMAT_NUMBER
,FORMAT_PERCENT
,FORMAT_CURRENCY
-
-
Method Detail
-
getAbbreviation
public Abbreviation getAbbreviation()
Returns the abbreviation of formatted values.- Returns:
- the abbreviation
- Since:
- 8.0
- See Also:
setAbbreviation(Abbreviation)
-
setAbbreviation
public void setAbbreviation(Abbreviation abbreviation)
Sets the abbreviation of formatted values. Note: this property works with number format only, not with currency or percent.- Parameters:
abbreviation
- the abbreviation (null
not permitted)- Since:
- 8.0
- See Also:
DEFAULT_ABBREVIATION
,Abbreviation.ABBREVIATION_NONE
,Abbreviation.ABBREVIATION_THOUSANDS
,Abbreviation.ABBREVIATION_MILLIONS
,Abbreviation.ABBREVIATION_BILLIONS
-
getNumberOfDecimalPlaces
public int getNumberOfDecimalPlaces()
Returns the number of decimal places of this number format. The format handles a value with more digits to the right of the decimal point as set with this function by rounding up.- Returns:
- the number of decimals.
- Since:
- 8.0
- See Also:
setNumberOfDecimalPlaces(int)
-
setNumberOfDecimalPlaces
public void setNumberOfDecimalPlaces(int numberOfDecimalPlaces)
Sets the number of decimal places of this number format. The format handles a value with more digits to the right of the decimal point as set with this function by rounding up.- Parameters:
numberOfDecimalPlaces
- the number of places- Throws:
java.lang.IllegalArgumentException
- by negative number.- Since:
- 8.0
-
isUseThousandSeparator
public boolean isUseThousandSeparator()
Returns the flag that controls the showing of thousands separator.- Returns:
- the flag.
- Since:
- 8.0
- See Also:
setUseThousandSeparator(boolean)
-
setUseThousandSeparator
public void setUseThousandSeparator(boolean useThousandSeparator)
Sets the flag that controls the showing of thousands separator.- Parameters:
useThousandSeparator
- the flag- Since:
- 8.0
- See Also:
isUseThousandSeparator()
-
getMinusSymbol
public int getMinusSymbol()
Returns the flag that control the placing and form of the minus symbol.- Returns:
- the flag.
- Since:
- 8.0
- See Also:
setMinusSymbol(int)
-
setMinusSymbol
public void setMinusSymbol(int minusSymbol)
Sets the flag that control the placing and form of the minus symbol.- Parameters:
minusSymbol
- the flag- Since:
- 8.0
- See Also:
getMinusSymbol()
,MINUS_SIGN_AFTER
,MINUS_SIGN_BEFORE
,MINUS_SIGN_BRACKETS
,MINUS_SIGN_SYSTEM_DEFAULT
-
setFormatingProperties
public void setFormatingProperties(com.inet.report.chart.format.FormatingProperties properties)
Sets the location specific formating properties, e.g. locale, time zone, first day of week.- Specified by:
setFormatingProperties
in interfaceChartFormat
- Parameters:
properties
- the properties object (null
not permitted)
-
format
public java.lang.StringBuffer format(double number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
- Specified by:
format
in classjava.text.NumberFormat
-
format
public java.lang.StringBuffer format(long number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
- Specified by:
format
in classjava.text.NumberFormat
-
parse
public java.lang.Number parse(java.lang.String source, java.text.ParsePosition parsePosition)
- Specified by:
parse
in classjava.text.NumberFormat
-
saveProperties
public void saveProperties(java.lang.StringBuilder buffer, int depth)
Writes the format properties to output.- Specified by:
saveProperties
in interfaceChartFormat
- Parameters:
buffer
- the outputdepth
- the depth of XML indent
-
readProperties
public void readProperties(org.w3c.dom.Element element)
Reads the XML properties of a chart format.- Specified by:
readProperties
in interfaceChartFormat
- Parameters:
element
- DOM element- See Also:
ChartFormat.saveProperties(StringBuilder, int)
-
clone
public FixedNumberFormat clone()
Overrides Cloneable- Specified by:
clone
in interfaceChartFormat
- Overrides:
clone
in classjava.text.NumberFormat
- Returns:
- the chart format
-
getName
protected java.lang.String getName()
FOR INTERNAL USE ONLY Returns the XML attribute name for this dataset.- Returns:
- the name.
-
getType
public int getType()
Returns the formating type: number, currency or percent.- Returns:
- the type
- Since:
- 8.0
- See Also:
FORMAT_NUMBER
,FORMAT_PERCENT
,FORMAT_CURRENCY
-
-