diff --git a/core/src/test/java/UIDemo.java b/core/src/test/java/UIDemo.java index e0d8a6fa..d9dfb079 100644 --- a/core/src/test/java/UIDemo.java +++ b/core/src/test/java/UIDemo.java @@ -19,7 +19,6 @@ import java.util.logging.Logger; public final class UIDemo { public static void main(final String[] args) { - System.setProperty("org.apache.batik.warn_destination", "false"); SwingUtilities.invokeLater( () -> { LafManager.install(); diff --git a/core/src/test/java/icon/AllIcons.java b/core/src/test/java/icon/AllIcons.java index 18d5514c..1ebaa080 100644 --- a/core/src/test/java/icon/AllIcons.java +++ b/core/src/test/java/icon/AllIcons.java @@ -35,15 +35,22 @@ import javax.swing.*; import javax.swing.event.ListDataListener; import java.awt.*; import java.io.File; +import java.io.IOException; +import java.net.URI; import java.net.URISyntaxException; -import java.net.URL; -import java.util.ArrayList; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.List; +import java.util.*; +import java.util.stream.Stream; public class AllIcons { private static String[] FOLDERS = new String[]{ - "control", "dialog", "files", "indicator", "menu", "misc", "navigation", "window", + "icons/control", "icons/dialog", "icons/files", "icons/indicator", "icons/menu", "icons/misc", + "icons/navigation", "platform/windows/icons/window", "platform/windows/icons" }; public static void main(final String[] args) { @@ -79,38 +86,51 @@ public class AllIcons { frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setLocationRelativeTo(null); frame.setVisible(true); - } catch (URISyntaxException e) { + } catch (URISyntaxException | IOException e) { e.printStackTrace(); } }); } - private static List> loadIcons() throws URISyntaxException { + private static List> loadIcons() throws URISyntaxException, IOException { List> list = new ArrayList<>(); for (String folder : FOLDERS) { - File[] files = getResourceFolderFiles("icons/" + folder, DarkLaf.class); - for (File f : files) { - if (f.getName().endsWith(".svg")) { - int SIZE = 30; - ThemedSVGIcon icon = (ThemedSVGIcon) IconLoader.get().loadSVGIcon(folder + "/" + f.getName(), - SIZE, SIZE, true); - SVGIcon svgIcon = icon.getSVGIcon(); - int autosize = svgIcon.getAutosize(); - svgIcon.setAutosize(SVGIcon.AUTOSIZE_NONE); - icon.setDisplaySize(svgIcon.getIconWidth() * 2, svgIcon.getIconHeight() * 2); - svgIcon.setAutosize(autosize); - list.add(new Pair<>(f.getName(), icon)); - } + Pair, Optional> files = walk(folder, DarkLaf.class); + try (FileSystem fs = files.getSecond().isPresent() ? files.getSecond().get() : null) { + files.getFirst().forEach(p -> { + if (p.getFileName().toString().endsWith(".svg")) { + int SIZE = 30; + ThemedSVGIcon icon = (ThemedSVGIcon) IconLoader.get(DarkLaf.class) + .loadSVGIcon(folder + "/" + p.getFileName(), + SIZE, SIZE, true); + SVGIcon svgIcon = icon.getSVGIcon(); + int autosize = svgIcon.getAutosize(); + svgIcon.setAutosize(SVGIcon.AUTOSIZE_NONE); + int width = Math.min(svgIcon.getIconWidth() * 2, 100); + int height = (int) (((double) width / svgIcon.getIconWidth()) * svgIcon.getIconHeight()); + icon.setDisplaySize(width, height); + svgIcon.setAutosize(autosize); + list.add(new Pair<>(p.getFileName().toString(), icon)); + } + }); } } return list; } - private static File[] getResourceFolderFiles(final String folder, - final Class clazz) throws URISyntaxException { - URL url = clazz.getResource(folder); - return new File(url.toURI()).listFiles(); + public static Pair, Optional> walk(final String path, final Class clazz) + throws URISyntaxException, IOException { + URI uri = clazz.getResource(path).toURI(); + if ("jar".equals(uri.getScheme())) { + FileSystem fileSystem = FileSystems.newFileSystem(uri, Collections.emptyMap()); + Path resourcePath = fileSystem.getPath("com/github/weisj/darklaf/" + path); + // Get all contents of a resource (skip resource itself), if entry is a directory remove trailing / + return new Pair<>(Files.walk(resourcePath, 1), Optional.of(fileSystem)); + } else { + return new Pair<>(Arrays.stream(Optional.ofNullable(new File(uri).listFiles()) + .orElse(new File[0])).map(File::toPath), Optional.empty()); + } } private static final class IconListRenderer extends JLabel implements ListCellRenderer> { diff --git a/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/duke.svg b/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/duke.svg index 39cb6391..14eb1e0e 100644 --- a/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/duke.svg +++ b/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/duke.svg @@ -3,13 +3,14 @@ + - - - - + - - + - - - - - - - - - + + + + + + + + + - + diff --git a/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/closeActive.svg b/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/closeActive.svg similarity index 100% rename from windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/closeActive.svg rename to windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/closeActive.svg diff --git a/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/closeHover.svg b/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/closeHover.svg similarity index 100% rename from windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/closeHover.svg rename to windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/closeHover.svg diff --git a/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/closeInactive.svg b/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/closeInactive.svg similarity index 100% rename from windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/closeInactive.svg rename to windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/closeInactive.svg diff --git a/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/maximize.svg b/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/maximize.svg similarity index 100% rename from windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/maximize.svg rename to windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/maximize.svg diff --git a/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/maximizeInactive.svg b/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/maximizeInactive.svg similarity index 100% rename from windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/maximizeInactive.svg rename to windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/maximizeInactive.svg diff --git a/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/minimize.svg b/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/minimize.svg similarity index 100% rename from windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/minimize.svg rename to windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/minimize.svg diff --git a/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/minimizeInactive.svg b/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/minimizeInactive.svg similarity index 100% rename from windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/minimizeInactive.svg rename to windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/minimizeInactive.svg diff --git a/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/restore.svg b/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/restore.svg similarity index 100% rename from windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/restore.svg rename to windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/restore.svg diff --git a/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/restoreInactive.svg b/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/restoreInactive.svg similarity index 100% rename from windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/restoreInactive.svg rename to windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/restoreInactive.svg diff --git a/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/windows_decorations.properties b/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/windows_decorations.properties index e209e237..21128cfb 100644 --- a/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/windows_decorations.properties +++ b/windows/src/main/resources/com/github/weisj/darklaf/platform/windows/windows_decorations.properties @@ -21,15 +21,15 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # -TitlePane.minimize.icon = icons/windows/minimize.svg[themed] -TitlePane.minimizeInactive.icon = icons/windows/minimizeInactive.svg[themed] -TitlePane.maximize.icon = icons/windows/maximize.svg[themed] -TitlePane.maximizeInactive.icon = icons/windows/maximizeInactive.svg[themed] -TitlePane.restore.icon = icons/windows/restore.svg[themed] -TitlePane.restoreInactive.icon = icons/windows/restoreInactive.svg[themed] -TitlePane.close.icon = icons/windows/closeActive.svg[themed] -TitlePane.closeInactive.icon = icons/windows/closeInactive.svg[themed] -TitlePane.closeHover.icon = icons/windows/closeHover.svg[themed] +TitlePane.minimize.icon = icons/window/minimize.svg[themed] +TitlePane.minimizeInactive.icon = icons/window/minimizeInactive.svg[themed] +TitlePane.maximize.icon = icons/window/maximize.svg[themed] +TitlePane.maximizeInactive.icon = icons/window/maximizeInactive.svg[themed] +TitlePane.restore.icon = icons/window/restore.svg[themed] +TitlePane.restoreInactive.icon = icons/window/restoreInactive.svg[themed] +TitlePane.close.icon = icons/window/closeActive.svg[themed] +TitlePane.closeInactive.icon = icons/window/closeInactive.svg[themed] +TitlePane.closeHover.icon = icons/window/closeHover.svg[themed] TitlePane.close.clickColor = F1707A TitlePane.close.rollOverColor = E81123