support for SVG icons via com.formdev.flatlaf.extras.FlatSVGIcon from flatlaf-extras (which is based on JSVG);
authorwenzelm
Tue, 15 Apr 2025 21:32:50 +0200
changeset 82546 553aa1dd0feb
parent 82545 0d955ab17466
child 82547 cbeef60a8435
support for SVG icons via com.formdev.flatlaf.extras.FlatSVGIcon from flatlaf-extras (which is based on JSVG);
Admin/components/components.sha1
Admin/components/main
etc/build.props
src/Pure/Admin/component_flatlaf.scala
src/Pure/Admin/component_jsvg.scala
src/Pure/System/isabelle_tool.scala
src/Tools/jEdit/patches/icons
--- a/Admin/components/components.sha1	Tue Apr 15 16:53:07 2025 +0200
+++ b/Admin/components/components.sha1	Tue Apr 15 21:32:50 2025 +0200
@@ -129,6 +129,7 @@
 31d6abd58a4c2f7522f14283dfe04e2801a6e828 flatlaf-2.6.tar.gz
 95aff7a320715c473ea63294a288ba30a71dec88 flatlaf-3.5.4-1.tar.gz
 a93a98c80536a6984db118e129b1b3a778c700ce flatlaf-3.5.4.tar.gz
+7de5b13afd4d9ac09e4d591b63c1979b9276e4f6 flatlaf-3.6-1.tar.gz
 1363421c87dd24bbff318e37c4788ba0339db7ad flatlaf-3.6.tar.gz
 b1c40ce6c087da7e70e221ddd3fcadfa569acb2f foiltex-2.1.4b.tar.gz
 f339234ec18369679be0095264e0c0af7762f351 gnu-utils-20210414.tar.gz
@@ -267,6 +268,7 @@
 12f22ccb48a0a7dc9ad8c1b27552e8fd26d4ae0c jedit-20250215.tar.gz
 1aa375149dc5e84cfdd64bf66e7e0f68319b7db7 jedit-20250402.tar.gz
 88c9cc14f5618ad21ca17664fdb57b8f5f6f6d2e jedit-20250404.tar.gz
+cab6dca89dc2e0d922e92cc47df07941a3c6b29c jedit-20250415.tar.gz
 44775a22f42a9d665696bfb49e53c79371c394b0 jedit_build-20111217.tar.gz
 a242a688810f2bccf24587b0062ce8027bf77fa2 jedit_build-20120304.tar.gz
 4c948dee53f74361c097c08f49a1a5ff9b17bd1d jedit_build-20120307.tar.gz
@@ -323,6 +325,7 @@
 df8bb213d39a7eecae97e6af3b11752d6c704c90 jsoup-1.15.4.tar.gz
 b1c8e2a289e40cbc139a3c371348cef3b537b1c7 jsoup-1.17.2.tar.gz
 342f12a07889ec173b13df9327db684b45118252 jsoup-1.18.3.tar.gz
+a7419f9dab68e50d05533980b6729d1dd7aafb3b jsvg-1.7.1.tar.gz
 6c737137cc597fc920943783382e928ea79e3feb kodkodi-1.2.16.tar.gz
 afb04f4048a87bb888fe7b05b0139cb060c7925b kodkodi-1.5.2-1.tar.gz
 5f95c96bb99927f3a026050f85bd056f37a9189e kodkodi-1.5.2.tar.gz
--- a/Admin/components/main	Tue Apr 15 16:53:07 2025 +0200
+++ b/Admin/components/main	Tue Apr 15 21:32:50 2025 +0200
@@ -9,17 +9,18 @@
 easychair-3.5
 eptcs-1.7.0
 find_facts_web-20250223
-flatlaf-3.6
+flatlaf-3.6-1
 foiltex-2.1.4b
 idea-icons-20210508
 isabelle_fonts-20241227
 isabelle_setup-20240327
 javamail-20250122
 jdk-21.0.6
-jedit-20250404
+jedit-20250415
 jfreechart-1.5.3
 jortho-1.0-2
 jsoup-1.18.3
