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); }
/** 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); } }); }
@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(); }); }
/** * Called after the controls have been parsed from the XML. Sets up logic and components that * could not be set up using the GUI builder. */ @Override public void initialize(URL url, ResourceBundle rb) { // the transformedTrajectory provides a view of the trajectory that reflects the selected // transformedTrajectory transformedTrajectory = new Cacheable<double[][]>() { private int eachKthPoint; private int embeddingDimension, embeddingDelay; private double noiseRatio; private int getSubsampleLength() { int prefixLength = (int) (subsampleLengthSlider.getValue() * trajectory[0].length); // per started block of k elements, one output element will be generated int k = getEachKthPoint(); // full blocks + 1 block if there is a fractional block return prefixLength / k + (prefixLength % k > 0 ? 1 : 0); } @Override public synchronized boolean isValid() { if (cachedValue == null) return false; if (eachKthPoint != getEachKthPoint()) return false; // any embedding dimension <= 0 signifies that no embedding should be used, thus the // actual dimension does not matter if (getEmbeddingDimension() > 0 && (embeddingDimension != getEmbeddingDimension())) return false; // for an embedding dimension of <= 1, the delay is insignificant if (getEmbeddingDimension() > 1 && (embeddingDelay != getEmbeddingDelay())) return false; if (getNoiseRatio() != noiseRatio) return false; return trajectory == null || cachedValue == null || getSubsampleLength() == cachedValue[0].length; } @Override public synchronized void recompute() { if (trajectory == null) cachedValue = null; else { // create an empty array with the desired number of dimensions cachedValue = new double[trajectory.length][]; eachKthPoint = getEachKthPoint(); // crop to sampling size int newLength = getSubsampleLength(); for (int dimIdx = 0; dimIdx < trajectory.length; dimIdx++) { cachedValue[dimIdx] = new double[newLength]; // Arrays.copyOf(trajectory[dimIdx], newLength); for (int i = 0, t = 0; i < newLength; i++, t += eachKthPoint) { cachedValue[dimIdx][i] = trajectory[dimIdx][t]; } } int dim = getEmbeddingDimension(); int tau = getEmbeddingDelay(); double noiseRatio = getNoiseRatio(); if (dim > 0 && tau > 0) { cachedValue = PhaseSpaceReconstructed.embed(cachedValue[0], dim, tau); } cachedValue = TimeSeriesGenerator.addNoise(cachedValue, 0.05, noiseRatio); this.noiseRatio = noiseRatio; this.embeddingDimension = dim; this.embeddingDelay = tau; } } }; // sync recurrence threshold slider and text field Bindings.bindBidirectional( recurrenceThresholdTextField.textProperty(), recurrenceThresholdSlider.valueProperty(), DecimalFormat.getInstance()); // sync GUI and model recurrence threshold Bindings.bindBidirectional( recurrenceThresholdTextField.textProperty(), recurrenceThresholdProperty(), DecimalFormat.getInstance()); // sync GUI and model embedding parameters Bindings.bindBidirectional( embeddingDimensionTextField.textProperty(), embeddingDimensionProperty(), DecimalFormat.getIntegerInstance()); Bindings.bindBidirectional( embeddingDelayTextField.textProperty(), embeddingDelayProperty(), DecimalFormat.getIntegerInstance()); // sync GUI and noise parameter Bindings.bindBidirectional(noiseSlider.valueProperty(), noiseRatioProperty()); Bindings.bindBidirectional( eachKthPointTextField.textProperty(), eachKthPointProperty(), DecimalFormat.getIntegerInstance()); // enable the compute button only if the auto-update checkbox is not on. computeRPButton.disableProperty().bind(sliderAutoUpdate.selectedProperty()); // recompute RP on parameter changes subsampleLengthSlider.valueProperty().addListener(this::parametersChanged); eachKthPointTextField .textProperty() .addListener( (obs, ov, nv) -> { parametersChanged(null, null, null); }); recurrenceThresholdProperty().addListener(this::parametersChanged); embeddingDimensionProperty().addListener(this::parametersChanged); embeddingDelayProperty().addListener(this::parametersChanged); noiseRatioProperty().addListener(this::parametersChanged); // Make CRT controls update the computation // size of the CRT histogram crtLimit .textProperty() .addListener( new ChangeListener<String>() { @Override public void changed( ObservableValue<? extends String> observable, String oldValue, String newValue) { parametersChanged(null, Integer.parseInt(oldValue), Integer.parseInt(newValue)); } }); // CRT log scale option logScaleCheckBox .selectedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (oldValue != newValue) parametersChanged(null, 0, 0); } }); // make the CRT image use all the available vertical space crtImageView.fitWidthProperty().bind(crtTabPane.widthProperty().subtract(20)); crtImageView.fitHeightProperty().bind(crtTabPane.heightProperty()); // swap the data of the line length histogram upon selecting another line type lineLengthTypeSelector.setItems( FXCollections.observableArrayList( "DIAGONAL", "VERTICAL", "WHITE_VERTICAL", "ORTHOGONAL")); // DRQA.LineType.DIAGONAL, DRQA.LineType.VERTICAL, // DRQA.LineType.WHITE_VERTICAL, DRQA.LineType.ORTHOGONAL lineLengthTypeSelector .getSelectionModel() .selectedIndexProperty() .addListener(this::updateLineLengthHistogram); lineLengthTypeSelector.getSelectionModel().select(0); distanceDistributionSelector.setItems(FXCollections.observableArrayList("SUBSEQ", "PAIRWISE")); distanceDistributionSelector .getSelectionModel() .selectedIndexProperty() .addListener((obs, ov, nv) -> updateDistanceDistributionChart()); distanceDistributionSelector.getSelectionModel().select(0); useDRQA .selectedProperty() .addListener( (obs, ov, nv) -> updateLineLengthHistogram( null, null, lineLengthTypeSelector.getSelectionModel().getSelectedIndex())); }