Skip to content

Commit

Permalink
chore(flamegraph)!: Change some runtime Colors
Browse files Browse the repository at this point in the history
BREAKING-CHANGE: Rename DarkLightColor to LightDarkColor.
  • Loading branch information
bric3 committed Jan 26, 2023
1 parent 1a25ac2 commit 16234e7
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
package io.github.bric3.fireplace

import io.github.bric3.fireplace.core.ui.LightDarkColor
import io.github.bric3.fireplace.flamegraph.FrameBox
import org.openjdk.jmc.common.IMCFrame
import org.openjdk.jmc.flightrecorder.stacktrace.tree.Node
Expand All @@ -21,7 +22,7 @@ import java.util.regex.Pattern
*/
enum class JfrFrameColorMode {
BY_PACKAGE {
private val runtimePrefixes = Pattern.compile("(java\\.|javax\\.|sun\\.|com\\.sun\\.|com\\.oracle\\.|com\\.ibm\\.)")
private val runtimePrefixes = Pattern.compile("(java\\.|javax\\.|sun\\.|com\\.sun\\.|com\\.oracle\\.|com\\.ibm\\.|jdk\\.)")
public override fun getJfrNodeColor(colorMapper: Function<Any, Color>, frameNode: Node): Color {
if (frameNode.isRoot) {
return rootNodeColor
Expand Down Expand Up @@ -70,8 +71,14 @@ enum class JfrFrameColorMode {
}

companion object {
var rootNodeColor = Color(198, 198, 198)
var runtimeColor = Color(34, 107, 232)
var rootNodeColor = LightDarkColor(
0xFF_77_4A_A4.toInt(),
0xFF_56_1D_8C.toInt()
)
var runtimeColor = LightDarkColor(
0xFF_D1_D4_DE.toInt(),
0xFF_3B_39_3D.toInt()
)
var undefinedColor = Color(108, 163, 189)
var jitCompiledColor = Color(21, 110, 64)
var inlinedColor = Color.pink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import io.github.bric3.fireplace.JfrFrameColorMode.BY_PACKAGE
import io.github.bric3.fireplace.JfrFrameNodeConverter
import io.github.bric3.fireplace.Utils
import io.github.bric3.fireplace.core.ui.Colors
import io.github.bric3.fireplace.core.ui.DarkLightColor
import io.github.bric3.fireplace.core.ui.LightDarkColor
import io.github.bric3.fireplace.flamegraph.ColorMapper
import io.github.bric3.fireplace.flamegraph.DimmingFrameColorProvider
import io.github.bric3.fireplace.flamegraph.FlamegraphView
Expand Down Expand Up @@ -58,7 +58,10 @@ class FlameGraphPane : JPanel(BorderLayout()) {
putClientProperty(FlamegraphView.SHOW_STATS, true)
setTooltipComponentSupplier { BalloonToolTip() }
}
val minimapShade = DarkLightColor(Colors.translucent_white_80, Colors.translucent_black_40).also {
val minimapShade = LightDarkColor(
Colors.translucent_white_80,
Colors.translucent_black_40
).also {
jfrFlamegraphView.setMinimapShadeColorSupplier { it }
}
val zoomAnimation = ZoomAnimation().also { it.install(jfrFlamegraphView) }
Expand Down Expand Up @@ -172,7 +175,7 @@ class FlameGraphPane : JPanel(BorderLayout()) {
private fun refreshToggle(
icicleModeToggle: JCheckBox,
minimapToggle: JCheckBox,
minimapShade: DarkLightColor,
minimapShade: LightDarkColor,
zoomAnimation: ZoomAnimation,
updateColorSettingsListener: ActionListener,
wrapper: JPanel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class Colors {
*/
public static final int DARK_PERCEIVED_BRIGHTNESS_THRESHOLD = gammaFunction(0.45);

public static final Color blue = new DarkLightColor(Color.decode("#2B4EFF"), Color.decode("#39ACE7"));
public static final Color blue = new LightDarkColor(Color.decode("#2B4EFF"), Color.decode("#39ACE7"));

/**
* Color BLACK with alpha 0xD0.
Expand Down Expand Up @@ -435,7 +435,7 @@ public static Color blend(Color c0, Color c1) {
*
* @param color The color to dim
* @return The dimmed color ({@link #darkMode} aware)
* @see DarkLightColor
* @see LightDarkColor
*/
public static Color dim(Color color) {
var hslaLight = hslaComponents(color);
Expand All @@ -454,7 +454,7 @@ public static Color dim(Color color) {
hslaLight[L] = 0.93f;
}

return new DarkLightColor(
return new LightDarkColor(
hsla(hslaLight[H], hslaLight[S], hslaLight[L], hslaLight[ALPHA]),
hsla(hslaDark[H], hslaDark[S], hslaDark[L], hslaDark[ALPHA])
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private static class ScrollBackToTopLayerUI extends LayerUI<JScrollPane> {
);
private final JButton button = new JButton(buttonIcon) {

private final Color ARMED_BUTTON_COLOR = new DarkLightColor(
private final Color ARMED_BUTTON_COLOR = new LightDarkColor(
Color.darkGray,
Color.lightGray
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* Represents a color that can return two values depending on the {@link Colors#isDarkMode()}
*/
public class DarkLightColor extends Color {
public class LightDarkColor extends Color {
private final Color dark;

/**
Expand All @@ -27,7 +27,7 @@ public class DarkLightColor extends Color {
* @param light the light color.
* @param dark the dark color.
*/
public DarkLightColor(Color light, Color dark) {
public LightDarkColor(Color light, Color dark) {
super(light.getRGB(), light.getAlpha() != 255);
this.dark = dark;
}
Expand All @@ -38,7 +38,7 @@ public DarkLightColor(Color light, Color dark) {
* @param light_rgba the light color.
* @param dark_rgba the dark color.
*/
public DarkLightColor(int light_rgba, int dark_rgba) {
public LightDarkColor(int light_rgba, int dark_rgba) {
super(light_rgba, true);
this.dark = new Color(dark_rgba, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
package io.github.bric3.fireplace.flamegraph;

import io.github.bric3.fireplace.core.ui.Colors;
import io.github.bric3.fireplace.core.ui.DarkLightColor;
import io.github.bric3.fireplace.core.ui.LightDarkColor;

import java.awt.*;
import java.util.Objects;
Expand Down Expand Up @@ -65,12 +65,12 @@
* @param <T> The actual type of frame.
*/
public class DimmingFrameColorProvider<T> implements FrameColorProvider<T> {
public static final Color DIMMED_TEXT_COLOR = new DarkLightColor(
public static final Color DIMMED_TEXT_COLOR = new LightDarkColor(
Colors.rgba(28, 43, 52, 0.68f),
Colors.rgba(255, 255, 255, 0.51f)
);

public static final Color ROOT_BACKGROUND_COLOR = new DarkLightColor(
public static final Color ROOT_BACKGROUND_COLOR = new LightDarkColor(
new Color(0xFFEAF6FC),
new Color(0xFF091222)
);
Expand Down

0 comments on commit 16234e7

Please sign in to comment.