X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fgui%2FSplashScreen.java;h=f5648d28c630e32a7634b5273d0ebb8a53c19088;hb=cb51e62fe2166b236ef488e0a8f35081fcd71388;hp=22b697e9016ecc6c2fc24c3b00c7a44b1a622324;hpb=3d0101179759ef157b088ea135423cd909512d9f;p=jalview.git
diff --git a/src/jalview/gui/SplashScreen.java b/src/jalview/gui/SplashScreen.java
index 22b697e..f5648d2 100755
--- a/src/jalview/gui/SplashScreen.java
+++ b/src/jalview/gui/SplashScreen.java
@@ -20,8 +20,11 @@
*/
package jalview.gui;
+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;
@@ -31,6 +34,7 @@ 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;
@@ -50,7 +54,10 @@ public class SplashScreen extends JPanel
JPanel iconimg = new JPanel(new BorderLayout());
- JTextPane authlist = new JTextPane();
+ /**
+ * either text area in javascript or in java text pane
+ */
+ Component authlist;
JInternalFrame iframe;
@@ -80,12 +87,30 @@ public class SplashScreen extends JPanel
{
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, "SplashScreen");
+ t.start();
+ }
+ }
+
}
MouseAdapter closer = new MouseAdapter()
{
+ @Override
public void mousePressed(MouseEvent evt)
{
try
@@ -114,7 +139,7 @@ public class SplashScreen extends JPanel
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()
@@ -130,13 +155,12 @@ public class SplashScreen extends JPanel
} catch (InterruptedException x)
{
}
- ;
if (mt.isErrorAny())
{
System.err.println("Error when loading images!");
}
} while (!mt.checkAll());
- Desktop.instance.setIconImage(logo);
+ Desktop.getInstance().setIconImage(logo);
}
} catch (Exception ex)
{
@@ -148,14 +172,26 @@ public class SplashScreen extends JPanel
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);
+ Desktop.getDesktopPane().add(iframe);
refreshText();
}
@@ -164,30 +200,48 @@ public class SplashScreen extends JPanel
/**
* update text in author text panel reflecting current version information
*/
+ @SuppressWarnings("unused")
protected boolean refreshText()
{
- String newtext = Desktop.instance.getAboutMessage(true).toString();
+ Desktop desktop = Desktop.getInstance();
+ String newtext = desktop.getAboutMessage(true).toString();
// System.err.println("Text found: \n"+newtext+"\nEnd of newtext.");
if (oldtext != newtext.length())
{
iframe.setVisible(false);
oldtext = newtext.length();
- authlist = new JTextPane();
- authlist.setEditable(false);
+ if (Platform.isJS()) // BH 2019
+ {
+ authlist = new JLabel(
+ "
"
+ + 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((Desktop.instance.getWidth() - 750) / 2,
- (Desktop.instance.getHeight() - 375) / 2, 750,
+ iframe.setBounds((desktop.getWidth() - 750) / 2,
+ (desktop.getHeight() - 375) / 2, 750,
authlist.getHeight() + iconimg.getHeight());
iframe.validate();
iframe.setVisible(true);
-
return true;
}
return false;
@@ -196,6 +250,7 @@ public class SplashScreen extends JPanel
/**
* Create splash screen, display it and clear it off again.
*/
+ @Override
public void run()
{
initSplashScreenWindow();
@@ -233,7 +288,7 @@ public class SplashScreen extends JPanel
}
closeSplash();
- Desktop.instance.startDialogQueue();
+ Desktop.getInstance().startDialogQueue();
}
/**
@@ -257,8 +312,11 @@ public class SplashScreen extends JPanel
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
@@ -267,6 +325,7 @@ public class SplashScreen extends JPanel
return new Dimension(image.getWidth(this) + 8, image.getHeight(this));
}
+ @Override
public void paintComponent(Graphics g)
{
g.setColor(Color.white);