Class VectorFormatter


public class VectorFormatter extends Formatter<VectorFormatContext>
VectorFormatter formats a vector as a String, using the settings of the VectorFormatContext. The VectorFormatContext is filled by setting flags using the VectorFormat. 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
  • Constructor Details

    • VectorFormatter

      VectorFormatter(Vector<?,?,?,?,?> vector, VectorFormatContext ctx)
      Parameters:
      vector - the quantity to format
      ctx - the format context
  • Method Details

    • vector

      Vector<?,?,?,?,?> vector()
      Return the value as a vector.
      Returns:
      the value as a vector
    • format

      public static String format(Vector<?,?,?,?,?> vector, VectorFormat<?> vectorFormat)
      Format a vector according to a number of vector format 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:
      vector - the vector to format
      vectorFormat - the format to apply to the vector
      Returns:
      a String with a formatted vector, matching the vector format settings as closely as possible
    • format

      public static String format(AbsVector<?,?,?,?,?> absVector, VectorFormat<?> vectorFormat)
      Format an absolute vector according to a number of vector format 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:
      absVector - the absolute vector to format
      vectorFormat - the format to apply to the vector
      Returns:
      a String with a formatted vector, matching the vector format settings as closely as possible
    • format

      String format()
      Return the vector, formatted according to the context settings.
      Specified by:
      format in class Formatter<VectorFormatContext>
      Returns:
      the formatted vector