JAL-3300 instant Splash screen on getdown
[jalview.git] / getdown / src / getdown / launcher / src / main / java / com / threerings / getdown / launcher / Getdown.java
index 539b47e..5750fce 100644 (file)
@@ -9,6 +9,7 @@ import java.awt.BorderLayout;
 import java.awt.Container;
 import java.awt.Dimension;
 import java.awt.EventQueue;
+import java.awt.Graphics;
 import java.awt.GraphicsEnvironment;
 import java.awt.Image;
 import java.awt.event.ActionEvent;
@@ -32,6 +33,7 @@ import javax.swing.AbstractAction;
 import javax.swing.JButton;
 import javax.swing.JFrame;
 import javax.swing.JLayeredPane;
+import javax.swing.JPanel;
 
 import com.samskivert.swing.util.SwingUtil;
 import com.threerings.getdown.data.*;
@@ -748,9 +750,10 @@ public abstract class Getdown extends Thread
         if (_silent || (_container != null && !reinit)) {
             return;
         }
-
+/*
         EventQueue.invokeLater(new Runnable() {
             public void run () {
+*/
                 if (_container == null || reinit) {
                     if (_container == null) {
                         _container = createContainer();
@@ -759,6 +762,42 @@ public abstract class Getdown extends Thread
                     }
                     configureContainer();
                     _layers = new JLayeredPane();
+                    
+                    
+                    
+                    // added in the instant display of a splashscreen
+                    try {
+                      readConfig(false);
+                      Graphics g = _container.getGraphics();
+                      String imageFile = _ifc.backgroundImage;
+                      BufferedImage bgImage = loadImage(_ifc.backgroundImage);
+                      int bwidth = bgImage.getWidth();
+                      int bheight = bgImage.getHeight();
+
+                      instantSplashPane = new JPanel() {
+                        @Override
+                        protected void paintComponent(Graphics g)
+                        {
+                          super.paintComponent(g);
+                          // attempt to draw a background image...
+                          if (bgImage != null) {
+                            g.drawImage(bgImage, 0, 0, this);
+                          }
+                        }
+                      };
+
+                      instantSplashPane.setSize(bwidth,bheight);
+                      instantSplashPane.setPreferredSize(new Dimension(bwidth,bheight));
+
+                      _layers.add(instantSplashPane, Integer.valueOf(0));
+                    
+                      _container.setPreferredSize(new Dimension(bwidth,bheight));
+                    } catch (Exception e) {
+                      log.warning("Failed to set instant background image", "bg", _ifc.backgroundImage);
+                    }
+
+                    
+                    
                     _container.add(_layers, BorderLayout.CENTER);
                     _patchNotes = new JButton(new AbstractAction(_msgs.getString("m.patch_notes")) {
                         @Override public void actionPerformed (ActionEvent event) {
@@ -768,12 +807,14 @@ public abstract class Getdown extends Thread
                     _patchNotes.setFont(StatusPanel.FONT);
                     _layers.add(_patchNotes);
                     _status = new StatusPanel(_msgs);
-                    _layers.add(_status);
+                    _layers.add(_status, Integer.valueOf(10));
                     initInterface();
                 }
                 showContainer();
+/*
             }
         });
+*/
     }
 
     /**
@@ -804,13 +845,12 @@ public abstract class Getdown extends Thread
 
     protected RotatingBackgrounds getBackground ()
     {
-        if (_ifc.rotatingBackgrounds != null) {
+        if (_ifc.rotatingBackgrounds != null && _ifc.rotatingBackgrounds.size() > 0) {
             if (_ifc.backgroundImage != null) {
                 log.warning("ui.background_image and ui.rotating_background were both specified. " +
                             "The background image is being used.");
             }
-            return new RotatingBackgrounds(loadImage(_ifc.backgroundImage));
-            //return new RotatingBackgrounds(_ifc.rotatingBackgrounds, _ifc.errorBackground, Getdown.this);
+            return new RotatingBackgrounds(_ifc.rotatingBackgrounds, _ifc.errorBackground, Getdown.this);
         } else if (_ifc.backgroundImage != null) {
             return new RotatingBackgrounds(loadImage(_ifc.backgroundImage));
         } else {
@@ -1044,6 +1084,7 @@ public abstract class Getdown extends Thread
     protected ResourceBundle _msgs;
     protected Container _container;
     protected JLayeredPane _layers;
+    protected JPanel instantSplashPane;
     protected StatusPanel _status;
     protected JButton _patchNotes;
     protected AbortPanel _abort;