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 jalview.util.Platform;
25 import java.awt.BorderLayout;
26 import java.awt.Color;
27 import java.awt.Component;
28 import java.awt.Dimension;
30 import java.awt.Graphics;
31 import java.awt.Image;
32 import java.awt.MediaTracker;
33 import java.awt.event.MouseAdapter;
34 import java.awt.event.MouseEvent;
36 import javax.swing.JInternalFrame;
37 import javax.swing.JLabel;
38 import javax.swing.JLayeredPane;
39 import javax.swing.JPanel;
40 import javax.swing.JTextField;
41 import javax.swing.JTextPane;
42 import javax.swing.event.HyperlinkEvent;
43 import javax.swing.event.HyperlinkListener;
51 public class SplashScreen extends JPanel
52 implements Runnable, HyperlinkListener
54 boolean visible = true;
56 JPanel iconimg = new JPanel(new BorderLayout());
59 * either text area in javascript or in java text pane
63 JInternalFrame iframe;
72 * Creates a new SplashScreen object.
79 private boolean interactiveDialog = false;
84 * if true - an internal dialog is opened rather than a free-floating
87 public SplashScreen(boolean interactive)
89 this.interactiveDialog = interactive;
90 // show a splashscreen that will disapper
93 authlist = new JLabel("");
102 authlist = new JTextPane();
103 Thread t = new Thread(this);
110 MouseAdapter closer = new MouseAdapter()
112 public void mousePressed(MouseEvent evt)
116 if (!interactiveDialog)
121 } catch (Exception ex)
128 * ping the jalview version page then create and display the jalview
129 * splashscreen window.
131 void initSplashScreenWindow()
133 addMouseListener(closer);
136 java.net.URL url = getClass().getResource("/images/Jalview_Logo.png");
137 java.net.URL urllogo = getClass()
138 .getResource("/images/Jalview_Logo_small.png");
140 if (!Platform.isJS() || url != null)
142 image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
143 Image logo = java.awt.Toolkit.getDefaultToolkit()
144 .createImage(urllogo);
145 MediaTracker mt = new MediaTracker(this);
146 mt.addImage(image, 0);
147 mt.addImage(logo, 1);
153 } catch (InterruptedException x)
159 System.err.println("Error when loading images!");
161 } while (!mt.checkAll());
162 Desktop.instance.setIconImage(logo);
164 } catch (Exception ex)
168 iframe = new JInternalFrame();
169 iframe.setFrameIcon(null);
170 iframe.setClosable(interactiveDialog);
171 this.setLayout(new BorderLayout());
172 iframe.setContentPane(this);
173 iframe.setLayer(JLayeredPane.PALETTE_LAYER);
175 * we add image directly in html for javascript ?
179 ((JTextPane) authlist).setEditable(false);
181 SplashImage splashimg = new SplashImage(image);
182 iconimg.add(splashimg, BorderLayout.CENTER);
183 add(iconimg, BorderLayout.NORTH);
185 add(authlist, BorderLayout.CENTER);
186 authlist.addMouseListener(closer);
187 Desktop.desktop.add(iframe);
194 * update text in author text panel reflecting current version information
196 @SuppressWarnings("unused")
197 protected boolean refreshText()
199 String newtext = Desktop.instance.getAboutMessage(true).toString();
200 // System.err.println("Text found: \n"+newtext+"\nEnd of newtext.");
201 if (oldtext != newtext.length())
203 iframe.setVisible(false);
204 oldtext = newtext.length();
207 authlist = new JLabel("<html><br/><br/><img src=\"swingjs/j2s/images/Jalview_Logo.png\"/><br/>"+newtext);
208 ((JLabel) authlist).setOpaque(true);
209 ((JLabel) authlist).setBackground(Color.white);
215 authlist = new JTextPane();
216 ((JTextPane) authlist).setEditable(false);
217 ((JTextPane) authlist).setContentType("text/html");
218 ((JTextPane) authlist).setText(newtext);
219 ((JTextPane) authlist).addHyperlinkListener(this);
222 authlist.addMouseListener(closer);
224 authlist.setVisible(true);
225 authlist.setSize(new Dimension(750, 375));
226 add(authlist, BorderLayout.CENTER);
228 iframe.setBounds((Desktop.instance.getWidth() - 750) / 2,
229 (Desktop.instance.getHeight() - 375) / 2, 750,
230 authlist.getHeight() + iconimg.getHeight());
232 iframe.setVisible(true);
239 * Create splash screen, display it and clear it off again.
243 initSplashScreenWindow();
245 long startTime = System.currentTimeMillis() / 1000;
253 } catch (Exception ex)
257 if (!interactiveDialog
258 && ((System.currentTimeMillis() / 1000) - startTime) > 5)
263 if (visible && refreshText())
265 // if (interactiveDialog) {
271 if (interactiveDialog)
278 Desktop.instance.startDialogQueue();
284 public void closeSplash()
289 iframe.setClosed(true);
290 } catch (Exception ex)
295 public class SplashImage extends JPanel
299 public SplashImage(Image todisplay)
303 { setPreferredSize(new Dimension(image.getWidth(this) + 8,
304 image.getHeight(this)));
309 public Dimension getPreferredSize()
311 return new Dimension(image.getWidth(this) + 8, image.getHeight(this));
314 public void paintComponent(Graphics g)
316 g.setColor(Color.white);
317 g.fillRect(0, 0, getWidth(), getHeight());
318 g.setColor(Color.black);
319 g.setFont(new Font("Verdana", Font.BOLD, fontSize + 6));
323 g.drawImage(image, (getWidth() - image.getWidth(this)) / 2,
324 (getHeight() - image.getHeight(this)) / 2, this);
330 * g.drawString("Jalview " + jalview.bin.Cache.getProperty("VERSION"), 50,
333 * FontMetrics fm = g.getFontMetrics(); int vwidth =
334 * fm.stringWidth("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
335 * g.setFont(new Font("Verdana", Font.BOLD, fontSize + 2)); g.drawString(
336 * "Last updated: " + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"),
337 * 50 + vwidth + 5, y); if (jalview.bin.Cache.getDefault("LATEST_VERSION",
338 * "Checking").equals( "Checking")) { // Displayed when code version and
339 * jnlp version do not match g.drawString("...Checking latest version...",
340 * 50, y += fontSize + 10); y += 5; g.setColor(Color.black); } else if
341 * (!jalview.bin.Cache.getDefault("LATEST_VERSION", "Checking")
342 * .equals(jalview.bin.Cache.getProperty("VERSION"))) { if
343 * (jalview.bin.Cache.getProperty("VERSION").toLowerCase()
344 * .indexOf("automated build") == -1) { // Displayed when code version and
345 * jnlp version do not match and code // version is not a development build
346 * g.setColor(Color.red); } g.drawString( "!! Jalview version " +
347 * jalview.bin.Cache.getDefault("LATEST_VERSION", "..Checking..") +
348 * " is available for download from "
349 * +jalview.bin.Cache.getDefault("www.jalview.org"
350 * ,"http://www.jalview.org")+" !!", 50, y += fontSize + 10); y += 5;
351 * g.setColor(Color.black); }
353 * g.setFont(new Font("Verdana", Font.BOLD, fontSize)); g.drawString(
354 * "Authors: Jim Procter, Andrew Waterhouse, Michele Clamp, James Cuff, Steve Searle,"
355 * , 50, y += fontSize + 4); g.drawString("David Martin & Geoff Barton.",
356 * 60, y += fontSize + 4); g.drawString(
357 * "Development managed by The Barton Group, University of Dundee.", 50, y
358 * += fontSize + 4); g.drawString("If you use Jalview, please cite: ", 50,
359 * y += fontSize + 4); g.drawString(
360 * "Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)"
361 * , 50, y += fontSize + 4); g.drawString(
362 * "Jalview Version 2 - a multiple sequence alignment editor and analysis workbench"
363 * , 50, y += fontSize + 4);
364 * g.drawString("Bioinformatics doi: 10.1093/bioinformatics/btp033", 50, y
365 * += fontSize + 4); }
370 public void hyperlinkUpdate(HyperlinkEvent e)
372 Desktop.hyperlinkUpdate(e);