예제 #1
0
  public void askImageScreen() {

    Integer[] randomImageNumber = new Integer[49];
    for (int i = 0; i < randomImageNumber.length; i++) {
      randomImageNumber[i] = i;
    }
    Collections.shuffle(Arrays.asList((randomImageNumber)));

    String[] listOfImageAsk = new String[levelFactor];

    Group group = new Group();
    for (int i = 0; i < listOfImageAsk.length; i++) {
      Image image = allImages[randomImageNumber[i]];
      ImageView imageAsk = new ImageView(image);
      imageAsk.setId(randomImageNumber[i] + ".gif");
      listOfImageAsk[i] = (randomImageNumber[i] + ".gif");
      imageAsk.setX(i * 83);
      group.getChildren().add(imageAsk);
      System.out.println(listOfImageAsk[i]);
    }

    // scene3 elements

    Label instruction = new Label("RULES TO BE HERE");
    Button nextButton = new Button("NEXT");

    BorderPane layout3 = new BorderPane();

    layout3.setCenter(group);
    layout3.setTop(instruction);
    layout3.setBottom(nextButton);
    layout3.setAlignment(instruction, Pos.TOP_CENTER);
    layout3.setAlignment(nextButton, Pos.BASELINE_CENTER);
    nextButton.setOnAction(e -> checkResultScreen(listOfImageAsk));
    nextButton.setOnKeyPressed(e -> checkResultScreen(listOfImageAsk));

    scene3 = new Scene(layout3, 800, 600);
    window1.setScene(scene3);
  }
  public SubExperimentListCell() {
    BorderPane.setMargin(progressRect, new Insets(2));
    BorderPane.setMargin(progressRect, new Insets(2, 0, 0, 0));
    BorderPane.setAlignment(label, Pos.BOTTOM_LEFT);

    progressRect.setMaxWidth(Integer.MAX_VALUE);
    progressRect.setPrefHeight(3);
    progressRect.setMinHeight(3);
    progressRect.getStyleClass().add("mini-progress-bar");

    content.setBottom(progressRect);
    content.setCenter(label);
  }
예제 #3
0
  public ButtonedSlider(double minValue, double maxValue, double currentValue) {
    double diff = Math.max(0, maxValue - minValue);
    slider = new Slider(minValue, maxValue, currentValue);
    slider.setPadding(new Insets(3));
    BorderPane.setAlignment(slider, Pos.CENTER);
    setCenter(slider);

    Button minusButton = new Button("-");
    minusButton.setMinSize(16, 16);
    minusButton.setPrefSize(16, 16);
    minusButton.setMaxSize(16, 16);
    BorderPane.setAlignment(minusButton, Pos.CENTER);
    minusButton.setOnAction(e -> slider.setValue(slider.getValue() - diff / 20.0));
    setLeft(minusButton);

    Button plusButton = new Button("+");
    plusButton.setMinSize(16, 16);
    plusButton.setPrefSize(16, 16);
    plusButton.setMaxSize(16, 16);
    BorderPane.setAlignment(plusButton, Pos.CENTER);
    plusButton.setOnAction(e -> slider.setValue(slider.getValue() + diff / 20.0));
    setRight(plusButton);
  }
예제 #4
0
  /**
   * Creates a new instance of the ace editor.
   *
   * @return
   * @throws java.io.IOException
   */
  public static AceEditor createNew() throws IOException {
    // init loader
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(AceEditor.class.getResource(AceEditor.class.getSimpleName() + ".fxml"));

    // attach node
    Node node = (Node) loader.load();
    BorderPane.setAlignment(node, Pos.CENTER);
    AceEditor ace = (AceEditor) loader.getController();
    ace.setCenter(node);
    ace.setMinSize(0, 0);
    ace.setPrefSize(600, 400);
    ace.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);

    // post load work
    ace.initialize();

    return ace;
  }
예제 #5
0
  /** {@inheritDoc} */
  @Override
  public void add(IComponent pComponent, Object pConstraints, int pIndex) {
    if (pConstraints == null || CENTER.equals(pConstraints)) {
      resource.setCenter((Node) pComponent.getResource());
    } else if (EAST.equals(pConstraints)) {
      resource.setRight((Node) pComponent.getResource());
    } else if (NORTH.equals(pConstraints)) {
      resource.setTop((Node) pComponent.getResource());
    } else if (SOUTH.equals(pConstraints)) {
      resource.setBottom((Node) pComponent.getResource());
    } else if (WEST.equals(pConstraints)) {
      resource.setLeft((Node) pComponent.getResource());
    } else {
      resource.setCenter((Node) pComponent.getResource());
    }

    BorderPane.setAlignment((Node) pComponent.getResource(), Pos.CENTER);

    updateGaps();
  }
