diff --git a/fireplace-swing/src/main/java/io/github/bric3/fireplace/flamegraph/DimmingFrameColorProvider.java b/fireplace-swing/src/main/java/io/github/bric3/fireplace/flamegraph/DimmingFrameColorProvider.java index 9c51d7fb..e86af565 100644 --- a/fireplace-swing/src/main/java/io/github/bric3/fireplace/flamegraph/DimmingFrameColorProvider.java +++ b/fireplace-swing/src/main/java/io/github/bric3/fireplace/flamegraph/DimmingFrameColorProvider.java @@ -48,17 +48,17 @@ import static io.github.bric3.fireplace.flamegraph.FrameRenderingFlags.isMinimapMode; public class DimmingFrameColorProvider implements FrameColorProvider { - public static final Color DIMMED_TEXT = new DarkLightColor( + public static final Color DIMMED_TEXT_COLOR = new DarkLightColor( Colors.rgba(28, 43, 52, 0.68f), Colors.rgba(255, 255, 255, 0.51f) ); - public static final Color HOVERED_NODE = new DarkLightColor( + public static final Color HOVERED_BACKGROUND_COLOR = new DarkLightColor( new Color(0xFFE0C268, true), new Color(0xD0E0C268, true) ); - public static final Color ROOT_NODE = new DarkLightColor( + public static final Color ROOT_BACKGROUND_COLOR = new DarkLightColor( new Color(0xFFEAF6FC), new Color(0xFF091222) ); @@ -68,11 +68,14 @@ public class DimmingFrameColorProvider implements FrameColorProvider { private final ConcurrentHashMap dimmedColorCache = new ConcurrentHashMap<>(); + private Color rootBackGroundColor = ROOT_BACKGROUND_COLOR; + private Color dimmedTextColor = DIMMED_TEXT_COLOR; + private Color hoveredBackgroundColor = HOVERED_BACKGROUND_COLOR; + public DimmingFrameColorProvider(Function, Color> baseColorFunction) { this.baseColorFunction = baseColorFunction; } - @Override public ColorModel getColors(FrameBox frame, int flags) { Color backgroundColor; @@ -80,7 +83,7 @@ public ColorModel getColors(FrameBox frame, int flags) { var rootNode = frame.isRoot(); if (rootNode) { - backgroundColor = ROOT_NODE; + backgroundColor = rootBackGroundColor; } else { backgroundColor = baseColorFunction.apply(frame); } @@ -92,13 +95,13 @@ public ColorModel getColors(FrameBox frame, int flags) { if (!rootNode && shouldDim(flags)) { backgroundColor = cachedDim(backgroundColor); - foreground = DIMMED_TEXT; + foreground = DIMMED_TEXT_COLOR; } else { foreground = Colors.foregroundColor(backgroundColor); } if (isHovered(flags) || isHoveredSibling(flags)) { - backgroundColor = Colors.blend(backgroundColor, HOVERED_NODE); + backgroundColor = Colors.blend(backgroundColor, HOVERED_BACKGROUND_COLOR); foreground = Colors.foregroundColor(backgroundColor); } @@ -137,4 +140,19 @@ private boolean shouldDim(int flags) { private Color cachedDim(Color color) { return dimmedColorCache.computeIfAbsent(color, Colors::dim); } + + public DimmingFrameColorProvider withRootBackgroundColor(Color rootBackgroundColor) { + this.rootBackGroundColor = rootBackgroundColor; + return this; + } + + public DimmingFrameColorProvider withDimmedTextColor(Color dimmedTextColor) { + this.dimmedTextColor = dimmedTextColor; + return this; + } + + public DimmingFrameColorProvider withHoveredBackgroundColor(Color hoveredBackgroundColor) { + this.hoveredBackgroundColor = hoveredBackgroundColor; + return this; + } }