X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FSplashScreen.java;h=465bc0d3d98947e94d307c1a4e4fabe9a4beefbe;hb=5640ec0623c6d1205e62f9fe15292f32bfdab7d9;hp=f4b275dbc5e52d76f39427be2b3aa1a86f290cf5;hpb=5757f3c3ee60e52a2446ab111f35452cf4435ab2;p=jalview.git
diff --git a/src/jalview/gui/SplashScreen.java b/src/jalview/gui/SplashScreen.java
index f4b275d..465bc0d 100755
--- a/src/jalview/gui/SplashScreen.java
+++ b/src/jalview/gui/SplashScreen.java
@@ -20,8 +20,6 @@
*/
package jalview.gui;
-import jalview.util.Platform;
-
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
@@ -30,19 +28,21 @@ import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.MediaTracker;
-import java.awt.Toolkit;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
-import java.net.URL;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import javax.swing.JTextPane;
+import javax.swing.SwingUtilities;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
+import jalview.util.ChannelProperties;
+import jalview.util.Platform;
+
/**
* DOCUMENT ME!
*
@@ -60,6 +60,14 @@ public class SplashScreen extends JPanel
private JPanel iconimg = new JPanel(new BorderLayout());
+ // could change fg, bg, font later to use ChannelProperties (these are not
+ // actually being used!)
+ private static Color bg = Color.WHITE;
+
+ private static Color fg = Color.BLACK;
+
+ private static Font font = new Font("SansSerif", Font.PLAIN, FONT_SIZE);
+
/*
* as JTextPane in Java, JLabel in javascript
*/
@@ -73,6 +81,8 @@ public class SplashScreen extends JPanel
private long oldTextLength = -1;
+ public static int logoSize = 32;
+
/*
* allow click in the initial splash screen to dismiss it
* immediately (not if opened from About menu)
@@ -105,6 +115,10 @@ public class SplashScreen extends JPanel
public SplashScreen(boolean isTransient)
{
this.transientDialog = isTransient;
+ if (this.transientDialog)
+ {
+ Desktop.instance.acquireDialogQueue();
+ }
if (Platform.isJS()) // BH 2019
{
@@ -120,6 +134,9 @@ public class SplashScreen extends JPanel
*/
{
splashText = new JTextPane();
+ splashText.setBackground(bg);
+ splashText.setForeground(fg);
+ splashText.setFont(font);
Thread t = new Thread(this);
t.start();
}
@@ -136,17 +153,19 @@ public class SplashScreen extends JPanel
try
{
- URL url = getClass().getResource("/images/Jalview_Logo.png");
- URL urllogo = getClass()
- .getResource("/images/Jalview_Logo_small.png");
-
- if (!Platform.isJS() && url != null)
+ if (!Platform.isJS())
{
- image = Toolkit.getDefaultToolkit().createImage(url);
- Image logo = Toolkit.getDefaultToolkit().createImage(urllogo);
+ image = ChannelProperties.getImage("banner");
+ Image logo = ChannelProperties.getImage("logo.48");
MediaTracker mt = new MediaTracker(this);
- mt.addImage(image, 0);
- mt.addImage(logo, 1);
+ if (image != null)
+ {
+ mt.addImage(image, 0);
+ }
+ if (logo != null)
+ {
+ mt.addImage(logo, 1);
+ }
do
{
try
@@ -157,21 +176,29 @@ public class SplashScreen extends JPanel
}
if (mt.isErrorAny())
{
- System.err.println("Error when loading images!");
+ jalview.bin.Console.errPrintln("Error when loading images!");
}
} while (!mt.checkAll());
- Desktop.instance.setIconImage(logo);
+ Desktop.instance.setIconImages(ChannelProperties.getIconList());
}
} catch (Exception ex)
{
}
+ this.setBackground(bg);
+ this.setForeground(fg);
+ this.setFont(font);
+
iframe = new JInternalFrame();
iframe.setFrameIcon(null);
iframe.setClosable(true);
this.setLayout(new BorderLayout());
iframe.setContentPane(this);
iframe.setLayer(JLayeredPane.PALETTE_LAYER);
+ iframe.setBackground(bg);
+ iframe.setForeground(fg);
+ iframe.setFont(font);
+
if (Platform.isJS())
{
// ignore in JavaScript
@@ -184,9 +211,13 @@ public class SplashScreen extends JPanel
*/
{
((JTextPane) splashText).setEditable(false);
+ splashText.setBackground(bg);
+ splashText.setForeground(fg);
+ splashText.setFont(font);
SplashImage splashimg = new SplashImage(image);
- iconimg.add(splashimg, BorderLayout.CENTER);
+ iconimg.add(splashimg, BorderLayout.LINE_START);
+ iconimg.setBackground(bg);
add(iconimg, BorderLayout.NORTH);
}
add(splashText, BorderLayout.CENTER);
@@ -201,7 +232,8 @@ public class SplashScreen extends JPanel
protected boolean refreshText()
{
String newtext = Desktop.instance.getAboutMessage();
- // System.err.println("Text found: \n"+newtext+"\nEnd of newtext.");
+ // jalview.bin.Console.errPrintln("Text found: \n"+newtext+"\nEnd of
+ // newtext.");
if (oldTextLength != newtext.length())
{
iframe.setVisible(false);
@@ -212,8 +244,9 @@ public class SplashScreen extends JPanel
* SwingJS doesn't have HTMLEditorKit, required for a JTextPane
* to display formatted html, so we use a simple alternative
*/
- String text = "
![](\"swingjs/j2s/images/Jalview_Logo.png\"/)
"
- + newtext + "";
+ String text = "
" + newtext
+ + "
";
JLabel ta = new JLabel(text);
ta.setOpaque(true);
ta.setBackground(Color.white);
@@ -228,6 +261,9 @@ public class SplashScreen extends JPanel
{
JTextPane jtp = new JTextPane();
jtp.setEditable(false);
+ jtp.setBackground(bg);
+ jtp.setForeground(fg);
+ jtp.setFont(font);
jtp.setContentType("text/html");
jtp.setText("" + newtext + "");
jtp.addHyperlinkListener(this);
@@ -236,12 +272,19 @@ public class SplashScreen extends JPanel
splashText.addMouseListener(closer);
splashText.setVisible(true);
- splashText.setSize(new Dimension(750, 375));
+ splashText.setSize(new Dimension(750,
+ 425 + logoSize + (Platform.isJS() ? 40 : 0)));
+ splashText.setBackground(bg);
+ splashText.setForeground(fg);
+ splashText.setFont(font);
add(splashText, BorderLayout.CENTER);
revalidate();
- iframe.setBounds((Desktop.instance.getWidth() - 750) / 2,
- (Desktop.instance.getHeight() - 375) / 2, 750,
- splashText.getHeight() + iconimg.getHeight());
+ int width = Math.max(splashText.getWidth(), iconimg.getWidth());
+ int height = splashText.getHeight() + iconimg.getHeight();
+ iframe.setBounds(
+ Math.max(0, (Desktop.instance.getWidth() - width) / 2),
+ Math.max(0, (Desktop.instance.getHeight() - height) / 2),
+ width, height);
iframe.validate();
iframe.setVisible(true);
return true;
@@ -269,8 +312,8 @@ public class SplashScreen extends JPanel
{
}
- if (transientDialog
- && ((System.currentTimeMillis() / 1000) - startTime) > SHOW_FOR_SECS)
+ if (transientDialog && ((System.currentTimeMillis() / 1000)
+ - startTime) > SHOW_FOR_SECS)
{
visible = false;
}
@@ -286,7 +329,6 @@ public class SplashScreen extends JPanel
}
closeSplash();
- Desktop.instance.startDialogQueue();
}
/**
@@ -294,10 +336,26 @@ public class SplashScreen extends JPanel
*/
public void closeSplash()
{
+ if (this.transientDialog)
+ {
+ Desktop.instance.releaseDialogQueue();
+ }
try
{
-
- iframe.setClosed(true);
+ final JInternalFrame frme = iframe;
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ frme.setClosed(true);
+ } catch (Exception ex)
+ {
+ }
+ }
+ });
} catch (Exception ex)
{
}
@@ -326,10 +384,10 @@ public class SplashScreen extends JPanel
@Override
public void paintComponent(Graphics g)
{
- g.setColor(Color.white);
+ g.setColor(bg);
g.fillRect(0, 0, getWidth(), getHeight());
- g.setColor(Color.black);
- g.setFont(new Font("Verdana", Font.BOLD, FONT_SIZE + 6));
+ g.setColor(fg);
+ g.setFont(new Font(font.getFontName(), Font.BOLD, FONT_SIZE + 6));
if (image != null)
{