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)
This commit is contained in:
Karl Tauber
2021-05-14 17:33:40 +02:00
parent 29e1dc6b55
commit 8998371cae
2 changed files with 4 additions and 3 deletions

View File

@@ -34,7 +34,7 @@ FlatLaf Change Log
and prettified class names (dimmed package name). and prettified class names (dimmed package name).
- Extras: `FlatSVGUtils.createWindowIconImages()` now returns a single - Extras: `FlatSVGUtils.createWindowIconImages()` now returns a single
multi-resolution image that creates requested image sizes on demand from SVG multi-resolution image that creates requested image sizes on demand from SVG
(Java 9+). (only on Windows with Java 9+).
#### Fixed bugs #### Fixed bugs

View File

@@ -28,6 +28,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import javax.swing.JWindow; import javax.swing.JWindow;
import com.formdev.flatlaf.util.MultiResolutionImageSupport; import com.formdev.flatlaf.util.MultiResolutionImageSupport;
import com.formdev.flatlaf.util.SystemInfo;
import com.kitfox.svg.SVGCache; import com.kitfox.svg.SVGCache;
import com.kitfox.svg.SVGDiagram; import com.kitfox.svg.SVGDiagram;
import com.kitfox.svg.SVGException; 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, * can be used for windows headers. The SVG should have a size of 16x16,
* otherwise it is scaled. * otherwise it is scaled.
* <p> * <p>
* 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 * then a single multi-resolution image is returned that creates images on demand
* for requested sizes from SVG. * for requested sizes from SVG.
* This has the advantage that only images for used sizes are created. * This has the advantage that only images for used sizes are created.
@@ -58,7 +59,7 @@ public class FlatSVGUtils
public static List<Image> createWindowIconImages( String svgName ) { public static List<Image> createWindowIconImages( String svgName ) {
SVGDiagram diagram = loadSVG( 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 // use a multi-resolution image that creates images on demand for requested sizes
return Collections.singletonList( MultiResolutionImageSupport.create( 0, return Collections.singletonList( MultiResolutionImageSupport.create( 0,
new Dimension[] { new Dimension[] {