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")); } } }); } }
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()); }
@FXML private void Close(ActionEvent event) { if (mp != null) { mp.dispose(); progressBar.setProgress(0); timeSlider.setValue(0.0); timeProgress.setText("00:00/00:00"); } }
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); }
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); }
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); }
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); }
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 initialize() { duringInitialization = true; ResourceBundle bundle = util.getBundle(); EmulationSection emulationSection = util.getConfig().getEmulationSection(); mainFilters = FXCollections.<String>observableArrayList(); mainFilter.setItems(mainFilters); secondFilters = FXCollections.<String>observableArrayList(); secondFilter.setItems(secondFilters); thirdFilters = FXCollections.<String>observableArrayList(); thirdFilter.setItems(thirdFilters); NumberToString<Double> doubleToString = new NumberToString<Double>(1); mainBalance.setValue(util.getConfig().getAudioSection().getMainBalance()); mainBalance.setLabelFormatter(doubleToString); mainBalance .valueProperty() .addListener( (observable, oldValue, newValue) -> { util.getConfig().getAudioSection().setMainBalance(newValue.floatValue()); util.getPlayer().configureMixer(m -> m.setBalance(0, newValue.floatValue())); }); secondBalance.setValue(util.getConfig().getAudioSection().getSecondBalance()); secondBalance.setLabelFormatter(doubleToString); secondBalance .valueProperty() .addListener( (observable, oldValue, newValue) -> { util.getConfig().getAudioSection().setSecondBalance(newValue.floatValue()); util.getPlayer().configureMixer(m -> m.setBalance(1, newValue.floatValue())); }); thirdBalance.setValue(util.getConfig().getAudioSection().getThirdBalance()); thirdBalance.setLabelFormatter(doubleToString); thirdBalance .valueProperty() .addListener( (observable, oldValue, newValue) -> { util.getConfig().getAudioSection().setThirdBalance(newValue.floatValue()); util.getPlayer().configureMixer(m -> m.setBalance(2, newValue.floatValue())); }); mainVolume.setValue(util.getConfig().getAudioSection().getMainVolume()); mainVolume .valueProperty() .addListener( (observable, oldValue, newValue) -> { util.getConfig().getAudioSection().setMainVolume(newValue.floatValue()); util.getPlayer().configureMixer(m -> m.setVolume(0, newValue.floatValue())); }); secondVolume.setValue(util.getConfig().getAudioSection().getSecondVolume()); secondVolume .valueProperty() .addListener( (observable, oldValue, newValue) -> { util.getConfig().getAudioSection().setSecondVolume(newValue.floatValue()); util.getPlayer().configureMixer(b -> b.setVolume(1, newValue.floatValue())); }); thirdVolume.setValue(util.getConfig().getAudioSection().getThirdVolume()); thirdVolume .valueProperty() .addListener( (observable, oldValue, newValue) -> { util.getConfig().getAudioSection().setThirdVolume(newValue.floatValue()); util.getPlayer().configureMixer(b -> b.setVolume(2, newValue.floatValue())); }); stereoModes = FXCollections.<StereoMode>observableArrayList(StereoMode.values()); stereoMode.setConverter(new EnumToString<StereoMode>(bundle)); stereoMode.setItems(stereoModes); baseAddress.setText(String.format("0x%4x", emulationSection.getDualSidBase())); thirdAddress.setText(String.format("0x%4x", emulationSection.getThirdSIDBase())); sidReads = FXCollections.<SidReads>observableArrayList(SidReads.values()); sidToRead.setConverter(new EnumToString<SidReads>(bundle)); sidToRead.setItems(sidReads); sidToRead.getSelectionModel().select(emulationSection.getSidNumToRead()); sid1Emulations = FXCollections.<Emulation>observableArrayList(Emulation.values()); sid1Emulation.setConverter(new EnumToString<Emulation>(bundle)); sid1Emulation.setItems(sid1Emulations); sid1Emulation.getSelectionModel().select(emulationSection.getUserEmulation()); sid2Emulations = FXCollections.<Emulation>observableArrayList(Emulation.values()); sid2Emulation.setConverter(new EnumToString<Emulation>(bundle)); sid2Emulation.setItems(sid2Emulations); sid2Emulation.getSelectionModel().select(emulationSection.getStereoEmulation()); sid3Emulations = FXCollections.<Emulation>observableArrayList(Emulation.values()); sid3Emulation.setConverter(new EnumToString<Emulation>(bundle)); sid3Emulation.setItems(sid3Emulations); sid3Emulation.getSelectionModel().select(emulationSection.getThirdEmulation()); sid1Models = FXCollections.<ChipModel>observableArrayList(ChipModel.values()); sid1Model.setConverter(new EnumToString<ChipModel>(bundle)); sid1Model.setItems(sid1Models); sid1Model.getSelectionModel().select(emulationSection.getUserSidModel()); sid2Models = FXCollections.<ChipModel>observableArrayList(ChipModel.values()); sid2Model.setConverter(new EnumToString<ChipModel>(bundle)); sid2Model.setItems(sid2Models); sid2Model.getSelectionModel().select(emulationSection.getStereoSidModel()); sid3Models = FXCollections.<ChipModel>observableArrayList(ChipModel.values()); sid3Model.setConverter(new EnumToString<ChipModel>(bundle)); sid3Model.setItems(sid3Models); sid3Model.getSelectionModel().select(emulationSection.getThirdSIDModel()); defaultModels = FXCollections.<ChipModel>observableArrayList(ChipModel.MOS6581, ChipModel.MOS8580); defaultModel.setConverter(new EnumToString<ChipModel>(bundle)); defaultModel.setItems(defaultModels); defaultModel.getSelectionModel().select(emulationSection.getDefaultSidModel()); defaultEmulations = FXCollections.<Emulation>observableArrayList(Emulation.RESID, Emulation.RESIDFP); defaultEmulation.setConverter(new EnumToString<Emulation>(bundle)); defaultEmulation.setItems(defaultEmulations); defaultEmulation.getSelectionModel().select(emulationSection.getDefaultEmulation()); boosted8580.setSelected(emulationSection.isDigiBoosted8580()); emulationChange = new EmulationChange(); util.getPlayer().stateProperty().addListener(emulationChange); Platform.runLater( () -> { updateSettingsForTune(util.getPlayer().getTune()); duringInitialization = false; }); }
@Override public void initialize(URL location, ResourceBundle resources) { AppController.instance = this; this.res = resources; ObservableList<String> modeItems = FXCollections.observableArrayList( Settings.MODE_NEXT, Settings.MODE_RANDOM, Settings.MODE_SAME); modeList.setItems(modeItems); modeList.getSelectionModel().select(Settings.currentMode); modeList .valueProperty() .addListener( (ObservableValue ov, Object oldVal, Object newVal) -> { Settings.currentMode = (String) newVal; }); setupPlaylistsView(); setupPlaylistsContextMenu(); setupTracksView(); tracksView.setContextMenu(tracksContextMenu); tracksView.setOnContextMenuRequested( (ContextMenuEvent evt) -> { setupTracksContextMenu(); evt.consume(); }); tracksView .getSelectionModel() .selectedItemProperty() .addListener( (ObservableValue observable, Object oldValue, Object newValue) -> { Settings.lastTrackId = newValue != null ? ((Track) newValue).getId() : null; }); playlistsView .getSelectionModel() .selectedItemProperty() .addListener( (ObservableValue observable, Object oldValue, Object newValue) -> { loadSelectedPlaylist(); Settings.lastPlaylistId = newValue != null ? ((Playlist) newValue).getId() : null; searching = false; searchText.setText(StringUtils.EMPTY); }); volumeSlider.setCursor(Cursor.HAND); volumeSlider .valueProperty() .addListener( (ObservableValue<? extends Number> ov, Number oldVal, Number newVal) -> { if (player != null) { player.setVolume(newVal.doubleValue()); } Settings.currentVolume = newVal.doubleValue(); volumeLabel.setText( String.valueOf((int) Math.ceil(newVal.doubleValue() * 100)) + "%"); }); volumeSlider.setValue(Settings.currentVolume); imagePlay = new ImageView(new Image(getClass().getResourceAsStream("/images/button_play.png"))); imagePlay.setScaleX(0.40); imagePlay.setScaleY(0.40); imagePause = new ImageView(new Image(getClass().getResourceAsStream("/images/button_pause.png"))); imagePause.setScaleX(0.5); imagePause.setScaleY(0.5); imageSettings = new ImageView(new Image(getClass().getResourceAsStream("/images/settings.png"))); imageSettings.setScaleX(0.5); imageSettings.setScaleY(0.5); imageUpdate = new ImageView(new Image(getClass().getResourceAsStream("/images/refresh.png"))); imageUpdate.setScaleX(0.5); imageUpdate.setScaleY(0.5); imageAdd = new ImageView(new Image(getClass().getResourceAsStream("/images/add.png"))); imageAdd.setScaleX(0.5); imageAdd.setScaleY(0.5); imageRename = new ImageView(new Image(getClass().getResourceAsStream("/images/rename.png"))); imageRename.setScaleX(0.5); imageRename.setScaleY(0.5); imageDelete = new ImageView(new Image(getClass().getResourceAsStream("/images/delete.png"))); imageDelete.setScaleX(0.5); imageDelete.setScaleY(0.5); stateButton.setGraphic(imagePlay); settingsButton.setGraphic(imageSettings); refreshButton.setGraphic(imageUpdate); refreshButton.setTooltip(new Tooltip(res.getString("tooltip_sync"))); addButton.setGraphic(imageAdd); addButton.setOnAction((evt) -> createOfflinePlaylist()); addButton.setTooltip(new Tooltip(res.getString("tooltip_add_offline"))); renameButton.setGraphic(imageRename); renameButton.setOnAction(evt -> renamePlaylist()); renameButton.setTooltip(new Tooltip(res.getString("rename_playlist"))); deleteButton.setGraphic(imageDelete); deleteButton.setOnAction(evt -> deletePlaylist()); deleteButton.setTooltip(new Tooltip(res.getString("delete_playlist"))); loadProgressBar.setCursor(Cursor.HAND); volumeSlider.setCursor(Cursor.HAND); updatePlaylists(); if (Settings.lastPlaylistId != null) { currentPlaylist = ((ObservableList<Playlist>) playlistsView.getItems()) .stream() .filter((playlist) -> playlist.getId().equals(Settings.lastPlaylistId)) .findFirst() .orElse(null); playlistsView.getSelectionModel().select(currentPlaylist); playlistsView.scrollTo(currentPlaylist); Platform.runLater( () -> { if (Settings.lastTrackId != null) { currentTrack = ((ObservableList<Track>) tracksView.getItems()) .stream() .filter((track) -> track.getId().equals(Settings.lastTrackId)) .findFirst() .orElse(null); tracksView.getSelectionModel().select(currentTrack); tracksView.scrollTo(currentTrack); } }); } new Timer() .scheduleAtFixedRate( new TimerTask() { @Override public void run() { updatePlayProgress(); } }, 100, 100); setupTracksContextMenu(); setupShortcuts(); Platform.runLater( () -> { tracksView.requestFocus(); }); }
public void setValue(double value) { slider.setValue(value); }
@FXML private void initialize() { m_combo.setItems(Person.DEFAULT_DATA); m_combo.setConverter( new StringConverter<Person>() { @Override public String toString(Person p) { return p.getFirstName().get() + " " + p.getLastName().get() + " (" + p.getAge().get() + ")"; } @Override public Person fromString(String string) { for (Person p : m_combo.getItems()) { String current = p.getFirstName().get() + " " + p.getLastName().get() + " (" + p.getAge().get() + ")"; if (current.equals(string)) { return p; } } return null; } }); m_slider.setMin(0); m_slider.setMax(100); m_slider.setValue(50); m_spinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 100, 0, 1)); m_list.setItems(Person.DEFAULT_DATA); m_list.setCellFactory( new Callback<ListView<Person>, ListCell<Person>>() { @Override public ListCell<Person> call(ListView<Person> p) { return new ListCell<Person>() { @Override protected void updateItem(Person p1, boolean bln) { super.updateItem(p1, bln); if (p1 != null) { String current = p1.getFirstName().get() + " " + p1.getLastName().get() + " (" + p1.getAge().get() + ")"; setText(current); } } }; } }); }
protected void setControls(PropDesc... properties) { GridPane grid = new GridPane(); grid.getStyleClass().add("sample-control-grid"); grid.setVgap(10); grid.setHgap(10); int row = 0; for (PropDesc property : properties) { final PropDesc prop = property; Label propName = new Label(prop.name + ":"); propName.getStyleClass().add("sample-control-grid-prop-label"); GridPane.setConstraints(propName, 0, row); grid.getChildren().add(propName); if (prop.valueModel instanceof DoubleProperty) { final Label valueLabel = new Label(twoDp.format(prop.initialValue)); GridPane.setConstraints(valueLabel, 2, row); final Slider slider = new Slider(); slider.setMin(prop.min); slider.setMax(prop.max); slider.setValue(((Number) prop.initialValue).doubleValue()); GridPane.setConstraints(slider, 1, row); slider.setMaxWidth(Double.MAX_VALUE); slider .valueProperty() .addListener( new InvalidationListener() { @Override public void invalidated(Observable ov) { set(prop.valueModel, slider.getValue()); valueLabel.setText(twoDp.format(slider.getValue())); } }); grid.getChildren().addAll(slider, valueLabel); } else { // if (prop.property.getType() == Color.class || prop.property.getType() == // Paint.class) { // FIXME we assume anything that isn't a double property is now a colour property final Rectangle colorRect = new Rectangle(20, 20, (Color) prop.initialValue); colorRect.setStroke(Color.GRAY); final Label valueLabel = new Label(formatWebColor((Color) prop.initialValue)); valueLabel.setGraphic(colorRect); valueLabel.setContentDisplay(ContentDisplay.LEFT); GridPane.setConstraints(valueLabel, 2, row); final ColorPicker colorPicker = new ColorPicker(); GridPane.setConstraints(colorPicker, 1, row); colorPicker .getColor() .addListener( new InvalidationListener() { @Override public void invalidated(Observable valueModel) { Color c = colorPicker.getColor().get(); set(prop.valueModel, c); valueLabel.setText(formatWebColor(c)); colorRect.setFill(c); } }); grid.getChildren().addAll(colorPicker, valueLabel); } row++; } controls = grid; }
@FXML private void handleEnterAction(Event e) { numSlider.setValue(Config.getInstance().numOfPlayers); adjustPlayerCount(); }