separate Java FX modules -- no need to include jfxrt.jar by default;
authorwenzelm
Tue, 12 Aug 2014 12:06:22 +0200
changeset 57908 1937603dbdf2
parent 57907 7fc36b4c7cce
child 57909 0fb331032f02
separate Java FX modules -- no need to include jfxrt.jar by default;
src/Pure/GUI/gui.scala
src/Pure/GUI/html5_panel.scala
src/Pure/GUI/jfx_gui.scala
src/Pure/GUI/jfx_thread.scala
src/Pure/System/isabelle_font.scala
src/Pure/build-jars
src/Tools/jEdit/src/plugin.scala
src/Tools/jEdit/src/symbols_dockable.scala
--- a/src/Pure/GUI/gui.scala	Tue Aug 12 00:23:30 2014 +0200
+++ b/src/Pure/GUI/gui.scala	Tue Aug 12 12:06:22 2014 +0200
@@ -7,9 +7,10 @@
 
 package isabelle
 
-
 import java.lang.{ClassLoader, ClassNotFoundException, NoSuchMethodException}
-import java.awt.{Image, Component, Container, Toolkit, Window, Font, KeyboardFocusManager}
+import java.io.{FileInputStream, BufferedInputStream}
+import java.awt.{GraphicsEnvironment, Image, Component, Container, Toolkit, Window, Font,
+  KeyboardFocusManager}
 import java.awt.font.{TextAttribute, TransformAttribute, FontRenderContext, LineMetrics}
 import java.awt.geom.AffineTransform
 import javax.swing.{ImageIcon, JOptionPane, UIManager, JLayeredPane, JFrame, JWindow, JDialog,
@@ -232,5 +233,15 @@
     import scala.collection.JavaConversions._
     font.deriveFont(Map(TextAttribute.TRANSFORM -> new TransformAttribute(transform)))
   }
+
+  def font(family: String = "IsabelleText", size: Int = 1, bold: Boolean = false): Font =
+    new Font(family, if (bold) Font.BOLD else Font.PLAIN, size)
+
+  def install_fonts()
+  {
+    val ge = GraphicsEnvironment.getLocalGraphicsEnvironment()
+    for (font <- Path.split(Isabelle_System.getenv_strict("ISABELLE_FONTS")))
+      ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, font.file))
+  }
 }
 
