equal
deleted
inserted
replaced
1 /* Title: Pure/GUI/jfx_gui.scala |
|
2 Author: Makarius |
|
3 |
|
4 Basic GUI tools (for Java FX). |
|
5 */ |
|
6 |
|
7 package isabelle |
|
8 |
|
9 |
|
10 import java.io.{FileInputStream, BufferedInputStream} |
|
11 |
|
12 import javafx.application.{Platform => JFX_Platform} |
|
13 import javafx.scene.text.{Font => JFX_Font} |
|
14 |
|
15 |
|
16 object JFX_GUI |
|
17 { |
|
18 /* evaluation within the Java FX application thread */ |
|
19 |
|
20 object Thread |
|
21 { |
|
22 def assert() = Predef.assert(JFX_Platform.isFxApplicationThread()) |
|
23 def require() = Predef.require(JFX_Platform.isFxApplicationThread()) |
|
24 |
|
25 def later(body: => Unit) |
|
26 { |
|
27 if (JFX_Platform.isFxApplicationThread()) body |
|
28 else JFX_Platform.runLater(new Runnable { def run = body }) |
|
29 } |
|
30 |
|
31 def future[A](body: => A): Future[A] = |
|
32 { |
|
33 if (JFX_Platform.isFxApplicationThread()) Future.value(body) |
|
34 else { |
|
35 val promise = Future.promise[A] |
|
36 later { promise.fulfill_result(Exn.capture(body)) } |
|
37 promise |
|
38 } |
|
39 } |
|
40 } |
|
41 |
|
42 |
|
43 /* Isabelle fonts */ |
|
44 |
|
45 def install_fonts() |
|
46 { |
|
47 for (font <- Isabelle_System.fonts()) { |
|
48 val stream = new BufferedInputStream(new FileInputStream(font.file)) |
|
49 try { JFX_Font.loadFont(stream, 1.0) } |
|
50 finally { stream.close } |
|
51 } |
|
52 } |
|
53 |
|
54 } |
|