+jsvg-1.7.1
 kodkodi-1.5.7
 lipics-3.1.3
 llncs-2.25
--- a/etc/build.props	Tue Apr 15 16:53:07 2025 +0200
+++ b/etc/build.props	Tue Apr 15 21:32:50 2025 +0200
@@ -36,6 +36,7 @@
   src/Pure/Admin/component_jdk.scala \
   src/Pure/Admin/component_jedit.scala \
   src/Pure/Admin/component_jsoup.scala \
+  src/Pure/Admin/component_jsvg.scala \
   src/Pure/Admin/component_lipics.scala \
   src/Pure/Admin/component_llncs.scala \
   src/Pure/Admin/component_minisat.scala \
--- a/src/Pure/Admin/component_flatlaf.scala	Tue Apr 15 16:53:07 2025 +0200
+++ b/src/Pure/Admin/component_flatlaf.scala	Tue Apr 15 21:32:50 2025 +0200
@@ -25,7 +25,8 @@
       Lib("flatlaf/{V}/flatlaf-{V}-macos-x86_64.dylib"),
       Lib("flatlaf/{V}/flatlaf-{V}-linux-arm64.so"),
       Lib("flatlaf/{V}/flatlaf-{V}-linux-x86_64.so"),
-      Lib("flatlaf/{V}/flatlaf-{V}-windows-x86_64.dll", exe = true))
+      Lib("flatlaf/{V}/flatlaf-{V}-windows-x86_64.dll", exe = true),
+      Lib("flatlaf-extras/{V}/flatlaf-extras-{V}.jar"))
 
 
   /* build flatlaf */
@@ -81,11 +82,14 @@
 
     File.write(component_dir.README,
       """This is the FlatLaf Java/Swing look-and-feel from
-https://www.formdev.com/flatlaf and
 https://mvnrepository.com/artifact/com.formdev
 
 It is covered by the Apache License 2.0 license.
 
+See also https://www.formdev.com/flatlaf  and especially the demo
+application https://download.formdev.com/flatlaf/flatlaf-demo-latest.jar
+(which may be run via "java -jar ...").
+
 
         Makarius
         """ + Date.Format.date(Date.now()) + "\n")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Pure/Admin/component_jsvg.scala	Tue Apr 15 21:32:50 2025 +0200
@@ -0,0 +1,92 @@
+/*  Title:      Pure/Admin/component_jsvg.scala
+    Author:     Makarius
+
+Build Isabelle jsvg component from official download.
+*/
+
+package isabelle
+
+
+object Component_JSVG {
+  /* build jsvg */
+
+  val default_download_url =
+    "https://repo1.maven.org/maven2/com/github/weisj/jsvg/1.7.1/jsvg-1.7.1.jar"
+
+  def build_jsvg(
+    download_url: String = default_download_url,
+    progress: Progress = new Progress,
+    target_dir: Path = Path.current
+  ): Unit = {
+    val Download_Name = """^.*/([^/]+)\.jar""".r
+    val download_name =
+      download_url match {
+        case Download_Name(download_name) => download_name
+        case _ => error("Malformed jar download URL: " + quote(download_url))
+      }
+
+
+    /* component */
+
+    val component_dir =
+      Components.Directory(target_dir + Path.basic(download_name)).create(progress = progress)
+
+    File.write(component_dir.LICENSE,
+      Url.read("https://raw.githubusercontent.com/weisJ/jsvg/refs/heads/master/LICENSE"))
+
+
+    /* README */
+
+    File.write(component_dir.README,
+      "This is a Java SVG implementation (JSVG) from\n" + download_url +
+        "\n\nSee also https://github.com/weisJ/jsvg" +
+        "\n\n        Makarius\n        " + Date.Format.date(Date.now()) + "\n")
+
+
+    /* settings */
+
+    component_dir.write_settings("""
+ISABELLE_JSVG_HOME="$COMPONENT"
+
+classpath "$ISABELLE_JSVG_HOME/lib/""" + download_name + """.jar"
+""")
+
+
+    /* jar */
+
+    val jar = component_dir.lib + Path.basic(download_name).jar
+    Isabelle_System.make_directory(jar.dir)
+    Isabelle_System.download_file(download_url, jar, progress = progress)
+  }
+
+
+  /* Isabelle tool wrapper */
+
+  val isabelle_tool =
+    Isabelle_Tool("component_jsvg", "build Isabelle jsvg component from official download",
+      Scala_Project.here,
+      { args =>
+        var target_dir = Path.current
+        var download_url = default_download_url
+
+        val getopts = Getopts("""
+Usage: isabelle component_jsvg [OPTIONS] DOWNLOAD
+
+  Options are:
+    -D DIR       target directory (default ".")
+    -U URL       download URL
+                 (default: """" + default_download_url + """")
+
+  Build jsvg component from the specified download URL (JAR).
+""",
+          "D:" -> (arg => target_dir = Path.explode(arg)),
+          "U:" -> (arg => download_url = arg))
+
+        val more_args = getopts(args)
+        if (more_args.nonEmpty) getopts.usage()
+
+        val progress = new Console_Progress()
+
+        build_jsvg(download_url = download_url, progress = progress, target_dir = target_dir)
+      })
+}
--- a/src/Pure/System/isabelle_tool.scala	Tue Apr 15 16:53:07 2025 +0200
+++ b/src/Pure/System/isabelle_tool.scala	Tue Apr 15 21:32:50 2025 +0200
@@ -189,6 +189,7 @@
   Component_JDK.isabelle_tool,
   Component_JEdit.isabelle_tool,
   Component_Jsoup.isabelle_tool,
