Skip to content

Commit 0b8bc33

Browse files
committed
Merge branch 'master' into release
2 parents 27a7e98 + 2161b93 commit 0b8bc33

File tree

22 files changed

+1363
-43
lines changed

22 files changed

+1363
-43
lines changed

.scalafmt.conf

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

33
runner.dialect = scala3
44
fileOverride {
@@ -8,6 +8,12 @@ fileOverride {
88
"glob:**/src/main/scala-2/**" {
99
runner.dialect = scala213source3
1010
}
11+
"glob:**/project/**.scala" {
12+
runner.dialect = scala213source3
13+
}
14+
"glob:**/**.sbt" {
15+
runner.dialect = scala213source3
16+
}
1117
}
1218

1319
preset = IntelliJ

ReadMe.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Extras do not have direct corresponding concepts in JavaFX.
2424
* [Example 2](#example-2)
2525
* [Simpler Use of FXML with MVCfx Pattern](#simpler-use-of-fxml-with-mvcfx-pattern)
2626
* [ImageDisplay Component](#imagedisplay-component)
27+
* [Batch Processing and Progress Dialog](#batch-processing-and-progress-dialog)
2728
* [Demos](#demos)
2829
* [StopWatch Application](#stopwatch-application)
2930
* [ShowMessage Demo](#showmessage-demo)
@@ -328,9 +329,15 @@ The demos module has a complete example of a simple application: [StopWatchApp][
328329

329330
### ImageDisplay Component
330331

331-
ImageDisplay Component is an image view with ability to zoom in, zoom out, zoom to fit. It can also automatically resize
332+
ImageDisplay Component is an image view with the ability to zoom in, zoom out, zoom to fit. It can also automatically resize
332333
to parent size.
333334

335+
### Batch Processing and Progress Dialog
336+
337+
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
340+
334341

335342
Demos
336343
-----
@@ -364,11 +371,19 @@ and [ShowMessageDemo Scala 3] files for details.
364371

365372
### ImageDisplay Demo
366373

367-
[ImageDisplayDemoApp][ImageDisplayDemo] a simple example of an application that can display images, with ability to zoom
368-
in, zoom out, and fit to current window. Illustrates use of the `ImageDisplay` component.
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.
376+
Illustrates use of the `ImageDisplay` component.
369377

370378
![Image Display Demo](notes/assets/ImageDisplayDemo.gif)
371379

380+
### BatchRunnerWithProgress Demo
381+
382+
[BatchRunnerWithProgressDemoApp] demo of `BatchRunnerWithProgress` GUI.
383+
384+
![BatchRunnerWithProgress Demo](notes/assets/BatchRunnerProgressDemoApp.gif)
385+
386+
372387
Status
373388
------
374389

@@ -406,6 +421,8 @@ BSD-3-Clause ScalaFX license.
406421

407422
[StopWatchDemo Scala 3]: scalafx-extras-demos/src/main/scala-3/org/scalafx/extras/mvcfx/stopwatch
408423

424+
[BatchRunnerWithProgressDemoApp]: scalafx-extras-demos/src/main/scala-3/org/scalafx/extras/batch/BatchRunnerWithProgressDemoApp.scala
425+
409426
[ScalaFX Users Group]: https://groups.google.com/forum/#!forum/scalafx-users
410427

411428
[Discussions]: https://github.com/scalafx/scalafx-extras/discussions

build.sbt

Lines changed: 5 additions & 5 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.9.0"
12+
val projectVersion = "0.9.0.6-SNAPSHOT"
1313
val versionTagDir = if (projectVersion.endsWith("SNAPSHOT")) "master" else "v." + projectVersion
14-
val _scalaVersions = Seq("3.3.3", "2.13.13", "2.12.19")
14+
val _scalaVersions = Seq("3.3.3", "2.13.14", "2.12.19")
1515
val _scalaVersion = _scalaVersions.head
1616

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

25-
lazy val libEnumeratum = "com.beachape" %% "enumeratum" % "1.7.3"
26-
lazy val libLogbackClassic = "ch.qos.logback" % "logback-classic" % "1.5.3"
25+
lazy val libEnumeratum = "com.beachape" %% "enumeratum" % "1.7.4"
26+
lazy val libLogbackClassic = "ch.qos.logback" % "logback-classic" % "1.5.6"
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" % "22.0.0-R33"
3030
lazy val libScalaFXML = "org.scalafx" %% "scalafxml-core-sfx8" % "0.5"
31-
lazy val libScalaTest = "org.scalatest" %% "scalatest" % "3.2.18"
31+
lazy val libScalaTest = "org.scalatest" %% "scalatest" % "3.2.19"
3232
lazy val libScalaReflect = "org.scala-lang" % "scala-reflect"
3333

3434
def isScala2(scalaVersion: String): Boolean = {

notes/0.10.0.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
## ScalaFX-Extras Release v.0.10.0
2+
3+
This release of [ScalaFX-Extras] is a feature release.
4+
5+
### New features
6+
7+
* Add component to display the progress of batch processing tasks [[#33]]
8+
* Add helper UI for running batch processing tasks [[#34]]
9+
* ShowMessage: allow for resizing all message dialogs [[#32]]
10+
* ImageDisplay: add an option to flip image in X or Z axis [[#35]]
11+
12+
### Bug fixes
13+
14+
* ShowMessage dialogs may display cropped messages [[#31]]
15+
16+
To post questions, please use [Project Discussions][Discussions] or [ScalaFX Users Group][scalafx-users]
17+
18+
[ScalaFX-Extras]: https://github.com/scalafx/scalafx-extras
19+
20+
[Discussions]: https://github.com/scalafx/scalafx-extras/discussions
21+
22+
[scalafx-users]: https://groups.google.com/forum/#!forum/scalafx-users
23+
24+
25+
[#31]: https://github.com/scalafx/scalafx-extras/issues/31
26+
27+
[#32]: https://github.com/scalafx/scalafx-extras/issues/32
28+
29+
[#33]: https://github.com/scalafx/scalafx-extras/issues/33
30+
31+
[#34]: https://github.com/scalafx/scalafx-extras/issues/34
32+
33+
[#35]: https://github.com/scalafx/scalafx-extras/issues/35
34+
35+
4.55 MB
Loading

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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.9.9
27+
sbt.version=1.10.1
2828

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Copyright (c) 2000-2023 Jarek Sacha. All Rights Reserved.
3+
* Author's e-mail: jpsacha at gmail.com
4+
*/
5+
6+
package org.scalafx.extras.batch
7+
8+
import org.scalafx.extras.BusyWorker
9+
import org.scalafx.extras.BusyWorker.SimpleTask
10+
import scalafx.application.JFXApp3
11+
import scalafx.application.JFXApp3.PrimaryStage
12+
import scalafx.geometry.Insets
13+
import scalafx.scene.Scene
14+
import scalafx.scene.control.{Button, Label}
15+
import scalafx.scene.layout.VBox
16+
import scalafx.stage.Window
17+
18+
import scala.util.Random
19+
20+
/**
21+
* Example of a task that for batch execution.
22+
*/
23+
private class MyTask(val i: Int) extends ItemTask[String] {
24+
25+
import MyTask.*
26+
27+
val name = s"Task #$i"
28+
29+
def run(): String =
30+
val t = minTime + new Random().nextInt(maxTime - minTime)
31+
Thread.sleep(t)
32+
if t % 6 != 0 then
33+
s"name t = $t"
34+
else
35+
throw new Exception(s"Do not like $t")
36+
}
37+
38+
object MyTask {
39+
val minTime = 500
40+
val maxTime = 1000
41+
}
42+
43+
/**
44+
* Demo of `BatchRunnerWithProgress` GUI
45+
* @author Jarek Sacha
46+
*/
47+
object BatchRunnerProgressDemoApp extends JFXApp3:
48+
49+
private lazy val busyWorker = new BusyWorker(Title, parentWindow)
50+
private val Title = "Batch Processing / Progress Dialog Demo"
51+
private val nTasks = 10
52+
53+
override def start(): Unit =
54+
stage = new PrimaryStage:
55+
title = Title
56+
scene = new Scene:
57+
content = new VBox:
58+
padding = Insets(21)
59+
spacing = 14
60+
children = Seq(
61+
new Label(
62+
s"""Press "Run x" to initiate processing.
63+
|Wait till processing finished or press "Abort".
64+
|There will be $nTasks processed.
65+
|Tasks will have randomly generated execution time,
66+
|between ${MyTask.minTime} and ${MyTask.maxTime} ms.
67+
|If task's time is divisible by 6, that task will fail.
68+
|""".stripMargin
69+
),
70+
new Button("Run as Sequence"):
71+
onAction = _ => onStart(false)
72+
prefWidth = 120
73+
,
74+
new Button("Run in Parallel"):
75+
onAction = _ => onStart(true)
76+
prefWidth = 120
77+
)
78+
79+
private def onStart(runInParallel: Boolean): Unit = busyWorker.doTask("Start") { () =>
80+
type ResultType = String
81+
val helper =
82+
new BatchRunnerWithProgress[ResultType]("Sample batch processing", Option(stage), runInParallel):
83+
def createTasks(): Seq[ItemTask[ResultType]] = (1 to nTasks).map { i => new MyTask(i) }
84+
85+
helper.run()
86+
}
87+
88+
private def parentWindow: Option[Window] = Option(stage)
89+
90+
end BatchRunnerProgressDemoApp
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* Copyright (c) 2011-2024, ScalaFX Project
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of the ScalaFX Project nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
* DISCLAIMED. IN NO EVENT SHALL THE SCALAFX PROJECT OR ITS CONTRIBUTORS BE LIABLE
20+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23+
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
package org.scalafx.extras.batch
29+
30+
import scala.util.{Failure, Success}
31+
32+
import scala.util.{Failure, Success, Try}
33+
34+
/**
35+
* Example of using `ParallelBatchRunner` and `ItemTask`.
36+
* Results are printed to standard output.
37+
*
38+
* @author Jarek Sacha
39+
*/
40+
object ParallelBatchRunnerDemo {
41+
private class DemoTaskItem(n: Int) extends ItemTask[Int] {
42+
val name = s"Demo TaskItem $n"
43+
44+
def run(): Int = {
45+
// println(s"Item ${n} - start")
46+
Thread.sleep(300)
47+
if n == 7 then
48+
// println(s"Item ${n} - error")
49+
throw new IllegalArgumentException(s"Don't give me $n")
50+
51+
// println(s"Item ${n} - end")
52+
n
53+
}
54+
}
55+
56+
def main(args: Array[String]): Unit = {
57+
val items: Seq[DemoTaskItem] = Range(0, 10).map { i => new DemoTaskItem(i) }
58+
59+
val batchHelper = new ParallelBatchRunner(items, progressUpdate, useParallelProcessing = true)
60+
61+
val results: Seq[(String, Try[Option[Int]])] = batchHelper.execute()
62+
63+
println()
64+
println("Summarize processing")
65+
results.foreach {
66+
case (name, Success(r)) => println(s"$name: SUCCESS: $r")
67+
case (name, Failure(e)) => println(s"$name: ERROR : ${e.getMessage}")
68+
}
69+
}
70+
71+
@FunctionalInterface
72+
private def progressUpdate(
73+
running: Long,
74+
successful: Long,
75+
failed: Long,
76+
canceled: Long,
77+
executed: Long,
78+
total: Long,
79+
isCanceled: Boolean,
80+
perc: Double,
81+
message: String
82+
): Unit = {
83+
val m =
84+
f"R:$running%2d, S:$successful%2d, F:$failed%2d, E:$executed%2d, C:$canceled, T:$total%d, " +
85+
f"C:$isCanceled, perc:${perc.toInt}%3d, $message"
86+
println(m)
87+
}
88+
}

0 commit comments

Comments
 (0)