commit 09/04/2025
This commit is contained in:
@@ -8,8 +8,12 @@ import javafx.scene.Scene;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Circle;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Screen;
|
||||
import javafx.stage.Stage;
|
||||
@@ -32,6 +36,11 @@ public class AutoCloseAlert {
|
||||
public static Image shownBanner = null;
|
||||
public static Image banner_01;
|
||||
public static Image banner_02;
|
||||
private static Circle Cam1;
|
||||
private static Circle Cam2;
|
||||
private static Circle Cam3;
|
||||
private static Circle Cam4;
|
||||
private static Circle Cam5;
|
||||
|
||||
public static void init(){
|
||||
String f_01 = ExtractResource("/IU photoboth-01.jpg");
|
||||
@@ -42,6 +51,29 @@ public class AutoCloseAlert {
|
||||
if (banner_01!=null) System.out.println("Banner 01 loaded"); else System.out.println("Banner 01 not loaded");
|
||||
banner_02 = LoadImage(f_02);
|
||||
if (banner_02!=null) System.out.println("Banner 02 loaded"); else System.out.println("Banner 02 not loaded");
|
||||
Cam1 = new Circle(10, Color.RED);
|
||||
Cam2 = new Circle(10, Color.RED);
|
||||
Cam3 = new Circle(10, Color.RED);
|
||||
Cam4 = new Circle(10, Color.RED);
|
||||
Cam5 = new Circle(10, Color.RED);
|
||||
}
|
||||
|
||||
public static void ChangeCamStatus(int id, boolean active){
|
||||
Circle x = switch (id){
|
||||
case 1 -> Cam1;
|
||||
case 2 -> Cam2;
|
||||
case 3 -> Cam3;
|
||||
case 4 -> Cam4;
|
||||
case 5 -> Cam5;
|
||||
default -> null;
|
||||
};
|
||||
if (x!=null){
|
||||
if (active){
|
||||
x.setFill(Color.GREEN);
|
||||
} else {
|
||||
x.setFill(Color.RED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,10 +95,16 @@ public class AutoCloseAlert {
|
||||
* @param onClose What to do after auto close
|
||||
*/
|
||||
public static void show(String title, String content, int seconds, Consumer<String> onClose){
|
||||
Platform.runLater(()->{
|
||||
if (Platform.isFxApplicationThread()){
|
||||
Stage alertStage = _showtext(title, "", content);
|
||||
closeAlertStage(seconds, onClose, alertStage);
|
||||
});
|
||||
} else {
|
||||
Platform.runLater(()->{
|
||||
Stage alertStage = _showtext(title, "", content);
|
||||
closeAlertStage(seconds, onClose, alertStage);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -82,17 +120,34 @@ public class AutoCloseAlert {
|
||||
* @param onClose What to do after auto close
|
||||
*/
|
||||
public static void show(String title, String header, String content, int seconds, Consumer<String> onClose) {
|
||||
Platform.runLater(()->{
|
||||
if (Platform.isFxApplicationThread()){
|
||||
Stage alertStage = _showtext(title, header, content);
|
||||
closeAlertStage(seconds, onClose, alertStage);
|
||||
});
|
||||
} else {
|
||||
Platform.runLater(()->{
|
||||
Stage alertStage = _showtext(title, header, content);
|
||||
closeAlertStage(seconds, onClose, alertStage);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a banner image
|
||||
* @param b1 Image to show
|
||||
* @param seconds the number of seconds before the alert is closed, or put 0 to keep it open
|
||||
* @param onClose What to do after auto close
|
||||
*/
|
||||
public static void showbanner(Image b1, int seconds, Consumer<String> onClose){
|
||||
Platform.runLater(()->{
|
||||
if (Platform.isFxApplicationThread()){
|
||||
Stage alertStage = _showbanner(b1);
|
||||
closeAlertStage(seconds, onClose, alertStage);
|
||||
});
|
||||
} else {
|
||||
Platform.runLater(()->{
|
||||
Stage alertStage = _showbanner(b1);
|
||||
closeAlertStage(seconds, onClose, alertStage);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static Stage _showbanner(Image image){
|
||||
@@ -103,24 +158,41 @@ public class AutoCloseAlert {
|
||||
alertStage.initStyle(StageStyle.UTILITY);
|
||||
alertStage.setAlwaysOnTop(true);
|
||||
alertStage.setResizable(false);
|
||||
//System.out.println("_showbanner creating stage");
|
||||
int width = (int) Screen.getPrimary().getBounds().getWidth();
|
||||
int height = (int) Screen.getPrimary().getBounds().getHeight();
|
||||
|
||||
BorderPane borderPane = new BorderPane();
|
||||
|
||||
StackPane stackPane = new StackPane();
|
||||
|
||||
if (image!=null){
|
||||
ImageView imageView = new ImageView(image);
|
||||
imageView.setPreserveRatio(true);
|
||||
imageView.setFitWidth(1280);
|
||||
imageView.setFitWidth(width);
|
||||
imageView.setSmooth(true);
|
||||
StackPane stackPane = new StackPane(imageView);
|
||||
alertStage.setScene(new Scene(stackPane, 1280, 720));
|
||||
//System.out.println("_showbanner setscene");
|
||||
} //else System.out.println("_showbanner not setscene because image is null");
|
||||
stackPane.getChildren().add(imageView);
|
||||
}
|
||||
HBox CamStatus = new HBox(30, Cam1, Cam2, Cam3, Cam4, Cam5);
|
||||
CamStatus.setMinHeight(60);
|
||||
CamStatus.setAlignment(Pos.CENTER);
|
||||
|
||||
VBox vBox = new VBox(CamStatus);
|
||||
vBox.setAlignment(Pos.BOTTOM_CENTER);
|
||||
|
||||
stackPane.getChildren().add(vBox);
|
||||
|
||||
borderPane.setCenter(stackPane);
|
||||
|
||||
alertStage.setScene(new Scene(borderPane, width, height));
|
||||
alertStage.centerOnScreen();
|
||||
alertStage.show();
|
||||
//System.out.println("_showbanner show stage");
|
||||
|
||||
currentAlertStage = alertStage;
|
||||
shownBanner = image;
|
||||
CamStatus.prefWidthProperty().bind(currentAlertStage.widthProperty());
|
||||
|
||||
|
||||
|
||||
shownTitle = "";
|
||||
shownContent = "";
|
||||
shownHeader = "";
|
||||
@@ -147,20 +219,22 @@ public class AutoCloseAlert {
|
||||
alertStage.setAlwaysOnTop(true);
|
||||
alertStage.setResizable(false);
|
||||
|
||||
double screenwidth = Screen.getPrimary().getVisualBounds().getWidth();
|
||||
double width = screenwidth/4;
|
||||
double height = width * 9 / 16;
|
||||
double screenwidth = Screen.getPrimary().getBounds().getWidth();
|
||||
double screenheight = Screen.getPrimary().getBounds().getHeight();
|
||||
|
||||
double height = screenheight/4;
|
||||
double width = height * 21/9;
|
||||
|
||||
List<Node> children = new ArrayList<>();
|
||||
if (ValidString(header)){
|
||||
Label headerLabel = new Label(header);
|
||||
headerLabel.setStyle("-fx-font-weight: bold; -fx-font-size: 16px;");
|
||||
headerLabel.setStyle("-fx-font-weight: bold; -fx-font-size: 28px;");
|
||||
headerLabel.setMinHeight(height*0.25);
|
||||
children.add(headerLabel);
|
||||
}
|
||||
if (ValidString(content)){
|
||||
Label contentLabel = new Label(content);
|
||||
contentLabel.setStyle("-fx-font-size: 12px;");
|
||||
contentLabel.setStyle("-fx-font-size: 24px;");
|
||||
contentLabel.setMinHeight(height*0.75);
|
||||
children.add(contentLabel);
|
||||
}
|
||||
@@ -174,6 +248,11 @@ public class AutoCloseAlert {
|
||||
|
||||
alertStage.setTitle(title);
|
||||
|
||||
double x = screenwidth/2 - width/2;
|
||||
double y = screenheight - height - 10;
|
||||
alertStage.setX(x);
|
||||
alertStage.setY(y);
|
||||
|
||||
alertStage.show();
|
||||
currentAlertStage = alertStage;
|
||||
shownHeader = ValidString(header) ? header : "";
|
||||
|
||||
Reference in New Issue
Block a user