예제 #1
0
  public static Node createProgressIndicator() {
    ProgressIndicator indicator = new ProgressIndicator();
    indicator.setMaxHeight(350);
    indicator.setMaxWidth(350);

    BorderPane borderPane = new BorderPane();
    BorderPane.setMargin(indicator, new Insets(5));
    borderPane.setCenter(indicator);
    borderPane.setStyle("-fx-background-color: rgba(230,230,230,0.7);");
    return borderPane;
  }
예제 #2
0
  @Override
  public void start(Stage stage) throws Exception {
    game = GameImpl.INSTANCE;

    LocalEndpoint.client = this;

    final BorderPane root = new BorderPane();
    root.setStyle("-fx-padding: 20");
    //		root.setCenter(rows);

    Timeline fiveSecondsWonder =
        new Timeline(
            new KeyFrame(
                Duration.seconds(1),
                new EventHandler<ActionEvent>() {

                  @Override
                  public void handle(ActionEvent event) {

                    final Sprite[][] grille = game.getGrille();
                    // *
                    //						final Sprite[][] grille = new Sprite[][] {
                    //								{ Sprite.MUR, Sprite.SOL, Sprite.FANTOME },
                    //								{ Sprite.MUR, Sprite.SOL, Sprite.FANTOME },
                    //								{ Sprite.MUR, Sprite.SOL, Sprite.FANTOME } };
                    // */
                    if (grille.length == 0) {
                      System.out.println("Grille vide");
                    } else {
                      System.out.println(
                          "Grille de taille : (" + grille.length + " x " + grille[0].length + ")");
                    }
                    VBox rows = prepareBoard(grille);

                    root.setCenter(rows);
                  }
                }));
    fiveSecondsWonder.setCycleCount(Timeline.INDEFINITE);
    fiveSecondsWonder.play();

    Scene scene = new Scene(root);
    scene.setOnKeyPressed(
        new EventHandler<KeyEvent>() {
          @Override
          public void handle(KeyEvent event) {
            System.out.println(
                "AmiEnnemisClient.start(...).new EventHandler() {...}.handle()" + event.getCode());
            doMove(event);
          }
        });
    stage.setScene(scene);
    stage.show();
  }
예제 #3
0
  public void setSimpleOverlay(Parent content) {
    BorderPane con = new BorderPane();
    BorderPane background = new BorderPane(content);
    BorderPane.setMargin(background, new Insets(50));

    background.setStyle("-fx-background-color: rgba(41, 41, 41, 0);");
    contentPane.setEffect(new BoxBlur());

    con.setCenter(background);
    con.setPickOnBounds(true);
    overlayPane.setCenter(con);
  }
예제 #4
0
 /**
  * Add a radio button corresponding to the save of name name
  *
  * @param name name of the corresponding save file
  */
 private void setUpRegistry(final Engine engine) {
   String name = engine.getNode().nameProperty().get();
   BorderPane registry = new BorderPane();
   HBox box = new HBox();
   Network network = (Network) engine.getNetwork();
   ConnectionButton connectionState = new ConnectionButton(network);
   Button launcher = new LoadNode(name);
   box.getChildren().addAll(connectionState, launcher);
   Button deleter = new DeleteNode(name);
   registry.setLeft(box);
   registry.setRight(deleter);
   registry.setStyle("-fx-background-color: white;");
   registries.add(registry);
 }
예제 #5
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    // Add mouse click event handler to the canvas to show the context menu
    canvas.setOnMouseClicked(this::showContextMenu);

    //
    BorderPane root = new BorderPane(canvas);
    root.setTop(new Label(Msg.get(this, "label.info")));
    root.setStyle(Msg.get(FlowPaneApp.class, "style"));

    Scene scene = new Scene(root);
    primaryStage.setScene(scene);
    primaryStage.setTitle(Msg.get(this, "title"));
    primaryStage.show();
  }
예제 #6
0
  @Override
  public void start(Stage primaryStage) {
    // primaryStage.initStyle(StageStyle.TRANSPARENT);
    accessor = new TwitchAPIAccessor();

    GridPane root = new GridPane();
    root.setHgap(20);
    root.setVgap(20);
    Button exit = new Button("Exit");
    exit.setOnAction(e -> primaryStage.close());
    root.add(exit, 0, 0);

    authStage = new Authentication();
    Button auth = new Button("Authenticate");
    auth.setOnAction(e -> authStage.authenticate(false, this::authSuccess, this::authFailure));
    root.add(auth, 0, 1);

    Button forceAuth = new Button("Force Authenticate");
    forceAuth.setOnAction(e -> authStage.authenticate(true, this::authSuccess, this::authFailure));
    root.add(forceAuth, 0, 2);

    Button isValid = new Button("Is Valid");
    isValid.setOnAction(e -> accessor.isOAuthValid(this::oauthValid, this::oauthInvalid));
    root.add(isValid, 0, 3);

    Button follows = new Button("Get Follows");
    follows.setOnAction(
        e -> accessor.getFollowAccessor().getUserStreamsFollowed(this::follows, this::exception));
    root.add(follows, 0, 4);

    ImageView imageView = new ImageView(image);
    imageView.setEffect(new ColorAdjust(0, -1, 0, 0));

    BorderPane imagePane = new BorderPane(imageView);
    imagePane.setStyle(
        "-fx-border-color: green;\n"
            + "-fx-border-insets: 5;\n"
            + "-fx-border-width:3;\n"
            + "-fx-border-style: dashed;\n");

    root.add(imagePane, 0, 5);

    Scene scene = new Scene(root);
    primaryStage.setScene(scene);
    primaryStage.show();
  }
