| author | wenzelm |
| Mon, 04 Dec 2017 21:23:56 +0100 | |
| changeset 67129 | 0262a378d5d6 |
| parent 65083 | 9a0e34edfad1 |
| permissions | -rw-r--r-- |
/* Title: Pure/GUI/jfx_gui.scala 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 <- Isabelle_System.fonts()) { val stream = new BufferedInputStream(new FileInputStream(font.file)) try { JFX_Font.loadFont(stream, 1.0) } finally { stream.close } } } }