Skip to content

Commit c32e374

Browse files
committed
Merge branch 'master' into release
2 parents bb44c7c + 32f111f commit c32e374

File tree

8 files changed

+244
-136
lines changed

8 files changed

+244
-136
lines changed

.scalafmt.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = 3.8.3
1+
version = 3.9.4
22

33
runner.dialect = scala3
44
fileOverride {

ReadMe.md

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,30 @@ Extras do not have direct corresponding concepts in JavaFX.
1111
**Contents**
1212

1313
<!-- TOC -->
14-
* [Project Structure](#project-structure)
15-
* [SBT](#sbt)
16-
* [Features](#features)
14+
15+
* [Project Structure](#project-structure)
16+
* [SBT](#sbt)
17+
* [Features](#features)
1718
* [Helper Methods](#helper-methods)
1819
* [Simpler Display of Standard Dialogs](#simpler-display-of-standard-dialogs)
1920
* [Easy Custom Panes](#easy-custom-panes)
2021
* [Easy Custom Dialogs](#easy-custom-dialogs)
2122
* [Edit a Case Class object with AutoDialog](#edit-a-case-class-object-with-autodialog)
2223
* [BusyWorker](#busyworker)
23-
* [Example 1](#example-1)
24-
* [Example 2](#example-2)
24+
* [Example 1](#example-1)
25+
* [Example 2](#example-2)
2526
* [Simpler Use of FXML with MVCfx Pattern](#simpler-use-of-fxml-with-mvcfx-pattern)
2627
* [ImageDisplay Component](#imagedisplay-component)
2728
* [Batch Processing and Progress Dialog](#batch-processing-and-progress-dialog)
28-
* [Demos](#demos)
29+
* [Demos](#demos)
2930
* [StopWatch Application](#stopwatch-application)
3031
* [ShowMessage Demo](#showmessage-demo)
3132
* [BusyWorker Demo](#busyworker-demo)
3233
* [ImageDisplay Demo](#imagedisplay-demo)
33-
* [Status](#status)
34-
* [Discussion and Support](#discussion-and-support)
35-
* [License](#license)
34+
* [Status](#status)
35+
* [Discussion and Support](#discussion-and-support)
36+
* [License](#license)
37+
3638
<!-- TOC -->
3739

3840
Project Structure
@@ -239,7 +241,7 @@ A more elaborate example is in the `GenericDialogFXDemo`.
239241
### Edit a Case Class object with AutoDialog
240242

241243
`AutoDialog` can be used too quickly open auto generated dialog from case class. After closing, the dialog will return
242-
edited version of the input case class.
244+
an edited version of the input case class.
243245

244246
Here is an example of usage:
245247

@@ -266,10 +268,10 @@ println(s"Result: $result")
266268

267269
### BusyWorker
268270

269-
BusyWorker helps running a UI task on separate threads (other than the JavaFX Application thread). It will show busy
271+
BusyWorker helps to run a UI task on separate threads (other than the JavaFX Application thread). It will show busy
270272
cursor and disable specified nodes while the task is performed. It gives an option to show progress and status messages.
271273
`BusyWorker` takes care of handling exceptions and displaying error dialogs. It provides for an option to perform custom
272-
finish actions after task is completed.
274+
finish actions after the task is completed.
273275

274276
#### Example 1
275277

@@ -323,21 +325,24 @@ The full code example can be found in the
323325
### Simpler Use of FXML with MVCfx Pattern
324326

325327
Package `org.scalafx.extras.mvcfx` contains classes for creating with UI components based on FXML that use
326-
Model-View-Controller, here we call it the MVCfx Pattern. See wiki page [MVCfx Pattern] for details.
328+
Model-View-Controller, here we call it the MVCfx Pattern. See the wiki page [MVCfx Pattern] for details.
327329

328330
The demos module has a complete example of a simple application: [StopWatchApp][StopWatchDemo].
329331

330332
### ImageDisplay Component
331333

332-
ImageDisplay Component is an image view with the ability to zoom in, zoom out, zoom to fit. It can also automatically resize
333-
to parent size.
334+
ImageDisplay Component is an image view with the ability to zoom in, zoom out, zoom to fit.
335+
It can also automatically resize to parent size (zoom-to-fit).
336+
Image cane also rotated and flipped along the X and Y axis.
337+
338+
ImageDisplay provides an option to show overlay on top of the image. Overlays scale and rotate with the image.
334339

335340
### Batch Processing and Progress Dialog
336341

337342
Work in progress
338-
* Helper UI for running batch processing tasks, see `BatchRunnerProgressDemoApp` for example of use
339-
* Component for display of progress of batch processing tasks, see `ProgressStatusDemoApp` for example of use
340343

344+
* Helper UI for running batch processing tasks, see `BatchRunnerProgressDemoApp` for example of use
345+
* Component for display of the progress of batch processing tasks, see `ProgressStatusDemoApp` for example of use
341346

342347
Demos
343348
-----
@@ -371,8 +376,8 @@ and [ShowMessageDemo Scala 3] files for details.
371376

372377
### ImageDisplay Demo
373378

374-
[ImageDisplayDemoApp][ImageDisplayDemo] a simple example of an application that can display images,
375-
with the ability to zoom in, zoom out, and fit to the current window, flip, and rotate the image.
379+
[ImageDisplayDemoApp][ImageDisplayDemo] a simple example of an application that can display images,
380+
with the ability to zoom in, zoom out, and fit to the current window, flip, and rotate the image.
376381
Illustrates use of the `ImageDisplay` component.
377382

378383
![Image Display Demo](notes/assets/ImageDisplayDemo.gif)
@@ -381,7 +386,7 @@ Illustrates use of the `ImageDisplay` component.
381386

382387
[BatchRunnerWithProgressDemoApp] demo of `BatchRunnerWithProgress` GUI.
383388

384-
![BatchRunnerWithProgress Demo](notes/assets/BatchRunnerProgressDemoApp.gif)
389+
![BatchRunnerWithProgress Demo](notes/assets/BatchRunnerProgressDemoApp.gif)
385390

386391

387392
Status

build.sbt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import scala.xml.{Node => XmlNode, NodeSeq => XmlNodeSeq, _}
99
// JAR_BUILT_BY - Name to be added to Jar metadata field "Built-By" (defaults to System.getProperty("user.name")
1010
//
1111

12-
val projectVersion = "0.10.1"
12+
val projectVersion = "0.10.1.4-SNAPSHOT"
1313
val versionTagDir = if (projectVersion.endsWith("SNAPSHOT")) "master" else "v." + projectVersion
14-
val _scalaVersions = Seq("3.3.4", "2.13.15", "2.12.20")
14+
val _scalaVersions = Seq("3.3.5", "2.13.16", "2.12.20")
1515
val _scalaVersion = _scalaVersions.head
1616

1717
ThisBuild / version := projectVersion
@@ -22,8 +22,8 @@ ThisBuild / organization := "org.scalafx"
2222
publishArtifact := false
2323
publish / skip := true
2424

25-
lazy val libEnumeratum = "com.beachape" %% "enumeratum" % "1.7.5"
26-
lazy val libLogbackClassic = "ch.qos.logback" % "logback-classic" % "1.5.11"
25+
lazy val libEnumeratum = "com.beachape" %% "enumeratum" % "1.7.6"
26+
lazy val libLogbackClassic = "ch.qos.logback" % "logback-classic" % "1.5.18"
2727
lazy val libParadise = "org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full
2828
lazy val libScalaLogging = "com.typesafe.scala-logging" %% "scala-logging" % "3.9.5"
2929
lazy val libScalaFX = "org.scalafx" %% "scalafx" % "23.0.1-R34"

notes/0.11.0.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## ScalaFX-Extras Release v.0.11.0
2+
3+
This is a feature release of [ScalaFX-Extras].
4+
5+
### New features
6+
7+
* ImageDisplay: add the ability to display simple overlays on top of the images [[#38]]
8+
9+
### API Breaking Changes
10+
11+
* ImageDisplay: `image` assignment is now an `Option`, the JavaFX `null` is not accepted
12+
* `imageDisplay.image = image` will need to be changed to `imageDisplay.setImage(image)` or `imageDisplay.image = Option(image)`
13+
* `imageDisplay.image = null` will need to be changed to `imageDisplay.image = None`
14+
15+
### Bug fixes
16+
17+
* ImageDisplay: fix some issues with "zoom-to-fit" and "flip" applied at the same time
18+
19+
To post questions, please use [Project Discussions][Discussions] or [ScalaFX Users Group][scalafx-users]
20+
21+
[ScalaFX-Extras]: https://github.com/scalafx/scalafx-extras
22+
23+
[Discussions]: https://github.com/scalafx/scalafx-extras/discussions
24+
25+
[scalafx-users]: https://groups.google.com/forum/#!forum/scalafx-users
26+
27+
28+
[#38]: https://github.com/scalafx/scalafx-extras/issues/31
29+
30+

project/build.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2011-2024, ScalaFX Project
2+
# Copyright (c) 2011-2025, ScalaFX Project
33
# All rights reserved.
44
#
55
# Redistribution and use in source and binary forms, with or without
@@ -24,5 +24,5 @@
2424
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2525
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2626
#
27-
sbt.version=1.10.3
27+
sbt.version=1.10.11
2828

project/sbt-sonatype.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// [https://github.com/xerial/sbt-sonatype]
2-
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.11.1")
3-
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")
2+
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.12.2")
3+
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.3.1")

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

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011-2024, ScalaFX Project
2+
* Copyright (c) 2011-2025, ScalaFX Project
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -32,24 +32,29 @@ import org.scalafx.extras.ShowMessage
3232
import scalafx.Includes.*
3333
import scalafx.application.JFXApp3
3434
import scalafx.application.JFXApp3.PrimaryStage
35+
import scalafx.beans.property.BooleanProperty
3536
import scalafx.collections.ObservableBuffer
37+
import scalafx.geometry.Orientation.Horizontal
3638
import scalafx.scene.Scene
3739
import scalafx.scene.control.*
3840
import scalafx.scene.image.Image
3941
import scalafx.scene.layout.{BorderPane, FlowPane}
42+
import scalafx.scene.paint.Color
43+
import scalafx.scene.shape.Rectangle
4044
import scalafx.stage.FileChooser
4145

4246
/**
4347
* Demonstrates use of `ImageDisplay` class.
4448
*/
4549
object ImageDisplayDemoApp extends JFXApp3 {
4650

47-
private val rotationItems = ObservableBuffer(0, 90, 180, 270)
51+
/** Show example ROI in the center of the Image */
52+
private val showROI: BooleanProperty = BooleanProperty(value = false)
53+
private val rotationItems = ObservableBuffer(0, 90, 180, 270)
4854

4955
override def start(): Unit = {
5056

5157
val imageDisplay = new ImageDisplay()
52-
// private var roi: Option[Rectangle] = None
5358

5459
stage = new PrimaryStage {
5560
scene = new Scene(640, 480) {
@@ -61,6 +66,7 @@ object ImageDisplayDemoApp extends JFXApp3 {
6166
new Button("Open...") {
6267
onAction = () => onFileOpen()
6368
},
69+
Separator(Horizontal),
6470
new Button("Zoom In") {
6571
onAction = () => imageDisplay.zoomIn()
6672
disable <== imageDisplay.zoomToFit
@@ -72,6 +78,7 @@ object ImageDisplayDemoApp extends JFXApp3 {
7278
new ToggleButton("Zoom to fit") {
7379
selected <==> imageDisplay.zoomToFit
7480
},
81+
Separator(Horizontal),
7582
new ToggleButton("Flip X") {
7683
selected <==> imageDisplay.flipX
7784
},
@@ -83,6 +90,10 @@ object ImageDisplayDemoApp extends JFXApp3 {
8390
imageDisplay.rotation = newValue
8491
}
8592
selectionModel().selectFirst()
93+
},
94+
Separator(Horizontal),
95+
new ToggleButton("Show ROI") {
96+
selected <==> showROI
8697
}
8798
)
8899
}
@@ -105,6 +116,33 @@ object ImageDisplayDemoApp extends JFXApp3 {
105116

106117
// setROI()
107118
// ---------------------------------------------------------------------------
119+
showROI.onChange { (_, _, _) =>
120+
updateROI()
121+
}
122+
123+
def updateROI(): Unit = {
124+
if (showROI())
125+
imageDisplay.image() match {
126+
case Some(im) =>
127+
val w = im.width.value
128+
val h = im.height.value
129+
val roi = new Rectangle {
130+
x = w / 4
131+
y = h / 4 + h / 8
132+
width = w / 2
133+
height = h / 4
134+
fill = Color(1, 1, 1, 0.5)
135+
stroke = Color.Yellow
136+
strokeWidth = 1
137+
}
138+
imageDisplay.overlays.value = Seq(roi)
139+
case None =>
140+
imageDisplay.overlays.value = Seq.empty[Rectangle]
141+
}
142+
else
143+
imageDisplay.overlays.value = Seq.empty[Rectangle]
144+
// imageView.scaleY.value = if (newValue) -v else v
145+
}
108146

109147
/**
110148
* Let user select an image file and load it.
@@ -116,7 +154,8 @@ object ImageDisplayDemoApp extends JFXApp3 {
116154
try {
117155
val image = new Image("file:" + file.getCanonicalPath)
118156
if (!image.error()) {
119-
imageDisplay.image() = image
157+
imageDisplay.setImage(image)
158+
updateROI()
120159
} else {
121160
image.exception().printStackTrace()
122161
ShowMessage.exception(
@@ -135,18 +174,8 @@ object ImageDisplayDemoApp extends JFXApp3 {
135174
t = ex,
136175
parentWindow = stage
137176
)
138-
139177
}
140178
}
141179
}
142-
143-
// private def setROI(): Unit = {
144-
// roi = roi match {
145-
// case Some(r) => None
146-
// case None => Some(Rectangle(278, 205, 37, 10))
147-
// }
148-
//
149-
// imageDisplay.roi() = roi
150-
// }
151180
}
152181
}

0 commit comments

Comments
 (0)