示例#1
22
 protected void updateValues() {
   if (timeProgress != null && timeSlider != null && volumeSlider != null) {
     Platform.runLater(
         () -> {
           Duration currentTime = mp.getCurrentTime();
           timeProgress.setText(formatTime(currentTime, duration));
           timeSlider.setDisable(duration.isUnknown());
           if (!timeSlider.isDisabled()
               && duration.greaterThan(Duration.ZERO)
               && !timeSlider.isValueChanging()) {
             timeSlider.setValue(mp.getCurrentTime().divide(duration).toMillis() * 100.0);
             progressBar.setProgress(timeSlider.getValue() / 100);
           }
           if (!volumeSlider.isValueChanging()) {
             volumeSlider.setValue(mp.getVolume());
             if (mp.getVolume() == 0.0) {
               volumeButton.setImage(new Image("icon/Volume_button/mute.png"));
             } else {
               volumeButton.setImage(new Image("icon/Volume_button/volume.png"));
             }
           }
         });
   }
 }
示例#2
0
  private Slider createSlider(Scene scene) {
    Slider slider =
        SliderBuilder.create()
            .min(0)
            .max(100)
            .value(1)
            .showTickLabels(true)
            .showTickMarks(true)
            .build();

    slider
        .valueProperty()
        .addListener(
            new ChangeListener<Number>() {
              public void changed(
                  ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                if (paused) {
                  long dur = newValue.intValue() * 1000;
                  mediaPlayer.seek(new Duration(dur));
                }
              }
            });
    slider.translateYProperty().bind(scene.heightProperty().subtract(30));
    return slider;
  }
示例#3
0
  /*
   * Function that creates a volume slider, adds the relevant event handlers to it, and
   * adds it to the MediaControl bar.
   */
  void setVolumeSlider() {
    // Create a new volume slider
    volumeSlider = new Slider();
    volumeSlider.setManaged(true);
    volumeSlider.setMaxWidth(mpWidth / 6);
    volumeSlider.setMinWidth(20);

    // Detect the change in volume slider bar and sets the MediaPlayer's volume accordingly
    volumeSlider
        .valueProperty()
        .addListener(
            new ChangeListener<Number>() {

              @Override
              public void changed(
                  ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                if (volumeSlider.isValueChanging()) {
                  // If the slider is being dragged set volume to that requested
                  mp.setVolume(volumeSlider.getValue() / 100.0);
                }

                // Update the text labels to display
                updateValues();
              }
            });

    // Add the volume slider to MediaControl bar
    mediaBar.getChildren().add(volumeSlider);
  }
  @Override
  public void start(Stage stage) {
    if (!Platform.isSupported(ConditionalFeature.SCENE3D)) {
      throw new RuntimeException("*** ERROR: common conditional SCENE3D is not supported");
    }

    stage.setTitle("JavaFX SubScene And Scene Anti-aliasing Test");

    Group root = new Group();
    Scene scene = new Scene(root, 1000, 800);
    scene.setFill(Color.color(0.2, 0.2, 0.2, 1.0));

    HBox hbox = new HBox();
    hbox.setLayoutX(75);
    hbox.setLayoutY(200);

    PhongMaterial phongMaterial = new PhongMaterial(Color.color(1.0, 0.7, 0.8));
    Cylinder cylinder1 = new Cylinder(100, 200);
    cylinder1.setMaterial(phongMaterial);
    SubScene noMsaa =
        createSubScene(
            "Scene Anti-aliasing = false",
            cylinder1,
            Color.TRANSPARENT,
            new PerspectiveCamera(),
            false);
    hbox.getChildren().add(noMsaa);

    Cylinder cylinder2 = new Cylinder(100, 200);
    cylinder2.setMaterial(phongMaterial);
    SubScene msaa =
        createSubScene(
            "Scene Anti-aliasing = true",
            cylinder2,
            Color.TRANSPARENT,
            new PerspectiveCamera(),
            true);
    hbox.getChildren().add(msaa);

    Slider slider = new Slider(0, 360, 0);
    slider.setBlockIncrement(1);
    slider.setTranslateX(425);
    slider.setTranslateY(625);
    cylinder1.rotateProperty().bind(slider.valueProperty());
    cylinder2.rotateProperty().bind(slider.valueProperty());
    root.getChildren().addAll(hbox, slider);

    stage.setScene(scene);
    stage.show();
  }
