Package org.djunits.formatter
Class Format<F extends Format<F,C>,C extends FormatContext>
java.lang.Object
org.djunits.formatter.Format<F,C>
- Type Parameters:
F- theFormattypeC- theFormatContexttype
- Direct Known Subclasses:
MatrixFormat,QuantityFormat,TableFormat,VectorFormat
Format is the abstract base class for the settings the format. It contains generic methods to influence the format of
Quantity, AbsQuantity, Vector, AbsVector, Matrix, AbsMatrix,
QuantityTable and AbsQuantityTable. The main methods to set the format in this class are about the way to
format the number, the unit, and the locale. Specific setter methods for quantities, vectors, matrices and tables can be
found in the extensions of this class, such as QuantityFormat.
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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionself()Return the object for fluent design.setDecimals(int decimals) Set the number of decimal digits of the numerical output.Set display mode.setDisplayUnit(String unit) Set the display unit to use, based on a String representation.setDisplayUnit(Unit<?, ?> unit) Set the display unit to use.setDivider(boolean on) Set whether the divider symbol is used.setDotSeparator(String symbol) Set the dot separator symbol to the given String.Apply engineering notation.Apply fixed length float-only notation.Apply fixed length float-only notation with engineering notation as a fallback.Apply fixed length float-only notation with scientific notation as a fallback.setFormatString(String formatString) Set the format string to use.setGroupingSeparator(boolean on) Set the grouping separator (e.g., 1000s separator) or or off.Apply locale to formatting.Do not print the reference.setPowerPostfix(String symbol) Set the symbol to use as the postfix for a power to the given String.setPowerPrefix(String symbol) Set the symbol to use as the prefix for a power to the given String.Print the reference.setPrintReference(boolean on) Indicate whether to print the reference or not.setReferencePostfix(String postfix) Set the postfix for the reference, e.g., ")".setReferencePrefix(String prefix) Set the prefix for the reference, e.g., "(relative to ".Apply scientific notation.Set SI unit mode.Set textual mode.setTextual(boolean on) Set textual mode on or off.setUnitPostfix(String postfix) Set the postfix separator after the unit.setUnitPrefix(String prefix) Set the prefix separator between value and unit.setUpperE(boolean upper) Set the scientific exponential character to E or e.Apply variable length notation.setWidth(int width) Set the width of the numerical output.
-
Field Details
-
ctx
The format context.
-
-
Constructor Details
-
Format
Format(C ctx) Construct a Format 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 format context to use
-
-
Method Details
-
self
Return the object for fluent design.- Returns:
- the object for fluent design
-
setVariableLength
Apply variable length notation. Ignore width and decimals restrictions.- Returns:
- the the object instance for fluent design
-
setFixedFloat
Apply fixed length float-only notation.- Returns:
- the the object instance for fluent design
-
setScientific
Apply scientific notation.- Returns:
- the the object instance for fluent design
-
setFixedWithSciFallback
Apply fixed length float-only notation with scientific notation as a fallback.- Returns:
- the the object instance for fluent design
-
setFixedWithEngFallback
Apply fixed length float-only notation with engineering notation as a fallback. Engineering notation uses an e formatter with exponents that are multiples of 3.- Returns:
- the the object instance for fluent design
-
setEngineering
Apply engineering notation. Engineering notation uses an e formatter with exponents that are multiples of 3.- Returns:
- the the object instance for fluent design
-
setWidth
Set the width of the numerical output.- Parameters:
width- the width of the numerical output- Returns:
- the the object instance for fluent design
-
setDecimals
Set the number of decimal digits of the numerical output.- Parameters:
decimals- the number of decimal digits of the numerical output- Returns:
- the the object instance for fluent design
-
setUpperE
Set the scientific exponential character to E or e.- Parameters:
upper- results in E when true, and in e when false- Returns:
- the the object instance for fluent design
-
setGroupingSeparator
Set the grouping separator (e.g., 1000s separator) or or off.- Parameters:
on- indicates whether the grouping separator is on or not- Returns:
- the the object instance for fluent design
-
setFormatString
Set the format string to use.- Parameters:
formatString- the format string to use- Returns:
- the the object instance for fluent design
-
setUnitPrefix
Set the prefix separator between value and unit.- Parameters:
prefix- separator string between the value and the unit- Returns:
- the object instance for fluent design
-
setUnitPostfix
Set the postfix separator after the unit.- Parameters:
postfix- string after the unit- Returns:
- the object instance for fluent design
-
setDisplayUnit
Set the display unit to use.- Parameters:
unit- the display unit to use- Returns:
- the object instance for fluent design
-
setDisplayUnit
Set the display unit to use, based on a String representation.- Parameters:
unit- the String representation of the display unit to use- Returns:
- the object instance for fluent design
-
setTextual
Set textual mode.- Returns:
- the object instance for fluent design
-
setDisplay
Set display mode.- Returns:
- the object instance for fluent design
-
setTextual
Set textual mode on or off.- Parameters:
on- whether to turn textual mode on or off- Returns:
- the object instance for fluent design
-
setSiUnits
Set SI unit mode.- Returns:
- the object instance for fluent design
-
setDivider
Set whether the divider symbol is used. This setting only works when siUnits has been switched on.- Parameters:
on- true when the divider symbol is used, false when not- Returns:
- the object instance for fluent design
-
setPowerPrefix
Set the symbol to use as the prefix for a power to the given String. This setting only works when siUnits has been switched on.- Parameters:
symbol- the string to use for the power prefix- Returns:
- the object instance for fluent design
-
setPowerPostfix
Set the symbol to use as the postfix for a power to the given String. This setting only works when siUnits has been switched on.- Parameters:
symbol- the string to use for the power postfix- Returns:
- the object instance for fluent design
-
setDotSeparator
Set the dot separator symbol to the given String. This setting only works when siUnits has been switched on.- Parameters:
symbol- the string to use for the dot separator symbol- Returns:
- the object instance for fluent design
-
setLocale
Apply locale to formatting.- Parameters:
locale- the locale to use- Returns:
- the object instance for fluent design
-
setPrintReference
Print the reference.- Returns:
- the object instance for fluent design
-
setNoReference
Do not print the reference.- Returns:
- the object instance for fluent design
-
setPrintReference
Indicate whether to print the reference or not.- Parameters:
on- boolean that indicates whether to print the reference or not- Returns:
- the object instance for fluent design
-
setReferencePrefix
Set the prefix for the reference, e.g., "(relative to ".- Parameters:
prefix- the prefix for the reference- Returns:
- the object instance for fluent design
-
setReferencePostfix
Set the postfix for the reference, e.g., ")".- Parameters:
postfix- the postfix for the reference- Returns:
- the object instance for fluent design
-