From 3f5acda132fafb58b1ed40ce0de6647dda02a1d3 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Thu, 5 Aug 2021 18:49:03 +0200 Subject: [PATCH] UI defaults inspector: round HSL values (as also done in theme editor) --- .../flatlaf/extras/FlatUIDefaultsInspector.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/FlatUIDefaultsInspector.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/FlatUIDefaultsInspector.java index 6a49e7c8..596f490e 100644 --- a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/FlatUIDefaultsInspector.java +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/FlatUIDefaultsInspector.java @@ -700,16 +700,16 @@ public class FlatUIDefaultsInspector if( value instanceof Color ) { Color color = (info instanceof Color[]) ? ((Color[])info)[0] : (Color) value; HSLColor hslColor = new HSLColor( color ); + int hue = Math.round( hslColor.getHue() ); + int saturation = Math.round( hslColor.getSaturation() ); + int luminance = Math.round( hslColor.getLuminance() ); if( color.getAlpha() == 255 ) { return String.format( "%-9s HSL %3d %3d %3d", - color2hex( color ), - (int) hslColor.getHue(), (int) hslColor.getSaturation(), - (int) hslColor.getLuminance() ); + color2hex( color ), hue, saturation, luminance ); } else { + int alpha = Math.round( hslColor.getAlpha() * 100 ); return String.format( "%-9s HSL %3d %3d %3d %2d", - color2hex( color ), - (int) hslColor.getHue(), (int) hslColor.getSaturation(), - (int) hslColor.getLuminance(), (int) (hslColor.getAlpha() * 100) ); + color2hex( color ), hue, saturation, luminance, alpha ); } } else if( value instanceof Insets ) { Insets insets = (Insets) value;