示例#5
0
 private void initSettingsPane() {
   trainTroopsSlider.setMin(0);
   trainTroopsSlider.setMax(Settings.MAX_TRAIN_TROOPS);
   trainTroopsSlider.setBlockIncrement(1);
   trainTroopsSlider
       .valueProperty()
       .addListener(
           (observable, oldValue, newValue) -> {
             trainTroopsSliderPreview.setText(
                 String.format("%d", MainController.toInt(newValue.doubleValue())));
           });
   final Troop[] availableTroops = model.getAvailableTroops();
   rax1ComboBox.getItems().addAll(availableTroops);
   rax2ComboBox.getItems().addAll(availableTroops);
   rax3ComboBox.getItems().addAll(availableTroops);
   rax4ComboBox.getItems().addAll(availableTroops);
   rax5ComboBox.getItems().addAll(availableTroops);
   rax6ComboBox.getItems().addAll(availableTroops);
   autoAttackComboBox.getItems().addAll(Attack.noStrategy());
   autoAttackComboBox.getItems().addAll(Attack.getAvailableStrategies());
   autoAttackComboBox.setValue(autoAttackComboBox.getItems().get(0));
   final ChangeListener<String> intFieldListener =
       (observable, oldValue, newValue) -> {
         try {
           if (!newValue.isEmpty()) {
             Integer.parseInt(newValue);
           }
         } catch (final NumberFormatException e) {
           ((TextField) ((StringProperty) observable).getBean()).setText(oldValue);
         }
       };
   goldField.textProperty().addListener(intFieldListener);
   elixirField.textProperty().addListener(intFieldListener);
   deField.textProperty().addListener(intFieldListener);
   maxThField.textProperty().addListener(intFieldListener);
   logLevelComboBox
       .getItems()
       .addAll(
           Level.FINEST,
           Level.FINER,
           Level.FINE,
           Level.CONFIG,
           Level.INFO,
           Level.WARNING,
           Level.SEVERE);
   logLevelComboBox.setValue(logLevelComboBox.getItems().get(1));
   updateUI();
 }
 private void generateCostAndStat() {
   String skill = selectedSkill.getText();
   power = (int) power_slider.getValue();
   dailyCost = power * 50;
   credits_label.setText(dailyCost + " Credits");
   stat_name_label.setText(skill + ": ");
   switch (skill) {
     case "Fighter":
       stats_label.setText("" + (player.getFighterSkillPoints() + power));
       break;
     case "Pilot":
       stats_label.setText("" + (player.getPilotSkillPoints() + power));
       break;
     case "Engineer":
       stats_label.setText("" + (player.getEngineerSkillPoints() + power));
       break;
     case "Trader":
       stats_label.setText("" + (player.getTraderSkillPoints() + power));
       break;
     default:
       stats_label.setText("" + (player.getInvestorSkillPoints() + power));
       break;
   }
   checkForHire();
 }
示例#7
0
 @FXML
 public void handleSaveButtonAction() {
   model.saveSettings(
       (settings) -> {
         if (!goldField.getText().isEmpty()) {
           settings.setGoldThreshold(Integer.parseInt(goldField.getText()));
         }
         if (!elixirField.getText().isEmpty()) {
           settings.setElixirThreshold(Integer.parseInt(elixirField.getText()));
         }
         if (!deField.getText().isEmpty()) {
           settings.setDarkElixirThreshold(Integer.parseInt(deField.getText()));
         }
         if (!maxThField.getText().isEmpty()) {
           settings.setMaxThThreshold(Integer.parseInt(maxThField.getText()));
         }
         settings.setDetectEmptyCollectors(detectEmptyCollectorsCheckBox.isSelected());
         settings.setMatchAllConditions(isMatchAllConditionsCheckBox.isSelected());
         settings.setCollectResources(collectResourcesCheckBox.isSelected());
         settings.setTrainMaxTroops(toInt(trainTroopsSlider.getValue()));
         settings.setLogLevel(logLevelComboBox.getValue());
         settings.setAttackStrategy(autoAttackComboBox.getValue());
         settings.getRaxInfo()[0] = rax1ComboBox.getValue();
         settings.getRaxInfo()[1] = rax2ComboBox.getValue();
         settings.getRaxInfo()[2] = rax3ComboBox.getValue();
         settings.getRaxInfo()[3] = rax4ComboBox.getValue();
         settings.getRaxInfo()[4] = rax5ComboBox.getValue();
         settings.getRaxInfo()[5] = rax6ComboBox.getValue();
         settings.setExtraFunctions(extraFuncCheckBox.isSelected());
       });
   showSettings(false);
 }
