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.Component;
26 import java.awt.Dimension;
28 import java.awt.Graphics;
29 import java.awt.Image;
30 import java.awt.MediaTracker;
31 import java.awt.event.MouseAdapter;
32 import java.awt.event.MouseEvent;
34 import javax.swing.JInternalFrame;
35 import javax.swing.JLabel;
36 import javax.swing.JLayeredPane;
37 import javax.swing.JPanel;
38 import javax.swing.JTextField;
39 import javax.swing.JTextPane;
40 import javax.swing.event.HyperlinkEvent;
41 import javax.swing.event.HyperlinkListener;
49 public class SplashScreen extends JPanel
50 implements Runnable, HyperlinkListener
52 boolean visible = true;
54 JPanel iconimg = new JPanel(new BorderLayout());
57 * either text area in javascript or in java text pane
61 JInternalFrame iframe;
70 * Creates a new SplashScreen object.
77 private boolean interactiveDialog = false;
82 * if true - an internal dialog is opened rather than a free-floating
85 public SplashScreen(boolean interactive)
87 this.interactiveDialog = interactive;
88 // show a splashscreen that will disapper
89 if (/** @j2sNative true || */ false)
91 authlist = new JLabel("");
100 authlist = new JTextPane();
101 Thread t = new Thread(this);
108 MouseAdapter closer = new MouseAdapter()
110 public void mousePressed(MouseEvent evt)
114 if (!interactiveDialog)
119 } catch (Exception ex)
126 * ping the jalview version page then create and display the jalview
127 * splashscreen window.
129 void initSplashScreenWindow()
131 addMouseListener(closer);
134 java.net.URL url = getClass().getResource("/images/Jalview_Logo.png");
135 java.net.URL urllogo = getClass()
136 .getResource("/images/Jalview_Logo_small.png");
138 if (/** @j2sNative false || */ url != null)
140 image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
141 Image logo = java.awt.Toolkit.getDefaultToolkit()
142 .createImage(urllogo);
143 MediaTracker mt = new MediaTracker(this);
144 mt.addImage(image, 0);
145 mt.addImage(logo, 1);
151 } catch (InterruptedException x)
157 System.err.println("Error when loading images!");
159 } while (!mt.checkAll());
160 Desktop.instance.setIconImage(logo);
162 } catch (Exception ex)
166 iframe = new JInternalFrame();
167 iframe.setFrameIcon(null);
168 iframe.setClosable(interactiveDialog);
169 this.setLayout(new BorderLayout());
170 iframe.setContentPane(this);
171 iframe.setLayer(JLayeredPane.PALETTE_LAYER);
173 * we add image directly in html for javascript ?
177 ((JTextPane) authlist).setEditable(false);
179 SplashImage splashimg = new SplashImage(image);
180 iconimg.add(splashimg, BorderLayout.CENTER);
181 add(iconimg, BorderLayout.NORTH);
183 add(authlist, BorderLayout.CENTER);
184 authlist.addMouseListener(closer);
185 Desktop.desktop.add(iframe);
192 * update text in author text panel reflecting current version information
194 @SuppressWarnings("unused")
195 protected boolean refreshText()
197 String newtext = Desktop.instance.getAboutMessage(true).toString();
198 // System.err.println("Text found: \n"+newtext+"\nEnd of newtext.");
199 if (oldtext != newtext.length())
201 iframe.setVisible(false);
202 oldtext = newtext.length();
203 if (/** @j2sNative true || */ false)
205 authlist = new JLabel("<html><br/><br/><img src=\"swingjs/j2s/images/Jalview_Logo.png\"/><br/>"+newtext);
206 ((JLabel) authlist).setOpaque(true);
207 ((JLabel) authlist).setBackground(Color.white);
213 authlist = new JTextPane();
214 ((JTextPane) authlist).setEditable(false);
215 ((JTextPane) authlist).setContentType("text/html");
216 ((JTextPane) authlist).setText(newtext);
217 ((JTextPane) authlist).addHyperlinkListener(this);
220 authlist.addMouseListener(closer);
222 authlist.setVisible(true);
223 authlist.setSize(new Dimension(750, 375));
224 add(authlist, BorderLayout.CENTER);
226 iframe.setBounds((Desktop.instance.getWidth() - 750) / 2,
227 (Desktop.instance.getHeight() - 375) / 2, 750,
228 authlist.getHeight() + iconimg.getHeight());
230 iframe.setVisible(true);
237 * Create splash screen, display it and clear it off again.
241 initSplashScreenWindow();
243 long startTime = System.currentTimeMillis() / 1000;
251 } catch (Exception ex)
255 if (!interactiveDialog
256 && ((System.currentTimeMillis() / 1000) - startTime) > 5)
261 if (visible && refreshText())
263 // if (interactiveDialog) {
269 if (interactiveDialog)
276 Desktop.instance.startDialogQueue();
282 public void closeSplash()
287 iframe.setClosed(true);
288 } catch (Exception ex)
293 public class SplashImage extends JPanel
297 public SplashImage(Image todisplay)
301 { setPreferredSize(new Dimension(image.getWidth(this) + 8,
302 image.getHeight(this)));
307 public Dimension getPreferredSize()
309 return new Dimension(image.getWidth(this) + 8, image.getHeight(this));
312 public void paintComponent(Graphics g)
314 g.setColor(Color.white);
315 g.fillRect(0, 0, getWidth(), getHeight());
316 g.setColor(Color.black);
317 g.setFont(new Font("Verdana", Font.BOLD, fontSize + 6));
321 g.drawImage(image, (getWidth() - image.getWidth(this)) / 2,
322 (getHeight() - image.getHeight(this)) / 2, this);
328 * g.drawString("Jalview " + jalview.bin.Cache.getProperty("VERSION"), 50,
331 * FontMetrics fm = g.getFontMetrics(); int vwidth =
332 * fm.stringWidth("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
333 * g.setFont(new Font("Verdana", Font.BOLD, fontSize + 2)); g.drawString(
334 * "Last updated: " + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"),
335 * 50 + vwidth + 5, y); if (jalview.bin.Cache.getDefault("LATEST_VERSION",
336 * "Checking").equals( "Checking")) { // Displayed when code version and
337 * jnlp version do not match g.drawString("...Checking latest version...",
338 * 50, y += fontSize + 10); y += 5; g.setColor(Color.black); } else if
339 * (!jalview.bin.Cache.getDefault("LATEST_VERSION", "Checking")
340 * .equals(jalview.bin.Cache.getProperty("VERSION"))) { if
341 * (jalview.bin.Cache.getProperty("VERSION").toLowerCase()
342 * .indexOf("automated build") == -1) { // Displayed when code version and
343 * jnlp version do not match and code // version is not a development build
344 * g.setColor(Color.red); } g.drawString( "!! Jalview version " +
345 * jalview.bin.Cache.getDefault("LATEST_VERSION", "..Checking..") +
346 * " is available for download from "
347 * +jalview.bin.Cache.getDefault("www.jalview.org"
348 * ,"http://www.jalview.org")+" !!", 50, y += fontSize + 10); y += 5;
349 * g.setColor(Color.black); }
351 * g.setFont(new Font("Verdana", Font.BOLD, fontSize)); g.drawString(
352 * "Authors: Jim Procter, Andrew Waterhouse, Michele Clamp, James Cuff, Steve Searle,"
353 * , 50, y += fontSize + 4); g.drawString("David Martin & Geoff Barton.",
354 * 60, y += fontSize + 4); g.drawString(
355 * "Development managed by The Barton Group, University of Dundee.", 50, y
356 * += fontSize + 4); g.drawString("If you use Jalview, please cite: ", 50,
357 * y += fontSize + 4); g.drawString(
358 * "Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)"
359 * , 50, y += fontSize + 4); g.drawString(
360 * "Jalview Version 2 - a multiple sequence alignment editor and analysis workbench"
361 * , 50, y += fontSize + 4);
362 * g.drawString("Bioinformatics doi: 10.1093/bioinformatics/btp033", 50, y
363 * += fontSize + 4); }
368 public void hyperlinkUpdate(HyperlinkEvent e)
370 Desktop.hyperlinkUpdate(e);