예제 #6
0
  @Override
  protected void initTitle() {
    oneClick.addListener(
        (observable, oldValue, newValue) ->
            GlobalCachedExecutorService.submit(
                new Task() {
                  @Override
                  protected Object call() {
                    if (toggleSwitch.isSelected()) {
                      sendStateToRemote(ActivationState.State.DEACTIVE);
                    } else {
                      sendStateToRemote(ActivationState.State.ACTIVE);
                    }
                    return null;
                  }
                }));

    toggleSwitch.setOnMouseClicked(
        event ->
            GlobalCachedExecutorService.submit(
                new Task() {
                  @Override
                  protected Object call() {
                    if (toggleSwitch.isSelected()) {
                      sendStateToRemote(ActivationState.State.ACTIVE);
                    } else {
                      sendStateToRemote(ActivationState.State.DEACTIVE);
                    }
                    return null;
                  }
                }));

    unknownForegroundIcon.setForegroundIconColor(Color.BLUE);
    unknownBackgroundIcon.setForegroundIconColor(Color.WHITE);

    headContent.setCenter(getUnitLabel());
    headContent.setAlignment(getUnitLabel(), Pos.CENTER_LEFT);
    headContent.prefHeightProperty().set(appIcon.getHeight() + Constants.INSETS);
  }
예제 #7
0
    public MediaControl(final MediaPlayer mp) {
      this.mp = mp;
      setStyle("-fx-background-color: #bfc2c7;"); // TODO: Use css file
      mediaView = new MediaView(mp);
      mvPane = new Pane();
      mvPane.getChildren().add(mediaView);
      mvPane.setStyle("-fx-background-color: black;"); // TODO: Use css file
      setCenter(mvPane);
      mediaBar = new HBox(5.0);
      mediaBar.setPadding(new Insets(5, 10, 5, 10));
      mediaBar.setAlignment(Pos.CENTER_LEFT);
      BorderPane.setAlignment(mediaBar, Pos.CENTER);

      final Button playButton = ButtonBuilder.create().minWidth(Control.USE_PREF_SIZE).build();

      playButton.setGraphic(imageViewPlay);
      playButton.setOnAction(
          new EventHandler<ActionEvent>() {
            public void handle(ActionEvent e) {
              updateValues();
              MediaPlayer.Status status = mp.getStatus();
              if (status == MediaPlayer.Status.UNKNOWN || status == MediaPlayer.Status.HALTED) {
                // don't do anything in these states
                return;
              }

              if (status == MediaPlayer.Status.PAUSED
                  || status == MediaPlayer.Status.READY
                  || status == MediaPlayer.Status.STOPPED) {
                // rewind the movie if we're sitting at the end
                if (atEndOfMedia) {
                  mp.seek(mp.getStartTime());
                  atEndOfMedia = false;
                  playButton.setGraphic(imageViewPlay);
                  // playButton.setText(">");
                  updateValues();
                }
                mp.play();
                playButton.setGraphic(imageViewPause);
                // playButton.setText("||");
              } else {
                mp.pause();
              }
            }
          });
      mp.currentTimeProperty()
          .addListener(
              new ChangeListener<Duration>() {
                @Override
                public void changed(
                    ObservableValue<? extends Duration> observable,
                    Duration oldValue,
                    Duration newValue) {
                  updateValues();
                }
              });
      mp.setOnPlaying(
          new Runnable() {
            public void run() {

              if (stopRequested) {
                mp.pause();
                stopRequested = false;
              } else {
                playButton.setGraphic(imageViewPause);
                // playButton.setText("||");
              }
            }
          });
      mp.setOnPaused(
          new Runnable() {
            public void run() {

              playButton.setGraphic(imageViewPlay);
              // playButton.setText("||");
            }
          });
      mp.setOnReady(
          new Runnable() {
            public void run() {
              duration = mp.getMedia().getDuration();
              updateValues();
            }
          });

      mp.setCycleCount(repeat ? MediaPlayer.INDEFINITE : 1);
      mp.setOnEndOfMedia(
          new Runnable() {
            public void run() {
              if (!repeat) {
                playButton.setGraphic(imageViewPlay);
                // playButton.setText(">");
                stopRequested = true;
                atEndOfMedia = true;
              }
            }
          });
      mediaBar.getChildren().add(playButton);

      // Time label
      Label timeLabel = new Label("Time");
      timeLabel.setMinWidth(Control.USE_PREF_SIZE);
      mediaBar.getChildren().add(timeLabel);

      // Time slider
      timeSlider = SliderBuilder.create().minWidth(30).maxWidth(Double.MAX_VALUE).build();
      HBox.setHgrow(timeSlider, Priority.ALWAYS);
      timeSlider
          .valueProperty()
          .addListener(
              new InvalidationListener() {
                public void invalidated(Observable ov) {
                  if (timeSlider.isValueChanging()) {
                    // multiply duration by percentage calculated by slider position
                    if (duration != null) {
                      mp.seek(duration.multiply(timeSlider.getValue() / 100.0));
                    }
                    updateValues();
                  }
                }
              });
      mediaBar.getChildren().add(timeSlider);

      // Play label
      playTime =
          LabelBuilder.create()
              // .prefWidth(130)
              .minWidth(Control.USE_PREF_SIZE)
              .build();

      mediaBar.getChildren().add(playTime);

      // Fullscreen button

      Button buttonFullScreen =
          ButtonBuilder.create().text("Full Screen").minWidth(Control.USE_PREF_SIZE).build();

      buttonFullScreen.setOnAction(
          new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
              if (!fullScreen) {
                newStage = new Stage();
                newStage
                    .fullScreenProperty()
                    .addListener(
                        new ChangeListener<Boolean>() {
                          @Override
                          public void changed(
                              ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
                            onFullScreen();
                          }
                        });
                final BorderPane borderPane =
                    new BorderPane() {
                      @Override
                      protected void layoutChildren() {
                        if (mediaView != null && getBottom() != null) {
                          mediaView.setFitWidth(getWidth());
                          mediaView.setFitHeight(getHeight() - getBottom().prefHeight(-1));
                        }
                        super.layoutChildren();
                        if (mediaView != null) {
                          mediaView.setTranslateX(
                              (((Pane) getCenter()).getWidth() - mediaView.prefWidth(-1)) / 2);
                          mediaView.setTranslateY(
                              (((Pane) getCenter()).getHeight() - mediaView.prefHeight(-1)) / 2);
                        }
                      };
                    };

                setCenter(null);
                setBottom(null);
                borderPane.setCenter(mvPane);
                borderPane.setBottom(mediaBar);

                Scene newScene = new Scene(borderPane);
                newStage.setScene(newScene);
                // Workaround for disposing stage when exit fullscreen
                newStage.setX(-100000);
                newStage.setY(-100000);

                newStage.setFullScreen(true);
                fullScreen = true;
                newStage.show();

              } else {
                // toggle FullScreen
                fullScreen = false;
                newStage.setFullScreen(false);
              }
            }
          });
      mediaBar.getChildren().add(buttonFullScreen);

      // Volume label
      Label volumeLabel = new Label("Vol");
      volumeLabel.setMinWidth(Control.USE_PREF_SIZE);
      mediaBar.getChildren().add(volumeLabel);

      // Volume slider
      volumeSlider =
          SliderBuilder.create().prefWidth(70).minWidth(30).maxWidth(Region.USE_PREF_SIZE).build();
      volumeSlider
          .valueProperty()
          .addListener(
              new InvalidationListener() {
                public void invalidated(Observable ov) {}
              });
      volumeSlider
          .valueProperty()
          .addListener(
              new ChangeListener<Number>() {
                @Override
                public void changed(
                    ObservableValue<? extends Number> observable,
                    Number oldValue,
                    Number newValue) {
                  if (volumeSlider.isValueChanging()) {
                    mp.setVolume(volumeSlider.getValue() / 100.0);
                  }
                }
              });
      mediaBar.getChildren().add(volumeSlider);

      setBottom(mediaBar);
    }
