Uploaded by gurbanovdavut

Full Code

advertisement
package com.example.hackathon;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.PauseTransition;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.fxml.FXML;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.effect.DropShadow;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import javafx.util.Duration;
import java.io.*;
import java.util.ArrayList;
import java.util.Scanner;
public class Main extends Application {
@FXML
private Button yesButton1;
@FXML
private Button yesButton2;
@FXML
private Button yesButton3 = new Button();
@FXML
private Button noButton1;
@FXML
private Button noButton2;
@FXML
private Button noButton3 = new Button();
final private ProgressIndicator progressIndicator = new ProgressIndicator();
int count = 0;
int k = 0;
private final String[][] foodOption = {
{"Chicken Broth", "Mergemek", "Lentil soup"},
{"Tacos", "Chiken Briany", "Chicken Takamasala"},
{"Candy", "Apple pie", "Wedding cake"},
{"Olives", "Cucumber", "Watermelon"},
{"Samsa", "Stake", "Plov"},
{"Greek salad", "Smoked salad", "Cezar salad"},
{"Fries", "Chicken nuggets", "American burger"},
{"Cookie", "Cinamon roles", "Berry pie"}
};
Label thirdQuestionLabel = new Label("Do you want something random");
ImageView tray3 = new ImageView();
ImageView tray6 = new ImageView();
Scanner scanner = new Scanner(System.in);
final ArrayList<String> smth= new ArrayList<String>();
@Override
public void start(Stage primaryStage) {
BorderPane root = new BorderPane();
root.setMaxHeight(Double.NEGATIVE_INFINITY);
root.setMaxWidth(Double.NEGATIVE_INFINITY);
root.setMinHeight(Double.NEGATIVE_INFINITY);
root.setMinWidth(Double.NEGATIVE_INFINITY);
root.setPrefHeight(852.0);
root.setPrefWidth(1193.0);
BorderPane leftPane = new BorderPane();
leftPane.setPrefHeight(852.0);
leftPane.setPrefWidth(367.0);
leftPane.setStyle("-fx-background-color: #D4AF37;");
BorderPane.setAlignment(leftPane, Pos.CENTER);
Label titleLabel = new Label("FoodPicker");
titleLabel.setAlignment(Pos.CENTER);
titleLabel.setPrefHeight(117.0);
titleLabel.setPrefWidth(381.0);
titleLabel.setTextFill(Color.valueOf("#fffdfd"));
BorderPane.setAlignment(titleLabel, Pos.CENTER);
titleLabel.setFont(new Font("Songti SC Black", 64.0));
titleLabel.setEffect(new DropShadow());
Line topLine = new Line();
topLine.setEndX(207.9317626953125);
topLine.setFill(Color.WHITE);
topLine.setStartX(-127.0);
topLine.setStroke(Color.WHITE);
topLine.setStrokeWidth(6.0);
topLine.setTranslateY(462.0);
BorderPane.setAlignment(topLine, Pos.CENTER);
topLine.setEffect(new DropShadow());
Label bottomLabel = new Label("Copyright © . All rights reserved");
bottomLabel.setAlignment(Pos.CENTER);
bottomLabel.setContentDisplay(ContentDisplay.CENTER);
bottomLabel.setPrefHeight(17.0);
bottomLabel.setPrefWidth(197.0);
bottomLabel.setTextFill(Color.WHITE);
bottomLabel.setTranslateY(-13.0);
BorderPane.setAlignment(bottomLabel, Pos.CENTER);
bottomLabel.setEffect(new DropShadow());
leftPane.setCenter(titleLabel);
leftPane.setTop(topLine);
leftPane.setBottom(bottomLabel);
root.setLeft(leftPane);
AnchorPane centerPane = new AnchorPane();
centerPane.setPrefHeight(539.0);
centerPane.setPrefWidth(510.0);
BorderPane.setAlignment(centerPane, Pos.CENTER);
ImageView chefImageView = new ImageView();
chefImageView.setFitHeight(848.0);
chefImageView.setFitWidth(829.0);
chefImageView.setLayoutX(-1.0);
chefImageView.setLayoutY(3.0);
// Provide the absolute path to the "Chef.png" file
String imagePath = "/Users/davutgurbanov/Desktop/Chef.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath));
chefImageView.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Button eatButton = new Button("Eat!");
eatButton.setAlignment(Pos.CENTER);
eatButton.setLayoutX(526.0);
eatButton.setLayoutY(229.0);
eatButton.setMnemonicParsing(false);
eatButton.setPrefHeight(80.0);
eatButton.setPrefWidth(189.0);
eatButton.setStyle("-fx-background-color: #D4AF37;");
eatButton.setTextFill(Color.valueOf("#fffefe"));
eatButton.setFont(new Font("Verdana Bold", 24.0));
eatButton.setEffect(new DropShadow());
eatButton.setOnAction(e -> changeToNextScene(primaryStage));
centerPane.getChildren().addAll(chefImageView, eatButton);
root.setCenter(centerPane);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
//************************************************************************************
// Method to change the scene to another
private void changeToNextScene(Stage primaryStage) {
BorderPane root = new BorderPane();
root.setPrefSize(1193, 852);
BorderPane leftPane = new BorderPane();
leftPane.setPrefSize(367, 852);
leftPane.setStyle("-fx-background-color: #D4AF37;");
Label label = new Label("How do you want to\n pick your food?");
label.setPrefSize(367, 115);
label.setTextFill(javafx.scene.paint.Color.WHITE);
label.setFont(Font.font("Songti SC Black", 40));
label.setAlignment(Pos.CENTER);
label.setEffect(new DropShadow());
Line line = new Line(-127, 0, 207.93, 0);
line.setFill(javafx.scene.paint.Color.WHITE);
line.setStroke(javafx.scene.paint.Color.WHITE);
line.setStrokeWidth(6);
line.setTranslateY(490);
line.setEffect(new DropShadow());
Label copyrightLabel = new Label("Copyright © . All rights reserved");
copyrightLabel.setPrefSize(197, 17);
copyrightLabel.setTextFill(javafx.scene.paint.Color.WHITE);
copyrightLabel.setAlignment(Pos.CENTER);
copyrightLabel.setContentDisplay(javafx.scene.control.ContentDisplay.CENTER);
copyrightLabel.setTranslateY(-13);
copyrightLabel.setEffect(new DropShadow());
leftPane.setCenter(label);
leftPane.setTop(line);
leftPane.setBottom(copyrightLabel);
AnchorPane centerPane = new AnchorPane();
centerPane.setPrefSize(510, 539);
centerPane.setStyle("-fx-background-color: white;");
ImageView rightChefImage = new ImageView();
rightChefImage.setFitWidth(739);
rightChefImage.setFitHeight(397);
rightChefImage.setLayoutX(156);
rightChefImage.setLayoutY(456);
String imagePath2 = "/Users/davutgurbanov/Desktop/rightChef.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath2));
rightChefImage.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
ImageView leftChefImage = new ImageView();
leftChefImage.setFitWidth(721);
leftChefImage.setFitHeight(427);
leftChefImage.setLayoutX(11);
leftChefImage.setLayoutY(16);
String leftChefImagePath = "/Users/davutgurbanov/Desktop/leftChef.jpg";
try {
Image chefImage = new Image(new FileInputStream(leftChefImagePath));
leftChefImage.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Button questionnaireButton = new Button("Questionnaire");
questionnaireButton.setPrefSize(189, 80);
questionnaireButton.setStyle("-fx-background-color: #D4AF37;");
questionnaireButton.setTextFill(javafx.scene.paint.Color.web("#fffefe"));
questionnaireButton.setFont(Font.font("Verdana Bold", 20));
questionnaireButton.setAlignment(Pos.CENTER);
questionnaireButton.setEffect(new DropShadow());
questionnaireButton.setLayoutX(347);
questionnaireButton.setLayoutY(173);
questionnaireButton.setOnAction(e -> changeToQuestionnaireSceneImpl(primaryStage));
Button randomButton = new Button("Random");
randomButton.setPrefSize(189, 80);
randomButton.setStyle("-fx-background-color: #D4AF37;");
randomButton.setTextFill(javafx.scene.paint.Color.web("#fffefe"));
randomButton.setFont(Font.font("Verdana Bold", 24));
randomButton.setAlignment(Pos.CENTER);
randomButton.setEffect(new DropShadow());
randomButton.setLayoutX(305);
randomButton.setLayoutY(568);
randomButton.setTranslateX(52);
randomButton.setTranslateY(15);
randomButton.setOnAction(e -> changeToRandomScene(primaryStage));
centerPane.getChildren().addAll(leftChefImage, rightChefImage, questionnaireButton, randomButton);
root.setLeft(leftPane);
root.setCenter(centerPane);
primaryStage.setScene(new Scene(root));
primaryStage.show();
// Delay the progress indicator for 7 seconds
PauseTransition delay = new PauseTransition(Duration.seconds(7));
delay.setOnFinished(event -> progressIndicator.setProgress(0.0));
delay.play();
}
//************************************************************************************
//changeToQuestionnaireScene
public void changeToQuestionnaireSceneImpl(Stage primaryStage) {
BorderPane root3 = new BorderPane();
root3.setMaxHeight(Double.POSITIVE_INFINITY);
root3.setMaxWidth(Double.POSITIVE_INFINITY);
root3.setMinHeight(Double.NEGATIVE_INFINITY);
root3.setMinWidth(Double.NEGATIVE_INFINITY);
root3.setPrefHeight(852.0);
root3.setPrefWidth(1193.0);
// Left Pane
BorderPane leftPane = new BorderPane();
leftPane.setPrefHeight(852.0);
leftPane.setPrefWidth(367.0);
leftPane.setStyle("-fx-background-color: #D4AF37;");
BorderPane.setAlignment(leftPane, Pos.CENTER);
// Centered Label
Label centeredLabel = new Label("FoodPicker");
centeredLabel.setAlignment(Pos.CENTER);
centeredLabel.setPrefHeight(117.0);
centeredLabel.setPrefWidth(357.0);
centeredLabel.setTextFill(Color.WHITE);
BorderPane.setAlignment(centeredLabel, Pos.CENTER);
Font font = new Font("Songti SC Black", 64.0);
centeredLabel.setFont(font);
DropShadow dropShadow = new DropShadow();
centeredLabel.setEffect(dropShadow);
leftPane.setCenter(centeredLabel);
// Top Line
Line topLine = new Line(-127.0, 462.0, 207.9317626953125, 462.0);
topLine.setFill(Color.WHITE);
topLine.setStroke(Color.WHITE);
topLine.setStrokeWidth(6.0);
BorderPane.setAlignment(topLine, Pos.CENTER);
dropShadow = new DropShadow();
topLine.setEffect(dropShadow);
leftPane.setTop(topLine);
// Bottom Label
Label bottomLabel = new Label("Copyright © . All rights reserved");
bottomLabel.setAlignment(Pos.CENTER);
bottomLabel.setContentDisplay(ContentDisplay.CENTER);
bottomLabel.setPrefHeight(17.0);
bottomLabel.setPrefWidth(197.0);
bottomLabel.setTextFill(Color.WHITE);
bottomLabel.setTranslateY(-13.0);
BorderPane.setAlignment(bottomLabel, Pos.CENTER);
dropShadow = new DropShadow();
bottomLabel.setEffect(dropShadow);
leftPane.setBottom(bottomLabel);
root3.setLeft(leftPane);
// Center Pane
AnchorPane centerPane = new AnchorPane();
centerPane.setPrefHeight(539.0);
centerPane.setPrefWidth(510.0);
BorderPane.setAlignment(centerPane, Pos.CENTER);
ImageView backgroundIm = new ImageView();
backgroundIm.setFitHeight(856.0);
backgroundIm.setFitWidth(829.0);
backgroundIm.setLayoutX(-4.0);
backgroundIm.setLayoutY(-2.0);
backgroundIm.setOpacity(0.76);
String imagePath = "/Users/davutgurbanov/Desktop/backImage.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath));
backgroundIm.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
centerPane.getChildren().add(backgroundIm);
Label firstQuestion = new Label("Choose your portion size");
firstQuestion.setId("firstQuestion");
firstQuestion.setAlignment(Pos.CENTER);
firstQuestion.setLayoutX(62.0);
firstQuestion.setLayoutY(62.0);
firstQuestion.setPrefHeight(68.0);
firstQuestion.setPrefWidth(719.0);
firstQuestion.setStyle("-fx-background-color: #D4AF37;");
firstQuestion.setTextFill(Color.WHITE);
font = new Font("Verdana Bold", 29.0);
firstQuestion.setFont(font);
dropShadow = new DropShadow();
firstQuestion.setEffect(dropShadow);
centerPane.getChildren().add(firstQuestion);
Button nextButton = new Button("Next");
nextButton.setLayoutX(673.0);
nextButton.setLayoutY(674.0);
nextButton.setMnemonicParsing(false);
nextButton.setPrefHeight(142.0);
nextButton.setPrefWidth(112.0);
nextButton.setStyle("-fx-background-color: #D4AF37;");
nextButton.setTextFill(Color.WHITE);
nextButton.setOnAction(e -> changeToQ2Scene(primaryStage));
centerPane.getChildren().add(nextButton);
font = new Font("Verdana Bold", 25.0);
nextButton.setFont(font);
dropShadow = new DropShadow();
nextButton.setEffect(dropShadow);
Button smallButton = new Button("Small");
smallButton.setId("smallButton");
smallButton.setLayoutX(85.0);
smallButton.setLayoutY(286.0);
smallButton.setMnemonicParsing(false);
smallButton.setPrefHeight(131.0);
smallButton.setPrefWidth(156.0);
smallButton.setStyle("-fx-background-color: #D4AF37;");
smallButton.setTextFill(Color.WHITE);
smallButton.setOnAction(event -> k = 0);
font = new Font("Verdana Bold", 25.0);
smallButton.setFont(font);
dropShadow = new DropShadow();
smallButton.setEffect(dropShadow);
Button mediumButton = new Button("Medium");
mediumButton.setLayoutX(327.0);
mediumButton.setLayoutY(277.0);
mediumButton.setMnemonicParsing(false);
mediumButton.setPrefHeight(131.0);
mediumButton.setPrefWidth(156.0);
mediumButton.setStyle("-fx-background-color: #D4AF37;");
mediumButton.setTextFill(Color.WHITE);
mediumButton.setOnAction(event -> k = 1);
font = new Font("Verdana Bold", 25.0);
mediumButton.setFont(font);
dropShadow = new DropShadow();
mediumButton.setEffect(dropShadow);
Button largeButton = new Button("Large");
largeButton.setLayoutX(572.0);
largeButton.setLayoutY(281.0);
largeButton.setMnemonicParsing(false);
largeButton.setPrefHeight(131.0);
largeButton.setPrefWidth(156.0);
largeButton.setStyle("-fx-background-color: #D4AF37;");
largeButton.setTextFill(Color.WHITE);
largeButton.setOnAction(event -> k = 2);
font = new Font("Verdana Bold", 25.0);
largeButton.setFont(font);
dropShadow = new DropShadow();
largeButton.setEffect(dropShadow);
// Add event handler for the "Small" button
smallButton.setOnAction(e -> {
// Reset the background color for all buttons
smallButton.setStyle("-fx-background-color: #D4AF37;");
mediumButton.setStyle("-fx-background-color: #D4AF37;");
largeButton.setStyle("-fx-background-color: #D4AF37;");
// Highlight the "Small" button
smallButton.setStyle("-fx-background-color: green;");
});
centerPane.getChildren().add(smallButton);
// Add event handler for the "Medium" button
mediumButton.setOnAction(e -> {
// Reset the background color for all buttons
smallButton.setStyle("-fx-background-color: #D4AF37;");
mediumButton.setStyle("-fx-background-color: #D4AF37;");
largeButton.setStyle("-fx-background-color: #D4AF37;");
// Highlight the "Medium" button
mediumButton.setStyle("-fx-background-color: green;");
});
centerPane.getChildren().add(mediumButton);
// Add event handler for the "Large" button
largeButton.setOnAction(e -> {
// Reset the background color for all buttons
smallButton.setStyle("-fx-background-color: #D4AF37;");
mediumButton.setStyle("-fx-background-color: #D4AF37;");
largeButton.setStyle("-fx-background-color: #D4AF37;");
// Highlight the "Large" button
largeButton.setStyle("-fx-background-color: green;");
});
centerPane.getChildren().add(largeButton);
root3.setCenter(centerPane);
Scene scene3 = new Scene(root3);
primaryStage.setScene(scene3);
primaryStage.setTitle("Questionnaire Scene");
primaryStage.show();
}
//************************************************************************************
public void changeToRandomScene(Stage primaryStage) {
BorderPane root = new BorderPane();
root.setMaxHeight(Double.NEGATIVE_INFINITY);
root.setMaxWidth(Double.NEGATIVE_INFINITY);
root.setMinHeight(Double.NEGATIVE_INFINITY);
root.setMinWidth(Double.NEGATIVE_INFINITY);
root.setPrefHeight(852.0);
root.setPrefWidth(1193.0);
BorderPane leftPane = new BorderPane();
leftPane.setPrefHeight(852.0);
leftPane.setPrefWidth(367.0);
leftPane.setStyle("-fx-background-color: #D4AF37;");
BorderPane.setAlignment(leftPane, javafx.geometry.Pos.CENTER);
Label titleLabel = new Label("FoodPicker");
titleLabel.setPrefHeight(117.0);
titleLabel.setPrefWidth(381.0);
titleLabel.setTextFill(javafx.scene.paint.Color.web("#fffdfd"));
titleLabel.setFont(new Font("Songti SC Black", 64.0));
titleLabel.setAlignment(javafx.geometry.Pos.CENTER);
titleLabel.setEffect(new DropShadow());
Line line = new Line(-127.0, 462.0, 207.9317626953125, 462.0);
line.setFill(javafx.scene.paint.Color.WHITE);
line.setStroke(javafx.scene.paint.Color.WHITE);
line.setStrokeWidth(6.0);
line.setEffect(new DropShadow());
BorderPane.setAlignment(line, javafx.geometry.Pos.CENTER);
Label copyrightLabel = new Label("Copyright (c) . All rights reserved");
copyrightLabel.setAlignment(javafx.geometry.Pos.CENTER);
copyrightLabel.setContentDisplay(javafx.scene.control.ContentDisplay.CENTER);
copyrightLabel.setPrefHeight(17.0);
copyrightLabel.setPrefWidth(197.0);
copyrightLabel.setTextFill(javafx.scene.paint.Color.WHITE);
copyrightLabel.setTranslateY(-13.0);
copyrightLabel.setEffect(new DropShadow());
BorderPane.setAlignment(copyrightLabel, javafx.geometry.Pos.CENTER);
leftPane.setCenter(titleLabel);
leftPane.setTop(line);
leftPane.setBottom(copyrightLabel);
AnchorPane centerPane = new AnchorPane();
centerPane.setPrefHeight(539.0);
centerPane.setPrefWidth(510.0);
BorderPane.setAlignment(centerPane, javafx.geometry.Pos.CENTER);
ProgressBar progressBar = new ProgressBar();
progressBar.setLayoutX(103.0);
progressBar.setLayoutY(81.0);
progressBar.setPrefHeight(33.0);
progressBar.setPrefWidth(637.0);
progressBar.setProgress(0.0);
progressBar.setStyle("-fx-background-color: #D4AF37;");
progressBar.setEffect(new DropShadow());
Label processingLabel = new Label("Processing Information . . .");
processingLabel.setLayoutX(254.0);
processingLabel.setLayoutY(123.0);
processingLabel.setPrefHeight(43.0);
processingLabel.setPrefWidth(393.0);
processingLabel.setStyle("-fx-background-color: transparent;");
processingLabel.setTextFill(javafx.scene.paint.Color.BLACK);
processingLabel.setFont(new Font("Verdana Bold", 26.0));
Label recommendLabel = new Label("We recommend");
recommendLabel.setLayoutX(253.0);
recommendLabel.setLayoutY(328.0);
recommendLabel.setPrefHeight(43.0);
recommendLabel.setPrefWidth(393.0);
recommendLabel.setStyle("-fx-background-color: transparent;");
recommendLabel.setTextFill(javafx.scene.paint.Color.BLACK);
recommendLabel.setFont(new Font("Verdana Bold", 26.0));
recommendLabel.setVisible(false);
Label foodLabel = new Label("Food, Food, Food");
foodLabel.setLayoutX(186.0);
foodLabel.setLayoutY(380.0);
foodLabel.setPrefHeight(175.0);
foodLabel.setPrefWidth(512.0);
foodLabel.setStyle("-fx-background-color: #D4AF37;");
foodLabel.setTextFill(javafx.scene.paint.Color.WHITE);
foodLabel.setFont(new Font("Verdana Bold", 28.0));
foodLabel.setVisible(false);
centerPane.getChildren().addAll(progressBar, processingLabel, recommendLabel, foodLabel);
root.setLeft(leftPane);
root.setCenter(centerPane);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
// Animation to fill the progress bar in 2 seconds
Timeline timeline = new Timeline(
new KeyFrame(Duration.ZERO, new KeyValue(progressBar.progressProperty(), 0.0)),
new KeyFrame(Duration.seconds(2), new KeyValue(progressBar.progressProperty(), 1.0))
);
timeline.play();
// Listener to show recommendLabel and foodLabel when progress bar is filled
progressBar.progressProperty().addListener((observable, oldValue, newValue) -> {
if (newValue.doubleValue() >= 1.0) {
Timeline showLabelsTimeline = new Timeline(
new KeyFrame(Duration.ZERO, new KeyValue(recommendLabel.opacityProperty(), 0.0)),
new KeyFrame(Duration.seconds(0.5), new KeyValue(recommendLabel.opacityProperty(), 1.0)),
new KeyFrame(Duration.ZERO, new KeyValue(foodLabel.opacityProperty(), 0.0)),
new KeyFrame(Duration.seconds(0.5), new KeyValue(foodLabel.opacityProperty(), 1.0))
);
recommendLabel.setVisible(true);
foodLabel.setVisible(true);
showLabelsTimeline.play();
}
});
}
//************************************************************************************
public void changeToQ2Scene(Stage primaryStage) {
BorderPane root = new BorderPane();
root.setMaxSize(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
root.setMinSize(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
root.setPrefSize(1193, 852);
BorderPane leftPane = new BorderPane();
leftPane.setPrefSize(367, 852);
leftPane.setStyle("-fx-background-color: #D4AF37;");
Label titleLabel = new Label("FoodPicker");
titleLabel.setAlignment(Pos.CENTER);
titleLabel.setPrefSize(357, 117);
titleLabel.setTextFill(javafx.scene.paint.Color.WHITE);
titleLabel.setStyle("-fx-font-family: 'Songti SC Black'; -fx-font-size: 64;");
titleLabel.setEffect(new DropShadow());
Line topLine = new Line(-127, 462, 207.93, 462);
topLine.setFill(javafx.scene.paint.Color.WHITE);
topLine.setStroke(javafx.scene.paint.Color.WHITE);
topLine.setStrokeWidth(6);
topLine.setEffect(new DropShadow());
Label copyrightLabel = new Label("Copyright (c) . All rights reserved");
copyrightLabel.setAlignment(Pos.CENTER);
copyrightLabel.setContentDisplay(javafx.scene.control.ContentDisplay.CENTER);
copyrightLabel.setPrefSize(197, 17);
copyrightLabel.setTextFill(javafx.scene.paint.Color.WHITE);
copyrightLabel.setTranslateY(-13);
copyrightLabel.setEffect(new DropShadow());
leftPane.setCenter(titleLabel);
leftPane.setTop(topLine);
leftPane.setBottom(copyrightLabel);
AnchorPane centerPane = new AnchorPane();
centerPane.setPrefSize(510, 539);
Label firstQuestionLabel = new Label("Do you want soup?");
firstQuestionLabel.setId("firstQuestion");
firstQuestionLabel.setAlignment(Pos.CENTER);
firstQuestionLabel.setLayoutX(16);
firstQuestionLabel.setLayoutY(117);
firstQuestionLabel.setPrefSize(630, 68);
firstQuestionLabel.setTextFill(javafx.scene.paint.Color.WHITE);
firstQuestionLabel.setStyle("-fx-background-color: #D4AF37;");
firstQuestionLabel.setFont(Font.font("Verdana Bold", 29));
firstQuestionLabel.setEffect(new DropShadow());
Label secondQuestionLabel = new Label("Do you want something spicy?");
secondQuestionLabel.setId("secondQuestion");
secondQuestionLabel.setAlignment(Pos.CENTER);
secondQuestionLabel.setLayoutX(161);
secondQuestionLabel.setLayoutY(389);
secondQuestionLabel.setPrefSize(630, 68);
secondQuestionLabel.setTextFill(javafx.scene.paint.Color.WHITE);
secondQuestionLabel.setStyle("-fx-background-color: #D4AF37;");
secondQuestionLabel.setFont(Font.font("Verdana Bold", 29));
secondQuestionLabel.setEffect(new DropShadow());
Label thirdQuestionLabel = new Label("Do you want something sweet?");
thirdQuestionLabel.setId("thirdQuestion");
thirdQuestionLabel.setAlignment(Pos.CENTER);
thirdQuestionLabel.setLayoutX(22);
thirdQuestionLabel.setLayoutY(638);
thirdQuestionLabel.setPrefSize(630, 68);
thirdQuestionLabel.setTextFill(javafx.scene.paint.Color.WHITE);
thirdQuestionLabel.setStyle("-fx-background-color: #D4AF37;");
thirdQuestionLabel.setFont(Font.font("Verdana Bold", 29));
thirdQuestionLabel.setEffect(new DropShadow());
ImageView tray1 = new ImageView();
tray1.setFitHeight(149);
tray1.setFitWidth(216);
tray1.setLayoutX(17);
tray1.setLayoutY(217);
String imagePath = "/Users/davutgurbanov/Desktop/chefTray.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath));
tray1.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
ImageView tray2 = new ImageView();
tray2.setFitHeight(149);
tray2.setFitWidth(216);
tray2.setLayoutX(213);
tray2.setLayoutY(479);
String imagePath1 = "/Users/davutgurbanov/Desktop/chefTray.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath1));
tray2.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
ImageView tray3 = new ImageView();
tray3.setFitHeight(149);
tray3.setFitWidth(216);
tray3.setLayoutX(28);
tray3.setLayoutY(704);
String imagePath2 = "/Users/davutgurbanov/Desktop/chefTray.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath2));
tray3.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Button yesButton1 = new Button("Yes");
yesButton1.setId("yesButton1");
yesButton1.setLayoutX(57);
yesButton1.setLayoutY(269);
yesButton1.setPrefSize(136, 58);
yesButton1.setStyle("-fx-background-color: 0;");
yesButton1.setFont(Font.font("Verdana Bold", 27));
yesButton1.setOnAction(event -> {
smth.add(foodOption[0][k]);
count++;
});
Button yesButton2 = new Button("Yes");
yesButton2.setId("yesButton2");
yesButton2.setLayoutX(256);
yesButton2.setLayoutY(523);
yesButton2.setPrefSize(136, 58);
yesButton2.setStyle("-fx-background-color: 0;");
yesButton2.setFont(Font.font("Verdana Bold", 27));
yesButton2.setOnAction(event -> {
smth.add(foodOption[1][k]);
count++;
});
Button yesButton3 = new Button("Yes");
yesButton3.setId("yesButton3");
yesButton3.setLayoutX(67);
yesButton3.setLayoutY(752);
yesButton3.setPrefSize(136, 58);
yesButton3.setStyle("-fx-background-color: 0;");
yesButton3.setFont(Font.font("Verdana Bold", 27));
yesButton3.setOnAction(event -> {
smth.add(foodOption[2][k]);
count++;
});
ImageView tray4 = new ImageView();
tray4.setFitHeight(149);
tray4.setFitWidth(216);
tray4.setLayoutX(385);
tray4.setLayoutY(217);
String imagePath3 = "/Users/davutgurbanov/Desktop/chefTray.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath3));
tray4.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
ImageView tray5 = new ImageView();
tray5.setFitHeight(149);
tray5.setFitWidth(216);
tray5.setLayoutX(551);
tray5.setLayoutY(477);
String imagePath4 = "/Users/davutgurbanov/Desktop/chefTray.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath4));
tray5.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
ImageView tray6 = new ImageView();
tray6.setFitHeight(149);
tray6.setFitWidth(216);
tray6.setLayoutX(385);
tray6.setLayoutY(704);
String imagePath5 = "/Users/davutgurbanov/Desktop/chefTray.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath5));
tray6.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Button noButton2 = new Button("No");
noButton2.setId("noButton2");
noButton2.setLayoutX(589);
noButton2.setLayoutY(507);
noButton2.setPrefSize(136, 89);
noButton2.setStyle("-fx-background-color: 0;");
noButton2.setFont(Font.font("Verdana Bold", 27));
Button noButton1 = new Button("No");
noButton1.setId("noButton1");
noButton1.setLayoutX(425);
noButton1.setLayoutY(257);
noButton1.setPrefSize(136, 89);
noButton1.setStyle("-fx-background-color: 0;");
noButton1.setFont(Font.font("Verdana Bold", 27));
Button noButton3 = new Button("No");
noButton3.setId("noButton3");
noButton3.setLayoutX(429);
noButton3.setLayoutY(738);
noButton3.setPrefSize(136, 89);
noButton3.setStyle("-fx-background-color: 0;");
noButton3.setFont(Font.font("Verdana Bold", 27));
Button nextButton = new Button("Next");
nextButton.setLayoutX(673);
nextButton.setLayoutY(674);
nextButton.setPrefSize(112, 142);
nextButton.setStyle("-fx-background-color: #D4AF37;");
nextButton.setTextFill(javafx.scene.paint.Color.WHITE);
nextButton.setFont(Font.font("Verdana Bold", 25));
nextButton.setEffect(new DropShadow());
nextButton.setOnAction(event -> changeToThirdQScene(primaryStage));
ImageView chefImageRight = new ImageView();
chefImageRight.setFitHeight(216);
chefImageRight.setFitWidth(215);
chefImageRight.setLayoutX(608);
chefImageRight.setLayoutY(156);
String imagePath6 = "/Users/davutgurbanov/Desktop/chefImageR.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath6));
chefImageRight.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
ImageView chefImageLeft = new ImageView();
chefImageLeft.setFitHeight(200);
chefImageLeft.setFitWidth(200);
chefImageLeft.setLayoutX(-11);
chefImageLeft.setLayoutY(426);
String imagePath7 = "/Users/davutgurbanov/Desktop/chefImageL.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath7));
chefImageRight.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Button backButton = new Button("Back");
backButton.setId("backButton");
backButton.setLayoutX(54);
backButton.setLayoutY(21);
backButton.setPrefSize(148, 59);
backButton.setStyle("-fx-background-color: #D4AF37;");
backButton.setTextFill(javafx.scene.paint.Color.WHITE);
backButton.setFont(Font.font("Verdana Bold", 31));
backButton.setEffect(new DropShadow());
AnchorPane anchorPane = new AnchorPane();
anchorPane.setPrefSize(510, 539);
anchorPane.getChildren().addAll(firstQuestionLabel, secondQuestionLabel, thirdQuestionLabel, tray1, tray2, tray3, yesButton1, yesButton2, yesButton3, tray4, tray5, tray6, noButton2, noButton1, noButton3, nextButton, chefImageRight, chefImageLeft, backButton);
root.setPrefSize(1193, 852);
root.setLeft(leftPane);
root.setCenter(anchorPane);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
yesButton1.setOnAction(e -> {
// Reset the background color for all buttons
noButton1.setStyle("-fx-background-color: 0;");
// Highlight the "Small" button
yesButton1.setStyle("-fx-background-color: green;");
});
yesButton2.setOnAction(e -> {
// Reset the background color for all buttons
noButton2.setStyle("-fx-background-color: 0;");
// Highlight the "Small" button
yesButton2.setStyle("-fx-background-color: green;");
});
yesButton3.setOnAction(e -> {
// Reset the background color for all buttons
noButton3.setStyle("-fx-background-color: 0;");
// Highlight the "Small" button
yesButton3.setStyle("-fx-background-color: green;");
});
noButton1.setOnAction(e -> {
// Reset the background color for all buttons
yesButton1.setStyle("-fx-background-color: 0;");
// Highlight the "Small" button
noButton1.setStyle("-fx-background-color: red;");
});
noButton2.setOnAction(e -> {
// Reset the background color for all buttons
yesButton2.setStyle("-fx-background-color: 0;");
// Highlight the "Small" button
noButton2.setStyle("-fx-background-color: red;");
});
noButton3.setOnAction(e -> {
// Reset the background color for all buttons
yesButton3.setStyle("-fx-background-color: 0;");
// Highlight the "Small" button
noButton3.setStyle("-fx-background-color: red;");
});
// Back button action
backButton.setOnAction(event -> changeToQuestionnaireSceneImpl(primaryStage));
}
//************************************************************************************
public void changeToThirdQScene(Stage primaryStage) {
BorderPane root = new BorderPane();
root.setMaxSize(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
root.setMinSize(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
root.setPrefSize(1193, 852);
BorderPane leftPane = new BorderPane();
leftPane.setPrefSize(367, 852);
leftPane.setStyle("-fx-background-color: #D4AF37;");
Label titleLabel = new Label("FoodPicker");
titleLabel.setAlignment(Pos.CENTER);
titleLabel.setPrefSize(357, 117);
titleLabel.setTextFill(javafx.scene.paint.Color.WHITE);
titleLabel.setStyle("-fx-font-family: 'Songti SC Black'; -fx-font-size: 64;");
titleLabel.setEffect(new DropShadow());
Line topLine = new Line(-127, 462, 207.93, 462);
topLine.setFill(javafx.scene.paint.Color.WHITE);
topLine.setStroke(javafx.scene.paint.Color.WHITE);
topLine.setStrokeWidth(6);
topLine.setEffect(new DropShadow());
Label copyrightLabel = new Label("Copyright (c) . All rights reserved");
copyrightLabel.setAlignment(Pos.CENTER);
copyrightLabel.setContentDisplay(javafx.scene.control.ContentDisplay.CENTER);
copyrightLabel.setPrefSize(197, 17);
copyrightLabel.setTextFill(javafx.scene.paint.Color.WHITE);
copyrightLabel.setTranslateY(-13);
copyrightLabel.setEffect(new DropShadow());
leftPane.setCenter(titleLabel);
leftPane.setTop(topLine);
leftPane.setBottom(copyrightLabel);
AnchorPane centerPane = new AnchorPane();
centerPane.setPrefSize(510, 539);
Label firstQuestionLabel = new Label("Do you want something healthy?");
firstQuestionLabel.setId("firstQuestion");
firstQuestionLabel.setAlignment(Pos.CENTER);
firstQuestionLabel.setLayoutX(16);
firstQuestionLabel.setLayoutY(117);
firstQuestionLabel.setPrefSize(630, 68);
firstQuestionLabel.setTextFill(javafx.scene.paint.Color.WHITE);
firstQuestionLabel.setStyle("-fx-background-color: #D4AF37;");
firstQuestionLabel.setFont(Font.font("Verdana Bold", 29));
firstQuestionLabel.setEffect(new DropShadow());
Label secondQuestionLabel = new Label("Do you want something salty?");
secondQuestionLabel.setId("secondQuestion");
secondQuestionLabel.setAlignment(Pos.CENTER);
secondQuestionLabel.setLayoutX(161);
secondQuestionLabel.setLayoutY(389);
secondQuestionLabel.setPrefSize(630, 68);
secondQuestionLabel.setTextFill(javafx.scene.paint.Color.WHITE);
secondQuestionLabel.setStyle("-fx-background-color: #D4AF37;");
secondQuestionLabel.setFont(Font.font("Verdana Bold", 29));
secondQuestionLabel.setEffect(new DropShadow());
Label thirdQuestionLabel = new Label("Do you want salads?");
thirdQuestionLabel.setId("thirdQuestion");
thirdQuestionLabel.setAlignment(Pos.CENTER);
thirdQuestionLabel.setLayoutX(22);
thirdQuestionLabel.setLayoutY(638);
thirdQuestionLabel.setPrefSize(630, 68);
thirdQuestionLabel.setTextFill(javafx.scene.paint.Color.WHITE);
thirdQuestionLabel.setStyle("-fx-background-color: #D4AF37;");
thirdQuestionLabel.setFont(Font.font("Verdana Bold", 29));
thirdQuestionLabel.setEffect(new DropShadow());
ImageView tray1 = new ImageView();
tray1.setFitHeight(149);
tray1.setFitWidth(216);
tray1.setLayoutX(17);
tray1.setLayoutY(217);
String imagePath = "/Users/davutgurbanov/Desktop/chefTray.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath));
tray1.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
ImageView tray2 = new ImageView();
tray2.setFitHeight(149);
tray2.setFitWidth(216);
tray2.setLayoutX(213);
tray2.setLayoutY(479);
String imagePath1 = "/Users/davutgurbanov/Desktop/chefTray.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath1));
tray2.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
ImageView tray3 = new ImageView();
tray3.setFitHeight(149);
tray3.setFitWidth(216);
tray3.setLayoutX(28);
tray3.setLayoutY(704);
String imagePath2 = "/Users/davutgurbanov/Desktop/chefTray.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath2));
tray3.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Button yesButton1 = new Button("Yes");
yesButton1.setId("yesButton1");
yesButton1.setLayoutX(57);
yesButton1.setLayoutY(269);
yesButton1.setPrefSize(136, 58);
yesButton1.setStyle("-fx-background-color: 0;");
yesButton1.setFont(Font.font("Verdana Bold", 27));
yesButton1.setOnAction(event -> {
smth.add(foodOption[3][k]);
count++;
});
Button yesButton2 = new Button("Yes");
yesButton2.setId("yesButton2");
yesButton2.setLayoutX(256);
yesButton2.setLayoutY(523);
yesButton2.setPrefSize(136, 58);
yesButton2.setStyle("-fx-background-color: 0;");
yesButton2.setFont(Font.font("Verdana Bold", 27));
yesButton2.setOnAction(event -> {
smth.add(foodOption[4][k]);
count++;
});
Button yesButton3 = new Button("Yes");
yesButton3.setId("yesButton3");
yesButton3.setLayoutX(67);
yesButton3.setLayoutY(752);
yesButton3.setPrefSize(136, 58);
yesButton3.setStyle("-fx-background-color: 0;");
yesButton3.setFont(Font.font("Verdana Bold", 27));
yesButton3.setOnAction(event -> {
smth.add(foodOption[5][k]);
count++;
});
ImageView tray4 = new ImageView();
tray4.setFitHeight(149);
tray4.setFitWidth(216);
tray4.setLayoutX(385);
tray4.setLayoutY(217);
String imagePath3 = "/Users/davutgurbanov/Desktop/chefTray.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath3));
tray4.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
ImageView tray5 = new ImageView();
tray5.setFitHeight(149);
tray5.setFitWidth(216);
tray5.setLayoutX(551);
tray5.setLayoutY(477);
String imagePath4 = "/Users/davutgurbanov/Desktop/chefTray.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath4));
tray5.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
ImageView tray6 = new ImageView();
tray6.setFitHeight(149);
tray6.setFitWidth(216);
tray6.setLayoutX(385);
tray6.setLayoutY(704);
String imagePath5 = "/Users/davutgurbanov/Desktop/chefTray.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath5));
tray6.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Button noButton2 = new Button("No");
noButton2.setId("noButton2");
noButton2.setLayoutX(589);
noButton2.setLayoutY(507);
noButton2.setPrefSize(136, 89);
noButton2.setStyle("-fx-background-color: 0;");
noButton2.setFont(Font.font("Verdana Bold", 27));
Button noButton1 = new Button("No");
noButton1.setId("noButton1");
noButton1.setLayoutX(425);
noButton1.setLayoutY(257);
noButton1.setPrefSize(136, 89);
noButton1.setStyle("-fx-background-color: 0;");
noButton1.setFont(Font.font("Verdana Bold", 27));
Button noButton3 = new Button("No");
noButton3.setId("noButton3");
noButton3.setLayoutX(429);
noButton3.setLayoutY(738);
noButton3.setPrefSize(136, 89);
noButton3.setStyle("-fx-background-color: 0;");
noButton3.setFont(Font.font("Verdana Bold", 27));
Button nextButton = new Button("Next");
nextButton.setLayoutX(673);
nextButton.setLayoutY(674);
nextButton.setPrefSize(112, 142);
nextButton.setStyle("-fx-background-color: #D4AF37;");
nextButton.setTextFill(javafx.scene.paint.Color.WHITE);
nextButton.setFont(Font.font("Verdana Bold", 25));
nextButton.setEffect(new DropShadow());
nextButton.setOnAction(event -> changeToFourthQScene(primaryStage));
ImageView chefImageRight = new ImageView();
chefImageRight.setFitHeight(216);
chefImageRight.setFitWidth(215);
chefImageRight.setLayoutX(608);
chefImageRight.setLayoutY(156);
String imagePath6 = "/Users/davutgurbanov/Desktop/chefImageR.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath6));
chefImageRight.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
ImageView chefImageLeft = new ImageView();
chefImageLeft.setFitHeight(200);
chefImageLeft.setFitWidth(200);
chefImageLeft.setLayoutX(-11);
chefImageLeft.setLayoutY(426);
String imagePath7 = "/Users/davutgurbanov/Desktop/chefImageL.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath7));
chefImageRight.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Button backButton = new Button("Back");
backButton.setId("backButton");
backButton.setLayoutX(54);
backButton.setLayoutY(21);
backButton.setPrefSize(148, 59);
backButton.setStyle("-fx-background-color: #D4AF37;");
backButton.setTextFill(javafx.scene.paint.Color.WHITE);
backButton.setFont(Font.font("Verdana Bold", 31));
backButton.setEffect(new DropShadow());
AnchorPane anchorPane = new AnchorPane();
anchorPane.setPrefSize(510, 539);
anchorPane.getChildren().addAll(firstQuestionLabel, secondQuestionLabel, thirdQuestionLabel, tray1, tray2, tray3, yesButton1, yesButton2, yesButton3, tray4, tray5, tray6, noButton2, noButton1, noButton3, nextButton, chefImageRight, chefImageLeft, backButton);
root.setPrefSize(1193, 852);
root.setLeft(leftPane);
root.setCenter(anchorPane);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
yesButton1.setOnAction(e -> {
// Reset the background color for all buttons
noButton1.setStyle("-fx-background-color: 0;");
// Highlight the "Small" button
yesButton1.setStyle("-fx-background-color: green;");
});
yesButton2.setOnAction(e -> {
// Reset the background color for all buttons
noButton2.setStyle("-fx-background-color: 0;");
// Highlight the "Small" button
yesButton2.setStyle("-fx-background-color: green;");
});
yesButton3.setOnAction(e -> {
// Reset the background color for all buttons
noButton3.setStyle("-fx-background-color: 0;");
// Highlight the "Small" button
yesButton3.setStyle("-fx-background-color: green;");
});
noButton1.setOnAction(e -> {
// Reset the background color for all buttons
yesButton1.setStyle("-fx-background-color: 0;");
// Highlight the "Small" button
noButton1.setStyle("-fx-background-color: red;");
});
noButton2.setOnAction(e -> {
// Reset the background color for all buttons
yesButton2.setStyle("-fx-background-color: 0;");
// Highlight the "Small" button
noButton2.setStyle("-fx-background-color: red;");
});
noButton3.setOnAction(e -> {
// Reset the background color for all buttons
yesButton3.setStyle("-fx-background-color: 0;");
// Highlight the "Small" button
noButton3.setStyle("-fx-background-color: red;");
});
// Back button action
backButton.setOnAction(event -> changeToQ2Scene(primaryStage));
}
//************************************************************************************
public void changeToFourthQScene(Stage primaryStage) {
BorderPane root = new BorderPane();
root.setMaxSize(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
root.setMinSize(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
root.setPrefSize(1193, 852);
BorderPane leftPane = new BorderPane();
leftPane.setPrefSize(367, 852);
leftPane.setStyle("-fx-background-color: #D4AF37;");
Label titleLabel = new Label("FoodPicker");
titleLabel.setAlignment(Pos.CENTER);
titleLabel.setPrefSize(357, 117);
titleLabel.setTextFill(javafx.scene.paint.Color.WHITE);
titleLabel.setStyle("-fx-font-family: 'Songti SC Black'; -fx-font-size: 64;");
titleLabel.setEffect(new DropShadow());
Line topLine = new Line(-127, 462, 207.93, 462);
topLine.setFill(javafx.scene.paint.Color.WHITE);
topLine.setStroke(javafx.scene.paint.Color.WHITE);
topLine.setStrokeWidth(6);
topLine.setEffect(new DropShadow());
Label copyrightLabel = new Label("Copyright (c) . All rights reserved");
copyrightLabel.setAlignment(Pos.CENTER);
copyrightLabel.setContentDisplay(javafx.scene.control.ContentDisplay.CENTER);
copyrightLabel.setPrefSize(197, 17);
copyrightLabel.setTextFill(javafx.scene.paint.Color.WHITE);
copyrightLabel.setTranslateY(-13);
copyrightLabel.setEffect(new DropShadow());
leftPane.setCenter(titleLabel);
leftPane.setTop(topLine);
leftPane.setBottom(copyrightLabel);
AnchorPane centerPane = new AnchorPane();
centerPane.setPrefSize(510, 539);
Label firstQuestionLabel = new Label("Do you want fast food?");
firstQuestionLabel.setId("firstQuestion");
firstQuestionLabel.setAlignment(Pos.CENTER);
firstQuestionLabel.setLayoutX(16);
firstQuestionLabel.setLayoutY(117);
firstQuestionLabel.setPrefSize(630, 68);
firstQuestionLabel.setTextFill(javafx.scene.paint.Color.WHITE);
firstQuestionLabel.setStyle("-fx-background-color: #D4AF37;");
firstQuestionLabel.setFont(Font.font("Verdana Bold", 29));
firstQuestionLabel.setEffect(new DropShadow());
Label secondQuestionLabel = new Label("Do you want something baked?");
secondQuestionLabel.setId("secondQuestion");
secondQuestionLabel.setAlignment(Pos.CENTER);
secondQuestionLabel.setLayoutX(161);
secondQuestionLabel.setLayoutY(389);
secondQuestionLabel.setPrefSize(630, 68);
secondQuestionLabel.setTextFill(javafx.scene.paint.Color.WHITE);
secondQuestionLabel.setStyle("-fx-background-color: #D4AF37;");
secondQuestionLabel.setFont(Font.font("Verdana Bold", 29));
secondQuestionLabel.setEffect(new DropShadow());
thirdQuestionLabel.setId("thirdQuestion");
thirdQuestionLabel.setAlignment(Pos.CENTER);
thirdQuestionLabel.setLayoutX(22);
thirdQuestionLabel.setLayoutY(638);
thirdQuestionLabel.setPrefSize(630, 68);
thirdQuestionLabel.setTextFill(javafx.scene.paint.Color.WHITE);
thirdQuestionLabel.setStyle("-fx-background-color: #D4AF37;");
thirdQuestionLabel.setFont(Font.font("Verdana Bold", 29));
thirdQuestionLabel.setEffect(new DropShadow());
thirdQuestionLabel.setVisible(false);
ImageView tray1 = new ImageView();
tray1.setFitHeight(149);
tray1.setFitWidth(216);
tray1.setLayoutX(17);
tray1.setLayoutY(217);
String imagePath = "/Users/davutgurbanov/Desktop/chefTray.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath));
tray1.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
ImageView tray2 = new ImageView();
tray2.setFitHeight(149);
tray2.setFitWidth(216);
tray2.setLayoutX(213);
tray2.setLayoutY(479);
String imagePath1 = "/Users/davutgurbanov/Desktop/chefTray.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath1));
tray2.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
tray3.setFitHeight(149);
tray3.setFitWidth(216);
tray3.setLayoutX(28);
tray3.setLayoutY(704);
String imagePath2 = "/Users/davutgurbanov/Desktop/chefTray.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath2));
tray3.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Button yesButton1 = new Button("Yes");
yesButton1.setId("yesButton1");
yesButton1.setLayoutX(57);
yesButton1.setLayoutY(269);
yesButton1.setPrefSize(136, 58);
yesButton1.setStyle("-fx-background-color: 0;");
yesButton1.setFont(Font.font("Verdana Bold", 27));
yesButton1.setOnAction(event -> {
smth.add(foodOption[6][k]);
count++;
});
Button yesButton2 = new Button("Yes");
yesButton2.setId("yesButton2");
yesButton2.setLayoutX(256);
yesButton2.setLayoutY(523);
yesButton2.setPrefSize(136, 58);
yesButton2.setStyle("-fx-background-color: 0;");
yesButton2.setFont(Font.font("Verdana Bold", 27));
yesButton2.setOnAction(event -> {
smth.add(foodOption[7][k]);
count++;
});
Button yesButton3 = new Button("Yes");
yesButton3.setId("yesButton3");
yesButton3.setLayoutX(67);
yesButton3.setLayoutY(752);
yesButton3.setPrefSize(136, 58);
yesButton3.setStyle("-fx-background-color: 0;");
yesButton3.setFont(Font.font("Verdana Bold", 27));
ImageView tray4 = new ImageView();
tray4.setFitHeight(149);
tray4.setFitWidth(216);
tray4.setLayoutX(385);
tray4.setLayoutY(217);
String imagePath3 = "/Users/davutgurbanov/Desktop/chefTray.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath3));
tray4.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
ImageView tray5 = new ImageView();
tray5.setFitHeight(149);
tray5.setFitWidth(216);
tray5.setLayoutX(551);
tray5.setLayoutY(477);
String imagePath4 = "/Users/davutgurbanov/Desktop/chefTray.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath4));
tray5.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
tray6.setFitHeight(149);
tray6.setFitWidth(216);
tray6.setLayoutX(385);
tray6.setLayoutY(704);
String imagePath5 = "/Users/davutgurbanov/Desktop/chefTray.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath5));
tray6.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Button noButton2 = new Button("No");
noButton2.setId("noButton2");
noButton2.setLayoutX(589);
noButton2.setLayoutY(507);
noButton2.setPrefSize(136, 89);
noButton2.setStyle("-fx-background-color: 0;");
noButton2.setFont(Font.font("Verdana Bold", 27));
Button noButton1 = new Button("No");
noButton1.setId("noButton1");
noButton1.setLayoutX(425);
noButton1.setLayoutY(257);
noButton1.setPrefSize(136, 89);
noButton1.setStyle("-fx-background-color: 0;");
noButton1.setFont(Font.font("Verdana Bold", 27));
Button noButton3 = new Button("No");
noButton3.setId("noButton3");
noButton3.setLayoutX(429);
noButton3.setLayoutY(738);
noButton3.setPrefSize(136, 89);
noButton3.setStyle("-fx-background-color: 0;");
noButton3.setFont(Font.font("Verdana Bold", 27));
Button nextButton = new Button("Next");
nextButton.setLayoutX(673);
nextButton.setLayoutY(674);
nextButton.setPrefSize(112, 142);
nextButton.setStyle("-fx-background-color: #D4AF37;");
nextButton.setTextFill(javafx.scene.paint.Color.WHITE);
nextButton.setFont(Font.font("Verdana Bold", 25));
nextButton.setEffect(new DropShadow());
nextButton.setOnAction(event -> changeToRecommendScene(primaryStage));
ImageView chefImageRight = new ImageView();
chefImageRight.setFitHeight(216);
chefImageRight.setFitWidth(215);
chefImageRight.setLayoutX(608);
chefImageRight.setLayoutY(156);
String imagePath6 = "/Users/davutgurbanov/Desktop/chefImageR.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath6));
chefImageRight.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
ImageView chefImageLeft = new ImageView();
chefImageLeft.setFitHeight(200);
chefImageLeft.setFitWidth(200);
chefImageLeft.setLayoutX(-11);
chefImageLeft.setLayoutY(426);
String imagePath7 = "/Users/davutgurbanov/Desktop/chefImageL.png";
try {
Image chefImage = new Image(new FileInputStream(imagePath7));
chefImageRight.setImage(chefImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Button backButton = new Button("Back");
backButton.setId("backButton");
backButton.setLayoutX(54);
backButton.setLayoutY(21);
backButton.setPrefSize(148, 59);
backButton.setStyle("-fx-background-color: #D4AF37;");
backButton.setTextFill(javafx.scene.paint.Color.WHITE);
backButton.setFont(Font.font("Verdana Bold", 31));
backButton.setEffect(new DropShadow());
AnchorPane anchorPane = new AnchorPane();
anchorPane.setPrefSize(510, 539);
anchorPane.getChildren().addAll(firstQuestionLabel, secondQuestionLabel, thirdQuestionLabel, tray1, tray2, tray3, yesButton1, yesButton2, yesButton3, tray4, tray5, tray6, noButton2, noButton1, noButton3, nextButton, chefImageRight, chefImageLeft, backButton);
root.setPrefSize(1193, 852);
root.setLeft(leftPane);
root.setCenter(anchorPane);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
yesButton1.setOnAction(e -> {
// Reset the background color for all buttons
noButton1.setStyle("-fx-background-color: 0;");
// Highlight the "Small" button
yesButton1.setStyle("-fx-background-color: green;");
});
yesButton2.setOnAction(e -> {
// Reset the background color for all buttons
noButton2.setStyle("-fx-background-color: 0;");
// Highlight the "Small" button
yesButton2.setStyle("-fx-background-color: green;");
});
yesButton3.setOnAction(e -> {
// Reset the background color for all buttons
noButton3.setStyle("-fx-background-color: 0;");
// Highlight the "Small" button
yesButton3.setStyle("-fx-background-color: green;");
});
noButton1.setOnAction(e -> {
// Reset the background color for all buttons
yesButton1.setStyle("-fx-background-color: 0;");
// Highlight the "Small" button
noButton1.setStyle("-fx-background-color: red;");
});
noButton2.setOnAction(e -> {
// Reset the background color for all buttons
yesButton2.setStyle("-fx-background-color: 0;");
// Highlight the "Small" button
noButton2.setStyle("-fx-background-color: red;");
});
noButton3.setOnAction(e -> {
// Reset the background color for all buttons
yesButton3.setStyle("-fx-background-color: 0;");
// Highlight the "Small" button
noButton3.setStyle("-fx-background-color: red;");
});
// Back button action
backButton.setOnAction(event -> changeToThirdQScene(primaryStage));
}
public void changeToRecommendScene(Stage primaryStage) {
BorderPane root = new BorderPane();
root.setMaxHeight(Double.NEGATIVE_INFINITY);
root.setMaxWidth(Double.NEGATIVE_INFINITY);
root.setMinHeight(Double.NEGATIVE_INFINITY);
root.setMinWidth(Double.NEGATIVE_INFINITY);
root.setPrefHeight(852.0);
root.setPrefWidth(1193.0);
BorderPane leftPane = new BorderPane();
leftPane.setPrefHeight(852.0);
leftPane.setPrefWidth(367.0);
leftPane.setStyle("-fx-background-color: #D4AF37;");
BorderPane.setAlignment(leftPane, javafx.geometry.Pos.CENTER);
Label titleLabel = new Label("FoodPicker");
titleLabel.setPrefHeight(117.0);
titleLabel.setPrefWidth(381.0);
titleLabel.setTextFill(javafx.scene.paint.Color.web("#fffdfd"));
titleLabel.setFont(new Font("Songti SC Black", 64.0));
titleLabel.setAlignment(javafx.geometry.Pos.CENTER);
titleLabel.setEffect(new DropShadow());
Line line = new Line(-127.0, 462.0, 207.9317626953125, 462.0);
line.setFill(javafx.scene.paint.Color.WHITE);
line.setStroke(javafx.scene.paint.Color.WHITE);
line.setStrokeWidth(6.0);
line.setEffect(new DropShadow());
BorderPane.setAlignment(line, javafx.geometry.Pos.CENTER);
Label copyrightLabel = new Label("Copyright (c) . All rights reserved");
copyrightLabel.setAlignment(javafx.geometry.Pos.CENTER);
copyrightLabel.setContentDisplay(javafx.scene.control.ContentDisplay.CENTER);
copyrightLabel.setPrefHeight(17.0);
copyrightLabel.setPrefWidth(197.0);
copyrightLabel.setTextFill(javafx.scene.paint.Color.WHITE);
copyrightLabel.setTranslateY(-13.0);
copyrightLabel.setEffect(new DropShadow());
BorderPane.setAlignment(copyrightLabel, javafx.geometry.Pos.CENTER);
leftPane.setCenter(titleLabel);
leftPane.setTop(line);
leftPane.setBottom(copyrightLabel);
AnchorPane centerPane = new AnchorPane();
centerPane.setPrefHeight(539.0);
centerPane.setPrefWidth(510.0);
BorderPane.setAlignment(centerPane, javafx.geometry.Pos.CENTER);
ProgressBar progressBar = new ProgressBar();
progressBar.setLayoutX(103.0);
progressBar.setLayoutY(81.0);
progressBar.setPrefHeight(33.0);
progressBar.setPrefWidth(637.0);
progressBar.setProgress(0.0);
progressBar.setStyle("-fx-background-color: #D4AF37;");
progressBar.setEffect(new DropShadow());
Label processingLabel = new Label("Processing Information . . .");
processingLabel.setLayoutX(254.0);
processingLabel.setLayoutY(123.0);
processingLabel.setPrefHeight(43.0);
processingLabel.setPrefWidth(393.0);
processingLabel.setStyle("-fx-background-color: transparent;");
processingLabel.setTextFill(javafx.scene.paint.Color.BLACK);
processingLabel.setFont(new Font("Verdana Bold", 26.0));
Label recommendLabel = new Label("We recommend");
recommendLabel.setLayoutX(253.0);
recommendLabel.setLayoutY(328.0);
recommendLabel.setPrefHeight(43.0);
recommendLabel.setPrefWidth(393.0);
recommendLabel.setStyle("-fx-background-color: transparent;");
recommendLabel.setTextFill(javafx.scene.paint.Color.BLACK);
recommendLabel.setFont(new Font("Verdana Bold", 26.0));
recommendLabel.setVisible(false);
Label foodLabel = new Label();
foodLabel.setLayoutX(186.0);
foodLabel.setLayoutY(380.0);
foodLabel.setPrefHeight(175.0);
foodLabel.setPrefWidth(512.0);
foodLabel.setStyle("-fx-background-color: #D4AF37;");
foodLabel.setTextFill(javafx.scene.paint.Color.WHITE);
foodLabel.setFont(new Font("Verdana Bold", 20.0));
foodLabel.setVisible(false);
centerPane.getChildren().addAll(progressBar, processingLabel, recommendLabel, foodLabel);
root.setLeft(leftPane);
root.setCenter(centerPane);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
// Animation to fill the progress bar in 2 seconds
Timeline timeline = new Timeline(
new KeyFrame(Duration.ZERO, new KeyValue(progressBar.progressProperty(), 0.0)),
new KeyFrame(Duration.seconds(2), new KeyValue(progressBar.progressProperty(), 1.0))
);
timeline.play();
// Listener to show recommendLabel and foodLabel when progress bar is filled
progressBar.progressProperty().addListener((observable, oldValue, newValue) -> {
if (newValue.doubleValue() >= 1.0) {
Timeline showLabelsTimeline = new Timeline(
new KeyFrame(Duration.ZERO, new KeyValue(recommendLabel.opacityProperty(), 0.0)),
new KeyFrame(Duration.seconds(0.5), new KeyValue(recommendLabel.opacityProperty(), 1.0)),
new KeyFrame(Duration.ZERO, new KeyValue(foodLabel.opacityProperty(), 0.0)),
new KeyFrame(Duration.seconds(0.5), new KeyValue(foodLabel.opacityProperty(), 1.0))
);
recommendLabel.setVisible(true);
foodLabel.setVisible(true);
showLabelsTimeline.play();
}
});
if (count > 0) {
foodLabel.setText(" "+smth);
foodLabel.setVisible(true);
}
}
public static void main(String[] args) {
launch(args);
}
}
Download