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, "ShowSplashScreenThread");
87 MouseAdapter closer = new MouseAdapter()
90 public void mousePressed(MouseEvent evt)
94 if (!interactiveDialog)
99 } catch (Exception ex)
106 * ping the jalview version page then create and display the jalview
107 * splashscreen window.
109 void initSplashScreenWindow()
111 addMouseListener(closer);
114 java.net.URL url = getClass().getResource("/images/Jalview_Logo.png");
115 java.net.URL urllogo = getClass()
116 .getResource("/images/Jalview_Logo_small.png");
120 image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
121 Image logo = java.awt.Toolkit.getDefaultToolkit()
122 .createImage(urllogo);
123 MediaTracker mt = new MediaTracker(this);
124 mt.addImage(image, 0);
125 mt.addImage(logo, 1);
131 } catch (InterruptedException x)
137 System.err.println("Error when loading images!");
139 } while (!mt.checkAll());
140 Desktop.instance.setIconImage(logo);
142 } catch (Exception ex)
146 iframe = new JInternalFrame();
147 iframe.setFrameIcon(null);
148 iframe.setClosable(interactiveDialog);
149 this.setLayout(new BorderLayout());
150 iframe.setContentPane(this);
151 iframe.setLayer(JLayeredPane.PALETTE_LAYER);
153 SplashImage splashimg = new SplashImage(image);
154 iconimg.add(splashimg, BorderLayout.CENTER);
155 add(iconimg, BorderLayout.NORTH);
156 add(authlist, BorderLayout.CENTER);
157 authlist.setEditable(false);
158 authlist.addMouseListener(closer);
159 Desktop.desktop.add(iframe);
166 * update text in author text panel reflecting current version information
168 protected boolean refreshText()
170 String newtext = Desktop.instance.getAboutMessage(true).toString();
171 // System.err.println("Text found: \n"+newtext+"\nEnd of newtext.");
172 if (oldtext != newtext.length())
174 iframe.setVisible(false);
175 oldtext = newtext.length();
176 authlist = new JTextPane();
177 authlist.setEditable(false);
178 authlist.addMouseListener(closer);
179 authlist.addHyperlinkListener(this);
180 authlist.setContentType("text/html");
181 authlist.setText(newtext);
182 authlist.setVisible(true);
183 authlist.setSize(new Dimension(750, 375));
184 add(authlist, BorderLayout.CENTER);
186 iframe.setBounds((Desktop.instance.getWidth() - 750) / 2,
187 (Desktop.instance.getHeight() - 375) / 2, 750,
188 authlist.getHeight() + iconimg.getHeight());
190 iframe.setVisible(true);
198 * Create splash screen, display it and clear it off again.
203 initSplashScreenWindow();
205 long startTime = System.currentTimeMillis() / 1000;
213 } catch (Exception ex)
217 if (!interactiveDialog
218 && ((System.currentTimeMillis() / 1000) - startTime) > 5)
223 if (visible && refreshText())
225 // if (interactiveDialog) {
231 if (interactiveDialog)
238 Desktop.instance.startDialogQueue();
244 public void closeSplash()
249 iframe.setClosed(true);
250 } catch (Exception ex)
255 public class SplashImage extends JPanel
259 public SplashImage(Image todisplay)
262 setPreferredSize(new Dimension(image.getWidth(this) + 8,
263 image.getHeight(this)));
267 public Dimension getPreferredSize()
269 return new Dimension(image.getWidth(this) + 8, image.getHeight(this));
273 public void paintComponent(Graphics g)
275 g.setColor(Color.white);
276 g.fillRect(0, 0, getWidth(), getHeight());
277 g.setColor(Color.black);
278 g.setFont(new Font("Verdana", Font.BOLD, fontSize + 6));
282 g.drawImage(image, (getWidth() - image.getWidth(this)) / 2,
283 (getHeight() - image.getHeight(this)) / 2, this);
289 * g.drawString("Jalview " + jalview.bin.Cache.getProperty("VERSION"), 50,
292 * FontMetrics fm = g.getFontMetrics(); int vwidth =
293 * fm.stringWidth("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
294 * g.setFont(new Font("Verdana", Font.BOLD, fontSize + 2)); g.drawString(
295 * "Last updated: " + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"),
296 * 50 + vwidth + 5, y); if (jalview.bin.Cache.getDefault("LATEST_VERSION",
297 * "Checking").equals( "Checking")) { // Displayed when code version and
298 * jnlp version do not match g.drawString("...Checking latest version...",
299 * 50, y += fontSize + 10); y += 5; g.setColor(Color.black); } else if
300 * (!jalview.bin.Cache.getDefault("LATEST_VERSION", "Checking")
301 * .equals(jalview.bin.Cache.getProperty("VERSION"))) { if
302 * (jalview.bin.Cache.getProperty("VERSION").toLowerCase()
303 * .indexOf("automated build") == -1) { // Displayed when code version and
304 * jnlp version do not match and code // version is not a development build
305 * g.setColor(Color.red); } g.drawString( "!! Jalview version " +
306 * jalview.bin.Cache.getDefault("LATEST_VERSION", "..Checking..") +
307 * " is available for download from "
308 * +jalview.bin.Cache.getDefault("www.jalview.org"
309 * ,"http://www.jalview.org")+" !!", 50, y += fontSize + 10); y += 5;
310 * g.setColor(Color.black); }
312 * g.setFont(new Font("Verdana", Font.BOLD, fontSize)); g.drawString(
313 * "Authors: Jim Procter, Andrew Waterhouse, Michele Clamp, James Cuff, Steve Searle,"
314 * , 50, y += fontSize + 4); g.drawString("David Martin & Geoff Barton.",
315 * 60, y += fontSize + 4); g.drawString(
316 * "Development managed by The Barton Group, University of Dundee.", 50, y
317 * += fontSize + 4); g.drawString("If you use Jalview, please cite: ", 50,
318 * y += fontSize + 4); g.drawString(
319 * "Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)"
320 * , 50, y += fontSize + 4); g.drawString(
321 * "Jalview Version 2 - a multiple sequence alignment editor and analysis workbench"
322 * , 50, y += fontSize + 4);
323 * g.drawString("Bioinformatics doi: 10.1093/bioinformatics/btp033", 50, y
324 * += fontSize + 4); }
329 public void hyperlinkUpdate(HyperlinkEvent e)
331 Desktop.hyperlinkUpdate(e);