+  Component_JSVG.isabelle_tool,
   Component_LIPIcs.isabelle_tool,
   Component_LLNCS.isabelle_tool,
   Component_Minisat.isabelle_tool,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Tools/jEdit/patches/icons	Tue Apr 15 21:32:50 2025 +0200
@@ -0,0 +1,32 @@
+diff -ru jedit5.7.0/jEdit/ivy.xml jedit5.7.0-patched/jEdit/ivy.xml
+--- jedit5.7.0/jEdit/ivy.xml	2024-08-03 19:53:28.000000000 +0200
++++ jedit5.7.0-patched/jEdit/ivy.xml	2025-04-15 20:19:53.730502085 +0200
+@@ -94,5 +94,7 @@
+ 		<dependency org="com.google.code.findbugs" name="jsr305" rev="3.0.2"/>
+ 
+ 		<dependency org="com.evolvedbinary.appbundler" name="appbundler" rev="1.3.0" conf="appbundler"/>
++
++                <dependency org="com.formdev" name="flatlaf-extras" rev="3.6"/>
+ 	</dependencies>
+ </ivy-module>
+diff -ru jedit5.7.0/jEdit/org/gjt/sp/jedit/GUIUtilities.java jedit5.7.0-patched/jEdit/org/gjt/sp/jedit/GUIUtilities.java
+--- jedit5.7.0/jEdit/org/gjt/sp/jedit/GUIUtilities.java	2024-08-03 19:53:15.000000000 +0200
++++ jedit5.7.0-patched/jEdit/org/gjt/sp/jedit/GUIUtilities.java	2025-04-15 20:32:22.232820353 +0200
+@@ -72,6 +72,8 @@
+ import java.util.concurrent.ScheduledExecutorService;
+ import java.util.concurrent.TimeUnit;
+ import java.util.concurrent.atomic.AtomicLong;
++
++import com.formdev.flatlaf.extras.FlatSVGIcon;
+ //}}}
+ 
+ /** Various GUI utility functions related to icons, menus, toolbars, keyboard shortcuts, etc.
+@@ -164,7 +166,7 @@
+ 			}
+ 		}
+ 
+-		icon = new ImageIcon(url);
++		icon = url.toString().endsWith(".svg") ? new FlatSVGIcon(url): new ImageIcon(url);
+ 
+ 		cache.put(iconName,icon);
+ 		return icon;