Package org.aesh.charts.canvas
Class BlockEncoder
java.lang.Object
org.aesh.charts.canvas.BlockEncoder
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
FieldsModifier and TypeFieldDescriptionstatic final charFull block character.static final intNumber of vertical levels per cell (including empty). -
Method Summary
Modifier and TypeMethodDescriptionstatic charforFraction(double fraction) Get the block character for a fractional value.static charforLevel(int level) Get the block character for a specific level (0-8).
-
Field Details
-
FULL_BLOCK
public static final char FULL_BLOCKFull block character.- See Also:
-
LEVELS
public static final int LEVELSNumber 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
-