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