From 7aa643222eefde760ffe621bc1e04ca50713f66e Mon Sep 17 00:00:00 2001 From: jprocter Date: Mon, 10 Oct 2011 11:56:02 +0100 Subject: [PATCH] (JAL-957) change splash screen and about to HTML text, and author list now stored in resources/authors.props --- resources/authors.props | 4 + src/jalview/gui/Desktop.java | 73 ++++++++++---- src/jalview/gui/SplashScreen.java | 196 +++++++++++++++++++++---------------- 3 files changed, 168 insertions(+), 105 deletions(-) create mode 100644 resources/authors.props diff --git a/resources/authors.props b/resources/authors.props new file mode 100644 index 0000000..69c89a6 --- /dev/null +++ b/resources/authors.props @@ -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 diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index f4040fa..01a7e69 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -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(""); + if (shortv) + { + message.append("

Jalview " + + jalview.bin.Cache.getProperty("VERSION") + "


"); + message.append("Last Updated: "+jalview.bin.Cache.getDefault("BUILD_DATE", "unknown")+""); + + } else { + + message.append("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("
...Checking latest version...
"); } - // 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("
"); + } + + message.append("
!! 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("
"); + } + } + message.append("
Authors: "+jalview.bin.Cache.getDefault("AUTHORNAMES","Jim Procter, Andrew Waterhouse, Jan Engelhardt, Lauren Lui, Michele Clamp, James Cuff, Steve Searle, David Martin & Geoff Barton") + + "
Development managed by The Barton Group, University of Dundee, Scotland, UK.
" + + "
For help, see the FAQ at www.jalview.org and/or join the jalview-discuss@jalview.org mailing list" + + "
If you use Jalview, please cite:" + + "
Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)" + + "
Jalview Version 2 - a multiple sequence alignment editor and analysis workbench" + + "
Bioinformatics doi: 10.1093/bioinformatics/btp033" + + ""); + return message; } /** diff --git a/src/jalview/gui/SplashScreen.java b/src/jalview/gui/SplashScreen.java index 7059668..f7c42b3 100755 --- a/src/jalview/gui/SplashScreen.java +++ b/src/jalview/gui/SplashScreen.java @@ -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 -- 1.7.10.2