예제 #7
0
  public GameState(StateManager sm) {
    super(sm);
    shop = new Shop();
    game = new ShopSimulation(shop);
    gameClock = new GameClock();

    gameClock.setListener(
        new GameClock.GameClockListener() {
          @Override
          public void crappyHourBegins() {
            game.startCrappyHour();
            Platform.runLater(() -> shop.getLog().addLog("The chaos has begun.."));
          }

          @Override
          public void shopClosed() {

            Platform.runLater(() -> endGame());
          }
        });

    // Check if game closed
    sm.getStage().setOnCloseRequest(e -> stageClosed());

    statusLabel = new Label();
    shop.setListener(this);

    moneyFormat = NumberFormat.getCurrencyInstance();

    // Setup basic panes + contents
    BorderPane rootPane = new BorderPane();
    rootPane.setStyle("-fx-background-color: #474F53;");

    rootPane.setTop(new VBox(initMenu(), initStatusBar()));

    rootPane.setBottom(initGame());

    startGame();

    scene = new Scene(rootPane);
    setupStyle();
    setupSubWindow();
  }
  @Override // Override the getPane() method in the super class
  protected BorderPane getPane() {
    BorderPane pane = super.getPane();

    BorderPane paneForTextField = new BorderPane();
    paneForTextField.setPadding(new Insets(5, 5, 5, 5));
    paneForTextField.setStyle("-fx-border-color: green");
    paneForTextField.setLeft(new Label("Enter a new message: "));

    TextField tf = new TextField();
    tf.setAlignment(Pos.BOTTOM_RIGHT);
    tf.setPrefWidth(100);
    tf.setPrefHeight(100);
    paneForTextField.setCenter(tf);
    pane.setTop(paneForTextField);

    tf.setOnAction(e -> text.setText(tf.getText()));

    return pane;
  }
