Package org.djunits.formatter
Class QuantityFormat
java.lang.Object
org.djunits.formatter.Format<QuantityFormat,QuantityFormatContext>
org.djunits.formatter.QuantityFormat
QuantityFormat stores the settings that influence both the value part and the unit part of an output string when formatting a
quantity.
Copyright (c) 2026-2026 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djunits.org. The DJUNITS project is distributed under a three-clause BSD-style license.
- Author:
- Alexander Verbraeck
-
Field Summary
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstruct a QuantityFormat object with a given context. -
Method Summary
Modifier and TypeMethodDescriptionstatic QuantityFormatReturn an instance of QuantityFormat with the DEFAULT values, which can be changed for all subsequent calls.static QuantityFormatdefaults()Return an instance of QuantityFormat, initialized with the default values.static voidReset the default values of QuantityFormat to their original values.Use closest SI prefix.setScaleSiPrefixes(int minPrefixPower, int maxPrefixPower) Use closest SI prefix.Methods inherited from class org.djunits.formatter.Format
self, setDecimals, setDisplay, setDisplayUnit, setDisplayUnit, setDivider, setDotSeparator, setEngineering, setFixedFloat, setFixedWithEngFallback, setFixedWithSciFallback, setFormatString, setGroupingSeparator, setLocale, setNoReference, setPowerPostfix, setPowerPrefix, setPrintReference, setPrintReference, setReferencePostfix, setReferencePrefix, setScientific, setSiUnits, setTextual, setTextual, setUnitPostfix, setUnitPrefix, setUpperE, setVariableLength, setWidth
-
Constructor Details
-
QuantityFormat
Construct a QuantityFormat object with a given context. Note that the context can be an existing context that is being modified or a default context.- Parameters:
ctx- the quantity format context to use
-
-
Method Details
-
defaults
Return an instance of QuantityFormat, initialized with the default values.- Returns:
- an instance of QuantityFormat, initialized with the default values
-
changeDefaults
Return an instance of QuantityFormat with the DEFAULT values, which can be changed for all subsequent calls.- Returns:
- an instance of QuantityFormat with the DEFAULT values
-
resetDefaults
public static void resetDefaults()Reset the default values of QuantityFormat to their original values. -
setScaleSiPrefixes
Use closest SI prefix. E.g., turn 20400 m into "20.4 km".- Returns:
- QuantityFormat object for fluent design
-
setScaleSiPrefixes
Use closest SI prefix. E.g., turn 20400 m into "20.4 km".- Parameters:
minPrefixPower- minimum 10th power to use SI prefixes formaxPrefixPower- maximum 10th power to use SI prefixes for- Returns:
- QuantityFormat object for fluent design
-