Mercurial > hg > release > icedtea6-1.5
changeset 1525:50c172a7a7f4
2009-05-13 Omair Majid <omajid@redhat.com>
* rt/net/sourceforge/jnlp/JNLPSplashScreen.java: New file. This new class
is responsible for displaying the splash screen.
* rt/net/sourceforge/jnlp/Launcher.java (launchApplication): Show a splash
screen if specified in the JNLP file while loading the remote jars.
* rt/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java (getListener):
Reposition the frame at the bottom right corner of the screen.
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Wed, 13 May 2009 15:36:33 -0400 |
parents | d634a26fa3ce |
children | 30d0a78a8748 |
files | ChangeLog rt/net/sourceforge/jnlp/JNLPSplashScreen.java rt/net/sourceforge/jnlp/Launcher.java rt/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java |
diffstat | 4 files changed, 131 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed May 13 15:31:29 2009 -0400 +++ b/ChangeLog Wed May 13 15:36:33 2009 -0400 @@ -1,3 +1,12 @@ +2009-05-13 Omair Majid <omajid@redhat.com> + + * rt/net/sourceforge/jnlp/JNLPSplashScreen.java: New file. This new class + is responsible for displaying the splash screen. + * rt/net/sourceforge/jnlp/Launcher.java (launchApplication): Show a splash + screen if specified in the JNLP file while loading the remote jars. + * rt/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java (getListener): + Reposition the frame at the bottom right corner of the screen. + 2009-05-13 Lillian Angel <langel@redhat.com> * patches/icedtea-liveconnect.patch: Re-added.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rt/net/sourceforge/jnlp/JNLPSplashScreen.java Wed May 13 15:36:33 2009 -0400 @@ -0,0 +1,93 @@ +package net.sourceforge.jnlp; + +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Insets; +import java.awt.Toolkit; +import java.io.IOException; +import java.net.URL; + +import javax.imageio.ImageIO; +import javax.swing.JFrame; + +import net.sourceforge.jnlp.cache.ResourceTracker; +import net.sourceforge.jnlp.runtime.JNLPRuntime; + +public class JNLPSplashScreen extends JFrame { + + String applicationTitle; + String applicationVendor; + + ResourceTracker resourceTracker; + + URL splashImageUrl; + Image splashImage; + + public JNLPSplashScreen(ResourceTracker resourceTracker, + String applicationTitle, String applicationVendor) { + + // If the JNLP file does not contain any icon images, the splash image + // will consist of the application's title and vendor, as taken from the + // JNLP file. + + this.resourceTracker = resourceTracker; + this.applicationTitle = applicationTitle; + this.applicationVendor = applicationVendor; + + } + + public void setSplashImageURL(URL url) { + splashImageUrl = url; + splashImage = null; + try { + splashImage = ImageIO.read(resourceTracker + .getCacheFile(splashImageUrl)); + } catch (IOException e) { + if (JNLPRuntime.isDebug()) { + System.err.println("Error loading splash image: " + url); + } + splashImage = null; + return; + } catch (IllegalArgumentException argumentException) { + if (JNLPRuntime.isDebug()) { + System.err.println("Error loading splash image: " + url); + } + splashImage = null; + return; + } + + correctSize(); + } + + public boolean isSplashScreenValid() { + return (splashImage != null); + } + + private void correctSize() { + + Insets insets = getInsets(); + int minimumWidth = splashImage.getWidth(null) + insets.left + + insets.right; + int minimumHeight = splashImage.getHeight(null) + insets.top + + insets.bottom; + setMinimumSize(new Dimension(minimumWidth, minimumHeight)); + + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + setLocation((screenSize.width - minimumWidth) / 2, + (screenSize.height - minimumHeight) / 2); + } + + @Override + public void paint(Graphics g) { + if (splashImage == null) { + return; + } + + correctSize(); + Graphics2D g2 = (Graphics2D) g; + g2.drawImage(splashImage, getInsets().left, getInsets().top, null); + + } +}
--- a/rt/net/sourceforge/jnlp/Launcher.java Wed May 13 15:31:29 2009 -0400 +++ b/rt/net/sourceforge/jnlp/Launcher.java Wed May 13 15:36:33 2009 -0400 @@ -331,6 +331,22 @@ throw launchError(new LaunchException(file, null, R("LSFatal"), R("LCClient"), R("LNotApplication"), R("LNotApplicationInfo"))); try { + final int preferredWidth = 500; + final int preferredHeight = 400; + JNLPSplashScreen splashScreen = null; + URL splashImageURL = file.getInformation().getIconLocation( + IconDesc.SPLASH, preferredWidth, preferredHeight); + if (splashImageURL != null) { + ResourceTracker resourceTracker = new ResourceTracker(true); + resourceTracker.addResource(splashImageURL, "SPLASH", file.getFileVersion(), updatePolicy); + splashScreen = new JNLPSplashScreen(resourceTracker, null, null); + splashScreen.setSplashImageURL(splashImageURL); + if (splashScreen.isSplashScreenValid()) { + splashScreen.setVisible(true); + } + } + + ApplicationInstance app = createApplication(file); app.initialize(); @@ -361,6 +377,13 @@ // required to make some apps work right Thread.currentThread().setContextClassLoader(app.getClassLoader()); + if (splashScreen != null) { + if (splashScreen.isSplashScreenValid()) { + splashScreen.setVisible(false); + } + splashScreen.dispose(); + } + main.invoke(null, new Object[] { args } ); return app;
--- a/rt/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java Wed May 13 15:31:29 2009 -0400 +++ b/rt/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java Wed May 13 15:36:33 2009 -0400 @@ -110,9 +110,12 @@ frame.pack(); if (!frame.isVisible()) { - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - frame.setLocation(screen.width/2-frame.getWidth()/2, - screen.height/2-frame.getHeight()/2); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(frame.getGraphicsConfiguration()); + Dimension screen = new Dimension(screenSize.width - insets.left , + screenSize.height - insets.top); + frame.setLocation(screen.width-frame.getWidth(), + screen.height-frame.getHeight()); } frame.show();