예제 #9
0
  public MasterGUI(Stage stage) {
    parentStage = stage;

    // JsonHelpExtractor ujextractor = new JsonHelpExtractor();
    // HashMap<String,String> dataSetTab_tooltipHelp =
    // ujextractor.extractToolTipFile("TestJson.json");
    // HashMap<String, ExtensiveHelp> dataSetTab_extensiveHelp =
    // ujextractor.extractExtensiveHelpFile("DataSetExtensiveHelp.json");
    // final HelpDataStore dataSetTab_HelpStore = new
    // HelpDataStore("DataSetTab",dataSetTab_tooltipHelp,dataSetTab_extensiveHelp);

    // ujextractor.writeExtensiveHelpFile("C:\\Users\\user\\Desktop\\ExtensiveSectionTest.json");

    experiment = new Experiment();

    tabPane = new TabPane();
    final Tab tab1 = new DataSetTab(parentStage, experiment);
    tab1.setText("Dataset");

    final Tab tab2 = new PreprocessingTab(parentStage, experiment);
    tab2.setText("Preprocessing");

    final Tab tab3 = new FeatureSelectionTab(parentStage, experiment);
    tab3.setText("Feature Selection");

    final Tab tab4 = new AlgorithmTab(parentStage, experiment);
    tab4.setText("Preference Learning Methods");

    tabPane.tabClosingPolicyProperty().set(TabPane.TabClosingPolicy.UNAVAILABLE);
    tabPane.getTabs().addAll(tab1, tab2, tab3, tab4);

    BorderPane bottomPane = new BorderPane();

    final Button btnBack = new Button();
    btnBack.setPrefSize(200, 20);
    btnBack.setVisible(false);
    Label lblBackBtn = new Label("BACK");
    ImageView imgViewBkBtn =
        new ImageView(new Image(DataSetTab.class.getResourceAsStream("bkButton.png")));
    BorderPane backBtnInnerBPane = new BorderPane();
    backBtnInnerBPane.setLeft(imgViewBkBtn);
    backBtnInnerBPane.setCenter(lblBackBtn);
    btnBack.setGraphic(backBtnInnerBPane);

    btnBack.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent t) {

            if (tabPane.getSelectionModel().getSelectedIndex() > 0) {
              tabPane
                  .selectionModelProperty()
                  .get()
                  .select(tabPane.selectionModelProperty().get().getSelectedIndex() - 1);
            }
          }
        });

    final Button btnNext = new Button();
    btnNext.setPrefSize(200, 20);
    Label lblNextBtn = new Label("NEXT");
    ImageView imgViewNextBtn =
        new ImageView(new Image(DataSetTab.class.getResourceAsStream("nxtButton.png")));
    BorderPane nextBtnInnerBPane = new BorderPane();
    nextBtnInnerBPane.setCenter(lblNextBtn);
    nextBtnInnerBPane.setRight(imgViewNextBtn);
    btnNext.setGraphic(nextBtnInnerBPane);

    btnNext.disableProperty().bind(this.experiment.isReadyToUseDataSetProperty().not());

    tabPane.selectionModelProperty();

    btnNext.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent t) {

            if (!tab4.selectedProperty().get()) {
              tabPane
                  .selectionModelProperty()
                  .get()
                  .select(tabPane.selectionModelProperty().get().getSelectedIndex() + 1);
            } else if (tab4.selectedProperty().get()) {
              // Perform safety checks.
              boolean allClear = true;

              int numOfIgnoredFeatures = 0;
              boolean[] tmpIgArr = experiment.ignoredFeaturesProperty().get();
              for (int i = 0; i < tmpIgArr.length; i++) {
                if (tmpIgArr[i]) {
                  numOfIgnoredFeatures++;
                }
              }

              if (numOfIgnoredFeatures
                  == experiment.dataSetProperty().get().getNumberOfFeatures()) {
                // You must include at least one feature.

                ModalPopup notification = new ModalPopup();
                notification.show(
                    new Label("ERROR: You must include at least one feature from the dataset."),
                    parentStage.getScene().getRoot(),
                    null,
                    new Button("OK"),
                    200,
                    550,
                    false);

                allClear = false;
              } else if (experiment.featureSelectionProperty().get() != null) {
                if (experiment.featureSelectionProperty().get() instanceof NBest) {
                  NBest castNBest = (NBest) experiment.featureSelectionProperty().get();

                  int numOfUserIncludedFeatures =
                      (experiment.dataSetProperty().get().getNumberOfFeatures()
                          - numOfIgnoredFeatures);

                  if (castNBest.getN() > numOfUserIncludedFeatures) {
                    // N val should always be less than or equal to the number of user included
                    // features.

                    ModalPopup notification = new ModalPopup();
                    notification.show(
                        new Label(
                            "ERROR: N-Best N value cannot be greater than the number of included features. \n Current N Value = "
                                + castNBest.getN()
                                + " \n Current Num of Included Features = "
                                + numOfUserIncludedFeatures),
                        parentStage.getScene().getRoot(),
                        null,
                        new Button("OK"),
                        200,
                        600,
                        false);

                    allClear = false;
                  }
                }

                if (experiment.algorithmForFeatureSelectionProperty().get() == null) {
                  // You cannot select a feature selection type without stating an algorithm.

                  ModalPopup notification = new ModalPopup();
                  notification.show(
                      new Label(
                          "ERROR: You must state an algorithm to work with "
                              + experiment.featureSelectionProperty().get().getFSelName()
                              + "."),
                      parentStage.getScene().getRoot(),
                      null,
                      new Button("OK"),
                      200,
                      550,
                      false);

                  allClear = false;
                }
              }

              if (experiment.algorithmForFeatureSelectionProperty().get() != null) {
                if (experiment.algorithmForFeatureSelectionProperty().get()
                    instanceof PLNeuroEvolution) {
                  PLNeuroEvolution castPLNE =
                      (PLNeuroEvolution) experiment.algorithmForFeatureSelectionProperty().get();
                  PLNeuroEvolutionConfigurator neConfig = castPLNE.getConfigurator();
                  GeneticAlgorithmConfigurator gaConfig =
                      neConfig.getGeneticAlgorithmConfigurator();

                  if (gaConfig.getNumberOfParents() > gaConfig.getPopulationSize()) {
                    ModalPopup notification = new ModalPopup();
                    notification.show(
                        new Label(
                            "GA ERROR: The number of parents is greater than the GA population size."),
                        parentStage.getScene().getRoot(),
                        null,
                        new Button("OK"),
                        200,
                        550,
                        false);

                    allClear = false;
                  }

                  if (gaConfig.getElitSize() > gaConfig.getPopulationSize()) {
                    ModalPopup notification = new ModalPopup();
                    notification.show(
                        new Label(
                            "GA ERROR: The elitism size is greater than the GA population size."),
                        parentStage.getScene().getRoot(),
                        null,
                        new Button("OK"),
                        200,
                        550,
                        false);

                    allClear = false;
                  }
                }

                if (experiment.algorithmProperty().get() instanceof PLRankSvm) {
                  PLRankSvm castPLRS = (PLRankSvm) experiment.algorithmProperty().get();
                  PLRankSvmConfigurator svmConfig = castPLRS.getConfigurator();

                  if ((svmConfig.gammaRequired()) && (svmConfig.getGamma() == 0)) {
                    ModalPopup notification = new ModalPopup();
                    notification.show(
                        new Label("SVM ERROR: Gamma cannot be set to 0."),
                        parentStage.getScene().getRoot(),
                        null,
                        new Button("OK"),
                        200,
                        550,
                        false);

                    allClear = false;
                  }

                  if (svmConfig.degreeRequired()) {
                    try {
                      Integer.parseInt(svmConfig.getDegreeTextboxContents());
                    } catch (Exception NumberFormatException) {
                      ModalPopup notification = new ModalPopup();
                      notification.show(
                          new Label(
                              "SVM ERROR: Invalid Degree value \\"
                                  + svmConfig.getDegreeTextboxContents()
                                  + "\\"
                                  + "."),
                          parentStage.getScene().getRoot(),
                          null,
                          new Button("OK"),
                          200,
                          550,
                          false);

                      allClear = false;
                    }
                  }

                  if (svmConfig.betaRequired()) {
                    try {
                      Integer.parseInt(svmConfig.getBetaTextboxContents());
                    } catch (Exception NumberFormatException) {
                      ModalPopup notification = new ModalPopup();
                      notification.show(
                          new Label(
                              "SVM ERROR: Invalid Beta value \\"
                                  + svmConfig.getBetaTextboxContents()
                                  + "\\"
                                  + "."),
                          parentStage.getScene().getRoot(),
                          null,
                          new Button("OK"),
                          200,
                          550,
                          false);

                      allClear = false;
                    }
                  }
                }
              }

              if (experiment.algorithmProperty().get() instanceof PLNeuroEvolution) {
                PLNeuroEvolution castPLNE = (PLNeuroEvolution) experiment.algorithmProperty().get();
                PLNeuroEvolutionConfigurator neConfig = castPLNE.getConfigurator();
                GeneticAlgorithmConfigurator gaConfig = neConfig.getGeneticAlgorithmConfigurator();

                int numParents = gaConfig.getNumberOfParents();
                int popSize = gaConfig.getPopulationSize();
                if (numParents > popSize) {
                  ModalPopup notification = new ModalPopup();
                  notification.show(
                      new Label(
                          "GA ERROR: The number of parents is greater than the GA population size."),
                      parentStage.getScene().getRoot(),
                      null,
                      new Button("OK"),
                      200,
                      550,
                      false);

                  allClear = false;
                }

                if (gaConfig.getElitSize() > gaConfig.getPopulationSize()) {
                  ModalPopup notification = new ModalPopup();
                  notification.show(
                      new Label(
                          "GA ERROR: The elitism size is greater than the GA population size."),
                      parentStage.getScene().getRoot(),
                      null,
                      new Button("OK"),
                      200,
                      550,
                      false);

                  allClear = false;
                }
              }

              if (experiment.algorithmProperty().get() instanceof PLRankSvm) {
                PLRankSvm castPLRS = (PLRankSvm) experiment.algorithmProperty().get();
                PLRankSvmConfigurator svmConfig = castPLRS.getConfigurator();

                if ((svmConfig.gammaRequired()) && (svmConfig.getGamma() == 0)) {
                  ModalPopup notification = new ModalPopup();
                  notification.show(
                      new Label("SVM ERROR: Gamma cannot be set to 0."),
                      parentStage.getScene().getRoot(),
                      null,
                      new Button("OK"),
                      200,
                      550,
                      false);

                  allClear = false;
                }

                if (svmConfig.degreeRequired()) {
                  try {
                    Integer.parseInt(svmConfig.getDegreeTextboxContents());
                  } catch (Exception NumberFormatException) {
                    ModalPopup notification = new ModalPopup();
                    notification.show(
                        new Label(
                            "SVM ERROR: Invalid Degree value \\"
                                + svmConfig.getDegreeTextboxContents()
                                + "\\"
                                + "."),
                        parentStage.getScene().getRoot(),
                        null,
                        new Button("OK"),
                        200,
                        550,
                        false);

                    allClear = false;
                  }
                }

                if (svmConfig.betaRequired()) {
                  try {
                    Integer.parseInt(svmConfig.getBetaTextboxContents());
                  } catch (Exception NumberFormatException) {
                    ModalPopup notification = new ModalPopup();
                    notification.show(
                        new Label(
                            "SVM ERROR: Invalid Beta value \\"
                                + svmConfig.getBetaTextboxContents()
                                + "\\"
                                + "."),
                        parentStage.getScene().getRoot(),
                        null,
                        new Button("OK"),
                        200,
                        550,
                        false);

                    allClear = false;
                  }
                }
              }

              if (allClear) {
                Execution e = new Execution(experiment);
                e.show(parentStage);
              }
            }
          }
        });

    tab4.selectedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
                if (t1) {

                  Label lblNextBtn = new Label("RUN EXPERIMENT");
                  ImageView imgViewNextBtn =
                      new ImageView(
                          new Image(
                              DataSetTab.class.getResourceAsStream("runExperimentButton.png")));
                  BorderPane nextBtnInnerBPane = new BorderPane();
                  nextBtnInnerBPane.setCenter(lblNextBtn);
                  nextBtnInnerBPane.setRight(imgViewNextBtn);
                  btnNext.setGraphic(nextBtnInnerBPane);
                } else {
                  Label lblNextBtn = new Label("NEXT");
                  ImageView imgViewNextBtn =
                      new ImageView(
                          new Image(DataSetTab.class.getResourceAsStream("nxtButton.png")));
                  BorderPane nextBtnInnerBPane = new BorderPane();
                  nextBtnInnerBPane.setCenter(lblNextBtn);
                  nextBtnInnerBPane.setRight(imgViewNextBtn);
                  btnNext.setGraphic(nextBtnInnerBPane);
                }
              }
            });

    tab1.selectedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {

                if (t1) {
                  btnBack.setVisible(false);
                  btnNext.setVisible(true);
                } else {
                  btnBack.setVisible(true);
                }
              }
            });

    Button helpButton = new Button();
    helpButton.setVisible(true);
    helpButton.setGraphic(
        new ImageView(new Image(DataSetTab.class.getResourceAsStream("helpButton.png"))));
    helpButton.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent t) {
            if (tab1.selectedProperty().get()) {
              Tab1Help h = new Tab1Help();
              h.show(parentStage.getScene().getRoot(), null);
            } else if (tab2.selectedProperty().get()) {
              Tab2Help h = new Tab2Help();
              h.show(parentStage.getScene().getRoot(), null);
            } else if (tab3.selectedProperty().get()) {
              Tab3Help h = new Tab3Help();
              h.show(parentStage.getScene().getRoot(), null);
            } else if (tab4.selectedProperty().get()) {
              Tab4Help h = new Tab4Help();
              h.show(parentStage.getScene().getRoot(), null);
            }
          }
        });

    /*helpButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent t) {
            if (tab1.selectedProperty().get()) {
                ArrayList<String> itemsToInclude = new ArrayList<String>();
                itemsToInclude.add("Loading a dataset");
                itemsToInclude.add("Button: Import Object File");
                itemsToInclude.add("Button: Import Ranking File");

                String reqHTML = dataSetTab_HelpStore.constructHtml(itemsToInclude);
                HelpPopup hPopup = new HelpPopup(reqHTML);
                hPopup.show(parentStage.getScene().getRoot(), null);

                //Tab1Help h = new Tab1Help();
                //h.show(parentStage.getScene().getRoot(), null);
            }

            if (tab2.selectedProperty().get()) {
                Tab2Help h = new Tab2Help();
                h.show(parentStage.getScene().getRoot(), null);
            }

        }
    });*/

    // helpButton.visibleProperty().bind(tab1.selectedProperty().or(tab2.selectedProperty()));

    HBox navBtnBox = new HBox(10);
    navBtnBox.getChildren().addAll(btnBack, btnNext);

    bottomPane.setPadding(new Insets(10, 10, 10, 10));
    bottomPane.setStyle("-fx-background-color: #336699;");
    bottomPane.setLeft(helpButton);
    bottomPane.setRight(navBtnBox);

    this.setCenter(tabPane);
    this.setBottom(bottomPane);

    disableTabs(new ArrayList<Integer>(Arrays.asList(1, 2, 3)));
  }
