2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 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.
24 import java.awt.event.*;
27 import javax.swing.event.HyperlinkEvent;
28 import javax.swing.event.HyperlinkListener;
36 public class SplashScreen extends JPanel implements Runnable,
39 boolean visible = true;
41 JPanel iconimg = new JPanel(new BorderLayout());
43 JTextPane authlist = new JTextPane();
45 JInternalFrame iframe;
54 * Creates a new SplashScreen object.
61 private boolean interactiveDialog = false;
66 * if true - an internal dialog is opened rather than a free-floating
69 public SplashScreen(boolean interactive)
71 this.interactiveDialog = interactive;
72 // show a splashscreen that will disapper
73 Thread t = new Thread(this);
77 MouseAdapter closer = new MouseAdapter()
79 public void mousePressed(MouseEvent evt)
83 if (!interactiveDialog)
88 } catch (Exception ex)
95 * ping the jalview version page then create and display the jalview
96 * splashscreen window.
98 void initSplashScreenWindow()
100 addMouseListener(closer);
103 java.net.URL url = getClass().getResource("/images/Jalview_Logo.png");
104 java.net.URL urllogo = getClass().getResource(
105 "/images/Jalview_Logo_small.png");
109 image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
110 Image logo = java.awt.Toolkit.getDefaultToolkit().createImage(
112 MediaTracker mt = new MediaTracker(this);
113 mt.addImage(image, 0);
114 mt.addImage(logo, 1);
120 } catch (InterruptedException x)
126 System.err.println("Error when loading images!");
128 } while (!mt.checkAll());
129 Desktop.instance.setIconImage(logo);
131 } catch (Exception ex)
135 iframe = new JInternalFrame();
136 iframe.setFrameIcon(null);
137 iframe.setClosable(interactiveDialog);
138 this.setLayout(new BorderLayout());
139 iframe.setContentPane(this);
140 iframe.setLayer(JLayeredPane.PALETTE_LAYER);
142 SplashImage splashimg = new SplashImage(image);
143 iconimg.add(splashimg, BorderLayout.CENTER);
144 add(iconimg, BorderLayout.NORTH);
145 add(authlist, BorderLayout.CENTER);
146 authlist.setEditable(false);
147 authlist.addMouseListener(closer);
148 Desktop.desktop.add(iframe);
155 * update text in author text panel reflecting current version information
157 protected boolean refreshText()
159 String newtext = Desktop.instance.getAboutMessage(true).toString();
160 // System.err.println("Text found: \n"+newtext+"\nEnd of newtext.");
161 if (oldtext != newtext.length())
163 iframe.setVisible(false);
164 oldtext = newtext.length();
165 authlist = new JTextPane();
166 authlist.setEditable(false);
167 authlist.addMouseListener(closer);
168 authlist.addHyperlinkListener(this);
169 authlist.setContentType("text/html");
170 authlist.setText(newtext);
171 authlist.setVisible(true);
172 authlist.setSize(new Dimension(750, 375));
173 add(authlist, BorderLayout.CENTER);
175 iframe.setBounds((int) ((Desktop.instance.getWidth() - 750) / 2),
176 (int) ((Desktop.instance.getHeight() - 375) / 2), 750,
177 authlist.getHeight() + iconimg.getHeight());
179 iframe.setVisible(true);
187 * Create splash screen, display it and clear it off again.
191 initSplashScreenWindow();
193 long startTime = System.currentTimeMillis() / 1000;
201 } catch (Exception ex)
205 if (!interactiveDialog
206 && ((System.currentTimeMillis() / 1000) - startTime) > 5)
211 if (visible && refreshText())
213 // if (interactiveDialog) {
219 if (interactiveDialog)
226 Desktop.instance.startDialogQueue();
232 public void closeSplash()
237 iframe.setClosed(true);
238 } catch (Exception ex)
243 public class SplashImage extends JPanel
247 public SplashImage(Image todisplay)
250 setPreferredSize(new Dimension(image.getWidth(this) + 8,
251 image.getHeight(this)));
255 public Dimension getPreferredSize()
257 return new Dimension(image.getWidth(this) + 8, image.getHeight(this));
260 public void paintComponent(Graphics g)
262 g.setColor(Color.white);
263 g.fillRect(0, 0, getWidth(), getHeight());
264 g.setColor(Color.black);
265 g.setFont(new Font("Verdana", Font.BOLD, fontSize + 6));
269 g.drawImage(image, (getWidth() - image.getWidth(this)) / 2,
270 (getHeight() - image.getHeight(this)) / 2, this);
276 * g.drawString("Jalview " + jalview.bin.Cache.getProperty("VERSION"), 50,
279 * FontMetrics fm = g.getFontMetrics(); int vwidth =
280 * fm.stringWidth("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
281 * g.setFont(new Font("Verdana", Font.BOLD, fontSize + 2)); g.drawString(
282 * "Last updated: " + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"),
283 * 50 + vwidth + 5, y); if (jalview.bin.Cache.getDefault("LATEST_VERSION",
284 * "Checking").equals( "Checking")) { // Displayed when code version and
285 * jnlp version do not match g.drawString("...Checking latest version...",
286 * 50, y += fontSize + 10); y += 5; g.setColor(Color.black); } else if
287 * (!jalview.bin.Cache.getDefault("LATEST_VERSION", "Checking")
288 * .equals(jalview.bin.Cache.getProperty("VERSION"))) { if
289 * (jalview.bin.Cache.getProperty("VERSION").toLowerCase()
290 * .indexOf("automated build") == -1) { // Displayed when code version and
291 * jnlp version do not match and code // version is not a development build
292 * g.setColor(Color.red); } g.drawString( "!! Jalview version " +
293 * jalview.bin.Cache.getDefault("LATEST_VERSION", "..Checking..") +
294 * " is available for download from "
295 * +jalview.bin.Cache.getDefault("www.jalview.org"
296 * ,"http://www.jalview.org")+" !!", 50, y += fontSize + 10); y += 5;
297 * g.setColor(Color.black); }
299 * g.setFont(new Font("Verdana", Font.BOLD, fontSize)); g.drawString(
300 * "Authors: Jim Procter, Andrew Waterhouse, Michele Clamp, James Cuff, Steve Searle,"
301 * , 50, y += fontSize + 4); g.drawString("David Martin & Geoff Barton.",
302 * 60, y += fontSize + 4); g.drawString(
303 * "Development managed by The Barton Group, University of Dundee.", 50, y
304 * += fontSize + 4); g.drawString("If you use Jalview, please cite: ", 50,
305 * y += fontSize + 4); g.drawString(
306 * "Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)"
307 * , 50, y += fontSize + 4); g.drawString(
308 * "Jalview Version 2 - a multiple sequence alignment editor and analysis workbench"
309 * , 50, y += fontSize + 4);
310 * g.drawString("Bioinformatics doi: 10.1093/bioinformatics/btp033", 50, y
311 * += fontSize + 4); }
316 public void hyperlinkUpdate(HyperlinkEvent e)
318 Desktop.hyperlinkUpdate(e);