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.*;
24 import javax.swing.event.HyperlinkEvent;
25 import javax.swing.event.HyperlinkListener;
33 public class SplashScreen extends JPanel implements Runnable, HyperlinkListener
35 boolean visible = true;
37 JPanel iconimg = new JPanel(new BorderLayout());
39 JTextPane authlist = new JTextPane();
41 JInternalFrame iframe;
50 * Creates a new SplashScreen object.
56 private boolean interactiveDialog=false;
59 * @param interactive if true - an internal dialog is opened rather than a free-floating splash screen
61 public SplashScreen(boolean interactive)
63 this.interactiveDialog=interactive;
64 // show a splashscreen that will disapper
65 Thread t = new Thread(this);
70 MouseAdapter closer = new MouseAdapter()
72 public void mousePressed(MouseEvent evt)
76 if (!interactiveDialog)
81 } catch (Exception ex)
88 * ping the jalview version page then create and display the jalview
89 * splashscreen window.
91 void initSplashScreenWindow()
93 addMouseListener(closer);
96 java.net.URL url = getClass().getResource("/images/Jalview_Logo.png");
97 java.net.URL urllogo = getClass().getResource("/images/Jalview_Logo_small.png");
101 image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
102 Image logo=java.awt.Toolkit.getDefaultToolkit().createImage(urllogo);
103 MediaTracker mt = new MediaTracker(this);
104 mt.addImage(image, 0);
105 mt.addImage(logo, 1);
107 mt.waitForAll(); } catch (InterruptedException x) {};
110 System.err.println("Error when loading images!");
112 } while (!mt.checkAll());
113 Desktop.instance.setIconImage(logo);
115 } catch (Exception ex)
119 iframe = new JInternalFrame();
120 iframe.setFrameIcon(null);
121 iframe.setClosable(interactiveDialog);
122 this.setLayout(new BorderLayout());
123 iframe.setContentPane(this);
124 iframe.setLayer(JLayeredPane.PALETTE_LAYER);
126 SplashImage splashimg = new SplashImage(image);
127 iconimg.add(splashimg, BorderLayout.CENTER);
128 add(iconimg, BorderLayout.NORTH);
129 add(authlist, BorderLayout.CENTER);
130 authlist.setEditable(false);
131 authlist.addMouseListener(closer);
132 Desktop.desktop.add(iframe);
139 * update text in author text panel reflecting current version information
141 protected boolean refreshText()
143 String newtext = Desktop.instance.getAboutMessage(true).toString();
144 //System.err.println("Text found: \n"+newtext+"\nEnd of newtext.");
145 if (oldtext != newtext.length())
147 iframe.setVisible(false);
148 oldtext = newtext.length();
149 authlist=new JTextPane();
150 authlist.setEditable(false);
151 authlist.addMouseListener(closer);
152 authlist.addHyperlinkListener(this);
153 authlist.setContentType("text/html");
154 authlist.setText(newtext);
155 authlist.setVisible(true);
156 add(authlist, BorderLayout.CENTER);
157 iframe.setBounds((int) ((Desktop.instance.getWidth() - 750) / 2),
158 (int) ((Desktop.instance.getHeight() - 160) / 2), 750,
159 iframe.getPreferredSize().height);
160 //System.err.println("New preferred size: "+iframe.getPreferredSize().height);
162 iframe.setVisible(true);
170 * Create splash screen, display it and clear it off again.
174 initSplashScreenWindow();
176 long startTime = System.currentTimeMillis() / 1000;
184 } catch (Exception ex)
188 if (!interactiveDialog && ((System.currentTimeMillis() / 1000) - startTime) > 5)
193 if (visible && refreshText())
195 // if (interactiveDialog) {
201 if (interactiveDialog)
208 Desktop.instance.startDialogQueue();
214 public void closeSplash()
219 iframe.setClosed(true);
220 } catch (Exception ex)
225 public class SplashImage extends JPanel
229 public SplashImage(Image todisplay)
232 setPreferredSize(new Dimension(image.getWidth(this) + 8,
233 image.getHeight(this)));
236 public Dimension getPreferredSize()
238 return new Dimension(image.getWidth(this) + 8,
239 image.getHeight(this));
241 public void paintComponent(Graphics g)
243 g.setColor(Color.white);
244 g.fillRect(0, 0, getWidth(), getHeight());
245 g.setColor(Color.black);
246 g.setFont(new Font("Verdana", Font.BOLD, fontSize + 6));
250 g.drawImage(image, (getWidth() - image.getWidth(this)) / 2, (getHeight() - image.getHeight(this)) / 2,
257 * g.drawString("Jalview " + jalview.bin.Cache.getProperty("VERSION"), 50,
260 * FontMetrics fm = g.getFontMetrics(); int vwidth =
261 * fm.stringWidth("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
262 * g.setFont(new Font("Verdana", Font.BOLD, fontSize + 2)); g.drawString(
263 * "Last updated: " + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"),
264 * 50 + vwidth + 5, y); if (jalview.bin.Cache.getDefault("LATEST_VERSION",
265 * "Checking").equals( "Checking")) { // Displayed when code version and
266 * jnlp version do not match g.drawString("...Checking latest version...",
267 * 50, y += fontSize + 10); y += 5; g.setColor(Color.black); } else if
268 * (!jalview.bin.Cache.getDefault("LATEST_VERSION", "Checking")
269 * .equals(jalview.bin.Cache.getProperty("VERSION"))) { if
270 * (jalview.bin.Cache.getProperty("VERSION").toLowerCase()
271 * .indexOf("automated build") == -1) { // Displayed when code version and
272 * jnlp version do not match and code // version is not a development build
273 * g.setColor(Color.red); } g.drawString( "!! Jalview version " +
274 * jalview.bin.Cache.getDefault("LATEST_VERSION", "..Checking..") +
275 * " is available for download from "
276 * +jalview.bin.Cache.getDefault("www.jalview.org"
277 * ,"http://www.jalview.org")+" !!", 50, y += fontSize + 10); y += 5;
278 * g.setColor(Color.black); }
280 * g.setFont(new Font("Verdana", Font.BOLD, fontSize)); g.drawString(
281 * "Authors: Jim Procter, Andrew Waterhouse, Michele Clamp, James Cuff, Steve Searle,"
282 * , 50, y += fontSize + 4); g.drawString("David Martin & Geoff Barton.",
283 * 60, y += fontSize + 4); g.drawString(
284 * "Development managed by The Barton Group, University of Dundee.", 50, y
285 * += fontSize + 4); g.drawString("If you use Jalview, please cite: ", 50,
286 * y += fontSize + 4); g.drawString(
287 * "Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)"
288 * , 50, y += fontSize + 4); g.drawString(
289 * "Jalview Version 2 - a multiple sequence alignment editor and analysis workbench"
290 * , 50, y += fontSize + 4);
291 * g.drawString("Bioinformatics doi: 10.1093/bioinformatics/btp033", 50, y
292 * += fontSize + 4); }
296 public void hyperlinkUpdate(HyperlinkEvent e)
298 Desktop.hyperlinkUpdate(e);