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 classNumberFormatOptions.NumberFormatOptionsFactoryCreates a number format options by a native object and a default values instance.
-
Field Summary
Fields Modifier and Type Field Description static NumberFormatOptions.NumberFormatOptionsFactoryFACTORYPublic 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 CompactDisplaygetCompactDisplay()Returns the compact display whenNotation.COMPACTis set.CurrencygetCurrency()Returns the currency to use in currency formatting.CurrencyDisplaygetCurrencyDisplay()Returns how to display the currency in currency formatting.CurrencySigngetCurrencySign()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 DgetDefaultValues()LocaleMatchergetLocaleMatcher()Returns the locale matching algorithm to use.intgetMaximumFractionDigits()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.intgetMaximumSignificantDigits()Returns the maximum number of significant digits to use.intgetMinimumFractionDigits()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().intgetMinimumIntegerDigits()Returns the minimum number of integer digits to use.intgetMinimumSignificantDigits()Returns the minimum number of significant digits to use.NotationgetNotation()Returns the formatting that should be displayed for the number.NumberingSystemgetNumberingSystem()Returns the numbering system to use.SignDisplaygetSignDisplay()Returns when to display the sign for the number.StylegetStyle()Returns the formatting style to use.MeasureUnitDisplaygetUnitOfMeasureDisplay()Returns the unit formatting style to use in unit formatting.List<MeasureUnit>getUnitsOfMeasure()Returns an unmodifiable list of units to use in unit formatting.booleanisUseGrouping()Returnstruewhether to use grouping separators, such as thousands separators or thousand/lakh/crore separators.voidload(ChartEnvelop<NativeObject> envelop)Loads theNativeObjectin the envelop passed as argument.
This method is called fromHelpers.formatNumber(double, CLocale, NumberFormatOptions).voidsetCompactDisplay(CompactDisplay display)Set the compact display whenNotation.COMPACTis set.voidsetCurrency(Currency currency)Sets the currency to use in currency formatting.voidsetCurrencyDisplay(CurrencyDisplay currencyDisplay)Sets how to display the currency in currency formatting.voidsetCurrencySign(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".voidsetLocaleMatcher(LocaleMatcher localeMatcher)Sets the locale matching algorithm to use.voidsetMaximumFractionDigits(int maximumFractionDigits)Sets the maximum number of fraction digits to use.
Possible values are from 0 to 20.voidsetMaximumSignificantDigits(int minimumIntegerDigits)Sets the maximum number of significant digits to use.
Possible values are from 1 to 21.voidsetMinimumFractionDigits(int minimumFractionDigits)Sets the minimum number of fraction digits to use.
Possible values are from 0 to 20.voidsetMinimumIntegerDigits(int minimumIntegerDigits)Sets the minimum number of integer digits to use.
Possible values are from 1 to 21.voidsetMinimumSignificantDigits(int minimumIntegerDigits)Sets the minimum number of significant digits to use.
Possible values are from 1 to 21.voidsetNotation(Notation notation)Sets the formatting that should be displayed for the number.voidsetNumberingSystem(NumberingSystem numberingSystem)Sets the numbering system to use.voidsetSignDisplay(SignDisplay signDisplay)Sets when to display the sign for the number.voidsetStyle(Style style)Sets the formatting style to use.voidsetUnitOfMeasureDisplay(MeasureUnitDisplay unitDisplay)Sets the unit formatting style to use in unit formatting.voidsetUnitsOfMeasure(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.voidsetUnitsOfMeasure(MeasureUnit... units)Sets the unit to use in unit formatting.
If more that 1 unit has been passed, a compound unit has been created.voidsetUseGrouping(boolean useGrouping)Setstruewhether to use grouping separators, such as thousands separators or thousand/lakh/crore separators.-
Methods inherited from class org.pepstock.charba.client.commons.NativeObjectContainer
checkAndGetColor, 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, 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, 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.COMPACTis set.- Parameters:
display- the compact display whenNotation.COMPACTis set
-
getCompactDisplay
public CompactDisplay getCompactDisplay()
Returns the compact display whenNotation.COMPACTis set.- Specified by:
getCompactDisplayin interfaceIsDefaultNumberFormatOptions- Returns:
- the compact display when
Notation.COMPACTis 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:
getCurrencyin 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:
getCurrencyDisplayin 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:
getCurrencySignin 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:
getNotationin 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:
getSignDisplayin 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:
getStylein 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:
getUnitsOfMeasurein 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:
getUnitOfMeasureDisplayin interfaceIsDefaultNumberFormatOptions- Returns:
- the unit formatting style to use in unit formatting
-
setUseGrouping
public void setUseGrouping(boolean useGrouping)
Setstruewhether to use grouping separators, such as thousands separators or thousand/lakh/crore separators.- Parameters:
useGrouping-truewhether to use grouping separators, such as thousands separators or thousand/lakh/crore separators
-
isUseGrouping
public boolean isUseGrouping()
Returnstruewhether to use grouping separators, such as thousands separators or thousand/lakh/crore separators.- Specified by:
isUseGroupingin interfaceIsDefaultNumberFormatOptions- Returns:
truewhether 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:
getMinimumIntegerDigitsin 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:
getMinimumFractionDigitsin 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:
getMaximumFractionDigitsin 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:
getMinimumSignificantDigitsin 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:
getMaximumSignificantDigitsin interfaceIsDefaultNumberFormatOptions- Returns:
- the maximum number of significant digits to use
-
load
public void load(ChartEnvelop<NativeObject> envelop)
Loads theNativeObjectin 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:
getLocaleMatcherin 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:
getNumberingSystemin interfaceIsDefaultBaseFormatOptions- Returns:
- the numbering system to use
-
-