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. 64
      core/src/test/java/icon/AllIcons.java
  3. 36
      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();

64
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 -> {
int SIZE = 30; if (p.getFileName().toString().endsWith(".svg")) {
ThemedSVGIcon icon = (ThemedSVGIcon) IconLoader.get().loadSVGIcon(folder + "/" + f.getName(), int SIZE = 30;
SIZE, SIZE, true); ThemedSVGIcon icon = (ThemedSVGIcon) IconLoader.get(DarkLaf.class)
SVGIcon svgIcon = icon.getSVGIcon(); .loadSVGIcon(folder + "/" + p.getFileName(),
int autosize = svgIcon.getAutosize(); SIZE, SIZE, true);
svgIcon.setAutosize(SVGIcon.AUTOSIZE_NONE); SVGIcon svgIcon = icon.getSVGIcon();
icon.setDisplaySize(svgIcon.getIconWidth() * 2, svgIcon.getIconHeight() * 2); int autosize = svgIcon.getAutosize();
svgIcon.setAutosize(autosize); svgIcon.setAutosize(SVGIcon.AUTOSIZE_NONE);
list.add(new Pair<>(f.getName(), icon)); 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; 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>> {

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

@ -3,13 +3,14 @@
<!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
L48.859,43.518L48.859,43.518L48.859,43.518z"/> L48.859,43.518L48.859,43.518L48.859,43.518z"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M162.763,168.726c7.992,13.464,28.368,3.096,29.232-12.096 <path fill-rule="evenodd" clip-rule="evenodd" d="M162.763,168.726c7.992,13.464,28.368,3.096,29.232-12.096
c0.864-15.192-1.368-34.344-11.232-35.064c-9.864-0.72-16.92-10.584-26.784-11.304c-9.864-0.72-20.448,9.144-25.056-3.96 c0.864-15.192-1.368-34.344-11.232-35.064c-9.864-0.72-16.92-10.584-26.784-11.304c-9.864-0.72-20.448,9.144-25.056-3.96
s12.384-18.648,25.056-20.736c-11.304-11.304-17.928-23.832-22.896-36.864c-4.968-13.032-8.64-24.984,5.256-30.096 s12.384-18.648,25.056-20.736c-11.304-11.304-17.928-23.832-22.896-36.864c-4.968-13.032-8.64-24.984,5.256-30.096
c13.896-5.112,12.744,21.168,28.656,33.192c-4.68-17.712-6.408-25.056-6.048-35.352s-0.36-18.144,14.256-16.128 c13.896-5.112,12.744,21.168,28.656,33.192c-4.68-17.712-6.408-25.056-6.048-35.352s-0.36-18.144,14.256-16.128
@ -17,35 +18,36 @@
c-12.096,25.128,3.528,38.736-0.144,58.536c-3.672,19.8-15.048,16.2-19.944,28.944c-4.896,12.744,2.88,41.76-6.336,54.792 c-12.096,25.128,3.528,38.736-0.144,58.536c-3.672,19.8-15.048,16.2-19.944,28.944c-4.896,12.744,2.88,41.76-6.336,54.792
c-9.216,13.032-10.872,33.048-4.896,49.032C172.339,205.374,162.763,168.726,162.763,168.726L162.763,168.726L162.763,168.726 c-9.216,13.032-10.872,33.048-4.896,49.032C172.339,205.374,162.763,168.726,162.763,168.726L162.763,168.726L162.763,168.726
L162.763,168.726z"/> L162.763,168.726z"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M48.355,185.646c-7.416,50.832-33.192,56.88-34.488,77.976 <path fill-rule="evenodd" clip-rule="evenodd" d="M48.355,185.646c-7.416,50.832-33.192,56.88-34.488,77.976
c-1.296,21.096,6.84,23.112,6.336,42.624c-0.504,19.512-17.856,27.432-19.944,38.016s8.928,13.968,15.336,13.968 c-1.296,21.096,6.84,23.112,6.336,42.624c-0.504,19.512-17.856,27.432-19.944,38.016s8.928,13.968,15.336,13.968
c6.408,0,12.816-28.08,15.408-45.936s-8.496-28.368-8.496-40.608c0-12.24,16.056-34.632,13.104-14.976 c6.408,0,12.816-28.08,15.408-45.936s-8.496-28.368-8.496-40.608c0-12.24,16.056-34.632,13.104-14.976
C48.931,235.686,55.268,208.901,48.355,185.646L48.355,185.646L48.355,185.646L48.355,185.646z"/> C48.931,235.686,55.268,208.901,48.355,185.646L48.355,185.646L48.355,185.646L48.355,185.646z"/>
<path fill-rule="evenodd" clip-rule="evenodd" fill="#FFFFFF" d="M58.292,205.013c-5.616,27.504-40.68,181.08-22.824,183.024 <path fill-rule="evenodd" clip-rule="evenodd" fill="#FFFFFF" d="M58.292,205.013c-5.616,27.504-40.68,181.08-22.824,183.024
c17.856,1.944,43.272-47.52,84.888-47.16c41.688,0.36,58.104,55.44,68.256,55.08c10.152-0.36,16.848,3.6,17.928-58.464 c17.856,1.944,43.272-47.52,84.888-47.16c41.688,0.36,58.104,55.44,68.256,55.08c10.152-0.36,16.848,3.6,17.928-58.464
c1.08-62.064-36.792-141.336-59.184-176.256C116.971,163.181,84.283,187.518,58.292,205.013L58.292,205.013L58.292,205.013 c1.08-62.064-36.792-141.336-59.184-176.256C116.971,163.181,84.283,187.518,58.292,205.013L58.292,205.013L58.292,205.013
L58.292,205.013z"/> L58.292,205.013z"/>
<g> <g>
<path fill="none" d="M139.162,172.181c-1.95-18.251-19.12-25.421-35.661-23.168c-13.889,1.893-32.403,13.613-34.107,28.64 <path fill="none" d="M139.162,172.181c-1.95-18.251-19.12-25.421-35.661-23.168c-13.889,1.893-32.403,13.613-34.107,28.64
c-1.921,16.937,11.402,32.522,28.361,33.203c15.03,0.604,31.176-6.668,37.93-20.79 c-1.921,16.937,11.402,32.522,28.361,33.203c15.03,0.604,31.176-6.668,37.93-20.79
C138.415,184.362,139.482,178.488,139.162,172.181"/> C138.415,184.362,139.482,178.488,139.162,172.181"/>
<path d="M147.082,171.533c-1.662-17.195-14.407-27.988-30.895-30.627c-15.924-2.549-33.26,4.998-44.408,16.146 <path d="M147.082,171.533c-1.662-17.195-14.407-27.988-30.895-30.627c-15.924-2.549-33.26,4.998-44.408,16.146
c-12.538,12.538-13.039,29.978-4.26,44.833c8.661,14.657,27.847,19.501,43.563,15.835 c-12.538,12.538-13.039,29.978-4.26,44.833c8.661,14.657,27.847,19.501,43.563,15.835
C132.588,212.705,148.48,193.896,147.082,171.533"/> C132.588,212.705,148.48,193.896,147.082,171.533"/>
<radialGradient id="SVGID_1_" cx="86.6299" cy="167.0693" r="54.7155" gradientUnits="userSpaceOnUse"> <radialGradient id="SVGID_1_" cx="86.6299" cy="167.0693" r="54.7155" gradientUnits="userSpaceOnUse">
<stop offset="0" style="stop-color:#FFFFFF"/> <stop offset="0" style="stop-color:#FFFFFF"/>
<stop offset="0.0604" style="stop-color:#FBC8B4"/> <stop offset="0.0604" style="stop-color:#FBC8B4"/>
<stop offset="0.0712" style="stop-color:#FBC3B0"/> <stop offset="0.0712" style="stop-color:#FBC3B0"/>
<stop offset="0.1829" style="stop-color:#F7978B"/> <stop offset="0.1829" style="stop-color:#F7978B"/>
<stop offset="0.2995" style="stop-color:#F4716B"/> <stop offset="0.2995" style="stop-color:#F4716B"/>
<stop offset="0.4199" style="stop-color:#F15251"/> <stop offset="0.4199" style="stop-color:#F15251"/>
<stop offset="0.5453" style="stop-color:#EF3A3D"/> <stop offset="0.5453" style="stop-color:#EF3A3D"/>
<stop offset="0.6778" style="stop-color:#EE292F"/> <stop offset="0.6778" style="stop-color:#EE292F"/>
<stop offset="0.822" style="stop-color:#ED1F27"/> <stop offset="0.822" style="stop-color:#ED1F27"/>
<stop offset="1" style="stop-color:#ED1C24"/> <stop offset="1" style="stop-color:#ED1C24"/>
</radialGradient> </radialGradient>
<path fill="url(#SVGID_1_)" stroke="#000000" d="M139.162,177.941c-1.493,15.627-13.947,28.182-28.944,31.824 <path fill="url(#SVGID_1_)" stroke="#000000" d="M139.162,177.941c-1.493,15.627-13.947,28.182-28.944,31.824
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