示例#8
0
 private void updateUI() {
   final boolean running = model.isRunning();
   final boolean scriptRunning = model.isScriptRunning();
   startButton.setDisable(running || scriptRunning);
   stopButton.setDisable(!running && !scriptRunning);
   scriptsButton.setDisable(running || scriptRunning);
   final Settings settings = model.loadSettings();
   goldField.setText(settings.getGoldThreshold() + "");
   elixirField.setText(settings.getElixirThreshold() + "");
   deField.setText(settings.getDarkElixirThreshold() + "");
   maxThField.setText(settings.getMaxThThreshold() + "");
   detectEmptyCollectorsCheckBox.setSelected(settings.isDetectEmptyCollectors());
   isMatchAllConditionsCheckBox.setSelected(settings.isMatchAllConditions());
   collectResourcesCheckBox.setSelected(settings.isCollectResources());
   trainTroopsSlider.setValue(settings.getTrainMaxTroops());
   logLevelComboBox.getSelectionModel().select(settings.getLogLevel());
   autoAttackComboBox.getSelectionModel().select(settings.getAttackStrategy());
   rax1ComboBox.getSelectionModel().select(settings.getRaxInfo()[0]);
   rax2ComboBox.getSelectionModel().select(settings.getRaxInfo()[1]);
   rax3ComboBox.getSelectionModel().select(settings.getRaxInfo()[2]);
   rax4ComboBox.getSelectionModel().select(settings.getRaxInfo()[3]);
   rax5ComboBox.getSelectionModel().select(settings.getRaxInfo()[4]);
   rax6ComboBox.getSelectionModel().select(settings.getRaxInfo()[5]);
   extraFuncCheckBox.setSelected(settings.isExtraFunctions());
 }
 private void adjustPlayerCount() {
   int difficulty = 0;
   if (Config.getInstance().difficulty == Difficulty.HILL) {
     difficulty = 0;
   } else if (Config.getInstance().difficulty == Difficulty.MESA) {
     difficulty = 1;
   } else if (Config.getInstance().difficulty == Difficulty.PLATEAU) {
     difficulty = 2;
   } else if (Config.getInstance().difficulty == Difficulty.MOUNTAIN) {
     difficulty = 3;
   }
   int foodCount;
   if (difficulty == 0) {
     foodCount = 8;
   } else {
     foodCount = 4;
   }
   int energyCount;
   if (difficulty == 0) {
     energyCount = 4;
   } else {
     energyCount = 2;
   }
   for (int i = 0; i < Config.getInstance().maxPlayers; i++) {
     if (Config.getInstance().playerList[i] == null) {
       Config.getInstance().playerList[i] = new Player(i);
       Config.getInstance().playerList[i].changeStockOf(ResourceType.ENERGY, energyCount);
       Config.getInstance().playerList[i].changeStockOf(ResourceType.FOOD, foodCount);
     }
   }
   playerSlider.setMax(Config.getInstance().numOfPlayers);
   if (Config.getInstance().currentPlayer >= Config.getInstance().numOfPlayers) {
     changePlayer(0);
   }
 }
示例#10
0
 private void toggleSliding() {
   if (!slider.isValueChanging()) {
     // on finish reset slider and use new base value
     this.baseValue = this.computeCurrentValue();
     this.slider.setValue(0.0);
   }
 }
