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/Jalviewlogo.png");
100 image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
102 MediaTracker mt = new MediaTracker(this);
103 mt.addImage(image, 0);
105 Desktop.instance.setIconImage(image);
107 } catch (Exception ex)
111 iframe = new JInternalFrame();
112 iframe.setFrameIcon(null);
113 iframe.setClosable(interactiveDialog);
114 this.setLayout(new BorderLayout());
115 iframe.setContentPane(this);
116 iframe.setLayer(JLayeredPane.PALETTE_LAYER);
118 Desktop.desktop.add(iframe);
119 SplashImage splashimg = new SplashImage(image);
120 iconimg.add(splashimg, BorderLayout.CENTER);
121 add(iconimg, BorderLayout.NORTH);
122 add(authlist, BorderLayout.CENTER);
123 authlist.setEditable(false);
124 authlist.addMouseListener(closer);
131 * update text in author text panel reflecting current version information
133 protected boolean refreshText()
135 String newtext = Desktop.instance.getAboutMessage(true).toString();
136 //System.err.println("Text found: \n"+newtext+"\nEnd of newtext.");
137 if (oldtext != newtext.length())
139 iframe.setVisible(false);
140 oldtext = newtext.length();
141 authlist=new JTextPane();
142 authlist.setEditable(false);
143 authlist.addMouseListener(closer);
144 authlist.addHyperlinkListener(this);
145 authlist.setContentType("text/html");
146 authlist.setText(newtext);
147 authlist.setVisible(true);
148 add(authlist, BorderLayout.CENTER);
149 iframe.setBounds((int) ((Desktop.instance.getWidth() - 750) / 2),
150 (int) ((Desktop.instance.getHeight() - 160) / 2), 750,
151 iframe.getPreferredSize().height);
152 //System.err.println("New preferred size: "+iframe.getPreferredSize().height);
154 iframe.setVisible(true);
162 * Create splash screen, display it and clear it off again.
166 initSplashScreenWindow();
168 long startTime = System.currentTimeMillis() / 1000;
176 } catch (Exception ex)
180 if (!interactiveDialog && ((System.currentTimeMillis() / 1000) - startTime) > 5)
185 if (visible && refreshText())
187 // if (interactiveDialog) {
193 if (interactiveDialog)
205 public void closeSplash()
210 iframe.setClosed(true);
211 } catch (Exception ex)
216 public class SplashImage extends JPanel
220 public SplashImage(Image todisplay)
223 setPreferredSize(new Dimension(image.getWidth(this) + 8,
224 image.getHeight(this)));
227 public void paintComponent(Graphics g)
229 g.setColor(Color.white);
230 g.fillRect(0, 0, getWidth(), getHeight());
231 g.setColor(Color.black);
232 g.setFont(new Font("Verdana", Font.BOLD, fontSize + 6));
236 g.drawImage(image, (getWidth() - image.getWidth(this)) / 2, (getHeight() - image.getHeight(this)) / 2,
243 * g.drawString("Jalview " + jalview.bin.Cache.getProperty("VERSION"), 50,
246 * FontMetrics fm = g.getFontMetrics(); int vwidth =
247 * fm.stringWidth("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
248 * g.setFont(new Font("Verdana", Font.BOLD, fontSize + 2)); g.drawString(
249 * "Last updated: " + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"),
250 * 50 + vwidth + 5, y); if (jalview.bin.Cache.getDefault("LATEST_VERSION",
251 * "Checking").equals( "Checking")) { // Displayed when code version and
252 * jnlp version do not match g.drawString("...Checking latest version...",
253 * 50, y += fontSize + 10); y += 5; g.setColor(Color.black); } else if
254 * (!jalview.bin.Cache.getDefault("LATEST_VERSION", "Checking")
255 * .equals(jalview.bin.Cache.getProperty("VERSION"))) { if
256 * (jalview.bin.Cache.getProperty("VERSION").toLowerCase()
257 * .indexOf("automated build") == -1) { // Displayed when code version and
258 * jnlp version do not match and code // version is not a development build
259 * g.setColor(Color.red); } g.drawString( "!! Jalview version " +
260 * jalview.bin.Cache.getDefault("LATEST_VERSION", "..Checking..") +
261 * " is available for download from "
262 * +jalview.bin.Cache.getDefault("www.jalview.org"
263 * ,"http://www.jalview.org")+" !!", 50, y += fontSize + 10); y += 5;
264 * g.setColor(Color.black); }
266 * g.setFont(new Font("Verdana", Font.BOLD, fontSize)); g.drawString(
267 * "Authors: Jim Procter, Andrew Waterhouse, Michele Clamp, James Cuff, Steve Searle,"
268 * , 50, y += fontSize + 4); g.drawString("David Martin & Geoff Barton.",
269 * 60, y += fontSize + 4); g.drawString(
270 * "Development managed by The Barton Group, University of Dundee.", 50, y
271 * += fontSize + 4); g.drawString("If you use Jalview, please cite: ", 50,
272 * y += fontSize + 4); g.drawString(
273 * "Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)"
274 * , 50, y += fontSize + 4); g.drawString(
275 * "Jalview Version 2 - a multiple sequence alignment editor and analysis workbench"
276 * , 50, y += fontSize + 4);
277 * g.drawString("Bioinformatics doi: 10.1093/bioinformatics/btp033", 50, y
278 * += fontSize + 4); }
282 public void hyperlinkUpdate(HyperlinkEvent e)
284 Desktop.hyperlinkUpdate(e);