changeset in /hg/icedtea: Add missing file.

Andrew John Hughes ahughes at redhat.com
Thu May 21 04:27:40 PDT 2009


changeset 9d0d19948b10 in /hg/icedtea
details: http://icedtea.classpath.org/hg/icedtea?cmd=changeset;node=9d0d19948b10
description:
	Add missing file.

diffstat:

1 file changed, 93 insertions(+)
overlays/openjdk/jdk/src/share/classes/net/sourceforge/jnlp/JNLPSplashScreen.java |   93 ++++++++++

diffs (97 lines):

diff -r 97367bcc3bc1 -r 9d0d19948b10 overlays/openjdk/jdk/src/share/classes/net/sourceforge/jnlp/JNLPSplashScreen.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/openjdk/jdk/src/share/classes/net/sourceforge/jnlp/JNLPSplashScreen.java	Wed May 20 22:54:07 2009 +0100
@@ -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);
+
+    }
+}



More information about the distro-pkg-dev mailing list