Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.98 KB | None | 0 0
  1. package view;
  2.  
  3. import javafx.application.Application;
  4. import javafx.scene.Scene;
  5. import javafx.scene.control.Label;
  6. import javafx.scene.image.Image;
  7. import javafx.scene.image.ImageView;
  8. import javafx.scene.layout.BorderPane;
  9. import javafx.scene.layout.Pane;
  10. import javafx.scene.layout.StackPane;
  11. import javafx.scene.layout.VBox;
  12. import javafx.stage.Stage;
  13. import view.panes.*;
  14. import view.panes.event.ChangePaneEvent;
  15. import view.util.TransitionUtils;
  16.  
  17. public class Othello extends Application {
  18.  
  19.     private static int WIDTH = 1250;
  20.     private static int HEIGHT = 800;
  21.  
  22.     // Stage
  23.     private Stage stage;
  24.  
  25.     // Main scene
  26.     private Scene scene;
  27.  
  28.     // Home
  29.     private Pane home;
  30.     private Pane play;
  31.     private Pane rules;
  32.  
  33.     // Game
  34.     private Pane game;
  35.  
  36.     public static void main(String[] args) {
  37.         launch(args);
  38.     }
  39.  
  40.     private void createModel() {
  41.         // new model
  42.     }
  43.  
  44.     private void createView() {
  45.         stage.setTitle("Othello");
  46.  
  47.         home = new HomePane();
  48.         play = new PlayPane();
  49.         rules = new RulesPane();
  50.         game = new GamePane();
  51.     }
  52.  
  53.     private void placeComponents() {
  54.         BorderPane p = new BorderPane();
  55.         {
  56.             StackPane stack = new StackPane();
  57.             {
  58.                 stack.getChildren().addAll(home, play, rules);
  59.                 stack.setMinWidth(800);
  60.             }
  61.             p.setCenter(stack);
  62.  
  63.             VBox vbox = new VBox();
  64.             {
  65.                 Label l1 = new Label("Projet");
  66.                 Label l2 = new Label("Théorie des jeux (2019)");
  67.                 Label l3 = new Label("Développeurs");
  68.                 Label l4 = new Label("LE CREURER Benjamin");
  69.                 Label l5 = new Label("LEBIDOIS Yohann");
  70.                 Label l6 = new Label("LEROUX Romuald");
  71.                 Label l7 = new Label("MAKHLOUF Bilal");
  72.  
  73.                 Label nbsp = new Label();
  74.  
  75.                 ImageView iv = new ImageView();
  76.                 iv.setImage(new Image("/img/logo_univ.png"));
  77.  
  78.                 vbox.getChildren().add(l1);
  79.                 vbox.getChildren().add(l2);
  80.                 vbox.getChildren().add(l3);
  81.  
  82.                 vbox.getChildren().add(l4);
  83.                 vbox.getChildren().add(l5);
  84.                 vbox.getChildren().add(l6);
  85.                 vbox.getChildren().add(l7);
  86.                 vbox.getChildren().add(nbsp);
  87.                 vbox.getChildren().add(iv);
  88.  
  89.                 // Classe CSS
  90.                 vbox.getStyleClass().add("vbox");
  91.                 l1.getStyleClass().add("lbl-title");
  92.                 l3.getStyleClass().add("lbl-title");
  93.                 l2.getStyleClass().add("lbl-sub");
  94.                 l4.getStyleClass().add("lbl-sub");
  95.                 l5.getStyleClass().add("lbl-sub");
  96.                 l6.getStyleClass().add("lbl-sub");
  97.                 l7.getStyleClass().add("lbl-sub");
  98.                 nbsp.getStyleClass().add("nbsp-50");
  99.  
  100.                 //vbox.setPrefWidth(400);
  101.             }
  102.             p.setRight(vbox);
  103.         }
  104.  
  105.         scene = new Scene(p, WIDTH, HEIGHT);
  106.         scene.getStylesheets().add("css/style.css");
  107.  
  108.         stage.setScene(scene);
  109.     }
  110.  
  111.     private void createController() {
  112.         home.addEventHandler(ChangePaneEvent.HOME_TO_PLAY, e -> TransitionUtils.fadeInOut(play, home));
  113.         home.addEventHandler(ChangePaneEvent.HOME_TO_RULES, e -> TransitionUtils.fadeInOut(rules, home));
  114.  
  115.         play.addEventHandler(ChangePaneEvent.PLAY_TO_HOME, e -> TransitionUtils.fadeInOut(home, play));
  116.         rules.addEventHandler(ChangePaneEvent.RULES_TO_HOME, e -> TransitionUtils.fadeInOut(home, rules));
  117.  
  118.         play.addEventHandler(ChangePaneEvent.PLAY_TO_GAME, e -> {
  119.  
  120.             scene.setRoot(game);
  121.         });
  122.     }
  123.  
  124.     @Override
  125.     public void start(Stage primaryStage) {
  126.         stage = primaryStage;
  127.  
  128.         createModel();
  129.         createView();
  130.         placeComponents();
  131.         createController();
  132.  
  133.         stage.show();
  134.     }
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement