Coverage Report - org.jtheque.core.managers.view.SplashManager
 
Classes in this File Line Coverage Branch Coverage Complexity
SplashManager
0 %
0/18
0 %
0/2
1.091
SplashManager$1
0 %
0/8
N/A
1.091
SplashManager$2
0 %
0/6
N/A
1.091
SplashManager$3
0 %
0/4
N/A
1.091
SplashManager$4
0 %
0/4
N/A
1.091
 
 1  
 package org.jtheque.core.managers.view;
 2  
 
 3  
 import org.jtheque.core.managers.Managers;
 4  
 import org.jtheque.core.managers.view.able.ISplashManager;
 5  
 import org.jtheque.core.managers.view.able.components.ISplashView;
 6  
 import org.jtheque.core.managers.view.impl.components.filthy.java2d.SplashScreenPane;
 7  
 import org.jtheque.core.managers.view.impl.frame.MainView;
 8  
 import org.jtheque.utils.ui.SwingUtils;
 9  
 import org.pushingpixels.substance.api.SubstanceLookAndFeel;
 10  
 import org.pushingpixels.substance.api.skin.BusinessBlackSteelSkin;
 11  
 
 12  
 import javax.swing.JDialog;
 13  
 import javax.swing.JFrame;
 14  
 import javax.swing.UIManager;
 15  
 
 16  
 /*
 17  
  * This file is part of JTheque.
 18  
  *            
 19  
  * JTheque is free software: you can redistribute it and/or modify
 20  
  * it under the terms of the GNU General Public License as published by
 21  
  * the Free Software Foundation, either version 3 of the License. 
 22  
  *
 23  
  * JTheque is distributed in the hope that it will be useful,
 24  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 25  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 26  
  * GNU General Public License for more details.
 27  
  *
 28  
  * You should have received a copy of the GNU General Public License
 29  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 30  
  */
 31  
 
 32  
 /**
 33  
  * A manager for the splash. The splash is not in Spring to make it appears before spring context loading.
 34  
  *
 35  
  * @author Baptiste Wicht
 36  
  */
 37  0
 public final class SplashManager implements ISplashManager {
 38  0
     private static final ISplashManager INSTANCE = new SplashManager();
 39  
 
 40  
     private ISplashView splashScreenPane;
 41  
     private MainView mainView;
 42  
     private boolean mainDisplayed;
 43  
 
 44  
     /**
 45  
      * Construct a new <code>SplashManager</code>
 46  
      */
 47  
     public SplashManager() {
 48  0
         super();
 49  
 
 50  0
         SwingUtils.inEdt(new Runnable() {
 51  
             @Override
 52  
             public void run() {
 53  0
                 SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin());
 54  
 
 55  0
                 JFrame.setDefaultLookAndFeelDecorated(true);
 56  0
                 JDialog.setDefaultLookAndFeelDecorated(true);
 57  
 
 58  0
                 UIManager.put(SubstanceLookAndFeel.COLORIZATION_FACTOR, 1.0);
 59  
 
 60  0
                 mainView = new MainView();
 61  0
                 splashScreenPane = new SplashScreenPane();
 62  0
             }
 63  
         });
 64  0
     }
 65  
 
 66  
     /**
 67  
      * Return the unique instance of the manager.
 68  
      *
 69  
      * @return The unique instance of the manager.
 70  
      */
 71  
     public static ISplashManager getInstance() {
 72  0
         return INSTANCE;
 73  
     }
 74  
 
 75  
     @Override
 76  
     public void displaySplashScreen() {
 77  0
         SwingUtils.inEdt(new Runnable() {
 78  
             @Override
 79  
             public void run() {
 80  0
                 displayMainViewIfNecessary();
 81  
 
 82  0
                 mainView.getContent().setUI(splashScreenPane.getImpl());
 83  
 
 84  0
                 mainView.refresh();
 85  
 
 86  0
                 splashScreenPane.appearsAndAnimate();
 87  0
             }
 88  
         });
 89  0
     }
 90  
 
 91  
     @Override
 92  
     public void closeSplashScreen() {
 93  0
         SwingUtils.inEdt(new Runnable() {
 94  
             @Override
 95  
             public void run() {
 96  0
                 splashScreenPane.disappear();
 97  0
                 mainView.getContent().setUI(null);
 98  0
             }
 99  
         });
 100  0
     }
 101  
 
 102  
     /**
 103  
      * Display the main view if necessary.
 104  
      */
 105  
     private void displayMainViewIfNecessary() {
 106  0
         if (!mainDisplayed) {
 107  0
             mainDisplayed = true;
 108  0
             mainView.setTitle(Managers.getCore().getLifeCycleManager().getTitle());
 109  0
             mainView.display();
 110  
         }
 111  0
     }
 112  
 
 113  
     @Override
 114  
     public void fillMainView() {
 115  0
         SwingUtils.inEdt(new Runnable() {
 116  
             @Override
 117  
             public void run() {
 118  0
                 mainView.fill();
 119  0
                 mainView.refresh();
 120  0
             }
 121  
         });
 122  0
     }
 123  
 
 124  
     @Override
 125  
     public MainView getMainView() {
 126  0
         return mainView;
 127  
     }
 128  
 }