JAL-3253 jalview.bin.Instance handles all singleton instances -
[jalview.git] / src / jalview / gui / SplashScreen.java
index 52bd64f..96f5c8c 100755 (executable)
@@ -20,6 +20,7 @@
  */
 package jalview.gui;
 
+import jalview.bin.Instance;
 import jalview.util.Platform;
 
 import java.awt.BorderLayout;
@@ -88,7 +89,6 @@ public class SplashScreen extends JPanel
     this.interactiveDialog = interactive;
     // show a splashscreen that will disapper
     if (Platform.isJS()) // BH 2019
-    // if (/** @j2sNative true || */ false)
     {
       authlist = new JLabel("");
       run();
@@ -98,7 +98,7 @@ public class SplashScreen extends JPanel
       /**
        * Java only
        * 
-       * @j2sNative
+       * @j2sIgnore
        */
       {
         authlist = new JTextPane();
@@ -140,8 +140,7 @@ public class SplashScreen extends JPanel
       java.net.URL urllogo = getClass()
               .getResource("/images/Jalview_Logo_small.png");
 
-      if (/** @j2sNative false || */
-      url != null)
+      if (!Platform.isJS() && url != null)
       {
         image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
         Image logo = java.awt.Toolkit.getDefaultToolkit()
@@ -157,13 +156,12 @@ public class SplashScreen extends JPanel
           } catch (InterruptedException x)
           {
           }
-          ;
           if (mt.isErrorAny())
           {
             System.err.println("Error when loading images!");
           }
         } while (!mt.checkAll());
-        Desktop.instance.setIconImage(logo);
+        Instance.getDesktop().setIconImage(logo);
       }
     } catch (Exception ex)
     {
@@ -175,10 +173,15 @@ public class SplashScreen extends JPanel
     this.setLayout(new BorderLayout());
     iframe.setContentPane(this);
     iframe.setLayer(JLayeredPane.PALETTE_LAYER);
+    if (Platform.isJS())
+    {
+      // ignore in JavaScript
+    }
+    else
     /**
-     * we add image directly in html for javascript ?
+     * Java only
      * 
-     * @j2sNative
+     * @j2sIgnore
      */
     {
       ((JTextPane) authlist).setEditable(false);
@@ -189,7 +192,7 @@ public class SplashScreen extends JPanel
     }
     add(authlist, BorderLayout.CENTER);
     authlist.addMouseListener(closer);
-    Desktop.desktop.add(iframe);
+    Desktop.getDesktopPane().add(iframe);
     refreshText();
   }
 
@@ -201,14 +204,13 @@ public class SplashScreen extends JPanel
   @SuppressWarnings("unused")
   protected boolean refreshText()
   {
-    String newtext = Desktop.instance.getAboutMessage(true).toString();
+    String newtext = Instance.getDesktop().getAboutMessage(true).toString();
     // System.err.println("Text found: \n"+newtext+"\nEnd of newtext.");
     if (oldtext != newtext.length())
     {
       iframe.setVisible(false);
       oldtext = newtext.length();
       if (Platform.isJS()) // BH 2019
-      // if (/** @j2sNative true || */ false)
       {
         authlist = new JLabel(
                 "<html><br/><br/><img src=\"swingjs/j2s/images/Jalview_Logo.png\"/><br/>"
@@ -217,19 +219,17 @@ public class SplashScreen extends JPanel
         ((JLabel) authlist).setBackground(Color.white);
       }
       else
+      /**
+       * Java only
+       * 
+       * @j2sIgnore
+       */
       {
-        /**
-         * Java only
-         * 
-         * @j2sNative
-         */
-        {
-          authlist = new JTextPane();
-          ((JTextPane) authlist).setEditable(false);
-          ((JTextPane) authlist).setContentType("text/html");
-          ((JTextPane) authlist).setText(newtext);
-          ((JTextPane) authlist).addHyperlinkListener(this);
-        }
+        authlist = new JTextPane();
+        ((JTextPane) authlist).setEditable(false);
+        ((JTextPane) authlist).setContentType("text/html");
+        ((JTextPane) authlist).setText(newtext);
+        ((JTextPane) authlist).addHyperlinkListener(this);
       }
       authlist.addMouseListener(closer);
 
@@ -237,8 +237,8 @@ public class SplashScreen extends JPanel
       authlist.setSize(new Dimension(750, 375));
       add(authlist, BorderLayout.CENTER);
       revalidate();
-      iframe.setBounds((Desktop.instance.getWidth() - 750) / 2,
-              (Desktop.instance.getHeight() - 375) / 2, 750,
+      iframe.setBounds((Instance.getDesktop().getWidth() - 750) / 2,
+              (Instance.getDesktop().getHeight() - 375) / 2, 750,
               authlist.getHeight() + iconimg.getHeight());
       iframe.validate();
       iframe.setVisible(true);
@@ -288,7 +288,7 @@ public class SplashScreen extends JPanel
     }
 
     closeSplash();
-    Desktop.instance.startDialogQueue();
+    Instance.getDesktop().startDialogQueue();
   }
 
   /**