示例#11
0
 @FXML
 private void btvolumeChange1(MouseEvent event) {
   if (volumeSlider.getValue() != 0) {
     volumeButton.setImage(new Image("icon/Volume_button/volume_hover.png"));
   } else {
     volumeButton.setImage(new Image("icon/Volume_button/mute_hover.png"));
   }
 }
 public void start() {
   movie = new MediaPlayer(path);
   movie.play();
   VIEW.setMediaPlayer(movie);
   movie
       .currentTimeProperty()
       .addListener(
           new ChangeListener<javafx.util.Duration>() {
             @Override
             public void changed(
                 ObservableValue<? extends javafx.util.Duration> observable,
                 javafx.util.Duration duration,
                 javafx.util.Duration current) {
               timeSlider.setValue(current.toSeconds());
             }
           });
   movie.setOnReady(
       new Runnable() {
         @Override
         public void run() {
           timeSlider.setMin(0);
           timeSlider.setValue(0.0);
           timeSlider.setMax(movie.getTotalDuration().toSeconds());
           volumeSlider.setMin(0);
           volumeSlider.setValue(0.5);
         }
       });
   timeSlider.setOnMouseClicked(
       new EventHandler<MouseEvent>() {
         @Override
         public void handle(MouseEvent event) {
           movie.seek(javafx.util.Duration.seconds(timeSlider.getValue()));
         }
       });
   volumeSlider
       .valueProperty()
       .addListener(
           new InvalidationListener() {
             @Override
             public void invalidated(Observable observable) {
               if (volumeSlider.isValueChanging()) {
                 movie.setVolume(volumeSlider.getValue() / 100);
               }
             }
           });
 }
示例#13
0
 @FXML
 private void handleProgress(MouseEvent event) {
   if (event.getButton() == MouseButton.PRIMARY) {
     if (play = true) {
       mp.seek(
           Duration.seconds((mp.getTotalDuration().toSeconds() * timeSlider.getValue() / 100)));
     }
   }
 }
示例#14
0
 @FXML
 private void Close(ActionEvent event) {
   if (mp != null) {
     mp.dispose();
     progressBar.setProgress(0);
     timeSlider.setValue(0.0);
     timeProgress.setText("00:00/00:00");
   }
 }
示例#15
0
  void decreaseVolume() {
    if (player == null) return;
    double newVolume = Settings.currentVolume - 0.05;

    if (newVolume < 0.0) newVolume = 0.0;
    Settings.currentVolume = newVolume;
    player.setVolume(newVolume);
    volumeSlider.setValue(newVolume);
  }
示例#16
0
  public void MiniMP3Player() {

    System.out.println(songPath);
    song = new File(songPath + songName.getText());
    path = song.toURI().toASCIIString();
    media = new Media(path);
    mediaPlayer = new MediaPlayer(media);
    duration = new Duration(0);
    slVolume = new Slider();
    slVolume.setValue(100);
    mediaPlayer.setStartTime(duration);
  }
  @FXML
  public void compute() {
    double[][] transformedTrajectory = getTransformedTrajectory();
    if (transformedTrajectory == null) return;

    // compute and display RP
    BufferedImage rp =
        DRQA.getRPImage(
            transformedTrajectory, transformedTrajectory, recurrenceThresholdSlider.getValue());
    rpImageView.setImage(SwingFXUtils.toFXImage(rp, null));
    applyImageScale();

    // compute and display CRT
    DRQA.conditional_ww_limit = Integer.parseInt(crtLimit.getText());
    DRQA.CRT_LOG_SCALE = logScaleCheckBox.isSelected();
    drqa =
        new DRQA(
            transformedTrajectory, transformedTrajectory, recurrenceThresholdSlider.getValue());
    BufferedImage crt = drqa.getCRTImage(DRQA.conditional_ww_limit, drqa.conditional_ww);
    crtImageView.setImage(SwingFXUtils.toFXImage(crt, null));
    String[] stats = drqa.crtStatistics().split("\t");
    crtStats.setText(
        String.format(
            "mean row: %.2f\tmean col: %.2f\ncorrelation: %.2f\nmax row: %s\tmax col: %s\nlocal maxima: %s\nentropy: %.2f",
            Double.parseDouble(stats[0]),
            Double.parseDouble(stats[1]),
            Double.parseDouble(stats[2]),
            stats[3],
            stats[4],
            stats[5],
            Double.parseDouble(stats[6])));

    drqa.computeRQA(2, 2, 2);
    rqaMeasures.setText(drqa.printableString(DRQA.STANDARD_RQA));

    updateTimeSeriesChart();
    updateDistanceDistributionChart();
    updateLineLengthHistogram(
        null, null, lineLengthTypeSelector.getSelectionModel().getSelectedIndex());
  }
