Content of file JavaFxAudioRendererPresentationDelegate.java.html
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../../jacoco-resources/report.gif" type="image/gif"/><title>JavaFxAudioRendererPresentationDelegate.java</title><link rel="stylesheet" href="../../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../../index.html" class="el_report">blueMarine II :: Application :: JavaFX</a> > <a href="../index.html" class="el_bundle">it-tidalwave-bluemarine2-ui-javafx</a> > <a href="index.source.html" class="el_package">it.tidalwave.bluemarine2.ui.audio.renderer.impl.javafx</a> > <span class="el_source">JavaFxAudioRendererPresentationDelegate.java</span></div><h1>JavaFxAudioRendererPresentationDelegate.java</h1><pre class="source lang-java linenums">/*
* *********************************************************************************************************************
*
* blueMarine II: Semantic Media Centre
* http://tidalwave.it/projects/bluemarine2
*
* Copyright (C) 2015 - 2021 by Tidalwave s.a.s. (http://tidalwave.it)
*
* *********************************************************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* *********************************************************************************************************************
*
* git clone https://bitbucket.org/tidalwave/bluemarine2-src
* git clone https://github.com/tidalwave-it/bluemarine2-src
*
* *********************************************************************************************************************
*/
package it.tidalwave.bluemarine2.ui.audio.renderer.impl.javafx;
import javax.annotation.Nonnull;
import javax.inject.Inject;
import java.util.HashMap;
import java.util.Map;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.input.KeyCombination;
import javafx.scene.input.KeyEvent;
import it.tidalwave.role.ui.UserAction;
import it.tidalwave.role.ui.javafx.JavaFXBinder;
import it.tidalwave.bluemarine2.ui.audio.explorer.AudioExplorerPresentation;
import it.tidalwave.bluemarine2.ui.audio.renderer.AudioRendererPresentation;
import lombok.extern.slf4j.Slf4j;
import static javafx.scene.input.KeyCode.*;
/***********************************************************************************************************************
*
* The JavaFX Delegate for {@link AudioExplorerPresentation}.
*
* @stereotype JavaFXDelegate
*
* @author Fabrizio Giudici
*
**********************************************************************************************************************/
<span class="nc" id="L56">@Slf4j</span>
<span class="nc" id="L57">public class JavaFxAudioRendererPresentationDelegate implements AudioRendererPresentation</span>
{
@FXML
private Button btPrev;
@FXML
private Button btRewind;
@FXML
private Button btStop;
@FXML
private Button btPause;
@FXML
private Button btPlay;
@FXML
private Button btFastForward;
@FXML
private Button btNext;
@FXML
private ProgressBar pbPlayProgress;
@FXML
private Label lbTitle;
@FXML
private Label lbFolderName;
@FXML
private Label lbArtist;
@FXML
private Label lbComposer;
@FXML
private Label lbDuration;
@FXML
private Label lbPlayTime;
@FXML
private Label lbNextTrack;
@Inject
private JavaFXBinder binder;
<span class="nc" id="L107"> private final Map<KeyCombination, Runnable> accelerators = new HashMap<>();</span>
@FXML
private void initialize()
{
// final ObservableMap<KeyCombination, Runnable> accelerators = btPlay.getScene().getAccelerators();
<span class="nc" id="L113"> accelerators.put(new KeyCodeCombination(PLAY), btPlay::fire);</span>
<span class="nc" id="L114"> accelerators.put(new KeyCodeCombination(STOP), btStop::fire);</span>
<span class="nc" id="L115"> accelerators.put(new KeyCodeCombination(PAUSE), btPause::fire);</span>
<span class="nc" id="L116"> accelerators.put(new KeyCodeCombination(REWIND), btRewind::fire);</span>
<span class="nc" id="L117"> accelerators.put(new KeyCodeCombination(FAST_FWD), btFastForward::fire);</span>
<span class="nc" id="L118"> }</span>
@FXML // TODO: should be useless, but getScene().getAccelerators() doesn't work
| should be useless, but getScene().getAccelerators() doesn't work | |
public void onKeyReleased (@Nonnull final KeyEvent event)
{
<span class="nc" id="L123"> accelerators.getOrDefault(new KeyCodeCombination(event.getCode()), () -> {}).run();</span>
<span class="nc" id="L124"> }</span>
@Override
public void bind (@Nonnull final Properties properties,
@Nonnull final UserAction prevAction,
@Nonnull final UserAction rewindAction,
@Nonnull final UserAction stopAction,
@Nonnull final UserAction pauseAction,
@Nonnull final UserAction playAction,
@Nonnull final UserAction fastForwardAction,
@Nonnull final UserAction nextAction)
{
<span class="nc" id="L136"> binder.bind(btPrev, prevAction);</span>
<span class="nc" id="L137"> binder.bind(btRewind, rewindAction);</span>
<span class="nc" id="L138"> binder.bind(btStop, stopAction);</span>
<span class="nc" id="L139"> binder.bind(btPause, pauseAction);</span>
<span class="nc" id="L140"> binder.bind(btPlay, playAction);</span>
<span class="nc" id="L141"> binder.bind(btFastForward, fastForwardAction);</span>
<span class="nc" id="L142"> binder.bind(btNext, nextAction);</span>
<span class="nc" id="L144"> lbTitle.textProperty().bind(properties.titleProperty());</span>
<span class="nc" id="L145"> lbFolderName.textProperty().bind(properties.folderNameProperty());</span>
<span class="nc" id="L146"> lbArtist.textProperty().bind(properties.artistProperty());</span>
<span class="nc" id="L147"> lbComposer.textProperty().bind(properties.composerProperty());</span>
<span class="nc" id="L148"> lbDuration.textProperty().bind(properties.durationProperty());</span>
<span class="nc" id="L149"> lbPlayTime.textProperty().bind(properties.playTimeProperty());</span>
<span class="nc" id="L150"> lbNextTrack.textProperty().bind(properties.nextTrackProperty());</span>
<span class="nc" id="L151"> pbPlayProgress.progressProperty().bind(properties.progressProperty());</span>
<span class="nc" id="L152"> }</span>
@Override
public void showUp (@Nonnull final Object control)
{
<span class="nc" id="L157"> }</span>
@Override
public void focusOnPlayButton()
{
<span class="nc" id="L162"> btPlay.requestFocus();</span>
<span class="nc" id="L163"> }</span>
@Override
public void focusOnStopButton()
{
<span class="nc" id="L168"> btStop.requestFocus();</span>
<span class="nc" id="L169"> }</span>
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.7.202105040129</span></div></body></html>