2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3 * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
21 import java.awt.event.*;
31 public class SplashScreen extends JPanel implements Runnable
33 boolean visible = true;
35 JPanel iconimg = new JPanel(new BorderLayout());
37 JTextPane authlist = new JTextPane();
39 JInternalFrame iframe;
48 * Creates a new SplashScreen object.
52 Thread t = new Thread(this);
56 MouseAdapter closer = new MouseAdapter()
58 public void mousePressed(MouseEvent evt)
64 } catch (Exception ex)
71 * ping the jalview version page then create and display the jalview
72 * splashscreen window.
74 void initSplashScreenWindow()
76 addMouseListener(closer);
79 java.net.URL url = getClass().getResource("/images/logo.gif");
83 image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
85 MediaTracker mt = new MediaTracker(this);
86 mt.addImage(image, 0);
88 Desktop.instance.setIconImage(image);
90 } catch (Exception ex)
94 iframe = new JInternalFrame();
95 iframe.setFrameIcon(null);
96 iframe.setClosable(false);
97 this.setLayout(new BorderLayout());
98 iframe.setContentPane(this);
99 iframe.setLayer(JLayeredPane.PALETTE_LAYER);
101 Desktop.desktop.add(iframe);
102 SplashImage splashimg = new SplashImage(image);
103 iconimg.add(splashimg, BorderLayout.CENTER);
104 add(iconimg, BorderLayout.WEST);
105 add(authlist, BorderLayout.CENTER);
106 authlist.setEditable(false);
107 authlist.addMouseListener(closer);
114 * update text in author text panel reflecting current version information
116 protected boolean refreshText()
118 String newtext = Desktop.instance.getAboutMessage(true).toString();
119 System.err.println("Text found: \n"+newtext+"\nEnd of newtext.");
120 if (oldtext != newtext.length())
122 iframe.setVisible(false);
123 oldtext = newtext.length();
124 authlist=new JTextPane();
125 authlist.setEditable(false);
126 authlist.addMouseListener(closer);
127 authlist.setContentType("text/html");
128 authlist.setText(newtext);
129 authlist.setVisible(true);
130 add(authlist, BorderLayout.CENTER);
132 iframe.setVisible(true);
133 iframe.setBounds((int) ((Desktop.instance.getWidth() - 750) / 2),
134 (int) ((Desktop.instance.getHeight() - 160) / 2), 750,
135 iframe.getPreferredSize().height);
136 System.err.println("New preferred size: "+iframe.getPreferredSize().height);
144 * Create splash screen, display it and clear it off again.
148 initSplashScreenWindow();
150 long startTime = System.currentTimeMillis() / 1000;
157 } catch (Exception ex)
161 if (((System.currentTimeMillis() / 1000) - startTime) > 5)
166 if (visible && refreshText())
178 public void closeSplash()
183 iframe.setClosed(true);
184 } catch (Exception ex)
189 public class SplashImage extends JPanel
193 public SplashImage(Image todisplay)
196 setPreferredSize(new Dimension(image.getWidth(this) + 8,
197 image.getHeight(this)));
200 public void paintComponent(Graphics g)
202 g.setColor(Color.white);
203 g.fillRect(0, 0, getWidth(), getHeight());
204 g.setColor(Color.black);
205 g.setFont(new Font("Verdana", Font.BOLD, fontSize + 6));
209 g.drawImage(image, 4, (getHeight() - image.getHeight(this)) / 2,
216 * g.drawString("Jalview " + jalview.bin.Cache.getProperty("VERSION"), 50,
219 * FontMetrics fm = g.getFontMetrics(); int vwidth =
220 * fm.stringWidth("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
221 * g.setFont(new Font("Verdana", Font.BOLD, fontSize + 2)); g.drawString(
222 * "Last updated: " + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"),
223 * 50 + vwidth + 5, y); if (jalview.bin.Cache.getDefault("LATEST_VERSION",
224 * "Checking").equals( "Checking")) { // Displayed when code version and
225 * jnlp version do not match g.drawString("...Checking latest version...",
226 * 50, y += fontSize + 10); y += 5; g.setColor(Color.black); } else if
227 * (!jalview.bin.Cache.getDefault("LATEST_VERSION", "Checking")
228 * .equals(jalview.bin.Cache.getProperty("VERSION"))) { if
229 * (jalview.bin.Cache.getProperty("VERSION").toLowerCase()
230 * .indexOf("automated build") == -1) { // Displayed when code version and
231 * jnlp version do not match and code // version is not a development build
232 * g.setColor(Color.red); } g.drawString( "!! Jalview version " +
233 * jalview.bin.Cache.getDefault("LATEST_VERSION", "..Checking..") +
234 * " is available for download from "
235 * +jalview.bin.Cache.getDefault("www.jalview.org"
236 * ,"http://www.jalview.org")+" !!", 50, y += fontSize + 10); y += 5;
237 * g.setColor(Color.black); }
239 * g.setFont(new Font("Verdana", Font.BOLD, fontSize)); g.drawString(
240 * "Authors: Jim Procter, Andrew Waterhouse, Michele Clamp, James Cuff, Steve Searle,"
241 * , 50, y += fontSize + 4); g.drawString("David Martin & Geoff Barton.",
242 * 60, y += fontSize + 4); g.drawString(
243 * "Development managed by The Barton Group, University of Dundee.", 50, y
244 * += fontSize + 4); g.drawString("If you use Jalview, please cite: ", 50,
245 * y += fontSize + 4); g.drawString(
246 * "Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)"
247 * , 50, y += fontSize + 4); g.drawString(
248 * "Jalview Version 2 - a multiple sequence alignment editor and analysis workbench"
249 * , 50, y += fontSize + 4);
250 * g.drawString("Bioinformatics doi: 10.1093/bioinformatics/btp033", 50, y
251 * += fontSize + 4); }