--- a/src/Pure/GUI/html5_panel.scala	Tue Aug 12 00:23:30 2014 +0200
+++ b/src/Pure/GUI/html5_panel.scala	Tue Aug 12 12:06:22 2014 +0200
@@ -1,5 +1,5 @@
 /*  Title:      Pure/GUI/html5_panel.scala
-    Module:     PIDE-GUI
+    Module:     PIDE-JFX
     Author:     Makarius
 
 HTML5 panel based on Java FX WebView.
@@ -54,7 +54,7 @@
 class HTML5_Panel extends javafx.embed.swing.JFXPanel
 {
   private val future =
-    JFX_Thread.future {
+    JFX_GUI.Thread.future {
       val pane = new Web_View_Workaround
 
       val web_view = pane.web_view
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Pure/GUI/jfx_gui.scala	Tue Aug 12 12:06:22 2014 +0200
@@ -0,0 +1,55 @@
+/*  Title:      Pure/GUI/jfx_thread.scala
+    Module:     PIDE-JFX
+    Author:     Makarius
+
+Basic GUI tools (for Java FX).
+*/
+
+package isabelle
+
+
+import java.io.{FileInputStream, BufferedInputStream}
+
+import javafx.application.{Platform => JFX_Platform}
+import javafx.scene.text.{Font => JFX_Font}
+
+
+object JFX_GUI
+{
+  /* evaluation within the Java FX application thread */
+
+  object Thread
+  {
+    def assert() = Predef.assert(JFX_Platform.isFxApplicationThread())
+    def require() = Predef.require(JFX_Platform.isFxApplicationThread())
+
+    def later(body: => Unit)
+    {
+      if (JFX_Platform.isFxApplicationThread()) body
+      else JFX_Platform.runLater(new Runnable { def run = body })
+    }
+
+    def future[A](body: => A): Future[A] =
+    {
+      if (JFX_Platform.isFxApplicationThread()) Future.value(body)
+      else {
+        val promise = Future.promise[A]
+        later { promise.fulfill_result(Exn.capture(body)) }
+        promise
+      }
+    }
+  }
+
+
+  /* Isabelle fonts */
+
+  def install_fonts()
+  {
+    for (font <- Path.split(Isabelle_System.getenv_strict("ISABELLE_FONTS"))) {
+      val stream = new BufferedInputStream(new FileInputStream(font.file))
+      try { JFX_Font.loadFont(stream, 1.0) }
+      finally { stream.close }
+    }
+  }
+
+}
--- a/src/Pure/GUI/jfx_thread.scala	Tue Aug 12 00:23:30 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*  Title:      Pure/GUI/jfx_thread.scala
-    Module:     PIDE-GUI
-    Author:     Makarius
-
-Evaluation within the Java FX application thread.
-*/
-
-package isabelle
-
-import javafx.application.{Platform => JFX_Platform}
-
-
-object JFX_Thread
-{
-  /* checks */
-
-  def assert() = Predef.assert(JFX_Platform.isFxApplicationThread())
-  def require() = Predef.require(JFX_Platform.isFxApplicationThread())
-
-
-  /* asynchronous context switch */
-
-  def later(body: => Unit)
-  {
-    if (JFX_Platform.isFxApplicationThread()) body
-    else JFX_Platform.runLater(new Runnable { def run = body })
-  }
-
-  def future[A](body: => A): Future[A] =
-  {
-    if (JFX_Platform.isFxApplicationThread()) Future.value(body)
-    else {
-      val promise = Future.promise[A]
-      later { promise.fulfill_result(Exn.capture(body)) }
-      promise
-    }
-  }
-}
--- a/src/Pure/System/isabelle_font.scala	Tue Aug 12 00:23:30 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*  Title:      Pure/System/isabelle_font.scala
-    Author:     Makarius
-
-Isabelle font support.
-*/
-
-package isabelle
-
-
-import java.awt.{GraphicsEnvironment, Font}
-import java.io.{FileInputStream, BufferedInputStream}
-import javafx.scene.text.{Font => JFX_Font}
-
-
-object Isabelle_Font
-{
-  def apply(family: String = "IsabelleText", size: Int = 1, bold: Boolean = false): Font =
-    new Font(family, if (bold) Font.BOLD else Font.PLAIN, size)
-
-  def install_fonts()
-  {
-    val ge = GraphicsEnvironment.getLocalGraphicsEnvironment()
-    for (font <- Path.split(Isabelle_System.getenv_strict("ISABELLE_FONTS")))
-      ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, font.file))
-  }
-
-  def install_fonts_jfx()
-  {
-    for (font <- Path.split(Isabelle_System.getenv_strict("ISABELLE_FONTS"))) {
-      val stream = new BufferedInputStream(new FileInputStream(font.file))
-      try { JFX_Font.loadFont(stream, 1.0) }
-      finally { stream.close }
-    }
-  }
-}
-
--- a/src/Pure/build-jars	Tue Aug 12 00:23:30 2014 +0200
+++ b/src/Pure/build-jars	Tue Aug 12 12:06:22 2014 +0200
@@ -20,7 +20,7 @@
   GUI/gui.scala
   GUI/gui_thread.scala
   GUI/html5_panel.scala
-  GUI/jfx_thread.scala
+  GUI/jfx_gui.scala
   GUI/popup.scala
   GUI/system_dialog.scala
   GUI/wrap_panel.scala
@@ -72,7 +72,6 @@
   System/command_line.scala
   System/invoke_scala.scala
   System/isabelle_charset.scala
-  System/isabelle_font.scala
   System/isabelle_process.scala
   System/isabelle_system.scala
   System/options.scala
--- a/src/Tools/jEdit/src/plugin.scala	Tue Aug 12 00:23:30 2014 +0200
+++ b/src/Tools/jEdit/src/plugin.scala	Tue Aug 12 12:06:22 2014 +0200
@@ -373,7 +373,7 @@
 
       PIDE.plugin = this
       Isabelle_System.init()
-      Isabelle_Font.install_fonts()
+      GUI.install_fonts()
 
       PIDE.options.update(Options.init())
       PIDE.completion_history.load()
--- a/src/Tools/jEdit/src/symbols_dockable.scala	Tue Aug 12 00:23:30 2014 +0200
+++ b/src/Tools/jEdit/src/symbols_dockable.scala	Tue Aug 12 12:06:22 2014 +0200
@@ -24,8 +24,8 @@
 
     font =
       Symbol.fonts.get(symbol) match {
-        case None => Isabelle_Font(size = font_size)
-        case Some(font_family) => Isabelle_Font(family = font_family, size = font_size)
+        case None => GUI.font(size = font_size)
+        case Some(font_family) => GUI.font(family = font_family, size = font_size)
       }
     action =
       Action(decoded) {