Content of file Splash.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>Splash.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">SteelBlue - Examples - Large</a> &gt; <a href="../index.html" class="el_bundle">it-tidalwave-role-ui-javafx</a> &gt; <a href="index.source.html" class="el_package">it.tidalwave.ui.javafx</a> &gt; <span class="el_source">Splash.java</span></div><h1>Splash.java</h1><pre class="source lang-java linenums">/*
 * *********************************************************************************************************************
 *
 * SteelBlue: DCI User Interfaces
 * http://tidalwave.it/projects/steelblue
 *
 * Copyright (C) 2015 - 2021 by Tidalwave s.a.s. (http://tidalwave.it)
 *
 * *********************************************************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); 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 &quot;AS IS&quot; 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/steelblue-src
 * git clone https://github.com/tidalwave-it/steelblue-src
 *
 * *********************************************************************************************************************
 */
package it.tidalwave.ui.javafx;

import javax.annotation.Nonnull;
import java.io.IOException;
import javafx.util.Duration;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/***********************************************************************************************************************
 *
 * @author  Fabrizio Giudici
 *
 **********************************************************************************************************************/
<span class="nc bnc" id="L47" title="All 4 branches missed.">@RequiredArgsConstructor @Slf4j</span>
public class Splash
  {
    @Nonnull
    private final Object application;

    @Nonnull
    private final String fxml;

    private Pane splashPane;

    private Stage splashStage;

    /*******************************************************************************************************************
     *
     *
     *
     ******************************************************************************************************************/
    public void init()
      {
        try
          {
<span class="nc" id="L69">            log.info(&quot;Loading Splash.fxml for application {}&quot;, application);</span>
<span class="nc" id="L70">            splashPane = FXMLLoader.load(application.getClass().getResource(fxml));</span>
          }
<span class="nc" id="L72">        catch (IOException e)</span>
          {
<span class="nc" id="L74">            log.warn(&quot;No Splash.fxml&quot;, e);</span>
<span class="nc" id="L75">          }</span>
<span class="nc" id="L76">      }</span>

    /*******************************************************************************************************************
     *
     *
     *
     ******************************************************************************************************************/
    public void show (@Nonnull final Stage splashStage)
      {
<span class="nc" id="L85">        this.splashStage = splashStage;</span>
<span class="nc" id="L86">        final Scene splashScene = new Scene(splashPane);</span>
<span class="nc" id="L87">        splashStage.setScene(splashScene);</span>
<span class="nc" id="L88">        splashStage.show();</span>
<span class="nc" id="L89">      }</span>

    /*******************************************************************************************************************
     *
     *
     *
     ******************************************************************************************************************/
    public void dismiss()
      {
//        loadProgress.progressProperty().unbind();
//        loadProgress.setProgress(1);
//        progressText.setText(&quot;Done.&quot;);

<span class="nc" id="L102">        final KeyFrame start = new KeyFrame(Duration.ZERO, new KeyValue(splashStage.opacityProperty(), 1.0));</span>
<span class="nc" id="L103">        final KeyFrame end = new KeyFrame(Duration.millis(500), new KeyValue(splashStage.opacityProperty(), 0.0));</span>
<span class="nc" id="L104">        final Timeline slideAnimation = new Timeline(start, end);</span>
<span class="nc" id="L105">        slideAnimation.setOnFinished(event -&gt; splashStage.close());</span>
<span class="nc" id="L106">        slideAnimation.play();</span>

//         FIXME: fade transition really doesn't work: it fades out the pane, but the stage is opaque.
fade transition really doesn't work: it fades out the pane, but the stage is opaque.
// final FadeTransition fadeSplash = new FadeTransition(Duration.seconds(0.5), splashPane); // fadeSplash.setFromValue(1.0); // fadeSplash.setToValue(0.0); // fadeSplash.setOnFinished(event -&gt; splashStage.close()); // fadeSplash.play(); <span class="nc" id="L114"> }</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>