2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, 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,
36 boolean visible = true;
38 JPanel iconimg = new JPanel(new BorderLayout());
40 JTextPane authlist = new JTextPane();
42 JInternalFrame iframe;
51 * Creates a new SplashScreen object.
58 private boolean interactiveDialog = false;
63 * if true - an internal dialog is opened rather than a free-floating
66 public SplashScreen(boolean interactive)
68 this.interactiveDialog = interactive;
69 // show a splashscreen that will disapper
70 Thread t = new Thread(this);
74 MouseAdapter closer = new MouseAdapter()
76 public void mousePressed(MouseEvent evt)
80 if (!interactiveDialog)
85 } catch (Exception ex)
92 * ping the jalview version page then create and display the jalview
93 * splashscreen window.
95 void initSplashScreenWindow()
97 addMouseListener(closer);
100 java.net.URL url = getClass().getResource("/images/Jalview_Logo.png");
101 java.net.URL urllogo = getClass().getResource(
102 "/images/Jalview_Logo_small.png");
106 image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
107 Image logo = java.awt.Toolkit.getDefaultToolkit().createImage(
109 MediaTracker mt = new MediaTracker(this);
110 mt.addImage(image, 0);
111 mt.addImage(logo, 1);
117 } catch (InterruptedException x)
123 System.err.println("Error when loading images!");
125 } while (!mt.checkAll());
126 Desktop.instance.setIconImage(logo);
128 } catch (Exception ex)
132 iframe = new JInternalFrame();
133 iframe.setFrameIcon(null);
134 iframe.setClosable(interactiveDialog);
135 this.setLayout(new BorderLayout());
136 iframe.setContentPane(this);
137 iframe.setLayer(JLayeredPane.PALETTE_LAYER);
139 SplashImage splashimg = new SplashImage(image);
140 iconimg.add(splashimg, BorderLayout.CENTER);
141 add(iconimg, BorderLayout.NORTH);
142 add(authlist, BorderLayout.CENTER);
143 authlist.setEditable(false);
144 authlist.addMouseListener(closer);
145 Desktop.desktop.add(iframe);
152 * update text in author text panel reflecting current version information
154 protected boolean refreshText()
156 String newtext = Desktop.instance.getAboutMessage(true).toString();
157 // System.err.println("Text found: \n"+newtext+"\nEnd of newtext.");
158 if (oldtext != newtext.length())
160 iframe.setVisible(false);
161 oldtext = newtext.length();
162 authlist = new JTextPane();
163 authlist.setEditable(false);
164 authlist.addMouseListener(closer);
165 authlist.addHyperlinkListener(this);
166 authlist.setContentType("text/html");
167 authlist.setText(newtext);
168 authlist.setVisible(true);
169 authlist.setSize(new Dimension(750, 275));
170 add(authlist, BorderLayout.CENTER);
172 iframe.setBounds((int) ((Desktop.instance.getWidth() - 750) / 2),
173 (int) ((Desktop.instance.getHeight() - 140) / 2), 750,
174 authlist.getHeight() + iconimg.getHeight());
176 iframe.setVisible(true);
184 * Create splash screen, display it and clear it off again.
188 initSplashScreenWindow();
190 long startTime = System.currentTimeMillis() / 1000;
198 } catch (Exception ex)
202 if (!interactiveDialog
203 && ((System.currentTimeMillis() / 1000) - startTime) > 5)
208 if (visible && refreshText())
210 // if (interactiveDialog) {
216 if (interactiveDialog)
223 Desktop.instance.startDialogQueue();
229 public void closeSplash()
234 iframe.setClosed(true);
235 } catch (Exception ex)
240 public class SplashImage extends JPanel
244 public SplashImage(Image todisplay)
247 setPreferredSize(new Dimension(image.getWidth(this) + 8,
248 image.getHeight(this)));
252 public Dimension getPreferredSize()
254 return new Dimension(image.getWidth(this) + 8, image.getHeight(this));
257 public void paintComponent(Graphics g)
259 g.setColor(Color.white);
260 g.fillRect(0, 0, getWidth(), getHeight());
261 g.setColor(Color.black);
262 g.setFont(new Font("Verdana", Font.BOLD, fontSize + 6));
266 g.drawImage(image, (getWidth() - image.getWidth(this)) / 2,
267 (getHeight() - image.getHeight(this)) / 2, this);
273 * g.drawString("Jalview " + jalview.bin.Cache.getProperty("VERSION"), 50,
276 * FontMetrics fm = g.getFontMetrics(); int vwidth =
277 * fm.stringWidth("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
278 * g.setFont(new Font("Verdana", Font.BOLD, fontSize + 2)); g.drawString(
279 * "Last updated: " + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"),
280 * 50 + vwidth + 5, y); if (jalview.bin.Cache.getDefault("LATEST_VERSION",
281 * "Checking").equals( "Checking")) { // Displayed when code version and
282 * jnlp version do not match g.drawString("...Checking latest version...",
283 * 50, y += fontSize + 10); y += 5; g.setColor(Color.black); } else if
284 * (!jalview.bin.Cache.getDefault("LATEST_VERSION", "Checking")
285 * .equals(jalview.bin.Cache.getProperty("VERSION"))) { if
286 * (jalview.bin.Cache.getProperty("VERSION").toLowerCase()
287 * .indexOf("automated build") == -1) { // Displayed when code version and
288 * jnlp version do not match and code // version is not a development build
289 * g.setColor(Color.red); } g.drawString( "!! Jalview version " +
290 * jalview.bin.Cache.getDefault("LATEST_VERSION", "..Checking..") +
291 * " is available for download from "
292 * +jalview.bin.Cache.getDefault("www.jalview.org"
293 * ,"http://www.jalview.org")+" !!", 50, y += fontSize + 10); y += 5;
294 * g.setColor(Color.black); }
296 * g.setFont(new Font("Verdana", Font.BOLD, fontSize)); g.drawString(
297 * "Authors: Jim Procter, Andrew Waterhouse, Michele Clamp, James Cuff, Steve Searle,"
298 * , 50, y += fontSize + 4); g.drawString("David Martin & Geoff Barton.",
299 * 60, y += fontSize + 4); g.drawString(
300 * "Development managed by The Barton Group, University of Dundee.", 50, y
301 * += fontSize + 4); g.drawString("If you use Jalview, please cite: ", 50,
302 * y += fontSize + 4); g.drawString(
303 * "Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)"
304 * , 50, y += fontSize + 4); g.drawString(
305 * "Jalview Version 2 - a multiple sequence alignment editor and analysis workbench"
306 * , 50, y += fontSize + 4);
307 * g.drawString("Bioinformatics doi: 10.1093/bioinformatics/btp033", 50, y
308 * += fontSize + 4); }
313 public void hyperlinkUpdate(HyperlinkEvent e)
315 Desktop.hyperlinkUpdate(e);