2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
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
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import java.awt.BorderLayout;
24 import java.awt.Color;
25 import java.awt.Dimension;
27 import java.awt.Graphics;
28 import java.awt.Image;
29 import java.awt.MediaTracker;
30 import java.awt.event.MouseAdapter;
31 import java.awt.event.MouseEvent;
33 import javax.swing.JInternalFrame;
34 import javax.swing.JLayeredPane;
35 import javax.swing.JPanel;
36 import javax.swing.JTextPane;
37 import javax.swing.event.HyperlinkEvent;
38 import javax.swing.event.HyperlinkListener;
46 public class SplashScreen extends JPanel
47 implements Runnable, HyperlinkListener
49 boolean visible = true;
51 JPanel iconimg = new JPanel(new BorderLayout());
53 JTextPane authlist = new JTextPane();
55 JInternalFrame iframe;
64 * Creates a new SplashScreen object.
71 private boolean interactiveDialog = false;
76 * if true - an internal dialog is opened rather than a free-floating
79 public SplashScreen(boolean interactive)
81 this.interactiveDialog = interactive;
82 // show a splashscreen that will disapper
83 Thread t = new Thread(this);
87 MouseAdapter closer = new MouseAdapter()
89 public void mousePressed(MouseEvent evt)
93 if (!interactiveDialog)
98 } catch (Exception ex)
105 * ping the jalview version page then create and display the jalview
106 * splashscreen window.
108 void initSplashScreenWindow()
110 addMouseListener(closer);
113 java.net.URL url = getClass().getResource("/images/Jalview_Logo.png");
114 java.net.URL urllogo = getClass()
115 .getResource("/images/Jalview_Logo_small.png");
119 image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
120 Image logo = java.awt.Toolkit.getDefaultToolkit()
121 .createImage(urllogo);
122 MediaTracker mt = new MediaTracker(this);
123 mt.addImage(image, 0);
124 mt.addImage(logo, 1);
130 } catch (InterruptedException x)
136 System.err.println("Error when loading images!");
138 } while (!mt.checkAll());
139 Desktop.instance.setIconImage(logo);
141 } catch (Exception ex)
145 iframe = new JInternalFrame();
146 iframe.setFrameIcon(null);
147 iframe.setClosable(interactiveDialog);
148 this.setLayout(new BorderLayout());
149 iframe.setContentPane(this);
150 iframe.setLayer(JLayeredPane.PALETTE_LAYER);
152 SplashImage splashimg = new SplashImage(image);
153 iconimg.add(splashimg, BorderLayout.CENTER);
154 add(iconimg, BorderLayout.NORTH);
155 add(authlist, BorderLayout.CENTER);
156 authlist.setEditable(false);
157 authlist.addMouseListener(closer);
158 Desktop.desktop.add(iframe);
165 * update text in author text panel reflecting current version information
167 protected boolean refreshText()
169 String newtext = Desktop.instance.getAboutMessage(true).toString();
170 // System.err.println("Text found: \n"+newtext+"\nEnd of newtext.");
171 if (oldtext != newtext.length())
173 iframe.setVisible(false);
174 oldtext = newtext.length();
175 authlist = new JTextPane();
176 authlist.setEditable(false);
177 authlist.addMouseListener(closer);
178 authlist.addHyperlinkListener(this);
179 authlist.setContentType("text/html");
180 authlist.setText(newtext);
181 authlist.setVisible(true);
182 authlist.setSize(new Dimension(750, 375));
183 add(authlist, BorderLayout.CENTER);
185 iframe.setBounds((Desktop.instance.getWidth() - 750) / 2,
186 (Desktop.instance.getHeight() - 375) / 2, 750,
187 authlist.getHeight() + iconimg.getHeight());
189 iframe.setVisible(true);
197 * Create splash screen, display it and clear it off again.
201 initSplashScreenWindow();
203 long startTime = System.currentTimeMillis() / 1000;
211 } catch (Exception ex)
215 if (!interactiveDialog
216 && ((System.currentTimeMillis() / 1000) - startTime) > 5)
221 if (visible && refreshText())
223 // if (interactiveDialog) {
229 if (interactiveDialog)
236 Desktop.instance.startDialogQueue();
242 public void closeSplash()
247 iframe.setClosed(true);
248 } catch (Exception ex)
253 public class SplashImage extends JPanel
257 public SplashImage(Image todisplay)
260 setPreferredSize(new Dimension(image.getWidth(this) + 8,
261 image.getHeight(this)));
265 public Dimension getPreferredSize()
267 return new Dimension(image.getWidth(this) + 8, image.getHeight(this));
270 public void paintComponent(Graphics g)
272 g.setColor(Color.white);
273 g.fillRect(0, 0, getWidth(), getHeight());
274 g.setColor(Color.black);
275 g.setFont(new Font("Verdana", Font.BOLD, fontSize + 6));
279 g.drawImage(image, (getWidth() - image.getWidth(this)) / 2,
280 (getHeight() - image.getHeight(this)) / 2, this);
286 * g.drawString("Jalview " + jalview.bin.Cache.getProperty("VERSION"), 50,
289 * FontMetrics fm = g.getFontMetrics(); int vwidth =
290 * fm.stringWidth("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
291 * g.setFont(new Font("Verdana", Font.BOLD, fontSize + 2)); g.drawString(
292 * "Last updated: " + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"),
293 * 50 + vwidth + 5, y); if (jalview.bin.Cache.getDefault("LATEST_VERSION",
294 * "Checking").equals( "Checking")) { // Displayed when code version and
295 * jnlp version do not match g.drawString("...Checking latest version...",
296 * 50, y += fontSize + 10); y += 5; g.setColor(Color.black); } else if
297 * (!jalview.bin.Cache.getDefault("LATEST_VERSION", "Checking")
298 * .equals(jalview.bin.Cache.getProperty("VERSION"))) { if
299 * (jalview.bin.Cache.getProperty("VERSION").toLowerCase()
300 * .indexOf("automated build") == -1) { // Displayed when code version and
301 * jnlp version do not match and code // version is not a development build
302 * g.setColor(Color.red); } g.drawString( "!! Jalview version " +
303 * jalview.bin.Cache.getDefault("LATEST_VERSION", "..Checking..") +
304 * " is available for download from "
305 * +jalview.bin.Cache.getDefault("www.jalview.org"
306 * ,"http://www.jalview.org")+" !!", 50, y += fontSize + 10); y += 5;
307 * g.setColor(Color.black); }
309 * g.setFont(new Font("Verdana", Font.BOLD, fontSize)); g.drawString(
310 * "Authors: Jim Procter, Andrew Waterhouse, Michele Clamp, James Cuff, Steve Searle,"
311 * , 50, y += fontSize + 4); g.drawString("David Martin & Geoff Barton.",
312 * 60, y += fontSize + 4); g.drawString(
313 * "Development managed by The Barton Group, University of Dundee.", 50, y
314 * += fontSize + 4); g.drawString("If you use Jalview, please cite: ", 50,
315 * y += fontSize + 4); g.drawString(
316 * "Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)"
317 * , 50, y += fontSize + 4); g.drawString(
318 * "Jalview Version 2 - a multiple sequence alignment editor and analysis workbench"
319 * , 50, y += fontSize + 4);
320 * g.drawString("Bioinformatics doi: 10.1093/bioinformatics/btp033", 50, y
321 * += fontSize + 4); }
326 public void hyperlinkUpdate(HyperlinkEvent e)
328 Desktop.hyperlinkUpdate(e);