commit 25/07/2025
This commit is contained in:
Binary file not shown.
@@ -12,6 +12,7 @@ import javafx.scene.control.TextField;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.PixelFormat;
|
||||
import javafx.scene.image.WritableImage;
|
||||
import javafx.stage.Stage;
|
||||
import lombok.NonNull;
|
||||
import org.bytedeco.javacv.Frame;
|
||||
import org.bytedeco.javacv.Java2DFrameConverter;
|
||||
@@ -42,6 +43,7 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static org.bytedeco.opencv.global.opencv_core.CV_64F;
|
||||
@@ -879,4 +881,30 @@ public class SomeCodes {
|
||||
mat.data().get(data);
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Close Stage if not null
|
||||
* and wait until closed
|
||||
* @param obj Stage object to close
|
||||
*/
|
||||
public static void closeStage(Stage obj) throws InterruptedException {
|
||||
if (obj != null) {
|
||||
if (Platform.isFxApplicationThread()) {
|
||||
// Already on FX thread, just close directly
|
||||
obj.close();
|
||||
} else {
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
Platform.runLater(() -> {
|
||||
try {
|
||||
obj.close();
|
||||
} finally {
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
// Wait for runLater task to finish
|
||||
latch.await();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.tinylog.Logger;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static Config.SomeCodes.*;
|
||||
@@ -84,8 +83,16 @@ public class AutoCloseAlert {
|
||||
* Close the current alert if it is shown
|
||||
*/
|
||||
public static void close(){
|
||||
Optional.ofNullable(currentAlertStage).ifPresent(Stage::close);
|
||||
if (currentAlertStage!=null){
|
||||
try {
|
||||
closeStage(currentAlertStage);
|
||||
} catch (InterruptedException e) {
|
||||
Logger.error("Error closing alert stage: " + e.getMessage());
|
||||
}
|
||||
currentAlertStage = null;
|
||||
}
|
||||
|
||||
|
||||
clear();
|
||||
}
|
||||
|
||||
@@ -188,7 +195,12 @@ public class AutoCloseAlert {
|
||||
timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(0), event -> alertStage.show()));
|
||||
|
||||
timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(seconds* (pictures.length)), event -> {
|
||||
alertStage.close();
|
||||
try {
|
||||
closeStage(alertStage);
|
||||
} catch (InterruptedException e) {
|
||||
Logger.error("Error closing alert stage: " + e.getMessage());
|
||||
}
|
||||
//alertStage.close();
|
||||
if (currentAlertStage == alertStage) {
|
||||
currentAlertStage = null;
|
||||
}
|
||||
@@ -329,7 +341,12 @@ public class AutoCloseAlert {
|
||||
if (seconds>0){
|
||||
PauseTransition delay = new PauseTransition(Duration.seconds(seconds));
|
||||
delay.setOnFinished(e -> {
|
||||
alertStage.close();
|
||||
try {
|
||||
closeStage(alertStage);
|
||||
} catch (InterruptedException err) {
|
||||
Logger.error("Error closing alert stage: " + err.getMessage());
|
||||
}
|
||||
//alertStage.close();
|
||||
if (currentAlertStage == alertStage) {
|
||||
currentAlertStage = null;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import static Config.SomeCodes.config;
|
||||
|
||||
public class MainApplication extends Application {
|
||||
|
||||
final String version = "10072025-PRODUCTION-1.0.2";
|
||||
final String version = "10072025-PRODUCTION-1.0.3";
|
||||
PhotoCleaner photoCleaner;
|
||||
public static Map<Integer, Detectors> detectorsList = new HashMap<>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user