Package org.djunits.formatter
Class MatrixFormatter
MatrixFormatter formats a matrix as a String, using the settings of the
MatrixFormatContext. The
MatrixFormatContext is filled by setting properties of the MatrixFormatContext. Note that there is no
guarantee that the format can always be honored. As an example, when the required width is too small to fit the answer, the
output will show the correct result, but violate the width setting.
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
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) Stringformat()Return the matrix, formatted according to the context settings.static Stringformat(AbsMatrix<?, ?, ?, ?, ?> absMatrix, MatrixFormat matrixFormat) Format an absolute matrix according to a number of MatrixFormat settings.static Stringformat(Matrix<?, ?, ?, ?, ?> matrix, MatrixFormat matrixFormat) Format a matrix according to a number of MatrixFormat settings.(package private) Matrix<?,?, ?, ?, ?> matrix()Return the value as a matrix (or matrix).Methods inherited from class org.djunits.formatter.Formatter
checkDisplayUnit, checkSiUnits, checkUnitString, formatEngineering, formatFixedEngFallback, formatFixedFloat, formatFixedSciFallback, formatReference, formatScientific, formatUnit, formatValue, formatVariableLength, pad, restoreLocale, saveLocale
-
Constructor Details
-
MatrixFormatter
MatrixFormatter(Matrix<?, ?, ?, ?, ?> matrix, MatrixFormatContext ctx) - Parameters:
matrix- the matrix to formatctx- the format context
-
-
Method Details
-
matrix
Matrix<?,?, matrix()?, ?, ?> Return the value as a matrix (or matrix).- Returns:
- the value as a matrix (or matrix)
-
format
Format a matrix according to a number of MatrixFormat settings. Note that this method might not be thread-safe for setting the default Locale. If another thread changes the Locale while formatting, outcomes could vary.- Parameters:
matrix- the matrix to formatmatrixFormat- the format to apply to the matrix- Returns:
- a String with a formatted matrix, matching the MatrixFormat settings as closely as possible
-
format
Format an absolute matrix according to a number of MatrixFormat settings. Note that this method might not be thread-safe for setting the default Locale. If another thread changes the Locale while formatting, outcomes could vary.- Parameters:
absMatrix- the absolute matrix to formatmatrixFormat- the format to apply to the matrix- Returns:
- a String with a formatted matrix, matching the MatrixFormat settings as closely as possible
-
format
String format()Return the matrix, formatted according to the context settings.- Specified by:
formatin classFormatter<MatrixFormatContext>- Returns:
- the formatted matrix
-