Browse Source

View icons from jars in AllIcons.

Signed-off-by: weisj <weisj@arcor.de>
pull/52/head
weisj 5 years ago
parent
commit
616b81c76e
  1. 1
      core/src/test/java/UIDemo.java
  2. 50
      core/src/test/java/icon/AllIcons.java
  3. 4
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/duke.svg
  4. 0
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/closeActive.svg
  5. 0
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/closeHover.svg
  6. 0
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/closeInactive.svg
  7. 0
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/maximize.svg
  8. 0
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/maximizeInactive.svg
  9. 0
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/minimize.svg
  10. 0
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/minimizeInactive.svg
  11. 0
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/restore.svg
  12. 0
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/restoreInactive.svg
  13. 18
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/windows_decorations.properties

1
core/src/test/java/UIDemo.java

@ -19,7 +19,6 @@ import java.util.logging.Logger;
public final class UIDemo { public final class UIDemo {
public static void main(final String[] args) { public static void main(final String[] args) {
System.setProperty("org.apache.batik.warn_destination", "false");
SwingUtilities.invokeLater( SwingUtilities.invokeLater(
() -> { () -> {
LafManager.install(); LafManager.install();

50
core/src/test/java/icon/AllIcons.java

@ -35,15 +35,22 @@ import javax.swing.*;
import javax.swing.event.ListDataListener; import javax.swing.event.ListDataListener;
import java.awt.*; import java.awt.*;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.nio.file.FileSystem;
import java.util.ArrayList; import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List; import java.util.List;
import java.util.*;
import java.util.stream.Stream;
public class AllIcons { public class AllIcons {
private static String[] FOLDERS = new String[]{ 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) { public static void main(final String[] args) {
@ -79,38 +86,51 @@ public class AllIcons {
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setLocationRelativeTo(null); frame.setLocationRelativeTo(null);
frame.setVisible(true); frame.setVisible(true);
} catch (URISyntaxException e) { } catch (URISyntaxException | IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
}); });
} }
private static List<Pair<String, Icon>> loadIcons() throws URISyntaxException { private static List<Pair<String, Icon>> loadIcons() throws URISyntaxException, IOException {
List<Pair<String, Icon>> list = new ArrayList<>(); List<Pair<String, Icon>> list = new ArrayList<>();
for (String folder : FOLDERS) { for (String folder : FOLDERS) {
File[] files = getResourceFolderFiles("icons/" + folder, DarkLaf.class); Pair<Stream<Path>, Optional<FileSystem>> files = walk(folder, DarkLaf.class);
for (File f : files) { try (FileSystem fs = files.getSecond().isPresent() ? files.getSecond().get() : null) {
if (f.getName().endsWith(".svg")) { files.getFirst().forEach(p -> {
if (p.getFileName().toString().endsWith(".svg")) {
int SIZE = 30; int SIZE = 30;
ThemedSVGIcon icon = (ThemedSVGIcon) IconLoader.get().loadSVGIcon(folder + "/" + f.getName(), ThemedSVGIcon icon = (ThemedSVGIcon) IconLoader.get(DarkLaf.class)
.loadSVGIcon(folder + "/" + p.getFileName(),
SIZE, SIZE, true); SIZE, SIZE, true);
SVGIcon svgIcon = icon.getSVGIcon(); SVGIcon svgIcon = icon.getSVGIcon();
int autosize = svgIcon.getAutosize(); int autosize = svgIcon.getAutosize();
svgIcon.setAutosize(SVGIcon.AUTOSIZE_NONE); svgIcon.setAutosize(SVGIcon.AUTOSIZE_NONE);
icon.setDisplaySize(svgIcon.getIconWidth() * 2, svgIcon.getIconHeight() * 2); int width = Math.min(svgIcon.getIconWidth() * 2, 100);
int height = (int) (((double) width / svgIcon.getIconWidth()) * svgIcon.getIconHeight());
icon.setDisplaySize(width, height);
svgIcon.setAutosize(autosize); svgIcon.setAutosize(autosize);
list.add(new Pair<>(f.getName(), icon)); list.add(new Pair<>(p.getFileName().toString(), icon));
} }
});
} }
} }
return list; return list;
} }
private static File[] getResourceFolderFiles(final String folder, public static Pair<Stream<Path>, Optional<FileSystem>> walk(final String path, final Class<?> clazz)
final Class<?> clazz) throws URISyntaxException { throws URISyntaxException, IOException {
URL url = clazz.getResource(folder); URI uri = clazz.getResource(path).toURI();
return new File(url.toURI()).listFiles(); 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<Pair<String, Icon>> { private static final class IconListRenderer extends JLabel implements ListCellRenderer<Pair<String, Icon>> {

4
windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/duke.svg

@ -3,8 +3,9 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0px" <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0px"
y="0px" y="0px"
width="225.938px" height="407.407px" viewBox="0 0 225.938 407.407" enable-background="new 0 0 225.938 407.407" width="16px" height="16px" viewBox="-2 0 14 16" enable-background="new 0 0 225.938 407.407"
xml:space="preserve"> xml:space="preserve">
<g transform="scale(0.04)">
<path fill-rule="evenodd" clip-rule="evenodd" d="M48.859,43.518c8.424,17.64,2.736,140.832-7.128,184.032 <path fill-rule="evenodd" clip-rule="evenodd" d="M48.859,43.518c8.424,17.64,2.736,140.832-7.128,184.032
c-9.864,43.272-19.728,98.28-22.032,144.576c-1.008,19.728,2.016,27.504,14.904,27.504c22.752,0,51.624-47.952,87.84-46.872 c-9.864,43.272-19.728,98.28-22.032,144.576c-1.008,19.728,2.016,27.504,14.904,27.504c22.752,0,51.624-47.952,87.84-46.872
c36.288,1.08,47.808,55.008,64.8,54.648c16.992-0.36,30.672-6.264,30.816-58.752C218.563,191.981,87.235,64.973,48.859,43.518 c36.288,1.08,47.808,55.008,64.8,54.648c16.992-0.36,30.672-6.264,30.816-58.752C218.563,191.981,87.235,64.973,48.859,43.518
@ -48,4 +49,5 @@
c-15.87,3.854-33.393-2.257-39.096-18.576c-2.912-8.332-2.37-16.879,2.637-24.198c4.223-6.171,11.033-11,17.779-14.066 c-15.87,3.854-33.393-2.257-39.096-18.576c-2.912-8.332-2.37-16.879,2.637-24.198c4.223-6.171,11.033-11,17.779-14.066
c13.924-6.326,33.832-7.029,43.531,7.077C138.744,165.348,139.387,171.641,139.162,177.941"/> c13.924-6.326,33.832-7.029,43.531,7.077C138.744,165.348,139.387,171.641,139.162,177.941"/>
</g> </g>
</g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

0
windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/closeActive.svg → windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/closeActive.svg

Before

Width:  |  Height:  |  Size: 608 B

After

Width:  |  Height:  |  Size: 608 B

0
windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/closeHover.svg → windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/closeHover.svg

Before

Width:  |  Height:  |  Size: 612 B

After

Width:  |  Height:  |  Size: 612 B

0
windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/closeInactive.svg → windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/closeInactive.svg

Before

Width:  |  Height:  |  Size: 624 B

After

Width:  |  Height:  |  Size: 624 B

0
windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/maximize.svg → windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/maximize.svg

Before

Width:  |  Height:  |  Size: 477 B

After

Width:  |  Height:  |  Size: 477 B

0
windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/maximizeInactive.svg → windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/maximizeInactive.svg

Before

Width:  |  Height:  |  Size: 493 B

After

Width:  |  Height:  |  Size: 493 B

0
windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/minimize.svg → windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/minimize.svg

Before

Width:  |  Height:  |  Size: 435 B

After

Width:  |  Height:  |  Size: 435 B

0
windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/minimizeInactive.svg → windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/minimizeInactive.svg

Before

Width:  |  Height:  |  Size: 461 B

After

Width:  |  Height:  |  Size: 461 B

0
windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/restore.svg → windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/restore.svg

Before

Width:  |  Height:  |  Size: 702 B

After

Width:  |  Height:  |  Size: 702 B

0
windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/restoreInactive.svg → windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/window/restoreInactive.svg

Before

Width:  |  Height:  |  Size: 726 B

After

Width:  |  Height:  |  Size: 726 B

18
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 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE. # SOFTWARE.
# #
TitlePane.minimize.icon = icons/windows/minimize.svg[themed] TitlePane.minimize.icon = icons/window/minimize.svg[themed]
TitlePane.minimizeInactive.icon = icons/windows/minimizeInactive.svg[themed] TitlePane.minimizeInactive.icon = icons/window/minimizeInactive.svg[themed]
TitlePane.maximize.icon = icons/windows/maximize.svg[themed] TitlePane.maximize.icon = icons/window/maximize.svg[themed]
TitlePane.maximizeInactive.icon = icons/windows/maximizeInactive.svg[themed] TitlePane.maximizeInactive.icon = icons/window/maximizeInactive.svg[themed]
TitlePane.restore.icon = icons/windows/restore.svg[themed] TitlePane.restore.icon = icons/window/restore.svg[themed]
TitlePane.restoreInactive.icon = icons/windows/restoreInactive.svg[themed] TitlePane.restoreInactive.icon = icons/window/restoreInactive.svg[themed]
TitlePane.close.icon = icons/windows/closeActive.svg[themed] TitlePane.close.icon = icons/window/closeActive.svg[themed]
TitlePane.closeInactive.icon = icons/windows/closeInactive.svg[themed] TitlePane.closeInactive.icon = icons/window/closeInactive.svg[themed]
TitlePane.closeHover.icon = icons/windows/closeHover.svg[themed] TitlePane.closeHover.icon = icons/window/closeHover.svg[themed]
TitlePane.close.clickColor = F1707A TitlePane.close.clickColor = F1707A
TitlePane.close.rollOverColor = E81123 TitlePane.close.rollOverColor = E81123

Loading…
Cancel
Save