예제 #8
0
    public MediaControl(final MediaPlayer mp) {
      this.mp = mp;
      setStyle("-fx-background-color: #bfc2c7;"); // TODO: Use css file
      mediaView = new MediaView(mp);
      Pane mvPane = new Pane() {};

      mvPane.getChildren().add(mediaView);
      mvPane.setStyle("-fx-background-color: black;"); // TODO: Use css file
      setCenter(mvPane);
      mediaBar = new HBox();
      mediaBar.setPadding(new Insets(5, 10, 5, 10));
      mediaBar.setAlignment(Pos.CENTER_LEFT);
      BorderPane.setAlignment(mediaBar, Pos.CENTER);

      final Button playButton = new Button();
      playButton.setGraphic(imageViewPlay);
      playButton.setOnAction(
          new EventHandler<ActionEvent>() {
            public void handle(ActionEvent e) {
              updateValues();
              Status status = mp.getStatus();
              if (status == Status.UNKNOWN || status == Status.HALTED) {
                // don't do anything in these states
                return;
              }

              if (status == Status.PAUSED || status == Status.READY || status == Status.STOPPED) {
                // rewind the movie if we're sitting at the end
                if (atEndOfMedia) {
                  mp.seek(mp.getStartTime());
                  atEndOfMedia = false;
                  playButton.setGraphic(imageViewPlay);
                  // playButton.setText(">");
                  updateValues();
                }
                mp.play();
                playButton.setGraphic(imageViewPause);
                // playButton.setText("||");
              } else {
                mp.pause();
              }
            }
          });
      mp.currentTimeProperty()
          .addListener(
              new ChangeListener<Duration>() {
                @Override
                public void changed(
                    ObservableValue<? extends Duration> observable,
                    Duration oldValue,
                    Duration newValue) {
                  updateValues();
                }
              });
      mp.setOnPlaying(
          new Runnable() {
            public void run() {
              // System.out.println("onPlaying");
              if (stopRequested) {
                mp.pause();
                stopRequested = false;
              } else {
                playButton.setGraphic(imageViewPause);
                // playButton.setText("||");
              }
            }
          });
      mp.setOnPaused(
          new Runnable() {
            public void run() {
              // System.out.println("onPaused");
              playButton.setGraphic(imageViewPlay);
              // playButton.setText("||");
            }
          });
      mp.setOnReady(
          new Runnable() {
            public void run() {
              duration = mp.getMedia().getDuration();
              updateValues();
            }
          });

      mp.setCycleCount(repeat ? MediaPlayer.INDEFINITE : 1);
      mp.setOnEndOfMedia(
          new Runnable() {
            public void run() {
              if (!repeat) {
                playButton.setGraphic(imageViewPlay);
                // playButton.setText(">");
                stopRequested = true;
                atEndOfMedia = true;
              }
            }
          });
      mediaBar.getChildren().add(playButton);
      // Add spacer
      Label spacer = new Label("   ");
      mediaBar.getChildren().add(spacer);
      // Time label
      Label timeLabel = new Label("Time: ");
      timeLabel.setMinWidth(Control.USE_PREF_SIZE);
      mediaBar.getChildren().add(timeLabel);
      // Time slider
      timeSlider = new Slider();
      HBox.setHgrow(timeSlider, Priority.ALWAYS);
      timeSlider.setMinWidth(50);
      timeSlider.setMaxWidth(Double.MAX_VALUE);
      timeSlider
          .valueProperty()
          .addListener(
              new InvalidationListener() {
                public void invalidated(Observable ov) {
                  if (timeSlider.isValueChanging()) {
                    // multiply duration by percentage calculated by slider position
                    if (duration != null) {
                      mp.seek(duration.multiply(timeSlider.getValue() / 100.0));
                    }
                    updateValues();
                  }
                }
              });
      mediaBar.getChildren().add(timeSlider);
      // Play label
      playTime = new Label();
      playTime.setPrefWidth(130);
      playTime.setMinWidth(50);
      mediaBar.getChildren().add(playTime);
      // Volume label
      Label volumeLabel = new Label("Vol: ");
      volumeLabel.setMinWidth(Control.USE_PREF_SIZE);
      mediaBar.getChildren().add(volumeLabel);
      // Volume slider
      volumeSlider = new Slider();
      volumeSlider.setPrefWidth(70);
      volumeSlider.setMaxWidth(Region.USE_PREF_SIZE);
      volumeSlider.setMinWidth(30);
      volumeSlider
          .valueProperty()
          .addListener(
              new InvalidationListener() {
                public void invalidated(Observable ov) {}
              });
      volumeSlider
          .valueProperty()
          .addListener(
              new ChangeListener<Number>() {
                @Override
                public void changed(
                    ObservableValue<? extends Number> observable,
                    Number oldValue,
                    Number newValue) {
                  if (volumeSlider.isValueChanging()) {
                    mp.setVolume(volumeSlider.getValue() / 100.0);
                  }
                }
              });
      mediaBar.getChildren().add(volumeSlider);
      setBottom(mediaBar);
    }
  public ConfigurationsDialogBuilder create(
      DependencyDotFileGenerator dependencyDotFileGenerator,
      GradleScriptPreferences preferences,
      Os os,
      String outputFileName) {
    this.outputFileName = outputFileName;
    this.dependencyDotFileGenerator = dependencyDotFileGenerator;
    this.preferences = preferences;
    this.os = os;
    dialog = new ConfigurationChoiceDialog(this);
    dialog.setResizable(true);
    dialog.initStyle(UTILITY);
    dialog.initModality(APPLICATION_MODAL);
    dialog.setIconified(false);
    dialog.centerOnScreen();
    dialog.borderPanel = BorderPaneBuilder.create().styleClass("dialog").build();
    dialog.stackPane = new StackPane();

    StackPane stackPane = dialog.stackPane;

    dialog.log = new TextArea();

    TextArea log = dialog.log;
    BorderPane borderPanel = dialog.borderPanel;

    // message
    dialog.configurationsBox = new VBox();

    VBox configurationsBox = dialog.configurationsBox;

    dialog.configurationsBox = configurationsBox;
    dialog.progressIndicator = new ProgressIndicator();

    ProgressIndicator progressIndicator = dialog.progressIndicator;

    stackPane.getChildren().add(log);
    stackPane.getChildren().add(progressIndicator);
    progressIndicator.setPrefSize(50, 50);
    progressIndicator.setMaxSize(50, 50);
    configurationsBox.setSpacing(15);
    configurationsBox.setAlignment(CENTER_LEFT);
    dialog.scrollPane = new ScrollPane();

    ScrollPane scrollPane = dialog.scrollPane;

    scrollPane.setContent(configurationsBox);
    dialog.borderPanel.setCenter(stackPane);
    BorderPane.setAlignment(configurationsBox, CENTER_LEFT);
    BorderPane.setMargin(configurationsBox, new Insets(MARGIN, MARGIN, MARGIN, 2 * MARGIN));

    // buttons
    dialog.buttonsPanel = new HBox();

    final HBox buttonsPanel = dialog.buttonsPanel;

    buttonsPanel.setSpacing(MARGIN);
    buttonsPanel.setAlignment(BOTTOM_CENTER);
    BorderPane.setMargin(buttonsPanel, new Insets(0, 0, 1.5 * MARGIN, 0));
    borderPanel.setBottom(buttonsPanel);
    borderPanel
        .widthProperty()
        .addListener(
            new ChangeListener<Number>() {
              public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
                buttonsPanel.layout();
              }
            });
    dialog.scene = new Scene(borderPanel);
    dialog.setScene(dialog.scene);

    URL resource =
        ConfigurationsDialogBuilder.class.getResource(
            "/com/nurflugel/gradle/ui/dialogservice/dialog.css");
    String externalForm = resource.toExternalForm();

    // dialog.borderPanel.styleClass("dialog");
    dialog.getScene().getStylesheets().add(externalForm);

    return this;
  }
