Class ConsoleHistogramQuantityFormatter<T extends Quantity<T>>

  • Type Parameters:
    T - The type of quantity value the histogram counted, which this formatter will format using the provided quantityFormatter.

    public class ConsoleHistogramQuantityFormatter<T extends Quantity<T>>
    extends ConsoleHistogramFormatter<Quantity<T>>
    Format Histogram<Quantity> contents for a text display. The formatted output consists of a vertical list of labeled histogram buckets, with horizontal bar graphs showing the count in each bucket, followed by a percentage that represents the number of items counted in this bucket as a fraction of all items counted by this histogram.

    This version of ConsoleHistogramFormatter handles JSR-363 Quantity objects, which represent values of a certain measurement (e.g. Mass, Energy, Length, LuminousFlux) that have a unit attached (e.g. kilometers, megajoules, furlongs, bits per second, etc.).

    Example output from a ConsoleHistogramQuantityFormatter<Power>:

     <= 1 kW                                                                  0%
     <= 10 kW                                                                 0%
     <= 100 kW                                                                0%
     <= 1 MW   ****                                                           2%
     <= 10 MW  ************************************************************  38%
     <= 100 MW ********************************************************      35%
     <= 1 GW   ******************************                                19%
     <= 10 GW  ********                                                       5%
     >  10 GW                                                                 0%
     
    • Constructor Detail

      • ConsoleHistogramQuantityFormatter

        public ConsoleHistogramQuantityFormatter​(QuantityFormatter<T> quantityFormatter,
                                                 int maxBarGraphWidth)
        Create a ConsoleHistogramQuantityFormatter that formats upper bound values using quantityFormatter.
        Parameters:
        quantityFormatter - An object that converts an upper bound quantity into a String representation.
        maxBarGraphWidth - The maximum width of the bar graph portion of the formatted representation.