j2sNative clean-up. Fixes problem with second try of sequence fetching
[jalview.git] / src / jalview / gui / SplashScreen.java
index a122eb6..f7d7cbf 100755 (executable)
@@ -20,6 +20,8 @@
  */
 package jalview.gui;
 
+import jalview.util.Platform;
+
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Component;
@@ -35,7 +37,6 @@ import javax.swing.JInternalFrame;
 import javax.swing.JLabel;
 import javax.swing.JLayeredPane;
 import javax.swing.JPanel;
-import javax.swing.JTextField;
 import javax.swing.JTextPane;
 import javax.swing.event.HyperlinkEvent;
 import javax.swing.event.HyperlinkListener;
@@ -54,7 +55,7 @@ public class SplashScreen extends JPanel
   JPanel iconimg = new JPanel(new BorderLayout());
 
   /**
-   * either text area in javascript or in java text pane 
+   * either text area in javascript or in java text pane
    */
   Component authlist;
 
@@ -86,7 +87,7 @@ public class SplashScreen extends JPanel
   {
     this.interactiveDialog = interactive;
     // show a splashscreen that will disapper
-    if (/** @j2sNative true || */ false)
+    if (Platform.isJS()) // BH 2019
     {
       authlist = new JLabel("");
       run();
@@ -94,6 +95,8 @@ public class SplashScreen extends JPanel
     else
     {
       /**
+       * Java only
+       * 
        * @j2sNative
        */
       {
@@ -107,6 +110,7 @@ public class SplashScreen extends JPanel
 
   MouseAdapter closer = new MouseAdapter()
   {
+    @Override
     public void mousePressed(MouseEvent evt)
     {
       try
@@ -135,7 +139,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()
@@ -151,7 +155,6 @@ public class SplashScreen extends JPanel
           } catch (InterruptedException x)
           {
           }
-          ;
           if (mt.isErrorAny())
           {
             System.err.println("Error when loading images!");
@@ -169,8 +172,14 @@ 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
      */
     {
@@ -200,25 +209,29 @@ public class SplashScreen extends JPanel
     {
       iframe.setVisible(false);
       oldtext = newtext.length();
-      if (/** @j2sNative true  || */ false)
+      if (Platform.isJS()) // BH 2019
       {
-        authlist = new JLabel("<html><br/><br/><img src=\"swingjs/j2s/images/Jalview_Logo.png\"/><br/>"+newtext);
+        authlist = new JLabel(
+                "<html><br/><br/><img src=\"swingjs/j2s/images/Jalview_Logo.png\"/><br/>"
+                        + newtext);
         ((JLabel) authlist).setOpaque(true);
         ((JLabel) authlist).setBackground(Color.white);
-      } else {
-        /**
-         * @j2sNative 
-         */
-        {
-          authlist = new JTextPane();
-          ((JTextPane) authlist).setEditable(false);
-          ((JTextPane) authlist).setContentType("text/html");
-          ((JTextPane) authlist).setText(newtext);
-          ((JTextPane) authlist).addHyperlinkListener(this);
-        }
+      }
+      else
+      /**
+       * Java only
+       * 
+       * @j2sNative
+       */
+      {
+        authlist = new JTextPane();
+        ((JTextPane) authlist).setEditable(false);
+        ((JTextPane) authlist).setContentType("text/html");
+        ((JTextPane) authlist).setText(newtext);
+        ((JTextPane) authlist).addHyperlinkListener(this);
       }
       authlist.addMouseListener(closer);
-      
+
       authlist.setVisible(true);
       authlist.setSize(new Dimension(750, 375));
       add(authlist, BorderLayout.CENTER);
@@ -236,6 +249,7 @@ public class SplashScreen extends JPanel
   /**
    * Create splash screen, display it and clear it off again.
    */
+  @Override
   public void run()
   {
     initSplashScreenWindow();
@@ -297,9 +311,10 @@ public class SplashScreen extends JPanel
     public SplashImage(Image todisplay)
     {
       image = todisplay;
-      if (image!=null)
-      {      setPreferredSize(new Dimension(image.getWidth(this) + 8,
-              image.getHeight(this)));
+      if (image != null)
+      {
+        setPreferredSize(new Dimension(image.getWidth(this) + 8,
+                image.getHeight(this)));
       }
     }
 
@@ -309,6 +324,7 @@ public class SplashScreen extends JPanel
       return new Dimension(image.getWidth(this) + 8, image.getHeight(this));
     }
 
+    @Override
     public void paintComponent(Graphics g)
     {
       g.setColor(Color.white);