예제 #10
0
  @Override
  public void start(Stage theStage) {
    this.tStage = theStage;
    theStage.setTitle("Ball of Duty");
    theStage.setHeight(WINDOW_START_HEIGHT);
    theStage.setWidth(WINDOW_START_WIDTH);
    theStage.centerOnScreen();
    theStage.setResizable(false);
    theStage.setOnCloseRequest(
        new EventHandler<WindowEvent>() {
          public void handle(WindowEvent we) {
            gameManager.quitGame();
            System.exit(0);
          }
        });

    BorderPane startMenuRoot = new BorderPane();
    startMenu = new Scene(startMenuRoot);

    gameBox = new BorderPane();
    Scene gameScene = new Scene(gameBox);

    BorderPane createAccountRoot = new BorderPane();
    BorderPane lohInRoot = new BorderPane();

    theStage.setScene(startMenu);

    gameManager = new GameClient(getRelativeSceneLocation(theStage));

    scale = new Scale();
    scale.xProperty().bind(gameScene.widthProperty().divide(WINDOW_START_WIDTH));
    scale.yProperty().bind(gameScene.heightProperty().divide(WINDOW_START_HEIGHT));
    scale.setPivotX(0);
    scale.setPivotY(0);
    // gameBox.getTransforms().add(scale);
    // gameBox.setBackground(null);
    // TODO scaling

    theStage
        .heightProperty()
        .addListener(
            e -> {
              gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage)); // This
              // only
              // happens
              // once
              // for
              // some
              // reason.
            });
    theStage
        .widthProperty()
        .addListener(
            e -> {
              gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage));
            });
    theStage
        .xProperty()
        .addListener(
            e -> {
              gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage));
            });
    theStage
        .yProperty()
        .addListener(
            e -> {
              gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage));
            });
    gameScene
        .xProperty()
        .addListener(
            e -> {
              gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage));
            });
    gameScene
        .yProperty()
        .addListener(
            e -> {
              gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage));
            });
    Image image = new Image("images/frontpage.png");
    BackgroundSize backgroundSize = new BackgroundSize(100, 100, true, true, true, false);
    // new BackgroundImage(image, repeatX, repeatY, position, size)
    BackgroundImage backgroundImage =
        new BackgroundImage(
            image,
            BackgroundRepeat.REPEAT,
            BackgroundRepeat.NO_REPEAT,
            BackgroundPosition.CENTER,
            backgroundSize);
    // new Background(images...)
    Background background = new Background(backgroundImage);
    startMenuRoot.setBackground(background);

    RadioButton chooseBlaster = new RadioButton("Blaster");
    RadioButton chooseRoller = new RadioButton("Roller");
    RadioButton chooseHeavy = new RadioButton("Heavy");

    final ToggleGroup specializationGroup = new ToggleGroup();

    chooseBlaster.setToggleGroup(specializationGroup);
    chooseRoller.setToggleGroup(specializationGroup);
    chooseHeavy.setToggleGroup(specializationGroup);

    chooseBlaster.setSelected(true);

    HBox specializationBox = new HBox();
    specializationBox.setSpacing(9);
    specializationBox.getChildren().add(chooseBlaster);
    specializationBox.getChildren().add(chooseRoller);
    specializationBox.getChildren().add(chooseHeavy);

    Label lblNickname = new Label("Nickname:");
    TextField tfNickname = new TextField();
    Button loginStart = new Button("Log in");
    Button createStart = new Button("Create Account");
    theStage.getIcons().add(new Image("images/ball_red.png"));
    VBox mainButtonBox = new VBox();
    mainButtonBox.setSpacing(5);
    Button joinBtn = new Button("Join game");

    Button viewLB = new Button("Leaderboard");
    viewLB.setPrefSize(150, 50);
    viewLB.setId("viewLB");
    viewLB.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");

    BorderPane lbBorder = new BorderPane();
    VBox lbBox = new VBox();
    Scene lbScene = new Scene(lbBorder);

    Button lbBack = new Button("Start menu");
    lbBox.getChildren().add(lbBack);
    lbBorder.setLeft(lbBox);
    lbBack.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");

    Label topText = new Label("Only shows scores higher than 100!");
    topText.setStyle("-fx-font-size: 20pt;-fx-font-family: Segoe UI Semibold;");

    viewLB.setOnAction(
        ActionEvent -> {
          HighscoreLeaderboard hBoard = gameManager.getHighscoreLeaderboard();
          hBoard.setFocusTraversable(false);
          lbBorder.setCenter(hBoard);
          if (gameManager.getPlayer() != null) {
            Player client = gameManager.getPlayer();
            Label you =
                new Label(
                    "YOU:    "
                        + client.getNickname()
                        + " ["
                        + client.getId()
                        + "]    | Score: "
                        + client.getHighscore());

            you.setStyle("-fx-font-size: 15pt;-fx-font-family: Segoe UI Semibold;");
            lbBorder.setBottom(you);
          }

          BorderPane.setMargin(hBoard, new Insets(12, 12, 12, 12));

          lbBorder.setTop(topText);
          theStage.setScene(lbScene);

          lbBack.setOnAction(
              ActionEvent1 -> {
                theStage.setScene(startMenu);
                startMenuRoot.setLeft(mainButtonBox);

                BorderPane.setMargin(mainButtonBox, new Insets(350, 0, 0, 150));
              });
        });

    joinBtn.setPrefSize(150, 50);
    tfNickname.setPrefSize(150, 20);
    joinBtn.setId("joinBtn");
    joinBtn.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
    lblNickname.setId("lblNickname");
    lblNickname.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
    createStart.setId("CreateStart");
    createStart.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
    loginStart.setId("loginStart");
    loginStart.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");

    joinBtn.setOnAction(
        ActionEvent -> {
          Specializations spec;
          if (chooseRoller.isSelected()) {
            spec = Specializations.ROLLER;
          } else if (chooseHeavy.isSelected()) {
            spec = Specializations.HEAVY;
          } else // Blaster is default, if something goes wrong with radio
          // buttons
          {
            spec = Specializations.BLASTER;
          }

          theStage.setScene(gameScene);
          gameManager.joinAsGuest(gameBox, tfNickname.getText(), spec);
          gameManager.getMap().addObserver(this);
          gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage));
          gameBox.requestFocus();
        });
    tfNickname.setOnAction(
        ActionEvent -> {
          Specializations spec;
          if (chooseRoller.isSelected()) {
            spec = Specializations.ROLLER;
          } else if (chooseHeavy.isSelected()) {
            spec = Specializations.HEAVY;
          } else // Blaster is default, if something goes wrong with radio
          // buttons
          {
            spec = Specializations.BLASTER;
          }
          theStage.setScene(gameScene);
          gameManager.joinAsGuest(gameBox, tfNickname.getText(), spec);
          gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage));
          gameBox.requestFocus();
        });

    mainButtonBox.getChildren().add(lblNickname);
    mainButtonBox.getChildren().add(tfNickname);
    mainButtonBox.getChildren().add(specializationBox);
    mainButtonBox.getChildren().add(joinBtn);
    mainButtonBox.getChildren().add(loginStart);
    mainButtonBox.getChildren().add(createStart);
    mainButtonBox.getChildren().add(viewLB);
    startMenuRoot.setLeft(mainButtonBox);

    createStart.setOnAction(
        ActionEvent -> {
          VBox createAccountButtonBox = new VBox();
          Label lblNickname2 = new Label("Nickname:");
          TextField tfNickname2 = new TextField();
          Label lblUserName = new Label("Name:");
          TextField tfUserName = new TextField();
          Label lblPassword = new Label("Password:"******"Repeat password:"******"Create account");
          Button back = new Button("Start menu");

          createBtn.setId("join-yyyyy");
          createBtn.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
          lblUserName.setId("join-game");
          lblUserName.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
          lblPassword.setId("join-game");
          lblPassword.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
          lblPassword2.setId("join-game");
          lblPassword2.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
          back.setId("join-game");
          back.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");

          createAccountButtonBox.getChildren().add(lblNickname2);
          createAccountButtonBox.getChildren().add(tfNickname2);
          createAccountButtonBox.getChildren().add(lblUserName);
          createAccountButtonBox.getChildren().add(tfUserName);
          createAccountButtonBox.getChildren().add(lblPassword);
          createAccountButtonBox.getChildren().add(pf);
          createAccountButtonBox.getChildren().add(lblPassword2);
          createAccountButtonBox.getChildren().add(pf2);
          createAccountButtonBox.getChildren().add(createBtn);
          createAccountButtonBox.getChildren().add(back);

          startMenuRoot.setLeft(createAccountButtonBox);
          BorderPane.setMargin(createAccountButtonBox, new Insets(350, 0, 0, 150));

          createBtn.setOnAction(
              ActionEvent1 -> {
                gameManager.createAccount(
                    tfUserName.getText(),
                    tfNickname2.getText(),
                    pf.getText().toCharArray(),
                    pf2.getText().toCharArray());
                startMenuRoot.setLeft(mainButtonBox);
                BorderPane.setMargin(mainButtonBox, new Insets(350, 0, 0, 150));
              });

          back.setOnAction(
              ActionEvent1 -> {
                startMenuRoot.setLeft(mainButtonBox);
                BorderPane.setMargin(mainButtonBox, new Insets(350, 0, 0, 150));
              });
        });

    loginStart.setOnAction(
        ActionEvent -> {
          VBox loginButtonBox = new VBox();
          Button logInBtn = new Button("Log in");
          Label lblUserName2 = new Label("Name:");
          TextField tfUserName2 = new TextField();
          Label lblPassword2 = new Label("Password:"******"Start Menu");

          logInBtn.setId("join-game");
          logInBtn.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
          back2.setId("join-game");
          back2.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");

          loginButtonBox.getChildren().add(lblUserName2);
          loginButtonBox.getChildren().add(tfUserName2);
          loginButtonBox.getChildren().add(lblPassword2);
          loginButtonBox.getChildren().add(pf3);
          loginButtonBox.getChildren().add(logInBtn);
          loginButtonBox.getChildren().add(back2);

          startMenuRoot.setLeft(loginButtonBox);
          BorderPane.setMargin(loginButtonBox, new Insets(350, 0, 0, 150));

          logInBtn.setOnAction(
              ActionEvent1 -> {
                // TODO login
              });

          back2.setOnAction(
              ActionEvent1 -> {
                startMenuRoot.setLeft(mainButtonBox);
                BorderPane.setMargin(mainButtonBox, new Insets(350, 0, 0, 150));
              });
        });

    BorderPane.setMargin(mainButtonBox, new Insets(350, 0, 0, 150));

    Button quitBtn = new Button("Quit game");
    quitBtn.setPrefSize(80, 40);
    quitBtn.setId("quit-game");

    quitBtn.setOnAction(
        ActionEvent -> {
          gameManager.quitGame();
          theStage.setScene(startMenu);
        });

    canvas = new Canvas(CANVAS_START_WIDTH, CANVAS_START_HEIGHT);
    gameBox.setCenter(canvas);
    BorderPane.setAlignment(canvas, Pos.TOP_LEFT);

    gameBox.setBottom(quitBtn);
    BorderPane.setAlignment(quitBtn, Pos.TOP_LEFT);
    theStage.show();
  }
