commit 21/05/2025
This commit is contained in:
@@ -325,6 +325,7 @@ public class AutoCloseAlert {
|
||||
* @param alertStage the alert stage to be closed
|
||||
*/
|
||||
private static void closeAlertStage(int seconds, Consumer<String> onClose, Stage alertStage) {
|
||||
|
||||
if (seconds>0){
|
||||
PauseTransition delay = new PauseTransition(Duration.seconds(seconds));
|
||||
delay.setOnFinished(e -> {
|
||||
@@ -342,8 +343,7 @@ public class AutoCloseAlert {
|
||||
private static Image LoadImage(String filename){
|
||||
if (ValidFile(filename)){
|
||||
try{
|
||||
Image mm = new Image(Paths.get(filename).toUri().toString());
|
||||
return mm;
|
||||
return new Image(Paths.get(filename).toUri().toString());
|
||||
} catch (Exception e){
|
||||
Logger.error("Error loading image: " + filename+", Message: "+e.getMessage());
|
||||
}
|
||||
|
||||
@@ -152,11 +152,7 @@ public class CaptureView {
|
||||
isTakingPhoto.set(true);
|
||||
if (has_face){
|
||||
AutoCloseAlert.show("Pengambilan Foto", "Tahan Posisi Anda", "Proses ini kurang lebih 3 detik", 5, null);
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!Objects.equals(audioPlayer.getCurrentFile(), audio_tahan_posisi)){
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(500);
|
||||
audioPlayer.PlayFile(audio_tahan_posisi, new PlaybackStatus() {
|
||||
PlayFileWithEvent(audio_tahan_posisi, new PlaybackStatus() {
|
||||
@Override
|
||||
public void onPlaybackStarted(String filename) {
|
||||
|
||||
@@ -164,9 +160,8 @@ public class CaptureView {
|
||||
|
||||
@Override
|
||||
public void onPlaybackFinished(String filename) {
|
||||
|
||||
Wait(500);
|
||||
audioPlayer.PlayFile(audio_countdown, new PlaybackStatus() {
|
||||
PlayFileWithEvent(audio_countdown, new PlaybackStatus() {
|
||||
@Override
|
||||
public void onPlaybackStarted(String filename) {
|
||||
|
||||
@@ -182,8 +177,6 @@ public class CaptureView {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -192,20 +185,11 @@ public class CaptureView {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
AutoCloseAlert.show("Error", "No Face Detected", "No Face Detected", 5, null);
|
||||
isTakingPhoto.set(false);
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!Objects.equals(audioPlayer.getCurrentFile(),audio_posisikan_muka)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(500);
|
||||
audioPlayer.PlayFile(audio_posisikan_muka, null);
|
||||
}
|
||||
}
|
||||
|
||||
PlayFileWithoutEvent(audio_posisikan_muka);
|
||||
}
|
||||
} else {
|
||||
isTakingPhoto.set(false);
|
||||
@@ -215,14 +199,7 @@ public class CaptureView {
|
||||
AutoCloseAlert.showbanner(AutoCloseAlert.banner_01,0,null);
|
||||
}
|
||||
}
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!Objects.equals(audioPlayer.getCurrentFile(), audio_scan_barcode)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(500);
|
||||
audioPlayer.PlayFile(audio_scan_barcode, null);
|
||||
|
||||
}
|
||||
}
|
||||
PlayFileWithoutEvent(audio_scan_barcode);
|
||||
}
|
||||
} else {
|
||||
isTakingPhoto.set(false);
|
||||
@@ -264,7 +241,7 @@ public class CaptureView {
|
||||
AtomicInteger takephoto_failure_counter = new AtomicInteger(0);
|
||||
|
||||
private void take_photo_lanjutan(String directory, String prefix){
|
||||
audioPlayer.PlayFile(audio_camera_shutter, null);
|
||||
PlayFileWithoutEvent(audio_camera_shutter);
|
||||
Size thumbsize = new Size(160,120);
|
||||
|
||||
PhotoReviewClass prc = new PhotoReviewClass();
|
||||
@@ -337,21 +314,10 @@ public class CaptureView {
|
||||
String lowest_string = String.format("%.2f", lowest);
|
||||
AutoCloseAlert.show("Take Photos Failed", "Blurred Image Detected", "Blurred Image Detected at "+culprit+" with sharpness score "+lowest_string, 5, s -> isTakingPhoto.set(false));
|
||||
takephoto_failure_counter.incrementAndGet();
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (takephoto_failure_counter.get() < 2){
|
||||
if (!Objects.equals(audio_pengambilan_gagal, audioPlayer.getCurrentFile())){
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(500);
|
||||
audioPlayer.PlayFile(audio_pengambilan_gagal, null);
|
||||
}
|
||||
PlayFileWithoutEvent(audio_pengambilan_gagal);
|
||||
} else {
|
||||
if (!Objects.equals(audio_hubungi_staf_kami, audioPlayer.getCurrentFile())){
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(500);
|
||||
audioPlayer.PlayFile(audio_hubungi_staf_kami, null);
|
||||
}
|
||||
}
|
||||
|
||||
PlayFileWithoutEvent(audio_hubungi_staf_kami);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -513,11 +479,7 @@ public class CaptureView {
|
||||
|
||||
String[] files = prc.compressed();
|
||||
if (files.length>0){
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!Objects.equals(audioPlayer.getCurrentFile(),audio_pengambilan_berhasil)){
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(500);
|
||||
audioPlayer.PlayFile(audio_pengambilan_berhasil, new PlaybackStatus() {
|
||||
PlayFileWithEvent(audio_pengambilan_berhasil, new PlaybackStatus() {
|
||||
@Override
|
||||
public void onPlaybackStarted(String filename) {
|
||||
|
||||
@@ -533,26 +495,16 @@ public class CaptureView {
|
||||
if (runningTask!=null) runningTask.cancel(false);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlaybackFailure(String filename) {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!Objects.equals(audioPlayer.getCurrentFile(),audio_pengambilan_gagal)){
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(500);
|
||||
audioPlayer.PlayFile(audio_pengambilan_gagal, null);
|
||||
}
|
||||
}
|
||||
PlayFileWithoutEvent(audio_pengambilan_gagal);
|
||||
clear();
|
||||
if (runningTask!=null) runningTask.cancel(false);
|
||||
}
|
||||
@@ -593,13 +545,7 @@ public class CaptureView {
|
||||
uploadtask.setOnSucceeded(e-> clear());
|
||||
|
||||
uploadtask.setOnFailed(e-> {
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!Objects.equals(audioPlayer.getCurrentFile(), audio_upload_gagal)){
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(500);
|
||||
audioPlayer.PlayFile(audio_upload_gagal, null);
|
||||
}
|
||||
}
|
||||
PlayFileWithoutEvent(audio_upload_gagal);
|
||||
AutoCloseAlert.show("Upload Failed", "Upload Failed", "Upload Failed", 5, s -> clear());
|
||||
});
|
||||
|
||||
@@ -764,7 +710,12 @@ public class CaptureView {
|
||||
isTakingPhoto.set(false);
|
||||
TextAreaSetText(medicalRecordID,"");
|
||||
TextAreaSetText(PatientName,"");
|
||||
if (barcodeData.getText().isBlank()){
|
||||
// pancing supaya addlistener barcodeData trigger
|
||||
TextAreaSetText(barcodeData,"x");
|
||||
Wait(10);
|
||||
TextAreaSetText(barcodeData,"");
|
||||
} else TextAreaSetText(barcodeData,"");
|
||||
}
|
||||
|
||||
public void Unload(){
|
||||
@@ -896,18 +847,13 @@ public class CaptureView {
|
||||
// terakhir, PlayFile audio_hubungi_staf_kami
|
||||
|
||||
audioTimeline = new Timeline();
|
||||
int file_duration = 7; // audio_posisikan_muka durasi 7 detik
|
||||
audioTimeline.getKeyFrames().add(new KeyFrame(Duration.seconds(0), k1 ->{
|
||||
|
||||
}));
|
||||
audioTimeline.getKeyFrames().add(new KeyFrame(Duration.seconds(5+file_duration), k2 ->{
|
||||
|
||||
}));
|
||||
audioTimeline.getKeyFrames().add(new KeyFrame(Duration.seconds(10+file_duration), k3 ->{
|
||||
|
||||
}));
|
||||
int file_duration = 8; // audio_posisikan_muka durasi 7 detik
|
||||
audioTimeline.getKeyFrames().add(new KeyFrame(Duration.seconds(0), k1 -> PlayFileWithoutEvent(audio_posisikan_muka)));
|
||||
audioTimeline.getKeyFrames().add(new KeyFrame(Duration.seconds(5+file_duration), k2 -> PlayFileWithoutEvent(audio_posisikan_muka)));
|
||||
audioTimeline.getKeyFrames().add(new KeyFrame(Duration.seconds(10+file_duration), k3 -> PlayFileWithoutEvent(audio_posisikan_muka)));
|
||||
audioTimeline.getKeyFrames().add(new KeyFrame(Duration.seconds(15+file_duration), k4 ->{
|
||||
|
||||
PlayFileWithoutEvent(audio_hubungi_staf_kami);
|
||||
clear();
|
||||
}));
|
||||
|
||||
|
||||
@@ -955,7 +901,6 @@ public class CaptureView {
|
||||
|
||||
if (audioTimeline!=null) audioTimeline.play();
|
||||
|
||||
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!Objects.equals(audioPlayer.getCurrentFile(),audio_posisikan_muka)) {
|
||||
if (!anti_bawel.get()){
|
||||
@@ -996,12 +941,7 @@ public class CaptureView {
|
||||
});
|
||||
|
||||
checkpatientID.setOnFailed(event -> {
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!Objects.equals(audioPlayer.getCurrentFile(), audio_data_barcode_tidak_ditemukan)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
audioPlayer.PlayFile(audio_data_barcode_tidak_ditemukan,null);
|
||||
}
|
||||
}
|
||||
PlayFileWithoutEvent(audio_data_barcode_tidak_ditemukan);
|
||||
Task<?> failed = (Task<?>) event.getSource();
|
||||
Throwable t = failed.getException();
|
||||
final String message = t.getMessage();
|
||||
@@ -1035,14 +975,11 @@ public class CaptureView {
|
||||
|
||||
// instruksi scan barcode ketika welcomeUI masih muncul dan ada muka terdeteksi
|
||||
if (hasface && Objects.equals(AutoCloseAlert.shownBanner, AutoCloseAlert.banner_01)){
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!Objects.equals(audioPlayer.getCurrentFile(), audio_scan_barcode)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
if (anti_bawel.get()) return;
|
||||
audioPlayer.PlayFile(audio_scan_barcode, new PlaybackStatus() {
|
||||
PlayFileWithEvent(audio_scan_barcode, new PlaybackStatus() {
|
||||
@Override
|
||||
public void onPlaybackStarted(String filename) {
|
||||
anti_bawel.set(true);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1057,17 +994,15 @@ public class CaptureView {
|
||||
antibawel.setName("anti bawel");
|
||||
antibawel.setDaemon(true);
|
||||
antibawel.start();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlaybackFailure(String filename) {
|
||||
anti_bawel.set(false);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1210,4 +1145,24 @@ public class CaptureView {
|
||||
Sqlite sql = new Sqlite();
|
||||
sql.Insert(prc);
|
||||
}
|
||||
|
||||
private void PlayFileWithoutEvent(String filename){
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!Objects.equals(audioPlayer.getCurrentFile(),filename)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(500);
|
||||
audioPlayer.PlayFile(filename, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayFileWithEvent(String filename, PlaybackStatus ps){
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!Objects.equals(audioPlayer.getCurrentFile(),filename)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(500);
|
||||
audioPlayer.PlayFile(filename, ps);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class MainApplication extends Application {
|
||||
Screen screen = Screen.getPrimary();
|
||||
Rectangle2D screenbound = screen.getBounds();
|
||||
Scene scene = new Scene(fxmlLoader.load(), screenbound.getWidth(), screenbound.getHeight());
|
||||
stage.setTitle("MultiCam Capture App for ERHA 19052025-001");
|
||||
stage.setTitle("MultiCam Capture App for ERHA 20052025-001");
|
||||
stage.setScene(scene);
|
||||
stage.setResizable(true);
|
||||
stage.setMaximized(true);
|
||||
|
||||
Reference in New Issue
Block a user