diff --git a/build.gradle b/build.gradle index 4ccf25c1..16514166 100644 --- a/build.gradle +++ b/build.gradle @@ -31,7 +31,7 @@ repositories { } dependencies { - compile 'com.metsci.ext.com.kitfox.svg:svg-salamander:0.1.19' + compile 'com.formdev:svgSalamander:1.1.2.1' compile 'net.java.dev.jna:jna:4.1.0' compile 'org.swinglabs:jxlayer:3.0.4' compileOnly 'org.swinglabs:swingx:1.6.1' diff --git a/build_x64.gradle b/build_x64.gradle index e7d08093..d3bcf8e4 100644 --- a/build_x64.gradle +++ b/build_x64.gradle @@ -30,7 +30,7 @@ repositories { } dependencies { - compile 'com.metsci.ext.com.kitfox.svg:svg-salamander:0.1.19' + compile 'com.formdev:svgSalamander:1.1.2.1' compile 'net.java.dev.jna:jna:4.1.0' compile 'org.swinglabs:jxlayer:3.0.4' compileOnly 'org.swinglabs:swingx:1.6.1' diff --git a/build_x86.gradle b/build_x86.gradle index 3dbe6074..ac3001fc 100644 --- a/build_x86.gradle +++ b/build_x86.gradle @@ -30,7 +30,7 @@ repositories { } dependencies { - compile 'com.metsci.ext.com.kitfox.svg:svg-salamander:0.1.19' + compile 'com.formdev:svgSalamander:1.1.2.1' compile 'net.java.dev.jna:jna:4.1.0' compile 'org.swinglabs:jxlayer:3.0.4' compileOnly 'org.swinglabs:swingx:1.6.1' diff --git a/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java b/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java index 0a488e9f..c1e1936b 100644 --- a/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java +++ b/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java @@ -23,6 +23,7 @@ */ package com.github.weisj.darklaf.icons; +import com.github.weisj.darklaf.util.Pair; import com.kitfox.svg.Defs; import com.kitfox.svg.LinearGradient; import com.kitfox.svg.SVGDiagram; @@ -30,6 +31,7 @@ import com.kitfox.svg.SVGElement; import com.kitfox.svg.SVGElementException; import com.kitfox.svg.SVGRoot; import com.kitfox.svg.SVGUniverse; +import com.kitfox.svg.Stop; import com.kitfox.svg.animation.AnimationElement; import com.kitfox.svg.app.beans.SVGIcon; @@ -74,16 +76,41 @@ public final class IconColorMapper { c = Color.RED; LOGGER.warning("Could not load color with id'" + id + "'. Using Color.RED instead."); } - themedDefs.loaderAddChild(null, createColor(c, id)); + Pair result = createColor(c, id); + LinearGradient gradient = result.getFirst(); + Runnable finalizer = result.getSecond(); + themedDefs.loaderAddChild(null, gradient); + finalizer.run(); } } } - private static LinearGradient createColor(final Color c, final String name) throws SVGElementException { + private static Pair createColor(final Color c, final String name) throws SVGElementException { LinearGradient grad = new LinearGradient(); grad.addAttribute("id", AnimationElement.AT_XML, name); - grad.setStops(new Color[]{c, c}, new float[]{0.0f, 1.0f}); - return grad; + return new Pair<>(grad, () -> { + Stop stop1 = new Stop(); + Stop stop2 = new Stop(); + String color = toHexString(c); + System.out.println(c + " " + color); + try { + stop1.addAttribute("stop-color", AnimationElement.AT_XML, color); + stop1.addAttribute("offset", AnimationElement.AT_XML, "0"); + stop2.addAttribute("stop-color", AnimationElement.AT_XML, color); + stop2.addAttribute("offset", AnimationElement.AT_XML, "1"); + grad.loaderAddChild(null, stop1); + grad.loaderAddChild(null, stop2); + } catch (SVGElementException e) { + e.printStackTrace(); + } + }); + } + + private static String toHexString(final Color color) { + int r = color.getRed(); + int b = color.getBlue(); + int g = color.getGreen(); + return String.format("#%02X%02X%02X", r, g, b); } }