예제 #10
0
  private void initialize(BorderPane pane) {

    pane.setStyle("-fx-background-color: lightgrey;");

    pane.getChildren().addAll(drawInventory(5, 5, 27));
  }
예제 #11
0
  @Override
  public void start(Stage primaryStage) {
    try {
      screen = primaryStage;
      screen.setOnCloseRequest(
          e -> {
            engine.interrupt();
          });

      lives = new SimpleDoubleProperty(1);
      lives.addListener(
          e -> {
            if (lives.get() == 0) {
              engine.interrupt();
              newGame.setText("Start new game");
              changeScene();
            }
          });

      logo = new Image(getClass().getResourceAsStream("logo.png"), 256, 256, true, true);
      logoView = new ImageView(logo);
      menu = new StackPane(logoView);

      livesText = new Text(String.valueOf((int) lives.get()));
      slowDownsText = new Text(String.valueOf(slowDownCount));
      score = new Text("Score");
      scorePoints = new Text(String.valueOf(points));

      livesText.setFill(Color.BEIGE);
      slowDownsText.setFill(Color.BEIGE);
      score.setFill(Color.BEIGE);
      scorePoints.setFill(Color.BEIGE);

      live = new Image(getClass().getResourceAsStream("live.png"));
      slowDown = new Image(getClass().getResourceAsStream("slowdown.png"));

      spotView = new ImageView(new Image(getClass().getResourceAsStream("spot.png")));
      liveView = new ImageView(live);
      slowDownView = new ImageView(slowDown);
      liveCounterView = new ImageView(live);
      slowDownCounterView = new ImageView(slowDown);

      spotView.setVisible(false);
      liveView.setVisible(false);
      slowDownView.setVisible(false);

      spotView.setOnMouseClicked(
          e -> {
            spotView.setVisible(false);
            clicked = true;
            points++;
            if (time > 400) {
              time -= 20;
            }
            scorePoints.setText(String.valueOf(points * 10));
          });

      liveView.setOnMouseClicked(
          e -> {
            liveView.setVisible(false);
            clicked = true;
            points++;
            lives.set(lives.get() + 1);
            livesText.setText(String.valueOf((int) lives.get()));
            scorePoints.setText(String.valueOf(points * 10));
          });

      slowDownView.setOnMouseClicked(
          e -> {
            slowDownView.setVisible(false);
            clicked = true;
            points++;
            slowDownCount++;
            slowDownsText.setText(String.valueOf(slowDownCount));
            scorePoints.setText(String.valueOf(points * 10));
          });

      slowDownCounterView.setOnMouseClicked(
          e -> {
            if (slowDownCount > 0) {
              slowDownCount--;
              slowDownsText.setText(String.valueOf(slowDownCount));
              time += 150;
            }
          });

      Separator sepOne = new Separator(Orientation.VERTICAL);
      sepOne.setOpacity(0.1);

      Separator sepTwo = new Separator(Orientation.VERTICAL);
      sepTwo.setOpacity(0.1);

      HBox header =
          new HBox(
              5,
              liveCounterView,
              livesText,
              sepOne,
              slowDownCounterView,
              slowDownsText,
              sepTwo,
              score,
              scorePoints);
      header.setAlignment(Pos.CENTER_LEFT);
      header.setStyle(
          "-fx-background-color:linear-gradient(#242424 50%, #2D2D2D 75%, #3C3C3C 100%);");
      header.setPadding(new Insets(3, 1, 3, 1));

      playField = new StackPane(spotView, liveView, slowDownView);
      playField.setAlignment(Pos.TOP_LEFT);
      playField.setStyle(
          "-fx-background-color: linear-gradient(#9d9e9d 5%, #6b6a6b 20%, #343534 80%, #242424 100%);");

      root = new BorderPane(playField, header, null, null, null);
      root.setStyle("-fx-border-color: #13BFF8");

      playScene = new Scene(root, 300, 500);

      newGame = new Button("Start");
      newGame.setStyle(
          "-fx-background-color: linear-gradient(TRANSPARENT 50%, #FFFFFF 100%);  -fx-text-fill: #FFFFFF; -fx-min-width: 128px;");
      newGame.setOnMouseEntered(
          e ->
              newGame.setStyle(
                  "-fx-background-color: linear-gradient(TRANSPARENT 10%, #FFFFFF 100%);  -fx-text-fill: #FFFFFF; -fx-min-width: 128px;"));
      newGame.setOnMouseExited(
          e ->
              newGame.setStyle(
                  "-fx-background-color: linear-gradient(TRANSPARENT 50%, #FFFFFF 100%);  -fx-text-fill: #FFFFFF; -fx-min-width: 128px;"));
      newGame.setTranslateY(80);
      newGame.setOnMouseClicked(
          e -> {
            points = 0;
            time = 1500;
            clicked = false;
            slowDownCount = 0;
            lives.set(1);
            livesText.setText(String.valueOf((int) lives.get()));
            screen.setScene(playScene);
            engine = new Engine(this);
            engine.start();
          });
      menu.getChildren().add(newGame);

      menuScene = new Scene(menu, 256, 256);
      menu.setStyle(
          "-fx-background-color: linear-gradient(#9d9e9d 5%, #6b6a6b 20%, #343534 80%, #242424 100%); -fx-border-color: #13BFF8;");

      primaryStage.setScene(menuScene);
      primaryStage.setResizable(false);
      primaryStage.initStyle(StageStyle.UNDECORATED);
      primaryStage.show();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  /**
   * Draws the MapMaker screen and displays it to the user
   *
   * @param primaryStage the stage to show it in
   * @throws Exception
   */
  public void drawScreen(Stage primaryStage) throws Exception {
    // Create the base BorderPane for the whole window
    BorderPane borderPane = new BorderPane();
    borderPane.setStyle("-fx-background-color: papayawhip");

    // Add some instructions to the user
    String text =
        "Instructions:\n"
            + "1. Click on the map component that you would like to place in the map\n"
            + "2. Click on the place in the map where you want to place the component\n"
            + "3. Repeat until you built the map you want!\n"
            + "4. Hit the 'Save' button when you are done";
    Label instructions = new Label(text);
    instructions.setFont(Font.font("Arial", FontWeight.BOLD, 12));
    instructions.setPadding(new Insets(5, 5, 5, 5));
    borderPane.setTop(instructions);

    // Create the blank Map
    Pane mapPane = new Pane();
    Map map = new Map(width, height);
    MapGridGUIDecorator mapGridGUIDecorator = new MapGridGUIDecorator(map.getGrid());
    ResizeFactor rf = ResizeFactor.getSuggestedResizeFactor(width, height);
    mapGridGUIDecorator.setResizeFactor(rf);
    GridPane mapGridPane = mapGridGUIDecorator.drawComponents();
    mapGridPane.setPadding(new Insets(0, 0, 5, 5));
    mapPane.getChildren().add(mapGridPane);
    borderPane.setCenter(mapPane);
    MapMakerController.setCurrentFocused(ComponentType.NOTHING);

    VBox sideComponents = new VBox();

    /* Add "Components" label */
    Label componentsLabel = new Label("Components");
    componentsLabel.setFont(Font.font("Arial", FontWeight.EXTRA_BOLD, 14));
    componentsLabel.setPadding(new Insets(15, 5, 0, 20));
    sideComponents.getChildren().add(componentsLabel);

    /* Add Intersection square image */
    VBox intersectionPane = new VBox();
    Label intersectionLabel = new Label("Intersection");
    intersectionLabel.setPadding(new Insets(5, 5, 0, 30));
    intersectionLabel.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12));
    Image intersectionImg = new Image("IntersectionX.png", 60, 60, true, false);
    intersectionImgView = new ImageView(intersectionImg);
    StackPane intersectionStackPane = new StackPane(intersectionImgView);
    intersectionStackPane.setPadding(new Insets(0, 10, 10, 10));
    intersectionPane.getChildren().add(intersectionLabel);
    intersectionPane.getChildren().add(intersectionStackPane);
    sideComponents.getChildren().add(intersectionPane);

    /* Add RoadNS square image */
    VBox roadNSPane = new VBox();
    Label roadNSLabel = new Label("Road (North-South)");
    roadNSLabel.setPadding(new Insets(5, 5, 0, 15));
    roadNSLabel.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12));
    Image roadNSImg = new Image("RoadBackgroundNS.png", 60, 60, true, false);
    roadNSImgView = new ImageView(roadNSImg);
    StackPane roadNSStackPane = new StackPane(roadNSImgView);
    roadNSStackPane.setPadding(new Insets(0, 10, 10, 10));
    roadNSPane.getChildren().add(roadNSLabel);
    roadNSPane.getChildren().add(roadNSStackPane);
    sideComponents.getChildren().add(roadNSPane);

    /* Add RoadEW square image */
    VBox roadEWPane = new VBox();
    Label roadEWLabel = new Label("Road (East-West)");
    roadEWLabel.setPadding(new Insets(5, 5, 0, 15));
    roadEWLabel.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12));
    Image roadEWImg = new Image("RoadBackgroundEW.png", 60, 60, true, false);
    roadEWImgView = new ImageView(roadEWImg);
    StackPane roadEWStackPane = new StackPane(roadEWImgView);
    roadEWStackPane.setPadding(new Insets(0, 10, 10, 10));
    roadEWPane.getChildren().add(roadEWLabel);
    roadEWPane.getChildren().add(roadEWStackPane);
    sideComponents.getChildren().add(roadEWPane);

    /* Add Grass square image to empty out cells */
    VBox grassPane = new VBox();
    Label grassLabel = new Label("Grass (clear square)");
    grassLabel.setPadding(new Insets(5, 5, 0, 15));
    grassLabel.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12));
    Image grassImg = new Image("Grass.png", 60, 60, true, false);
    grassImgView = new ImageView(grassImg);
    StackPane grassStackPane = new StackPane(grassImgView);
    grassStackPane.setPadding(new Insets(0, 10, 10, 10));
    grassPane.getChildren().add(grassLabel);
    grassPane.getChildren().add(grassStackPane);
    sideComponents.getChildren().add(grassPane);

    /* Add Save, Reset buttons */
    VBox buttonsPane = new VBox();
    buttonsPane.setPadding(new Insets(0, 0, 0, 10));
    Label toolsLabel = new Label("Tools");
    toolsLabel.setFont(Font.font("Arial", FontWeight.EXTRA_BOLD, 14));
    toolsLabel.setPadding(new Insets(15, 5, 5, 35));
    buttonsPane.getChildren().add(toolsLabel);
    Insets padding = new Insets(0, 0, 5, 0);
    Button saveButton = new Button("Save Map");
    StackPane saveButtonPane = new StackPane(saveButton);
    saveButtonPane.setPadding(padding);
    saveButton.setStyle("-fx-base:Gold");
    saveButton.setFont(Font.font("System Bold Italic", FontWeight.BOLD, 13));
    buttonsPane.getChildren().add(saveButtonPane);
    Button resetButton = new Button("Reset Map");
    resetButton.setStyle("-fx-base:Gold");
    resetButton.setFont(Font.font("System Bold Italic", FontWeight.BOLD, 13));
    StackPane resetButtonPane = new StackPane(resetButton);
    resetButtonPane.setPadding(padding);
    buttonsPane.getChildren().add(resetButtonPane);
    Button backButton = new Button("Go Back");
    backButton.setStyle("-fx-base:Gold");
    backButton.setFont(Font.font("System Bold Italic", FontWeight.BOLD, 13));
    StackPane backButtonPane = new StackPane(backButton);
    backButtonPane.setPadding(padding);
    buttonsPane.getChildren().add(backButtonPane);

    sideComponents.getChildren().add(buttonsPane);

    Ticker.start();

    /* Add click processing for Map grid squares */
    for (int i = 0; i < height; i++) {
      for (int j = 0; j < width; j++) {
        Node current = getNodeFromIndex(i, j, mapGridPane);
        final int x = j;
        final int y = i;
        current.setOnMouseClicked(
            (MouseEvent click) -> {
              MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused());
              MapMakerController.setCurrentFocused(ComponentType.MAP_SQUARE);
              current.requestFocus();
            });
        current
            .focusedProperty()
            .addListener(
                (ObservableValue<? extends Boolean> observable,
                    Boolean oldValue,
                    Boolean newValue) -> {
                  ComponentType previous = MapMakerController.getPreviousFocused();
                  if (previous == ComponentType.INTERSECTION) {
                    addIntersection(
                        x, y, map, mapGridGUIDecorator, mapGridPane, intersectionImgView);
                  } else if (previous == ComponentType.ROADNS) {
                    addRoadNS(x, y, map, mapGridGUIDecorator, mapGridPane, roadNSImgView);
                  } else if (previous == ComponentType.ROADEW) {
                    addRoadEW(x, y, map, mapGridGUIDecorator, mapGridPane, roadEWImgView);
                  } else if (previous == ComponentType.GRASS) {
                    addGrass(x, y, map, mapGridGUIDecorator, mapGridPane, grassImgView);
                  }
                });
      }
    }

    /* Add intersection icon click processing */
    DropShadow ds = new DropShadow(15, Color.BLUE);
    intersectionImgView.setOnMouseClicked(
        click -> {
          MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused());
          MapMakerController.setCurrentFocused(ComponentType.INTERSECTION);
          intersectionImgView.requestFocus();
        });
    intersectionImgView
        .focusedProperty()
        .addListener(
            (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
              if (newValue) intersectionImgView.setEffect(ds);
              else intersectionImgView.setEffect(null);
            });

    /* Add roadNS icon click processing */
    roadNSImgView.setOnMouseClicked(
        click -> {
          MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused());
          MapMakerController.setCurrentFocused(ComponentType.ROADNS);
          roadNSImgView.requestFocus();
        });
    roadNSImgView
        .focusedProperty()
        .addListener(
            (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
              if (newValue) roadNSImgView.setEffect(ds);
              else roadNSImgView.setEffect(null);
            });

    /* Add roadEW icon click processing */
    roadEWImgView.setOnMouseClicked(
        click -> {
          MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused());
          MapMakerController.setCurrentFocused(ComponentType.ROADEW);
          roadEWImgView.requestFocus();
        });
    roadEWImgView
        .focusedProperty()
        .addListener(
            (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
              if (newValue) roadEWImgView.setEffect(ds);
              else roadEWImgView.setEffect(null);
            });

    /* Add grass icon click processing */
    grassImgView.setOnMouseClicked(
        click -> {
          MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused());
          MapMakerController.setCurrentFocused(ComponentType.GRASS);
          grassImgView.requestFocus();
        });
    grassImgView
        .focusedProperty()
        .addListener(
            (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
              if (newValue) grassImgView.setEffect(ds);
              else grassImgView.setEffect(null);
            });

    /* Add save button functionality */
    saveButton.setOnMouseClicked(
        click -> {
          TextInputDialog nameDialog = new TextInputDialog();
          nameDialog.setTitle("Save Map");
          nameDialog.setHeaderText(
              "Please provide a name for your map (no spaces or special characters).\nSaved maps go into the /maps directory of your working directory.");
          nameDialog.setContentText("File name");
          Button btOk = (Button) nameDialog.getDialogPane().lookupButton(ButtonType.OK);
          TextField textfield = nameDialog.getEditor();
          Platform.runLater(() -> textfield.requestFocus());
          btOk.setDisable(true);
          textfield
              .textProperty()
              .addListener(
                  ((observable, oldValue, newValue) -> {
                    btOk.setDisable(newValue.trim().isEmpty());
                  }));

          Optional<String> result = nameDialog.showAndWait();
          result.ifPresent(
              name -> {
                name = name.concat(".map");
                try {
                  Map finalMap = buildAndSaveMap(map);
                  finalMap.saveMap(name);
                  goBack(primaryStage);
                } catch (Exception e) {
                  e.printStackTrace();
                }
              });
        });

    resetButton.setOnMouseClicked(
        click -> {
          for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
              Component component = map.getAtLocation(new Coordinate(x, y));
              if (component instanceof Road || component instanceof Intersection) {
                addGrass(x, y, map, mapGridGUIDecorator, mapGridPane, grassImgView);
              }
            }
          }
        });

    backButton.setOnMouseClicked(
        click -> {
          try {
            goBack(primaryStage);
          } catch (Exception e) {
            e.printStackTrace();
          }
        });

    borderPane.setRight(sideComponents);
    Scene scene = new Scene(borderPane);
    primaryStage.setScene(scene);
    primaryStage.centerOnScreen();
    primaryStage.setResizable(false);
  }
