Skip to content

Commit 8875e1c

Browse files
committed
Add demo of image rotation
1 parent 66cbd77 commit 8875e1c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

scalafx-extras-demos/src/main/scala/org/scalafx/extras/image/ImageDisplayDemoApp.scala

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011-2022, ScalaFX Project
2+
* Copyright (c) 2011-2024, ScalaFX Project
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -32,6 +32,7 @@ import org.scalafx.extras.ShowMessage
3232
import scalafx.Includes.*
3333
import scalafx.application.JFXApp3
3434
import scalafx.application.JFXApp3.PrimaryStage
35+
import scalafx.collections.ObservableBuffer
3536
import scalafx.scene.Scene
3637
import scalafx.scene.control.*
3738
import scalafx.scene.image.Image
@@ -43,6 +44,8 @@ import scalafx.stage.FileChooser
4344
*/
4445
object ImageDisplayDemoApp extends JFXApp3 {
4546

47+
private val rotationItems = ObservableBuffer(0, 90, 180, 270)
48+
4649
override def start(): Unit = {
4750

4851
val imageDisplay = new ImageDisplay()
@@ -68,6 +71,13 @@ object ImageDisplayDemoApp extends JFXApp3 {
6871
},
6972
new ToggleButton("Zoom to fit") {
7073
selected <==> imageDisplay.zoomToFit
74+
},
75+
new ChoiceBox(rotationItems) {
76+
selectionModel().selectedItem.onChange { (_, _, newValue) =>
77+
println(s"$newValue chosen in ChoiceBox")
78+
imageDisplay.rotation = newValue
79+
}
80+
selectionModel().selectFirst()
7181
}
7282
)
7383
}

0 commit comments

Comments
 (0)