2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
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 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/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
22 import java.awt.event.*;
25 import javax.swing.event.HyperlinkEvent;
26 import javax.swing.event.HyperlinkListener;
34 public class SplashScreen extends JPanel implements Runnable,
37 boolean visible = true;
39 JPanel iconimg = new JPanel(new BorderLayout());
41 JTextPane authlist = new JTextPane();
43 JInternalFrame iframe;
52 * Creates a new SplashScreen object.
59 private boolean interactiveDialog = false;
64 * if true - an internal dialog is opened rather than a free-floating
67 public SplashScreen(boolean interactive)
69 this.interactiveDialog = interactive;
70 // show a splashscreen that will disapper
71 Thread t = new Thread(this);
75 MouseAdapter closer = new MouseAdapter()
77 public void mousePressed(MouseEvent evt)
81 if (!interactiveDialog)
86 } catch (Exception ex)
93 * ping the jalview version page then create and display the jalview
94 * splashscreen window.
96 void initSplashScreenWindow()
98 addMouseListener(closer);
101 java.net.URL url = getClass().getResource("/images/Jalview_Logo.png");
102 java.net.URL urllogo = getClass().getResource(
103 "/images/Jalview_Logo_small.png");
107 image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
108 Image logo = java.awt.Toolkit.getDefaultToolkit().createImage(
110 MediaTracker mt = new MediaTracker(this);
111 mt.addImage(image, 0);
112 mt.addImage(logo, 1);
118 } catch (InterruptedException x)
124 System.err.println("Error when loading images!");
126 } while (!mt.checkAll());
127 Desktop.instance.setIconImage(logo);
129 } catch (Exception ex)
133 iframe = new JInternalFrame();
134 iframe.setFrameIcon(null);
135 iframe.setClosable(interactiveDialog);
136 this.setLayout(new BorderLayout());
137 iframe.setContentPane(this);
138 iframe.setLayer(JLayeredPane.PALETTE_LAYER);
140 SplashImage splashimg = new SplashImage(image);
141 iconimg.add(splashimg, BorderLayout.CENTER);
142 add(iconimg, BorderLayout.NORTH);
143 add(authlist, BorderLayout.CENTER);
144 authlist.setEditable(false);
145 authlist.addMouseListener(closer);
146 Desktop.desktop.add(iframe);
153 * update text in author text panel reflecting current version information
155 protected boolean refreshText()
157 String newtext = Desktop.instance.getAboutMessage(true).toString();
158 // System.err.println("Text found: \n"+newtext+"\nEnd of newtext.");
159 if (oldtext != newtext.length())
161 iframe.setVisible(false);
162 oldtext = newtext.length();
163 authlist = new JTextPane();
164 authlist.setEditable(false);
165 authlist.addMouseListener(closer);
166 authlist.addHyperlinkListener(this);
167 authlist.setContentType("text/html");
168 authlist.setText(newtext);
169 authlist.setVisible(true);
170 authlist.setSize(new Dimension(750, 275));
171 add(authlist, BorderLayout.CENTER);
173 iframe.setBounds((int) ((Desktop.instance.getWidth() - 750) / 2),
174 (int) ((Desktop.instance.getHeight() - 140) / 2), 750,
175 authlist.getHeight() + iconimg.getHeight());
177 iframe.setVisible(true);
185 * Create splash screen, display it and clear it off again.
189 initSplashScreenWindow();
191 long startTime = System.currentTimeMillis() / 1000;
199 } catch (Exception ex)
203 if (!interactiveDialog
204 && ((System.currentTimeMillis() / 1000) - startTime) > 5)
209 if (visible && refreshText())
211 // if (interactiveDialog) {
217 if (interactiveDialog)
224 Desktop.instance.startDialogQueue();
230 public void closeSplash()
235 iframe.setClosed(true);
236 } catch (Exception ex)
241 public class SplashImage extends JPanel
245 public SplashImage(Image todisplay)
248 setPreferredSize(new Dimension(image.getWidth(this) + 8,
249 image.getHeight(this)));
253 public Dimension getPreferredSize()
255 return new Dimension(image.getWidth(this) + 8, image.getHeight(this));
258 public void paintComponent(Graphics g)
260 g.setColor(Color.white);
261 g.fillRect(0, 0, getWidth(), getHeight());
262 g.setColor(Color.black);
263 g.setFont(new Font("Verdana", Font.BOLD, fontSize + 6));
267 g.drawImage(image, (getWidth() - image.getWidth(this)) / 2,
268 (getHeight() - image.getHeight(this)) / 2, this);
274 * g.drawString("Jalview " + jalview.bin.Cache.getProperty("VERSION"), 50,
277 * FontMetrics fm = g.getFontMetrics(); int vwidth =
278 * fm.stringWidth("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
279 * g.setFont(new Font("Verdana", Font.BOLD, fontSize + 2)); g.drawString(
280 * "Last updated: " + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"),
281 * 50 + vwidth + 5, y); if (jalview.bin.Cache.getDefault("LATEST_VERSION",
282 * "Checking").equals( "Checking")) { // Displayed when code version and
283 * jnlp version do not match g.drawString("...Checking latest version...",
284 * 50, y += fontSize + 10); y += 5; g.setColor(Color.black); } else if
285 * (!jalview.bin.Cache.getDefault("LATEST_VERSION", "Checking")
286 * .equals(jalview.bin.Cache.getProperty("VERSION"))) { if
287 * (jalview.bin.Cache.getProperty("VERSION").toLowerCase()
288 * .indexOf("automated build") == -1) { // Displayed when code version and
289 * jnlp version do not match and code // version is not a development build
290 * g.setColor(Color.red); } g.drawString( "!! Jalview version " +
291 * jalview.bin.Cache.getDefault("LATEST_VERSION", "..Checking..") +
292 * " is available for download from "
293 * +jalview.bin.Cache.getDefault("www.jalview.org"
294 * ,"http://www.jalview.org")+" !!", 50, y += fontSize + 10); y += 5;
295 * g.setColor(Color.black); }
297 * g.setFont(new Font("Verdana", Font.BOLD, fontSize)); g.drawString(
298 * "Authors: Jim Procter, Andrew Waterhouse, Michele Clamp, James Cuff, Steve Searle,"
299 * , 50, y += fontSize + 4); g.drawString("David Martin & Geoff Barton.",
300 * 60, y += fontSize + 4); g.drawString(
301 * "Development managed by The Barton Group, University of Dundee.", 50, y
302 * += fontSize + 4); g.drawString("If you use Jalview, please cite: ", 50,
303 * y += fontSize + 4); g.drawString(
304 * "Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)"
305 * , 50, y += fontSize + 4); g.drawString(
306 * "Jalview Version 2 - a multiple sequence alignment editor and analysis workbench"
307 * , 50, y += fontSize + 4);
308 * g.drawString("Bioinformatics doi: 10.1093/bioinformatics/btp033", 50, y
309 * += fontSize + 4); }
314 public void hyperlinkUpdate(HyperlinkEvent e)
316 Desktop.hyperlinkUpdate(e);