예제 #13
0
  public Connexion(final Stage stage) throws Exception {

    panelTitre.getChildren().add(titre);
    panelTitre.setAlignment(Pos.CENTER);
    panelTitre.setMinHeight(50);

    gridPane.setAlignment(Pos.CENTER);
    borderCenter.setCenter(gridPane);
    borderCenter.setMinHeight(100);

    panelPrincipal.setTop(panelTitre);
    panelPrincipal.setCenter(borderCenter);

    titre.setFont(Font.font("Verdana", 40));

    FileReader fr = new FileReader(fichierLogin);
    @SuppressWarnings("resource")
    BufferedReader br = new BufferedReader(fr);

    String ligneAdmin = br.readLine();
    String ligneUtil = br.readLine();

    String[] tabAdmin = ligneAdmin.split(";");
    admin.setIdentifiant(tabAdmin[0]);
    admin.setMotDePasse(tabAdmin[1]);

    String[] tabUtil = ligneUtil.split(";");
    util.setIdentifiant(tabUtil[0]);
    util.setMotDePasse(tabUtil[1]);

    panelPrincipal.setPadding(new Insets(10, 50, 50, 50));

    gridPane.setPadding(new Insets(7));
    gridPane.setHgap(7);
    gridPane.setVgap(7);

    lblUserName.setFont(Font.font("Arial", 15));
    lblPassword.setFont(Font.font("Arial", 15));

    gridPane.add(lblUserName, 0, 0);
    gridPane.add(txtUserName, 1, 0);
    gridPane.add(lblPassword, 0, 1);
    gridPane.add(pf, 1, 1);
    gridPane.add(btnLogin, 1, 3);
    gridPane.add(lblMessage, 1, 5);
    btnLogin.setFont(Font.font(null, 15));
    gridPane.setMinWidth(100);

    btnLogin.setPrefSize(100, 15);
    btnLogin.setOnAction(
        new EventHandler<ActionEvent>() {
          public void handle(ActionEvent event) {
            checkUser = txtUserName.getText().toString();
            checkPw = pf.getText().toString();
            if (checkUser.equals(admin.getIdentifiant()) && checkPw.equals(admin.getMotDePasse())) {
              new EcranGestionStagiaire(stage);
            } else if (checkUser.equals(util.getIdentifiant())
                && checkPw.equals(util.getMotDePasse())) {
              new EcranAffichageStagiaire(stage);
            } else {
              lblMessage.setText("Identifiant ou mot de passe erroné");
              lblMessage.setFont(Font.font("Arial", 12));
              lblMessage.setTextFill(Color.RED);
            }
            txtUserName.setText("");
            pf.setText("");
          }
        });
    panelPrincipal.setStyle("-fx-background-color: #DCDCDC");
    Scene scene = new Scene(panelPrincipal, 800, 550);
    stage.setTitle("Annuaire des stagiaires");
    stage.setScene(scene);
    stage.show();
  }
  public entryView(Object object) {
    getChildren().clear();
    getStylesheets().add("css/entryView.css");
    giveNode(object);

    BorderPane mainpane = new BorderPane();
    BorderPane centerpane = new BorderPane();
    BorderPane bottompane = new BorderPane();
    GridPane divgrid = new GridPane();
    GridPane maingrid = new GridPane();
    Label emptylab = new Label();
    Label divlab = new Label();
    VBox options = new VBox();
    VBox tlist = new VBox();
    Button ok = new Button("ok");
    Periods periods = new Periods();
    TList loadteacher = new TList();
    DatePicker date = new DatePicker();
    BorderPane datepane = new BorderPane();
    BorderPane nextpane = new BorderPane();
    Button next = new Button("next");

    options.setId("options");
    tlist.setId("tlist");
    divgrid.setId("divgrid");
    bottompane.setId("bottompane");
    periods.setId("period");
    divlab.setId("divlabel");
    datepane.setId("datepane");
    nextpane.setId("nextpane");

    emptylab.setPrefHeight(100);
    bottompane.setStyle("-fx-background-color:#ecf0f1;");

    StringConverter converter =
        new StringConverter<LocalDate>() {
          DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");

          @Override
          public String toString(LocalDate date) {
            if (date != null) {
              return dateFormatter.format(date);
            } else {
              return "";
            }
          }

          @Override
          public LocalDate fromString(String string) {
            if (string != null && !string.isEmpty()) {
              return LocalDate.parse(string, dateFormatter);
            } else {
              return null;
            }
          }
        };
    date.setConverter(converter);
    date.setPromptText("dd-MM-yyyy".toLowerCase());

    date.setValue(LocalDate.now());

    maingrid = div.loadDiv();
    list = (ListView) div.takelist();
    periods.period();
    list.getSelectionModel().select(0);
    divlab.setText((String) list.getItems().get(0));
    list.setOnMouseClicked(
        e -> {
          divlab.setText((String) list.getSelectionModel().getSelectedItem());
          periods.getChildren().clear();
          periods.period();
        });
    final Node node = maingrid.getChildren().get(0);
    Platform.runLater(
        new Runnable() {
          @Override
          public void run() {
            node.requestFocus();
          }
        });
    next.setOnAction(
        e -> {
          //			list.getSelectionModel().getSelectedIndex()+1
          list.getSelectionModel().select(list.getSelectionModel().getSelectedIndex() + 1);
          divlab.setText((String) list.getSelectionModel().getSelectedItem());
        });

    nextpane.setRight(next);
    datepane.setRight(date);
    options.getChildren().clear();
    options.getChildren().add(maingrid);
    divgrid.setHgap(5);
    //		divgrid.add(emptylab, 0, 1);
    divgrid.add(datepane, 1, 0);
    divgrid.add(divlab, 0, 2);
    divgrid.add(periods, 1, 2);
    divgrid.add(nextpane, 1, 3);
    divgrid.setAlignment(Pos.TOP_CENTER);
    mainpane.setCenter(centerpane);
    mainpane.setLeft(options);
    mainpane.setRight(loadteacher);
    centerpane.setCenter(divgrid);
    centerpane.setBottom(bottompane);
    bottompane.setRight(ok);

    addCloseButton cb = new addCloseButton();
    cb.addxb(1);
    setTop(cb);
    setCenter(mainpane);
  }