예제 #11
0
  @Override
  public void start(Stage primaryStage) {
    FXFormPane formPane = new FXFormPane();

    formPane.addChild(
        createLabel("First 0, 0 / Butter", "fce94f"), formPane.createConstraint(0, 0));
    formPane.addChild(
        createLabel("Second 1, 0 / Orange", "fcaf3e"), formPane.createConstraint(1, 0));
    formPane.addChild(
        createLabel("Third 2, 0 / Chocolate", "e9b96e"), formPane.createConstraint(2, 0));
    formPane.addChild(
        createLabel("Fourth 3, 0 / Butter", "fce94f"), formPane.createConstraint(3, 0));
    formPane.addChild(
        createLabel("Right aligned -1, 0 / Chameleon", "8ae234"), formPane.createConstraint(-1, 0));

    formPane.addChild(
        createLabel("Next line 0, 1 / Sky Blue", "729fcf"), formPane.createConstraint(0, 1));
    formPane.addChild(
        createLabel("Right aligned -1, 1 / Plum", "ad7fa8"), formPane.createConstraint(-1, 1));

    formPane.addChild(
        createLabel("Next line 0, 2 / Sky Blue", "729fcf"), formPane.createConstraint(0, 2));
    formPane.addChild(
        createLabel("Right aligned -1, 2 / Plum", "ad7fa8"), formPane.createConstraint(-1, 2));

    formPane.addChild(
        createLabel("Centered 0, 3, -1, -4 / Aluminium", "eeeeec"),
        formPane.createConstraint(0, 3, -1, -4));

    formPane.addChild(
        createLabel("Bottom 0, -3 / Scarlet Red", "ef2929"), formPane.createConstraint(0, -3));
    formPane.addChild(
        createLabel("Bottom and Right aligned -1, -3 / Butter", "c4a000"),
        formPane.createConstraint(-1, -3));

    formPane.addChild(
        createLabel("Bottom 0, -2 / Scarlet Red", "ef2929"), formPane.createConstraint(0, -2));
    formPane.addChild(
        createLabel("Bottom and Right aligned -1, -2 / Butter", "c4a000"),
        formPane.createConstraint(-1, -2));

    formPane.addChild(
        createLabel("Bottom 0, -1 / Scarlet Red", "ef2929"), formPane.createConstraint(0, -1));
    formPane.addChild(
        createLabel("Bottom and Right aligned -1, -1 / Butter", "c4a000"),
        formPane.createConstraint(-1, -1));

    Slider hgapSlider = new Slider(0, 100, formPane.getHGap());
    formPane.hGapProperty().bind(hgapSlider.valueProperty());

    Slider vgapSlider = new Slider(0, 100, formPane.getVGap());
    formPane.vGapProperty().bind(vgapSlider.valueProperty());

    FXFormPane controlPane = new FXFormPane();
    controlPane.setNewlineCount(7);
    controlPane.addChild(hgapSlider);
    controlPane.addChild(vgapSlider);

    BorderPane root = new BorderPane();
    root.setBottom(createLabel("- - Bottom - -", "888a85"));
    root.setCenter(formPane);
    root.setLeft(createLabel(" | \n\n | \n\n Left \n\n | \n\n | \n\n", "babdb6"));
    root.setRight(createLabel(" | \n\n | \n\n Right \n\n | \n\n | \n\n", "555753"));
    root.setTop(controlPane);
    BorderPane.setAlignment(root.getBottom(), Pos.CENTER);
    BorderPane.setAlignment(root.getCenter(), Pos.CENTER);
    BorderPane.setAlignment(root.getLeft(), Pos.CENTER);
    BorderPane.setAlignment(root.getRight(), Pos.CENTER);
    BorderPane.setAlignment(root.getTop(), Pos.CENTER);

    primaryStage.setScene(new Scene(root));
    primaryStage.setTitle("JavaFX FormPane Test");
    primaryStage.show();
  }
