JAL-1130 new logo in help, splash screen and web services spinner
[jalview.git] / src / jalview / gui / SplashScreen.java
index b0be269..297a5e0 100755 (executable)
@@ -21,6 +21,8 @@ import java.awt.*;
 import java.awt.event.*;
 
 import javax.swing.*;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
 
 /**
  * DOCUMENT ME!
@@ -28,7 +30,7 @@ import javax.swing.*;
  * @author $author$
  * @version $Revision$
  */
-public class SplashScreen extends JPanel implements Runnable
+public class SplashScreen extends JPanel implements Runnable, HyperlinkListener
 {
   boolean visible = true;
 
@@ -49,18 +51,33 @@ public class SplashScreen extends JPanel implements Runnable
    */
   public SplashScreen()
   {
+    this(false);
+  }
+  private boolean interactiveDialog=false;
+  /**
+   * 
+   * @param interactive if true - an internal dialog is opened rather than a free-floating splash screen
+   */
+  public SplashScreen(boolean interactive)
+  {
+    this.interactiveDialog=interactive;
+    // show a splashscreen that will disapper
     Thread t = new Thread(this);
     t.start();
   }
 
+
   MouseAdapter closer = new MouseAdapter()
   {
     public void mousePressed(MouseEvent evt)
     {
       try
       {
-        visible = false;
-        closeSplash();
+        if (!interactiveDialog)
+        {
+          visible = false;
+          closeSplash();
+        }
       } catch (Exception ex)
       {
       }
@@ -76,7 +93,7 @@ public class SplashScreen extends JPanel implements Runnable
     addMouseListener(closer);
     try
     {
-      java.net.URL url = getClass().getResource("/images/logo_v2.jpeg");
+      java.net.URL url = getClass().getResource("/images/Jalviewlogo.png");
 
       if (url != null)
       {
@@ -93,7 +110,7 @@ public class SplashScreen extends JPanel implements Runnable
 
     iframe = new JInternalFrame();
     iframe.setFrameIcon(null);
-    iframe.setClosable(false);
+    iframe.setClosable(interactiveDialog);
     this.setLayout(new BorderLayout());
     iframe.setContentPane(this);
     iframe.setLayer(JLayeredPane.PALETTE_LAYER);
@@ -124,16 +141,17 @@ public class SplashScreen extends JPanel implements Runnable
       authlist=new JTextPane();
       authlist.setEditable(false);
       authlist.addMouseListener(closer);
+      authlist.addHyperlinkListener(this);
       authlist.setContentType("text/html");
       authlist.setText(newtext);
       authlist.setVisible(true);
       add(authlist, BorderLayout.CENTER);
-      iframe.pack();
-      iframe.setVisible(true);
       iframe.setBounds((int) ((Desktop.instance.getWidth() - 750) / 2),
               (int) ((Desktop.instance.getHeight() - 160) / 2), 750,
               iframe.getPreferredSize().height);
       //System.err.println("New preferred size: "+iframe.getPreferredSize().height);
+      iframe.validate();
+      iframe.setVisible(true);
 
       return true;
     }
@@ -151,21 +169,30 @@ public class SplashScreen extends JPanel implements Runnable
 
     while (visible)
     {
+      iframe.repaint();
       try
       {
         Thread.sleep(500);
       } catch (Exception ex)
       {
       }
-
-      if (((System.currentTimeMillis() / 1000) - startTime) > 5)
+      
+      if (!interactiveDialog && ((System.currentTimeMillis() / 1000) - startTime) > 5)
       {
         visible = false;
       }
 
       if (visible && refreshText())
       {
-          repaint();
+//          if (interactiveDialog) {
+            iframe.repaint();
+//          } else {
+//            iframe.repaint();
+//          };
+      }
+      if (interactiveDialog)
+      {
+        return;
       }
     }
 
@@ -251,4 +278,10 @@ public class SplashScreen extends JPanel implements Runnable
      * += fontSize + 4); }
      */
   }
+  @Override
+  public void hyperlinkUpdate(HyperlinkEvent e)
+  {
+    Desktop.hyperlinkUpdate(e);
+    
+  }
 }
\ No newline at end of file