示例#18
0
  private void initUI(Stage stage) {

    VBox root = new VBox(30);
    root.setPadding(new Insets(10));

    DoubleProperty azimuth = new SimpleDoubleProperty(0);

    Light.Distant light = new Light.Distant();
    light.setAzimuth(0);

    Lighting lighting = new Lighting(light);
    lighting.setSurfaceScale(5.0);

    Text text = new Text();
    text.setText("test");
    text.setFill(Color.LIGHTSKYBLUE);
    text.setFont(Font.font(null, FontWeight.BOLD, 60));

    Slider slider = new Slider(1, 360, 0);
    azimuth.bind(slider.valueProperty());

    slider
        .valueProperty()
        .addListener(
            event -> {
              light.setAzimuth(azimuth.get());
              lighting.setLight(light);
              text.setEffect(lighting);
            });

    text.setEffect(lighting);

    root.getChildren().addAll(slider, text);

    Scene scene = new Scene(root, 300, 250, Color.WHITESMOKE);

    stage.setTitle("Lighting");
    stage.setScene(scene);
    stage.show();
  }
示例#19
0
 private void enableStereoSettings(SidTune tune) {
   EmulationSection emulationSection = util.getConfig().getEmulationSection();
   boolean second = SidTune.isSIDUsed(emulationSection, tune, 1);
   boolean third = SidTune.isSIDUsed(emulationSection, tune, 2);
   int sidBase = SidTune.getSIDAddress(emulationSection, tune, 0);
   int dualSidBase = SidTune.getSIDAddress(emulationSection, tune, 1);
   boolean isForcedStereo = second && emulationSection.isForceStereoTune();
   boolean isFakeStereo = isForcedStereo && dualSidBase == sidBase;
   boolean isForced3Sid = third && emulationSection.isForce3SIDTune();
   if (isFakeStereo) {
     stereoMode.getSelectionModel().select(StereoMode.FAKE_STEREO);
   } else if (isForced3Sid) {
     stereoMode.getSelectionModel().select(StereoMode.THREE_SID);
   } else if (isForcedStereo) {
     stereoMode.getSelectionModel().select(StereoMode.STEREO);
   } else {
     stereoMode.getSelectionModel().select(StereoMode.AUTO);
   }
   // stereo, only:
   mainBalance.setDisable(!second);
   secondVolume.setDisable(!second);
   secondBalance.setDisable(!second);
   sid2Emulation.setDisable(!second);
   sid2Model.setDisable(!second);
   secondFilter.setDisable(!second);
   secondFilterCurve.setDisable(!second);
   // 3-SID, only:
   thirdVolume.setDisable(!third);
   thirdBalance.setDisable(!third);
   sid3Emulation.setDisable(!third);
   sid3Model.setDisable(!third);
   thirdFilter.setDisable(!third);
   thirdFilterCurve.setDisable(!third);
   // fake stereo, only:
   sidToRead.setDisable(!(isFakeStereo));
   // forced stereo or forced 3-SID, only:
   baseAddress.setDisable(!(isForcedStereo || isForced3Sid));
   // forced 3-SID, only:
   thirdAddress.setDisable(!isForced3Sid);
 }
示例#20
0
 private void updateValues() {
   raceCombo
       .getSelectionModel()
       .select(
           Config.getInstance()
               .playerList[Config.getInstance().currentPlayer]
               .getRace()
               .ordinal());
   colorPicker.setValue(
       Config.getInstance().playerList[Config.getInstance().currentPlayer].getColor());
   nameField.setText(
       Config.getInstance().playerList[Config.getInstance().currentPlayer].getName());
   playerSlider.setValue(Config.getInstance().currentPlayer + 1);
 }
示例#21
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);
  }
