-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
showcase-jvm/src/main/scala/doctus/jvm/ShowcaseJvmPointable.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package doctus.jvm | ||
|
||
import doctus.core._ | ||
import java.util.ArrayList | ||
import java.util.List | ||
import java.util.Random | ||
import javafx.application.Application | ||
import javafx.scene._ | ||
import javafx.stage.Stage | ||
import javafx.scene.canvas.Canvas | ||
import javafx.application._ | ||
import javafx.scene._ | ||
import javafx.scene.paint._ | ||
import javafx.stage.Stage | ||
import javafx.stage.WindowEvent | ||
import javafx.event.EventHandler | ||
import javafx.event.ActionEvent | ||
import javafx.event.Event | ||
|
||
object ShowcaseJvmPointable extends App { | ||
|
||
Application.launch(classOf[MyApp], args: _*); | ||
|
||
class MyApp extends Application { | ||
|
||
override def start(stage: Stage) { | ||
|
||
val width = 700 | ||
val height = 500 | ||
|
||
val canvasFx = new Canvas(width, height); | ||
|
||
val canvas = DoctusCanvasFx(canvasFx) | ||
val pointable = DoctusPointableFx(canvasFx) | ||
|
||
|
||
val grp = new Group(); | ||
grp.getChildren().add(canvasFx); | ||
|
||
val bgCol = Color.WHITE; | ||
val scene = new Scene(grp, width, height, bgCol); | ||
|
||
// Start the controller | ||
DoctusControllerPointable(pointable, canvas) | ||
|
||
stage.setScene(scene); | ||
|
||
stage.show(); | ||
def handler[T <: Event](h: (T => Unit)): EventHandler[T] = | ||
new EventHandler[T] { | ||
override def handle(event: T): Unit = h(event) | ||
} | ||
|
||
// Find a better solution to exit | ||
stage.setOnCloseRequest(handler(e => System.exit(0))) | ||
|
||
|
||
|
||
} | ||
} | ||
|
||
} | ||
|