From 0dc86e4c0cecba90ddc2b150a9b5992aa3a71779 Mon Sep 17 00:00:00 2001 From: weisj Date: Sat, 4 Apr 2020 16:50:28 +0200 Subject: [PATCH] Fixed color wheel not updating hue. --- .../weisj/darklaf/ui/colorchooser/ColorTriangle.java | 8 ++++++-- .../darklaf/ui/rootpane/DarkSubstanceRootLayout.java | 7 +------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorTriangle.java b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorTriangle.java index 499058a7..ae883494 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorTriangle.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorTriangle.java @@ -168,10 +168,12 @@ public class ColorTriangle extends JComponent { protected void setHSBHue(final double hue) { hueHSB = hue; + if (hueHSB < 0) hueHSB += 1.0; } protected void setHSLHue(final double hue) { hueHSL = hue; + if (hueHSL < 0) hueHSL += 1.0; } protected void setValue(final double value) { @@ -232,7 +234,7 @@ public class ColorTriangle extends JComponent { } protected void setHSB(final double h, final double s, final double b) { - setHue(h); + setHSBHue(h); setHSBSaturation(s); setHSBValue(b); } @@ -242,7 +244,7 @@ public class ColorTriangle extends JComponent { } protected void setHSL(final double h, final double s, final double l) { - setHue(h); + setHSLHue(h); setHSLSaturation(s); setHSLValue(l); } @@ -317,6 +319,7 @@ public class ColorTriangle extends JComponent { setHSL(h, s, l); color = DarkColorModelHSL.getColorFromHSLValues(h, s, l); setHSB(DarkColorModelHSB.RGBtoHSBValues(color.getRed(), color.getGreen(), color.getBlue())); + setHSBHue(h); rotation = -(getHue() * 2 * Math.PI) + Math.PI / 2; invalidateWheel(); fireColorChanged(source); @@ -327,6 +330,7 @@ public class ColorTriangle extends JComponent { setHSB(h, s, b); color = DarkColorModelHSB.getColorFromHSBValues(h, s, b); setHSL(DarkColorModelHSL.RGBtoHSLValues(color.getRed(), color.getGreen(), color.getBlue())); + setHSLHue(h); rotation = -(getHue() * 2 * Math.PI) + Math.PI / 2; invalidateWheel(); fireColorChanged(source); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkSubstanceRootLayout.java b/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkSubstanceRootLayout.java index f9083949..dc80f425 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkSubstanceRootLayout.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkSubstanceRootLayout.java @@ -68,12 +68,7 @@ class DarkSubstanceRootLayout implements LayoutManager2 { JRootPane root = (JRootPane) parent; if (root.getContentPane() != null) { - try { - cpd = root.getContentPane().getPreferredSize(); - } catch (NullPointerException e) { - cpd = null; - System.out.println(Thread.currentThread()); - } + cpd = root.getContentPane().getPreferredSize(); } else { cpd = root.getSize(); }