예제 #12
0
  @Override
  protected void updateItem(ShoppingItem item, boolean empty) {
    super.updateItem(item, empty);

    if (item != null) {
      if (empty) {
        setText(null);
        setGraphic(null);
      } else {
        setText(null);

        BorderPane pane = new BorderPane();
        pane.setPadding(new Insets(2, 5, 2, 5));
        TextField txtField = new TextField((int) item.getAmount() + "");
        txtField.setMaxWidth(40);
        txtField.setDisable(false);
        txtField.setEditable(true);
        pane.setLeft(txtField);

        Label name = new Label(item.getProduct().getName());
        BorderPane.setAlignment(name, Pos.CENTER_LEFT);
        BorderPane.setMargin(name, new Insets(0, 0, 0, 10));
        name.getStyleClass().add("produktnamn");
        pane.setCenter(name);

        GridPane priceAndDelete = new GridPane();
        double cost = item.getTotal();
        Label price = new Label(String.format("%.2f", cost) + " kr");
        price.setTextAlignment(TextAlignment.CENTER);
        GridPane.setMargin(price, new Insets(0, 10, 0, 0));
        priceAndDelete.add(price, 0, 0);

        Button delete = new Button("X");
        priceAndDelete.add(delete, 1, 0);

        pane.setRight(priceAndDelete);
        setGraphic(pane);

        delete.setOnMouseClicked(
            new EventHandler<MouseEvent>() {
              @Override
              public void handle(MouseEvent event) {
                IMatDataHandler.getInstance().getShoppingCart().removeItem(item);
                IMatDataHandler.getInstance()
                    .getShoppingCart()
                    .fireShoppingCartChanged(item, false);
              }
            });

        // Listen for TextField text changes
        txtField
            .textProperty()
            .addListener(
                new ChangeListener<String>() {
                  @Override
                  public void changed(
                      ObservableValue<? extends String> observable,
                      String oldValue,
                      String newValue) {
                    try {
                      if (!txtField.getText().equals("")) {
                        int amount = Integer.parseInt(txtField.getText());
                        if (amount < 1) {
                          txtField.setText(1 + "");
                        } else if (amount > 99) {
                          txtField.setText(99 + "");
                        }
                        item.setAmount(Integer.parseInt(txtField.getText()));
                        double cost2 = item.getTotal();
                        price.setText(String.format("%.2f", cost2) + " kr");
                        // IMatDataHandler.getInstance().getShoppingCart().fireShoppingCartChanged(item, true);
                        lastValidProductAmountString = txtField.getText();
                      }
                    } catch (NumberFormatException e) {
                      txtField.setText(lastValidProductAmountString);
                    }
                  }
                });
      }
    } else {
      if (count < 1) {
        Label noProducts = new Label("Din kundvagn är tom");
        noProducts.getStyleClass().add("produktnamn");
        setGraphic(noProducts);
        count++;
      } else {
        setText(null);
        setGraphic(null);
      }
    }
  }
  public ConfigurationPropertyEditor(ConfigurationEditor parent, Property collection) {
    this.parent = parent;
    this.parentCollection = collection;

    getStyleClass().add("configuration-property-editor");

    selected = new SimpleBooleanProperty(false);

    skinProperty()
        .addListener(
            (sp, o, n) -> {
              Node node = FXUtils.getTitledPaneTitleRegion(this);

              if (node != null) {
                node.addEventFilter(MouseEvent.MOUSE_RELEASED, eh -> eh.consume());
                node.addEventFilter(
                    MouseEvent.MOUSE_PRESSED,
                    eh -> {
                      eh.consume();
                      if (!selected.get()) {
                        selected.set(true);
                      } else {
                        setExpanded(!isExpanded());
                      }
                    });
              }
            });

    selected.addListener(
        (p, ov, nv) -> {
          if (nv && parent != null) {
            parent.select(this);
          }
        });

    infoContainer = new Label("");
    confEditor = new ConfigurationEditorInternal(parent, this);

    implementorsBorderPane = new BorderPane();
    implementorsBorderPane.getStyleClass().add("implementors");

    Label label = new Label("type :");
    label.setPadding(new Insets(0, LABEL_MARGING, 0, 0));
    BorderPane.setAlignment(label, Pos.CENTER_LEFT);
    implementorsBorderPane.setLeft(label);

    choiceBox = new ChoiceBox<>();
    //        choiceBox.setMaxWidth(Double.MAX_VALUE);
    choiceBox
        .valueProperty()
        .addListener(
            (ObservableValue<? extends String> p, String ov, String nv) -> {
              try {
                if (property != null) {
                  Configuration value = null;
                  if (!nv.equals("NULL")) {
                    value = Registery.get().getConfiguration(nv);
                  }
                  property.set(value == null ? null : new FromConfigurationPropertyValue(value));
                  setRepresentativeName();
                  confEditor.setModel(value, readOnly, filter);
                }
              } catch (ClassNotFoundException ex) {
                Logger.getLogger(ConfigurationPropertyEditor.class.getName())
                    .log(Level.SEVERE, null, ex);
              }
            });
    BorderPane.setAlignment(choiceBox, Pos.CENTER_LEFT);
    implementorsBorderPane.setCenter(choiceBox);

    editorVBox = new VBox();
    editorVBox.getChildren().addAll(implementorsBorderPane, confEditor);
    setContent(editorVBox);

    setGraphic(infoContainer);
    setExpanded(false);
  }