From 1259861007526f01bc916894e2010966f1a1f8f2 Mon Sep 17 00:00:00 2001 From: kitfox Date: Thu, 19 Mar 2009 03:23:58 +0000 Subject: Work around for running in webstart to handle URLs to the source jar where the path to the jar is hidden. git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@61 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b --- src/main/java/com/kitfox/svg/SVGUniverse.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/kitfox/svg/SVGUniverse.java b/src/main/java/com/kitfox/svg/SVGUniverse.java index 9ca3126..ed6c0ce 100644 --- a/src/main/java/com/kitfox/svg/SVGUniverse.java +++ b/src/main/java/com/kitfox/svg/SVGUniverse.java @@ -33,17 +33,16 @@ import java.awt.image.BufferedImage; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.io.BufferedInputStream; -import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Reader; import java.io.Serializable; import java.lang.ref.SoftReference; +import java.net.MalformedURLException; import java.net.URI; import java.net.URL; import java.net.URLConnection; @@ -296,14 +295,25 @@ public class SVGUniverse implements Serializable public SVGDiagram getDiagram(URI xmlBase, boolean loadIfAbsent) { if (xmlBase == null) return null; - + SVGDiagram dia = (SVGDiagram)loadedDocs.get(xmlBase); if (dia != null || !loadIfAbsent) return dia; //Load missing diagram try { - URL url = xmlBase.toURL(); + URL url; + if ("jar".equals(xmlBase.getScheme()) && !xmlBase.getPath().contains("!/")) + { + //Workaround for resources stored in jars loaded by Webstart. + //http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6753651 + url = SVGUniverse.class.getResource("xmlBase.getPath()"); + } + else + { + url = xmlBase.toURL(); + } + loadSVG(url, false); dia = (SVGDiagram)loadedDocs.get(xmlBase); -- cgit v1.2.3-55-g7522