X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSplashScreen.java;h=652aa751bc05465641720aa678a2639c61119bed;hb=b2f9a8d7bce642ff4011bc6d49e02bb0569fbb11;hp=7f55f8b08c94597365cbd3d7f8b0d8119dd06643;hpb=10866cba33b339de23e5a4e3121ab86c08b5ff2a;p=jalview.git diff --git a/src/jalview/gui/SplashScreen.java b/src/jalview/gui/SplashScreen.java index 7f55f8b..652aa75 100755 --- a/src/jalview/gui/SplashScreen.java +++ b/src/jalview/gui/SplashScreen.java @@ -1,19 +1,20 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) - * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1) + * Copyright (C) 2014 The Jalview Authors * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - * + * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.gui; @@ -30,7 +31,8 @@ import javax.swing.event.HyperlinkListener; * @author $author$ * @version $Revision$ */ -public class SplashScreen extends JPanel implements Runnable, HyperlinkListener +public class SplashScreen extends JPanel implements Runnable, + HyperlinkListener { boolean visible = true; @@ -53,20 +55,23 @@ public class SplashScreen extends JPanel implements Runnable, HyperlinkListener { this(false); } - private boolean interactiveDialog=false; + + private boolean interactiveDialog = false; + /** * - * @param interactive if true - an internal dialog is opened rather than a free-floating splash screen + * @param interactive + * if true - an internal dialog is opened rather than a free-floating + * splash screen */ public SplashScreen(boolean interactive) { - this.interactiveDialog=interactive; + this.interactiveDialog = interactive; // show a splashscreen that will disapper Thread t = new Thread(this); t.start(); } - MouseAdapter closer = new MouseAdapter() { public void mousePressed(MouseEvent evt) @@ -94,17 +99,26 @@ public class SplashScreen extends JPanel implements Runnable, HyperlinkListener try { java.net.URL url = getClass().getResource("/images/Jalview_Logo.png"); - java.net.URL urllogo = getClass().getResource("/images/Jalview_Logo_small.png"); + java.net.URL urllogo = getClass().getResource( + "/images/Jalview_Logo_small.png"); if (url != null) { image = java.awt.Toolkit.getDefaultToolkit().createImage(url); - Image logo=java.awt.Toolkit.getDefaultToolkit().createImage(urllogo); + Image logo = java.awt.Toolkit.getDefaultToolkit().createImage( + urllogo); MediaTracker mt = new MediaTracker(this); mt.addImage(image, 0); mt.addImage(logo, 1); - do { try { - mt.waitForAll(); } catch (InterruptedException x) {}; + do + { + try + { + mt.waitForAll(); + } catch (InterruptedException x) + { + } + ; if (mt.isErrorAny()) { System.err.println("Error when loading images!"); @@ -123,13 +137,13 @@ public class SplashScreen extends JPanel implements Runnable, HyperlinkListener iframe.setContentPane(this); iframe.setLayer(JLayeredPane.PALETTE_LAYER); - Desktop.desktop.add(iframe); SplashImage splashimg = new SplashImage(image); iconimg.add(splashimg, BorderLayout.CENTER); add(iconimg, BorderLayout.NORTH); add(authlist, BorderLayout.CENTER); authlist.setEditable(false); authlist.addMouseListener(closer); + Desktop.desktop.add(iframe); refreshText(); } @@ -141,23 +155,24 @@ public class SplashScreen extends JPanel implements Runnable, HyperlinkListener protected boolean refreshText() { String newtext = Desktop.instance.getAboutMessage(true).toString(); - //System.err.println("Text found: \n"+newtext+"\nEnd of newtext."); + // System.err.println("Text found: \n"+newtext+"\nEnd of newtext."); if (oldtext != newtext.length()) { iframe.setVisible(false); oldtext = newtext.length(); - authlist=new JTextPane(); + authlist = new JTextPane(); authlist.setEditable(false); authlist.addMouseListener(closer); authlist.addHyperlinkListener(this); authlist.setContentType("text/html"); authlist.setText(newtext); authlist.setVisible(true); + authlist.setSize(new Dimension(750, 275)); add(authlist, BorderLayout.CENTER); + revalidate(); iframe.setBounds((int) ((Desktop.instance.getWidth() - 750) / 2), - (int) ((Desktop.instance.getHeight() - 160) / 2), 750, - iframe.getPreferredSize().height); - //System.err.println("New preferred size: "+iframe.getPreferredSize().height); + (int) ((Desktop.instance.getHeight() - 140) / 2), 750, + authlist.getHeight() + iconimg.getHeight()); iframe.validate(); iframe.setVisible(true); @@ -184,19 +199,20 @@ public class SplashScreen extends JPanel implements Runnable, HyperlinkListener } catch (Exception ex) { } - - if (!interactiveDialog && ((System.currentTimeMillis() / 1000) - startTime) > 5) + + if (!interactiveDialog + && ((System.currentTimeMillis() / 1000) - startTime) > 5) { visible = false; } if (visible && refreshText()) { -// if (interactiveDialog) { - iframe.repaint(); -// } else { -// iframe.repaint(); -// }; + // if (interactiveDialog) { + iframe.repaint(); + // } else { + // iframe.repaint(); + // }; } if (interactiveDialog) { @@ -233,6 +249,12 @@ public class SplashScreen extends JPanel implements Runnable, HyperlinkListener image.getHeight(this))); } + @Override + public Dimension getPreferredSize() + { + return new Dimension(image.getWidth(this) + 8, image.getHeight(this)); + } + public void paintComponent(Graphics g) { g.setColor(Color.white); @@ -242,8 +264,8 @@ public class SplashScreen extends JPanel implements Runnable, HyperlinkListener if (image != null) { - g.drawImage(image, (getWidth() - image.getWidth(this)) / 2, (getHeight() - image.getHeight(this)) / 2, - this); + g.drawImage(image, (getWidth() - image.getWidth(this)) / 2, + (getHeight() - image.getHeight(this)) / 2, this); } } /* @@ -287,10 +309,11 @@ public class SplashScreen extends JPanel implements Runnable, HyperlinkListener * += fontSize + 4); } */ } + @Override public void hyperlinkUpdate(HyperlinkEvent e) { Desktop.hyperlinkUpdate(e); - + } -} \ No newline at end of file +}