-
Notifications
You must be signed in to change notification settings - Fork 0
/
Auginte.scala
75 lines (64 loc) · 2.01 KB
/
Auginte.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package com.auginte.desktop
import java.awt.SplashScreen
import akka.actor.{ActorSystem, Props}
import com.auginte.desktop.{actors => act}
import com.auginte.zooming.Grid
import javafx.embed.swing.JFXPanel
import javafx.scene.image.Image
import com.auginte.desktop.utilities.Config
import scalafx.Includes._
import scalafx.application.JFXApp.PrimaryStage
import scalafx.application.{JFXApp, Platform}
import scalafx.scene._
import scalafx.stage.WindowEvent
object Auginte extends JFXApp { app =>
val akka = ActorSystem("auginte")
// Shortcut to initialize JavaFX, force initialization by creating JFXPanel() object
// (we will not use it for anything else)
new JFXPanel()
stage = new PrimaryStage {
title = "Auginte"
width = 600
height = 450
icons add new Image(getClass.getResourceAsStream("/com/auginte/common/splash.gif"))
}
val view1 = new View {
prefWidth = 400.0
prefHeight = 400.0
}
view1.stylesheets add "css/view.css"
view1.stylesheets add "css/controls.css"
view1.getStyleClass.add("view")
val grid = new Grid
val viewsSupervisor = akka.actorOf(Props[act.Views], "views")
viewsSupervisor ! grid
viewsSupervisor ! view1
stage.onCloseRequest = (e: WindowEvent) => quit()
def quit(): Unit = {
akka.terminate()
Platform.exit()
}
parameters.named.get("config-file").foreach(Config.load)
val welcomeFile = "/examples/welcome.json"
if (parameters.unnamed.nonEmpty) {
val userFile = parameters.unnamed.head
try {
System.out.println(s"Loading user file: $userFile")
view1.load(userFile)
} catch {
case e: Exception =>
System.err.println(s"Failed to load file: $userFile: $e")
System.out.println("Loading default one instead")
view1.loadFromStream(getClass.getResourceAsStream(welcomeFile))
}
} else {
view1.loadFromStream(getClass.getResourceAsStream(welcomeFile))
}
stage.scene = new Scene {
root = view1
}
val splash = SplashScreen.getSplashScreen
if (splash != null) {
splash.close()
}
}