Class BlockEncoder

java.lang.Object
org.aesh.charts.canvas.BlockEncoder

public final class BlockEncoder extends Object
Maps fractional values (0.0-1.0) to Unicode block element characters.

Block elements provide 8 levels of vertical fill per character cell, useful for bar charts and sparklines.

Characters used (bottom-to-top fill):

   ▁ (1/8)  ▂ (2/8)  ▃ (3/8)  ▄ (4/8)
   ▅ (5/8)  ▆ (6/8)  ▇ (7/8)  █ (8/8)
 
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final char
    Full block character.
    static final int
    Number of vertical levels per cell (including empty).
  • Method Summary

    Modifier and Type
    Method
    Description
    static char
    forFraction(double fraction)
    Get the block character for a fractional value.
    static char
    forLevel(int level)
    Get the block character for a specific level (0-8).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • FULL_BLOCK

      public static final char FULL_BLOCK
      Full block character.
      See Also:
    • LEVELS

      public static final int LEVELS
      Number of vertical levels per cell (including empty).
  • Method Details

    • forFraction

      public static char forFraction(double fraction)
      Get the block character for a fractional value.
      Parameters:
      fraction - value between 0.0 and 1.0
      Returns:
      the corresponding block character
    • forLevel

      public static char forLevel(int level)
      Get the block character for a specific level (0-8).
      Parameters:
      level - the fill level (0 = empty, 8 = full)
      Returns:
      the corresponding block character