示例#22
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    Pane pane = new Pane();

    Circle circle = new Circle(250, 250, 50);
    circle.setStroke(Color.BLACK);

    Slider slider = new Slider(0, 250, 0);
    slider.setTranslateY(390);
    slider
        .valueProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              circle.setStrokeWidth(newValue.intValue());
            });

    pane.getChildren().addAll(slider, circle);

    Scene scene = new Scene(pane, 500, 500);
    primaryStage.setScene(scene);
    primaryStage.setOnCloseRequest(event -> System.exit(0));
    primaryStage.show();
  }
 /** Initializes the Slider */
 private void initializeSlider() {
   sliderSubsToRemove
       .valueProperty()
       .addListener(
           new ChangeListener<Number>() {
             @Override
             public void changed(
                 ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
               percentageToRemove = (int) sliderSubsToRemove.getValue();
               labelEffectivePercent.setText(Integer.toString(percentageToRemove) + " %");
               pieChartSubsToRemove.getData().get(0).setPieValue(100 - percentageToRemove);
               pieChartSubsToRemove.getData().get(1).setPieValue(percentageToRemove);
             }
           });
 }
  public void start(Stage primaryStage) {
    primaryStage.setTitle("Lines");

    Group root = new Group();
    Scene scene = new Scene(root, 300, 150, Color.GRAY);

    Line redLine = new Line(10, 10, 200, 10);

    redLine.setStroke(Color.RED);
    redLine.setStrokeWidth(10);
    redLine.setStrokeLineCap(StrokeLineCap.BUTT);

    redLine.getStrokeDashArray().addAll(10d, 5d, 15d, 5d, 20d);
    redLine.setStrokeDashOffset(0);

    root.getChildren().add(redLine);

    Line whiteLine = new Line(10, 30, 200, 30);
    whiteLine.setStroke(Color.WHITE);
    whiteLine.setStrokeWidth(10);
    whiteLine.setStrokeLineCap(StrokeLineCap.ROUND);

    root.getChildren().add(whiteLine);

    Line blueLine = new Line(10, 50, 200, 50);
    blueLine.setStroke(Color.BLUE);
    blueLine.setStrokeWidth(10);

    root.getChildren().add(blueLine);

    Slider slider = new Slider(0, 100, 0);
    slider.setLayoutX(10);
    slider.setLayoutY(95);

    redLine.strokeDashOffsetProperty().bind(slider.valueProperty());

    root.getChildren().add(slider);

    Text offsetText = new Text("Stroke Dash Offset: 0.0");
    offsetText.setX(10);
    offsetText.setY(80);
    offsetText.setStroke(Color.WHITE);

    slider
        .valueProperty()
        .addListener(
            (ov, curVal, newVal) -> offsetText.setText("Stroke Dash Offset: " + slider.getValue()));
    root.getChildren().add(offsetText);
    primaryStage.setScene(scene);
    primaryStage.show();
  }
示例#25
0
 @FXML
 private void handleNameAction(Event e) {
   emptyName = false;
   for (Player player : Config.getInstance().playerList) {
     if (player.getName().equals("") && player.getId() < numSlider.getValue()) {
       emptyName = true;
     }
   }
   if (emptyName) {
     nameLabel.setTextFill(Color.RED); // disallow empty name
     startButton.setDisable(true);
   } else {
     nameLabel.setTextFill(Color.BLACK);
     startButton.setDisable(false);
   }
   Config.getInstance()
       .playerList[Config.getInstance().currentPlayer]
       .setName(nameField.getText());
 }
  @Override
  public void initialize(URL url, ResourceBundle rb) {
    player = GameController.getGameData().getPlayer();
    dailyCost = 0;
    selectedSkill = pilot_button;
    pilot_button.requestFocus();

    checkForHire();

    Button[] buttons = {
      pilot_button, fighter_button, engineer_button, trader_button, investor_button
    };
    for (Button b : buttons) {
      b.setOnMouseClicked(
          (MouseEvent t) -> {
            selectedSkill = b;
            generateCostAndStat();
          });
    }

    name_field.addEventFilter(
        KeyEvent.KEY_TYPED,
        (KeyEvent event) -> {
          if (name_field.getText().length() >= 18) {
            event.consume();
          }
        });

    power_slider
        .valueProperty()
        .addListener(
            (ObservableValue<? extends Number> ov, Number old_val, Number new_val) -> {
              generateCostAndStat();
            });

    hire_button.setOnMouseClicked(
        (MouseEvent t) -> {
          Mercenary merc =
              new Mercenary(name_field.getText(), selectedSkill.getText(), power, dailyCost);
          player.getShip().addCrew(merc);
          checkForHire();
        });
  }
