Class FlameGraphTheme

java.lang.Object
com.helix.profiler.flamegraph.FlameGraphTheme

public class FlameGraphTheme extends Object
Color and theme management for flame graph visualization in terminal TUIs and ANSI consoles.

Implements perceptual luminance-based contrast calculation to guarantee 100% legibility on diverse terminal themes (dark, light, solarized, high contrast) by always selecting an explicit, high-contrast foreground color for any background color.

  • Constructor Details

    • FlameGraphTheme

      public FlameGraphTheme()
    • FlameGraphTheme

      public FlameGraphTheme(FlameGraphTheme.Mode mode)
  • Method Details

    • getMode

      public FlameGraphTheme.Mode getMode()
    • getContrastingTextColor

      public static com.googlecode.lanterna.TextColor getContrastingTextColor(int r, int g, int b)
      Returns an explicit high-contrast foreground color (dark or bright) based on the perceptual luminance of the background RGB.
      Parameters:
      r - Red component (0-255)
      g - Green component (0-255)
      b - Blue component (0-255)
      Returns:
      High-contrast TextColor (black/dark for light bg, white/bright for dark bg)
    • getContrastingTextColor

      public static com.googlecode.lanterna.TextColor getContrastingTextColor(com.googlecode.lanterna.TextColor backgroundColor)
      Overload accepting Lanterna TextColor.
    • getFrameBackgroundColor

      public com.googlecode.lanterna.TextColor.RGB getFrameBackgroundColor(String frameName, int depth, MetricType metricType)
      Computes a deterministic frame background color based on frame name, depth, and metric.
      Parameters:
      frameName - Fully qualified or short frame name
      depth - Call stack depth level
      metricType - CPU_TIME or ALLOCATION_BYTES
      Returns:
      Background TextColor.RGB
    • getSelectedFrameBackgroundColor

      public com.googlecode.lanterna.TextColor.RGB getSelectedFrameBackgroundColor()
      Frame background color for the currently selected/active cursor frame.
    • getBorderColor

      public com.googlecode.lanterna.TextColor.RGB getBorderColor()
      Border color for frame boxes.
    • getCanvasBackgroundColor

      public com.googlecode.lanterna.TextColor.RGB getCanvasBackgroundColor()
      Canvas background color for the flame graph viewport.
    • ansiBg

      public static String ansiBg(int r, int g, int b)
      Generates an ANSI 24-bit escape sequence for background color.
    • ansiFg

      public static String ansiFg(int r, int g, int b)
      Generates an ANSI 24-bit escape sequence for foreground color.
    • ansiReset

      public static String ansiReset()
      ANSI reset code.
    • ansiBold

      public static String ansiBold()
      ANSI bold code.