X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FSplashScreen.java;h=2b87e1063a63484fe224628f2005c800d03cb16a;hb=afffa24481a7d3cb65ae41e0948c16a5f490f302;hp=14e1a0e58078c3cb28efe85333180b02cc27d19a;hpb=c2214808f64b811a25cec10399dcff38db0c592c;p=jalview.git
diff --git a/src/jalview/gui/SplashScreen.java b/src/jalview/gui/SplashScreen.java
index 14e1a0e..2b87e10 100755
--- a/src/jalview/gui/SplashScreen.java
+++ b/src/jalview/gui/SplashScreen.java
@@ -1,6 +1,6 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
@@ -20,10 +20,24 @@
*/
package jalview.gui;
-import java.awt.*;
-import java.awt.event.*;
-
-import javax.swing.*;
+import jalview.util.Platform;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.MediaTracker;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+import javax.swing.JInternalFrame;
+import javax.swing.JLabel;
+import javax.swing.JLayeredPane;
+import javax.swing.JPanel;
+import javax.swing.JTextPane;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
@@ -33,14 +47,17 @@ 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;
JPanel iconimg = new JPanel(new BorderLayout());
- JTextPane authlist = new JTextPane();
+ /**
+ * either text area in javascript or in java text pane
+ */
+ Component authlist;
JInternalFrame iframe;
@@ -70,12 +87,30 @@ public class SplashScreen extends JPanel implements Runnable,
{
this.interactiveDialog = interactive;
// show a splashscreen that will disapper
- Thread t = new Thread(this);
- t.start();
+ if (Platform.isJS()) // BH 2019
+ {
+ authlist = new JLabel("");
+ run();
+ }
+ else
+ {
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
+ {
+ authlist = new JTextPane();
+ Thread t = new Thread(this);
+ t.start();
+ }
+ }
+
}
MouseAdapter closer = new MouseAdapter()
{
+ @Override
public void mousePressed(MouseEvent evt)
{
try
@@ -101,14 +136,14 @@ public class SplashScreen extends JPanel implements Runnable,
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)
+ if (!Platform.isJS() && 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);
@@ -120,7 +155,6 @@ public class SplashScreen extends JPanel implements Runnable,
} catch (InterruptedException x)
{
}
- ;
if (mt.isErrorAny())
{
System.err.println("Error when loading images!");
@@ -138,12 +172,24 @@ public class SplashScreen extends JPanel implements Runnable,
this.setLayout(new BorderLayout());
iframe.setContentPane(this);
iframe.setLayer(JLayeredPane.PALETTE_LAYER);
+ if (Platform.isJS())
+ {
+ // ignore in JavaScript
+ }
+ else
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
+ {
+ ((JTextPane) authlist).setEditable(false);
- SplashImage splashimg = new SplashImage(image);
- iconimg.add(splashimg, BorderLayout.CENTER);
- add(iconimg, BorderLayout.NORTH);
+ 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();
@@ -154,6 +200,7 @@ public class SplashScreen extends JPanel implements Runnable,
/**
* update text in author text panel reflecting current version information
*/
+ @SuppressWarnings("unused")
protected boolean refreshText()
{
String newtext = Desktop.instance.getAboutMessage(true).toString();
@@ -162,22 +209,38 @@ public class SplashScreen extends JPanel implements Runnable,
{
iframe.setVisible(false);
oldtext = newtext.length();
- authlist = new JTextPane();
- authlist.setEditable(false);
+ if (Platform.isJS()) // BH 2019
+ {
+ authlist = new JLabel(
+ "
![](\"swingjs/j2s/images/Jalview_Logo.png\"/)
"
+ + newtext);
+ ((JLabel) authlist).setOpaque(true);
+ ((JLabel) authlist).setBackground(Color.white);
+ }
+ else
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
+ {
+ authlist = new JTextPane();
+ ((JTextPane) authlist).setEditable(false);
+ ((JTextPane) authlist).setContentType("text/html");
+ ((JTextPane) authlist).setText(newtext);
+ ((JTextPane) authlist).addHyperlinkListener(this);
+ }
authlist.addMouseListener(closer);
- authlist.addHyperlinkListener(this);
- authlist.setContentType("text/html");
- authlist.setText(newtext);
+
authlist.setVisible(true);
authlist.setSize(new Dimension(750, 375));
add(authlist, BorderLayout.CENTER);
revalidate();
- iframe.setBounds((int) ((Desktop.instance.getWidth() - 750) / 2),
- (int) ((Desktop.instance.getHeight() - 375) / 2), 750,
+ iframe.setBounds((Desktop.instance.getWidth() - 750) / 2,
+ (Desktop.instance.getHeight() - 375) / 2, 750,
authlist.getHeight() + iconimg.getHeight());
iframe.validate();
iframe.setVisible(true);
-
return true;
}
return false;
@@ -186,6 +249,7 @@ public class SplashScreen extends JPanel implements Runnable,
/**
* Create splash screen, display it and clear it off again.
*/
+ @Override
public void run()
{
initSplashScreenWindow();
@@ -247,8 +311,11 @@ public class SplashScreen extends JPanel implements Runnable,
public SplashImage(Image todisplay)
{
image = todisplay;
- setPreferredSize(new Dimension(image.getWidth(this) + 8,
- image.getHeight(this)));
+ if (image != null)
+ {
+ setPreferredSize(new Dimension(image.getWidth(this) + 8,
+ image.getHeight(this)));
+ }
}
@Override
@@ -257,6 +324,7 @@ public class SplashScreen extends JPanel implements Runnable,
return new Dimension(image.getWidth(this) + 8, image.getHeight(this));
}
+ @Override
public void paintComponent(Graphics g)
{
g.setColor(Color.white);