示例#27
0
  public void initialize(URL location, ResourceBundle resources) {
    txtFieldGeldEingabe.textProperty().bindBidirectional(viewModel.geldEingabe());
    txtFieldZeitEingabe.textProperty().bindBidirectional(viewModel.zeitEinagabe());
    labelQualitaet.textProperty().bindBidirectional(viewModel.qualitaetText());
    labelZeit.textProperty().bindBidirectional(viewModel.zeitText());
    labelSkill.textProperty().bindBidirectional(viewModel.skillText());
    labelGehalt.textProperty().bindBidirectional(viewModel.gehaltText());
    labelGeld.textProperty().bindBidirectional(viewModel.geldText());
    labelGesundheit.textProperty().bindBidirectional(viewModel.gesundheitText());
    labelMotivation.textProperty().bindBidirectional(viewModel.motivationText());
    SliderGehalt.valueProperty().bindBidirectional(viewModel.gehaltProperty());
    SliderGehalt.setValue(1500);
    SliderGehalt.setShowTickMarks(false);
    SliderGehalt.setMajorTickUnit(1);
    SliderGehalt.setMinorTickCount(0);
    SliderGehalt.setBlockIncrement(100);
    SliderGehalt.setSnapToTicks(true);

    labelNeuesGehalt.textProperty().bind(SliderGehalt.valueProperty().asString("%.0f"));

    buttonStart.setOnAction(
        event -> {
          buttonNachsteRunde.setDisable(false);
          buttonStart.setDisable(true);
          txtFieldGeldEingabe.setDisable(true);
          txtFieldZeitEingabe.setDisable(true);
          viewModel.startRound();
        });

    buttonNachsteRunde.setOnAction(
        event -> {
          RadioButton rb = (RadioButton) ToggleGroupSelect.getSelectedToggle();
          viewModel.nextRound(rb.getText());
        });

    viewModel.setButtonNaechsteRunde(buttonNachsteRunde);
    viewModel.setButtonStart(buttonStart);
    viewModel.setTxtFieldGeldEingabe(txtFieldGeldEingabe);
    viewModel.setTxtFieldZeitEingabe(txtFieldZeitEingabe);
  }
 @FXML
 private void handleRecording() {
   if (recordingOn) {
     recordingOn = false;
     imageView.setImage(null);
     recordingButton.setText("Start Recording");
     appendToProtocol("... recording stopped");
     try {
       recorder.stop();
       speechToTextTransformer.stop();
     } catch (InterruptedException e) {
       appendToProtocol("error stopping recorder");
       e.printStackTrace();
     }
   } else {
     recordingOn = true;
     imageView.setImage(recordingImage);
     recordingButton.setText("Stop Recording");
     int timesInSeconds = new Double(slider.getValue()).intValue();
     appendToProtocol("start recording (" + timesInSeconds + "s chunks)...");
     recorder.start(timesInSeconds);
     speechToTextTransformer.start();
   }
 }
示例#29
0
  /**
   * Constructs a new SliderBlock
   *
   * @param pane The parent pane this Block resides on.
   * @param isIntegral wWhether this slider represent an integral value.
   */
  public SliderBlock(ToplevelPane pane, boolean isIntegral) {
    super(
        "SliderBlock",
        pane,
        pane.getEnvInstance().buildType(isIntegral ? "Num a => a" : "Fractional a => a"));

    this.isIntegral = isIntegral;
    this.baseValue = 0;
    this.slider.setValue(0);
    this.updateValue();

    slider.getStyleClass().add("inactive");
    slider.setOnMousePressed(e -> slider.getStyleClass().removeAll("inactive"));
    slider.setOnMouseReleased(e -> slider.getStyleClass().add("inactive"));
    slider.setOnTouchPressed(e -> slider.getStyleClass().removeAll("inactive"));
    slider.setOnTouchReleased(e -> slider.getStyleClass().add("inactive"));

    slider.valueProperty().addListener(ev -> this.updateValue());
    slider.valueChangingProperty().addListener(ev -> this.toggleSliding());

    slider.addEventHandler(TouchEvent.TOUCH_MOVED, event -> event.consume());
  }
示例#30
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);
    }