From 8998371caea610ee8f931f4ad2191fe2913a5fe6 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Fri, 14 May 2021 17:33:40 +0200 Subject: [PATCH] Extras: `FlatSVGUtils.createWindowIconImages()`: return multi-resolution image only on Windows because Java implementations for macOS and Linux do not support multi-resolution images for window title icons (issue #323) --- CHANGELOG.md | 2 +- .../main/java/com/formdev/flatlaf/extras/FlatSVGUtils.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a93f502..7f0089a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,7 +34,7 @@ FlatLaf Change Log and prettified class names (dimmed package name). - Extras: `FlatSVGUtils.createWindowIconImages()` now returns a single multi-resolution image that creates requested image sizes on demand from SVG - (Java 9+). + (only on Windows with Java 9+). #### Fixed bugs diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/FlatSVGUtils.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/FlatSVGUtils.java index 2ba944e6..08e308e9 100644 --- a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/FlatSVGUtils.java +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/FlatSVGUtils.java @@ -28,6 +28,7 @@ import java.util.Collections; import java.util.List; import javax.swing.JWindow; import com.formdev.flatlaf.util.MultiResolutionImageSupport; +import com.formdev.flatlaf.util.SystemInfo; import com.kitfox.svg.SVGCache; import com.kitfox.svg.SVGDiagram; import com.kitfox.svg.SVGException; @@ -44,7 +45,7 @@ public class FlatSVGUtils * can be used for windows headers. The SVG should have a size of 16x16, * otherwise it is scaled. *

- * If running on Java 9 or later and multi-resolution image support is available, + * If running on Windows in Java 9 or later and multi-resolution image support is available, * then a single multi-resolution image is returned that creates images on demand * for requested sizes from SVG. * This has the advantage that only images for used sizes are created. @@ -58,7 +59,7 @@ public class FlatSVGUtils public static List createWindowIconImages( String svgName ) { SVGDiagram diagram = loadSVG( svgName ); - if( MultiResolutionImageSupport.isAvailable() ) { + if( SystemInfo.isWindows && MultiResolutionImageSupport.isAvailable() ) { // use a multi-resolution image that creates images on demand for requested sizes return Collections.singletonList( MultiResolutionImageSupport.create( 0, new Dimension[] {