Package org.pepstock.charba.client.intl
Class NumberFormatOptions
- java.lang.Object
-
- org.pepstock.charba.client.commons.NativeObjectContainer
-
- org.pepstock.charba.client.intl.NumberFormatOptions
-
- All Implemented Interfaces:
IsDefaultBaseFormatOptions
,IsDefaultNumberFormatOptions
public final class NumberFormatOptions extends NativeObjectContainer implements IsDefaultNumberFormatOptions
The object configures a number formatter.
See MDN for more details.- Author:
- Andrea "Stock" Stocchero
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NumberFormatOptions.NumberFormatOptionsFactory
Creates a number format options by a native object and a default values instance.
-
Field Summary
Fields Modifier and Type Field Description static NumberFormatOptions.NumberFormatOptionsFactory
FACTORY
Public factory to create a number format options from a native object.
-
Constructor Summary
Constructors Constructor Description NumberFormatOptions()
Creates new number format options object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompactDisplay
getCompactDisplay()
Returns the compact display whenNotation.COMPACT
is set.Currency
getCurrency()
Returns the currency to use in currency formatting.CurrencyDisplay
getCurrencyDisplay()
Returns how to display the currency in currency formatting.CurrencySign
getCurrencySign()
In many locales, accounting format means to wrap the number with parentheses instead of appending a minus sign.
You can enable this formatting by setting the currency sign option to "accounting" otherwise "standard".protected D
getDefaultValues()
LocaleMatcher
getLocaleMatcher()
Returns the locale matching algorithm to use.int
getMaximumFractionDigits()
Returns the maximum number of fraction digits to use.
The default for plain number formatting is the larger ofgetMinimumFractionDigits()
and 3.
The default for currency formatting is the larger ofgetMinimumFractionDigits()
and the number of minor unit digits provided by currency, seeCurrency.getMinimumFractionDigits()
.
The default for percent formatting is the larger ofgetMinimumFractionDigits()
and 0.int
getMaximumSignificantDigits()
Returns the maximum number of significant digits to use.int
getMinimumFractionDigits()
Returns the minimum number of fraction digits to use.
The default for plain number and percent formatting is 0.
The default for currency formatting is the number of minor unit digits provided by the currency, seeCurrency.getMinimumFractionDigits()
.int
getMinimumIntegerDigits()
Returns the minimum number of integer digits to use.int
getMinimumSignificantDigits()
Returns the minimum number of significant digits to use.Notation
getNotation()
Returns the formatting that should be displayed for the number.NumberingSystem
getNumberingSystem()
Returns the numbering system to use.SignDisplay
getSignDisplay()
Returns when to display the sign for the number.Style
getStyle()
Returns the formatting style to use.MeasureUnitDisplay
getUnitOfMeasureDisplay()
Returns the unit formatting style to use in unit formatting.List<MeasureUnit>
getUnitsOfMeasure()
Returns an unmodifiable list of units to use in unit formatting.boolean
isUseGrouping()
Returnstrue
whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators.void
load(ChartEnvelop<NativeObject> envelop)
Loads theNativeObject
in the envelop passed as argument.
This method is called fromHelpers.formatNumber(double, CLocale, NumberFormatOptions)
.void
setCompactDisplay(CompactDisplay display)
Set the compact display whenNotation.COMPACT
is set.void
setCurrency(Currency currency)
Sets the currency to use in currency formatting.void
setCurrencyDisplay(CurrencyDisplay currencyDisplay)
Sets how to display the currency in currency formatting.void
setCurrencySign(CurrencySign currencySign)
In many locales, accounting format means to wrap the number with parentheses instead of appending a minus sign.
You can enable this formatting by setting the currency sign option to "accounting" otherwise "standard".void
setLocaleMatcher(LocaleMatcher localeMatcher)
Sets the locale matching algorithm to use.void
setMaximumFractionDigits(int maximumFractionDigits)
Sets the maximum number of fraction digits to use.
Possible values are from 0 to 20.void
setMaximumSignificantDigits(int minimumIntegerDigits)
Sets the maximum number of significant digits to use.
Possible values are from 1 to 21.void
setMinimumFractionDigits(int minimumFractionDigits)
Sets the minimum number of fraction digits to use.
Possible values are from 0 to 20.void
setMinimumIntegerDigits(int minimumIntegerDigits)
Sets the minimum number of integer digits to use.
Possible values are from 1 to 21.void
setMinimumSignificantDigits(int minimumIntegerDigits)
Sets the minimum number of significant digits to use.
Possible values are from 1 to 21.void
setNotation(Notation notation)
Sets the formatting that should be displayed for the number.void
setNumberingSystem(NumberingSystem numberingSystem)
Sets the numbering system to use.void
setSignDisplay(SignDisplay signDisplay)
Sets when to display the sign for the number.void
setStyle(Style style)
Sets the formatting style to use.void
setUnitOfMeasureDisplay(MeasureUnitDisplay unitDisplay)
Sets the unit formatting style to use in unit formatting.void
setUnitsOfMeasure(List<MeasureUnit> units)
Sets the unit to use in unit formatting.
If more that 1 unit has been passed, a compound unit has been created.void
setUnitsOfMeasure(MeasureUnit... units)
Sets the unit to use in unit formatting.
If more that 1 unit has been passed, a compound unit has been created.void
setUseGrouping(boolean useGrouping)
Setstrue
whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators.-
Methods inherited from class org.pepstock.charba.client.commons.NativeObjectContainer
checkDefaultValuesArgument, empty, getArrayValue, getElement, getIncrementalId, getNativeChart, getNativeEvent, getNativeObject, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValueForMultipleKeyTypes, getValueForMultipleKeyTypes, getValueForMultipleKeyTypes, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, has, has, isType, keys, loadNativeObject, remove, remove, setArrayValue, setArrayValue, setArrayValue, setElement, setEmptyValue, setNewIncrementalId, setNewIncrementalId, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, toJSON, type
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.pepstock.charba.client.defaults.IsDefaultBaseFormatOptions
getLocaleMatcher, getNumberingSystem
-
Methods inherited from interface org.pepstock.charba.client.defaults.IsDefaultNumberFormatOptions
create, create
-
-
-
-
Field Detail
-
FACTORY
public static final NumberFormatOptions.NumberFormatOptionsFactory FACTORY
Public factory to create a number format options from a native object.
-
-
Method Detail
-
setCompactDisplay
public void setCompactDisplay(CompactDisplay display)
Set the compact display whenNotation.COMPACT
is set.- Parameters:
display
- the compact display whenNotation.COMPACT
is set
-
getCompactDisplay
public CompactDisplay getCompactDisplay()
Returns the compact display whenNotation.COMPACT
is set.- Specified by:
getCompactDisplay
in interfaceIsDefaultNumberFormatOptions
- Returns:
- the compact display when
Notation.COMPACT
is set
-
setCurrency
public void setCurrency(Currency currency)
Sets the currency to use in currency formatting.- Parameters:
currency
- the currency to use in currency formatting
-
getCurrency
public Currency getCurrency()
Returns the currency to use in currency formatting.- Specified by:
getCurrency
in interfaceIsDefaultNumberFormatOptions
- Returns:
- the currency to use in currency formatting
-
setCurrencyDisplay
public void setCurrencyDisplay(CurrencyDisplay currencyDisplay)
Sets how to display the currency in currency formatting.- Parameters:
currencyDisplay
- how to display the currency in currency formatting
-
getCurrencyDisplay
public CurrencyDisplay getCurrencyDisplay()
Returns how to display the currency in currency formatting.- Specified by:
getCurrencyDisplay
in interfaceIsDefaultNumberFormatOptions
- Returns:
- how to display the currency in currency formatting
-
setCurrencySign
public void setCurrencySign(CurrencySign currencySign)
In many locales, accounting format means to wrap the number with parentheses instead of appending a minus sign.
You can enable this formatting by setting the currency sign option to "accounting" otherwise "standard".- Parameters:
currencySign
- the currency format to use on formatting
-
getCurrencySign
public CurrencySign getCurrencySign()
In many locales, accounting format means to wrap the number with parentheses instead of appending a minus sign.
You can enable this formatting by setting the currency sign option to "accounting" otherwise "standard".- Specified by:
getCurrencySign
in interfaceIsDefaultNumberFormatOptions
- Returns:
- the currency format to use on formatting
-
setNotation
public void setNotation(Notation notation)
Sets the formatting that should be displayed for the number.- Parameters:
notation
- the formatting that should be displayed for the number
-
getNotation
public Notation getNotation()
Returns the formatting that should be displayed for the number.- Specified by:
getNotation
in interfaceIsDefaultNumberFormatOptions
- Returns:
- the formatting that should be displayed for the number
-
setSignDisplay
public void setSignDisplay(SignDisplay signDisplay)
Sets when to display the sign for the number.- Parameters:
signDisplay
- when to display the sign for the number
-
getSignDisplay
public SignDisplay getSignDisplay()
Returns when to display the sign for the number.- Specified by:
getSignDisplay
in interfaceIsDefaultNumberFormatOptions
- Returns:
- when to display the sign for the number
-
setStyle
public void setStyle(Style style)
Sets the formatting style to use.- Parameters:
style
- the formatting style to use
-
getStyle
public Style getStyle()
Returns the formatting style to use.- Specified by:
getStyle
in interfaceIsDefaultNumberFormatOptions
- Returns:
- the formatting style to use
-
setUnitsOfMeasure
public void setUnitsOfMeasure(MeasureUnit... units)
Sets the unit to use in unit formatting.
If more that 1 unit has been passed, a compound unit has been created.- Parameters:
units
- the units to use in units formatting
-
setUnitsOfMeasure
public void setUnitsOfMeasure(List<MeasureUnit> units)
Sets the unit to use in unit formatting.
If more that 1 unit has been passed, a compound unit has been created.- Parameters:
units
- the units to use in units formatting
-
getUnitsOfMeasure
public List<MeasureUnit> getUnitsOfMeasure()
Returns an unmodifiable list of units to use in unit formatting.- Specified by:
getUnitsOfMeasure
in interfaceIsDefaultNumberFormatOptions
- Returns:
- an unmodifiable list of unit to use in unit formatting
-
setUnitOfMeasureDisplay
public void setUnitOfMeasureDisplay(MeasureUnitDisplay unitDisplay)
Sets the unit formatting style to use in unit formatting.- Parameters:
unitDisplay
- the unit formatting style to use in unit formatting
-
getUnitOfMeasureDisplay
public MeasureUnitDisplay getUnitOfMeasureDisplay()
Returns the unit formatting style to use in unit formatting.- Specified by:
getUnitOfMeasureDisplay
in interfaceIsDefaultNumberFormatOptions
- Returns:
- the unit formatting style to use in unit formatting
-
setUseGrouping
public void setUseGrouping(boolean useGrouping)
Setstrue
whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators.- Parameters:
useGrouping
-true
whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators
-
isUseGrouping
public boolean isUseGrouping()
Returnstrue
whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators.- Specified by:
isUseGrouping
in interfaceIsDefaultNumberFormatOptions
- Returns:
true
whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators
-
setMinimumIntegerDigits
public void setMinimumIntegerDigits(int minimumIntegerDigits)
Sets the minimum number of integer digits to use.
Possible values are from 1 to 21.- Parameters:
minimumIntegerDigits
- the minimum number of integer digits to use
-
getMinimumIntegerDigits
public int getMinimumIntegerDigits()
Returns the minimum number of integer digits to use.- Specified by:
getMinimumIntegerDigits
in interfaceIsDefaultNumberFormatOptions
- Returns:
- the minimum number of integer digits to use
-
setMinimumFractionDigits
public void setMinimumFractionDigits(int minimumFractionDigits)
Sets the minimum number of fraction digits to use.
Possible values are from 0 to 20.- Parameters:
minimumFractionDigits
- the minimum number of fraction digits to use
-
getMinimumFractionDigits
public int getMinimumFractionDigits()
Returns the minimum number of fraction digits to use.
The default for plain number and percent formatting is 0.
The default for currency formatting is the number of minor unit digits provided by the currency, seeCurrency.getMinimumFractionDigits()
.- Specified by:
getMinimumFractionDigits
in interfaceIsDefaultNumberFormatOptions
- Returns:
- the minimum number of fraction digits to use.
The default for plain number and percent formatting is 0.
The default for currency formatting is the number of minor unit digits provided by the currency, seeCurrency.getMinimumFractionDigits()
-
setMaximumFractionDigits
public void setMaximumFractionDigits(int maximumFractionDigits)
Sets the maximum number of fraction digits to use.
Possible values are from 0 to 20.- Parameters:
maximumFractionDigits
- the maximum number of fraction digits to use
-
getMaximumFractionDigits
public int getMaximumFractionDigits()
Returns the maximum number of fraction digits to use.
The default for plain number formatting is the larger ofgetMinimumFractionDigits()
and 3.
The default for currency formatting is the larger ofgetMinimumFractionDigits()
and the number of minor unit digits provided by currency, seeCurrency.getMinimumFractionDigits()
.
The default for percent formatting is the larger ofgetMinimumFractionDigits()
and 0.- Specified by:
getMaximumFractionDigits
in interfaceIsDefaultNumberFormatOptions
- Returns:
- the maximum number of fraction digits to use.
The default for plain number formatting is the larger ofgetMinimumFractionDigits()
and 3.
The default for currency formatting is the larger ofgetMinimumFractionDigits()
and the number of minor unit digits provided by currency, seeCurrency.getMinimumFractionDigits()
.
The default for percent formatting is the larger ofgetMinimumFractionDigits()
and 0.
-
setMinimumSignificantDigits
public void setMinimumSignificantDigits(int minimumIntegerDigits)
Sets the minimum number of significant digits to use.
Possible values are from 1 to 21.- Parameters:
minimumIntegerDigits
- the minimum number of significant digits to use
-
getMinimumSignificantDigits
public int getMinimumSignificantDigits()
Returns the minimum number of significant digits to use.- Specified by:
getMinimumSignificantDigits
in interfaceIsDefaultNumberFormatOptions
- Returns:
- the minimum number of significant digits to use
-
setMaximumSignificantDigits
public void setMaximumSignificantDigits(int minimumIntegerDigits)
Sets the maximum number of significant digits to use.
Possible values are from 1 to 21.- Parameters:
minimumIntegerDigits
- the maximum number of significant digits to use
-
getMaximumSignificantDigits
public int getMaximumSignificantDigits()
Returns the maximum number of significant digits to use.- Specified by:
getMaximumSignificantDigits
in interfaceIsDefaultNumberFormatOptions
- Returns:
- the maximum number of significant digits to use
-
load
public void load(ChartEnvelop<NativeObject> envelop)
Loads theNativeObject
in the envelop passed as argument.
This method is called fromHelpers.formatNumber(double, CLocale, NumberFormatOptions)
.- Parameters:
envelop
- envelop where loads theNativeObject
-
getDefaultValues
protected final D getDefaultValues()
- Returns:
- the defaultValues
-
setLocaleMatcher
public final void setLocaleMatcher(LocaleMatcher localeMatcher)
Sets the locale matching algorithm to use.- Parameters:
localeMatcher
- the locale matching algorithm to use
-
getLocaleMatcher
public final LocaleMatcher getLocaleMatcher()
Returns the locale matching algorithm to use.- Specified by:
getLocaleMatcher
in interfaceIsDefaultBaseFormatOptions
- Returns:
- the locale matching algorithm to use
-
setNumberingSystem
public final void setNumberingSystem(NumberingSystem numberingSystem)
Sets the numbering system to use.- Parameters:
numberingSystem
- the numbering system to use
-
getNumberingSystem
public final NumberingSystem getNumberingSystem()
Returns the numbering system to use.- Specified by:
getNumberingSystem
in interfaceIsDefaultBaseFormatOptions
- Returns:
- the numbering system to use
-
-