(JAL-957) change splash screen and about to HTML text, and author list now stored...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Mon, 10 Oct 2011 10:56:02 +0000 (11:56 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Mon, 10 Oct 2011 10:56:02 +0000 (11:56 +0100)
resources/authors.props [new file with mode: 0644]
src/jalview/gui/Desktop.java
src/jalview/gui/SplashScreen.java

diff --git a/resources/authors.props b/resources/authors.props
new file mode 100644 (file)
index 0000000..69c89a6
--- /dev/null
@@ -0,0 +1,4 @@
+YEAR=2011
+AUTHORS=J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
+AUTHORFNAMES=Jim Procter, Andrew Waterhouse, Jan Engelhardt, Lauren Lui, Michele Clamp, James Cuff, Steve Searle, David Martin & Geoff Barton
\ No newline at end of file
index f4040fa..01a7e69 100644 (file)
@@ -1046,30 +1046,63 @@ public class Desktop extends jalview.jbgui.GDesktop implements
    */
   public void aboutMenuItem_actionPerformed(ActionEvent e)
   {
-    StringBuffer message = new StringBuffer("Jalview version "
+    StringBuffer message = getAboutMessage(false);
+    JOptionPane.showInternalMessageDialog(Desktop.desktop,
+
+    message.toString(), "About Jalview", JOptionPane.INFORMATION_MESSAGE);
+  }
+  public StringBuffer getAboutMessage(boolean shortv)
+  {
+    StringBuffer message=new StringBuffer();
+    message.append("<html>");
+    if (shortv)
+    { 
+      message.append("<h1><strong>Jalview "
+              + jalview.bin.Cache.getProperty("VERSION") + "</strong></h1><br>");
+      message.append("<strong>Last Updated: <em>"+jalview.bin.Cache.getDefault("BUILD_DATE", "unknown")+"</em></strong>");
+      
+    } else {
+      
+    message.append("<strong>Jalview version "
             + jalview.bin.Cache.getProperty("VERSION") + "; last updated: "
             + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"));
-
-    if (!jalview.bin.Cache.getProperty("LATEST_VERSION").equals(
-            jalview.bin.Cache.getProperty("VERSION")))
+    }
+    
+    if (jalview.bin.Cache.getDefault("LATEST_VERSION", "Checking").equals(
+            "Checking"))
     {
-      message.append("\n\n!! Jalview version "
-              + jalview.bin.Cache.getProperty("LATEST_VERSION")
-              + " is available for download from "+jalview.bin.Cache.getDefault("www.jalview.org","http://www.jalview.org")+" !!\n");
-
+      message.append("<br>...Checking latest version...</br>");
     }
-    // TODO: update this text for each release or centrally store it for lite
-    // and application
-    message.append("\nAuthors:  Jim Procter, Jan Engelhardt, Lauren Lui, Andrew Waterhouse, Michele Clamp, James Cuff, Steve Searle,\n    David Martin & Geoff Barton."
-            + "\nDevelopment managed by The Barton Group, University of Dundee, Scotland, UK.\n"
-            + "\nFor help, see the FAQ at www.jalview.org and/or join the jalview-discuss@jalview.org mailing list\n"
-            + "\nIf  you use Jalview, please cite:"
-            + "\nWaterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)"
-            + "\nJalview Version 2 - a multiple sequence alignment editor and analysis workbench"
-            + "\nBioinformatics doi: 10.1093/bioinformatics/btp033");
-    JOptionPane.showInternalMessageDialog(Desktop.desktop,
-
-    message.toString(), "About Jalview", JOptionPane.INFORMATION_MESSAGE);
+    else if (!jalview.bin.Cache.getDefault("LATEST_VERSION", "Checking")
+            .equals(jalview.bin.Cache.getProperty("VERSION")))
+    {
+      boolean red=false;
+      if (jalview.bin.Cache.getProperty("VERSION").toLowerCase()
+              .indexOf("automated build") == -1)
+      {
+        red=true;
+        // Displayed when code version and jnlp version do not match and code
+        // version is not a development build
+        message.append("<div style=\"color: #FF0000;font-style: bold;\">");
+      }
+      
+      message.append("<br>!! Jalview version "
+                      + jalview.bin.Cache.getDefault("LATEST_VERSION",
+                              "..Checking..")
+                      + " is available for download from "+jalview.bin.Cache.getDefault("www.jalview.org","http://www.jalview.org")+" !!");
+      if (red) {
+        message.append("</div>");
+      }
+    }    
+    message.append("<br>Authors:  "+jalview.bin.Cache.getDefault("AUTHORNAMES","Jim Procter, Andrew Waterhouse, Jan Engelhardt, Lauren Lui, Michele Clamp, James Cuff, Steve Searle, David Martin & Geoff Barton")
+            + "<br>Development managed by The Barton Group, University of Dundee, Scotland, UK.<br>"
+            + "<br>For help, see the FAQ at www.jalview.org and/or join the jalview-discuss@jalview.org mailing list"
+            + "<br>If  you use Jalview, please cite:"
+            + "<br>Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)"
+            + "<br>Jalview Version 2 - a multiple sequence alignment editor and analysis workbench"
+            + "<br>Bioinformatics doi: 10.1093/bioinformatics/btp033"
+            + "</html>");
+    return message;
   }
 
   /**
index 7059668..f7c42b3 100755 (executable)
@@ -19,6 +19,7 @@ package jalview.gui;
 
 import java.awt.*;
 import java.awt.event.*;
+
 import javax.swing.*;
 
 /**
@@ -31,6 +32,10 @@ public class SplashScreen extends JPanel implements Runnable
 {
   boolean visible = true;
 
+  JPanel iconimg = new JPanel(new BorderLayout());
+
+  JTextPane authlist = new JTextPane();
+
   JInternalFrame iframe;
 
   Image image;
@@ -48,26 +53,27 @@ public class SplashScreen extends JPanel implements Runnable
     t.start();
   }
 
+  MouseAdapter closer = new MouseAdapter()
+  {
+    public void mousePressed(MouseEvent evt)
+    {
+      try
+      {
+        visible = false;
+        closeSplash();
+      } catch (Exception ex)
+      {
+      }
+    }
+  };
+
   /**
    * ping the jalview version page then create and display the jalview
    * splashscreen window.
    */
   void initSplashScreenWindow()
   {
-    addMouseListener(new MouseAdapter()
-    {
-      public void mousePressed(MouseEvent evt)
-      {
-        try
-        {
-          visible = false;
-          closeSplash();
-        } catch (Exception ex)
-        {
-        }
-      }
-    });
-
+    addMouseListener(closer);
     try
     {
       java.net.URL url = getClass().getResource("/images/logo.gif");
@@ -88,14 +94,41 @@ public class SplashScreen extends JPanel implements Runnable
     iframe = new JInternalFrame();
     iframe.setFrameIcon(null);
     iframe.setClosable(false);
+    this.setLayout(new BorderLayout());
     iframe.setContentPane(this);
     iframe.setLayer(JLayeredPane.PALETTE_LAYER);
 
     Desktop.desktop.add(iframe);
-
+    SplashImage splashimg = new SplashImage(image);
+    iconimg.add(splashimg, BorderLayout.CENTER);
+    add(iconimg, BorderLayout.WEST);
+    add(authlist, BorderLayout.CENTER);
+    authlist.setEditable(false);
+    authlist.addMouseListener(closer);
+    refreshText();
     iframe.setVisible(true);
     iframe.setBounds((int) ((Desktop.instance.getWidth() - 750) / 2),
-            (int) ((Desktop.instance.getHeight() - 160) / 2), 750, 190);
+            (int) ((Desktop.instance.getHeight() - 160) / 2), 750,
+            iframe.getPreferredSize().height);
+
+  }
+
+  long oldtext = -1;
+
+  /**
+   * update text in author text panel reflecting current version information
+   */
+  protected boolean refreshText()
+  {
+    String newtext = Desktop.instance.getAboutMessage(true).toString();
+    if (oldtext != newtext.hashCode())
+    {
+      oldtext = newtext.hashCode();
+      authlist.setContentType("text/html");
+      authlist.setText(newtext);
+      return true;
+    }
+    return false;
   }
 
   /**
@@ -104,6 +137,7 @@ public class SplashScreen extends JPanel implements Runnable
   public void run()
   {
     initSplashScreenWindow();
+
     long startTime = System.currentTimeMillis() / 1000;
 
     while (visible)
@@ -120,7 +154,12 @@ public class SplashScreen extends JPanel implements Runnable
         visible = false;
       }
       else
-        repaint();
+      {
+        if (refreshText())
+        {
+          repaint();
+        }
+      }
     }
 
     closeSplash();
@@ -140,82 +179,69 @@ public class SplashScreen extends JPanel implements Runnable
     }
   }
 
-  /**
-   * DOCUMENT ME!
-   * 
-   * @param g
-   *          DOCUMENT ME!
-   */
-  public void paintComponent(Graphics g)
+  public class SplashImage extends JPanel
   {
-    g.setColor(Color.white);
-    g.fillRect(0, 0, getWidth(), getHeight());
-    g.setColor(Color.black);
-    g.setFont(new Font("Verdana", Font.BOLD, fontSize + 6));
+    Image image;
 
-    if (image != null)
+    public SplashImage(Image todisplay)
     {
-      g.drawImage(image, 5, yoffset + 12, this);
+      image = todisplay;
+      setPreferredSize(new Dimension(image.getWidth(this) + 8,
+              image.getHeight(this)));
     }
 
-    int y = yoffset;
-
-    g.drawString("Jalview " + jalview.bin.Cache.getProperty("VERSION"), 50,
-            y);
-
-    FontMetrics fm = g.getFontMetrics();
-    int vwidth = fm.stringWidth("Jalview "
-            + jalview.bin.Cache.getProperty("VERSION"));
-    g.setFont(new Font("Verdana", Font.BOLD, fontSize + 2));
-    g.drawString(
-            "Last updated: "
-                    + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"),
-            50 + vwidth + 5, y);
-    if (jalview.bin.Cache.getDefault("LATEST_VERSION", "Checking").equals(
-            "Checking"))
+    public void paintComponent(Graphics g)
     {
-      // Displayed when code version and jnlp version do not match
-      g.drawString("...Checking latest version...", 50, y += fontSize + 10);
-      y += 5;
+      g.setColor(Color.white);
+      g.fillRect(0, 0, getWidth(), getHeight());
       g.setColor(Color.black);
-    }
-    else if (!jalview.bin.Cache.getDefault("LATEST_VERSION", "Checking")
-            .equals(jalview.bin.Cache.getProperty("VERSION")))
-    {
-      if (jalview.bin.Cache.getProperty("VERSION").toLowerCase()
-              .indexOf("automated build") == -1)
+      g.setFont(new Font("Verdana", Font.BOLD, fontSize + 6));
+
+      if (image != null)
       {
-        // Displayed when code version and jnlp version do not match and code
-        // version is not a development build
-        g.setColor(Color.red);
+        g.drawImage(image, 4, (getHeight() - image.getHeight(this)) / 2,
+                this);
       }
-      g.drawString(
-              "!! Jalview version "
-                      + jalview.bin.Cache.getDefault("LATEST_VERSION",
-                              "..Checking..")
-                      + " is available for download from "+jalview.bin.Cache.getDefault("www.jalview.org","http://www.jalview.org")+" !!",
-              50, y += fontSize + 10);
-      y += 5;
-      g.setColor(Color.black);
     }
-
-    g.setFont(new Font("Verdana", Font.BOLD, fontSize));
-    g.drawString(
-            "Authors: Jim Procter, Andrew Waterhouse, Michele Clamp, James Cuff, Steve Searle,",
-            50, y += fontSize + 4);
-    g.drawString("David Martin & Geoff Barton.", 60, y += fontSize + 4);
-    g.drawString(
-            "Development managed by The Barton Group, University of Dundee.",
-            50, y += fontSize + 4);
-    g.drawString("If  you use Jalview, please cite: ", 50,
-            y += fontSize + 4);
-    g.drawString(
-            "Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)",
-            50, y += fontSize + 4);
-    g.drawString(
-            "Jalview Version 2 - a multiple sequence alignment editor and analysis workbench",
-            50, y += fontSize + 4);
-    g.drawString("Bioinformatics doi: 10.1093/bioinformatics/btp033", 50,
-            y += fontSize + 4);
+    /*
+     * int y = yoffset;
+     * 
+     * g.drawString("Jalview " + jalview.bin.Cache.getProperty("VERSION"), 50,
+     * y);
+     * 
+     * FontMetrics fm = g.getFontMetrics(); int vwidth =
+     * fm.stringWidth("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
+     * g.setFont(new Font("Verdana", Font.BOLD, fontSize + 2)); g.drawString(
+     * "Last updated: " + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"),
+     * 50 + vwidth + 5, y); if (jalview.bin.Cache.getDefault("LATEST_VERSION",
+     * "Checking").equals( "Checking")) { // Displayed when code version and
+     * jnlp version do not match g.drawString("...Checking latest version...",
+     * 50, y += fontSize + 10); y += 5; g.setColor(Color.black); } else if
+     * (!jalview.bin.Cache.getDefault("LATEST_VERSION", "Checking")
+     * .equals(jalview.bin.Cache.getProperty("VERSION"))) { if
+     * (jalview.bin.Cache.getProperty("VERSION").toLowerCase()
+     * .indexOf("automated build") == -1) { // Displayed when code version and
+     * jnlp version do not match and code // version is not a development build
+     * g.setColor(Color.red); } g.drawString( "!! Jalview version " +
+     * jalview.bin.Cache.getDefault("LATEST_VERSION", "..Checking..") +
+     * " is available for download from "
+     * +jalview.bin.Cache.getDefault("www.jalview.org"
+     * ,"http://www.jalview.org")+" !!", 50, y += fontSize + 10); y += 5;
+     * g.setColor(Color.black); }
+     * 
+     * g.setFont(new Font("Verdana", Font.BOLD, fontSize)); g.drawString(
+     * "Authors: Jim Procter, Andrew Waterhouse, Michele Clamp, James Cuff, Steve Searle,"
+     * , 50, y += fontSize + 4); g.drawString("David Martin & Geoff Barton.",
+     * 60, y += fontSize + 4); g.drawString(
+     * "Development managed by The Barton Group, University of Dundee.", 50, y
+     * += fontSize + 4); g.drawString("If  you use Jalview, please cite: ", 50,
+     * y += fontSize + 4); g.drawString(
+     * "Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)"
+     * , 50, y += fontSize + 4); g.drawString(
+     * "Jalview Version 2 - a multiple sequence alignment editor and analysis workbench"
+     * , 50, y += fontSize + 4);
+     * g.drawString("Bioinformatics doi: 10.1093/bioinformatics/btp033", 50, y
+     * += fontSize + 4); }
+     */
   }
-}
+}
\ No newline at end of file