summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkitfox2013-03-09 16:51:42 +0100
committerkitfox2013-03-09 16:51:42 +0100
commit19628a60a133ecb1421ae2b0ac09ec9791239c8f (patch)
tree4855ea9964dae7a06cd08959dc3b8fbb88b5d37e
parentClip paths now only applied in tag where it is requested. (diff)
downloadsvg-salamander-core-19628a60a133ecb1421ae2b0ac09ec9791239c8f.tar.gz
svg-salamander-core-19628a60a133ecb1421ae2b0ac09ec9791239c8f.tar.xz
svg-salamander-core-19628a60a133ecb1421ae2b0ac09ec9791239c8f.zip
Error handling now sends warnings to Logger.
git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@149 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b
-rw-r--r--src/main/java/com/kitfox/svg/Gradient.java11
-rw-r--r--src/main/java/com/kitfox/svg/ImageSVG.java13
-rw-r--r--src/main/java/com/kitfox/svg/PatternSVG.java69
-rw-r--r--src/main/java/com/kitfox/svg/SVGDiagram.java5
-rw-r--r--src/main/java/com/kitfox/svg/SVGDisplayPanel.java5
-rw-r--r--src/main/java/com/kitfox/svg/SVGLoader.java8
-rw-r--r--src/main/java/com/kitfox/svg/SVGLoaderHelper.java13
-rw-r--r--src/main/java/com/kitfox/svg/SVGUniverse.java128
-rw-r--r--src/main/java/com/kitfox/svg/Use.java35
-rw-r--r--src/main/java/com/kitfox/svg/animation/AnimTimeParser.jjt41
-rw-r--r--src/main/java/com/kitfox/svg/animation/AnimateBase.java13
-rw-r--r--src/main/java/com/kitfox/svg/animation/AnimationElement.java12
-rw-r--r--src/main/java/com/kitfox/svg/app/SVGPlayer.java14
-rw-r--r--src/main/java/com/kitfox/svg/app/SVGViewer.java29
-rw-r--r--src/main/java/com/kitfox/svg/app/VersionDialog.java5
-rw-r--r--src/main/java/com/kitfox/svg/app/data/Handler.java12
-rw-r--r--src/main/java/com/kitfox/svg/batik/LinearGradientPaint.java9
-rw-r--r--src/main/java/com/kitfox/svg/composite/AdobeComposite.java7
-rw-r--r--src/main/java/com/kitfox/svg/pattern/PatternPaintContext.java8
-rw-r--r--src/main/java/com/kitfox/svg/xml/StyleAttribute.java11
-rw-r--r--src/main/java/com/kitfox/svg/xml/XMLParseUtil.java82
-rw-r--r--src/main/java/com/kitfox/svg/xml/cpx/CPXInputStream.java13
-rw-r--r--src/main/java/com/kitfox/svg/xml/cpx/CPXTest.java11
23 files changed, 270 insertions, 284 deletions
diff --git a/src/main/java/com/kitfox/svg/Gradient.java b/src/main/java/com/kitfox/svg/Gradient.java
index 46ea986..5cd17e9 100644
--- a/src/main/java/com/kitfox/svg/Gradient.java
+++ b/src/main/java/com/kitfox/svg/Gradient.java
@@ -42,6 +42,10 @@ import java.awt.geom.*;
import java.awt.*;
import com.kitfox.svg.xml.*;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
* @author Mark McKay
@@ -275,10 +279,11 @@ abstract public class Gradient extends FillElement
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not parse xlink:href", e);
}
}
-
+
//Check stops, if any
for (Iterator it = stops.iterator(); it.hasNext();)
{
@@ -293,5 +298,5 @@ abstract public class Gradient extends FillElement
return stateChange;
}
-
+
}
diff --git a/src/main/java/com/kitfox/svg/ImageSVG.java b/src/main/java/com/kitfox/svg/ImageSVG.java
index d78aad7..5ac93d3 100644
--- a/src/main/java/com/kitfox/svg/ImageSVG.java
+++ b/src/main/java/com/kitfox/svg/ImageSVG.java
@@ -44,6 +44,8 @@ import java.awt.geom.*;
import java.awt.image.*;
import java.net.*;
import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
* Implements an image.
@@ -98,7 +100,9 @@ public class ImageSVG extends RenderableElement
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not parse xlink:href", e);
+// e.printStackTrace();
imageSrc = null;
}
}
@@ -281,11 +285,14 @@ public class ImageSVG extends RenderableElement
}
catch (IllegalArgumentException ie)
{
- new Exception("Image provided with illegal value for href: \"" + sty.getStringValue() + '"', ie).printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Image provided with illegal value for href: \""
+ + sty.getStringValue() + '"', ie);
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not parse xlink:href", e);
}
diff --git a/src/main/java/com/kitfox/svg/PatternSVG.java b/src/main/java/com/kitfox/svg/PatternSVG.java
index 7d75a98..c413f5b 100644
--- a/src/main/java/com/kitfox/svg/PatternSVG.java
+++ b/src/main/java/com/kitfox/svg/PatternSVG.java
@@ -48,6 +48,8 @@ import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.net.URI;
import java.util.Iterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
@@ -74,71 +76,7 @@ public class PatternSVG extends FillElement {
/** Creates a new instance of Gradient */
public PatternSVG() {
}
-/*
- public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
- {
- //Load style string
- super.loaderStartElement(helper, attrs, parent);
-
- String href = attrs.getValue("xlink:href");
- //If we have a link to another pattern, initialize ourselves with it's values
- if (href != null)
- {
-//System.err.println("Gradient.loaderStartElement() href '" + href + "'");
- try {
- URI src = getXMLBase().resolve(href);
-// URL url = srcUrl.toURL();
-// URL url = new URL(helper.docRoot, href);
- PatternSVG patSrc = (PatternSVG)helper.universe.getElement(src);
- gradientUnits = patSrc.gradientUnits;
- x = patSrc.x;
- y = patSrc.y;
- width = patSrc.width;
- height = patSrc.height;
- viewBox = patSrc.viewBox;
- patternXform.setTransform(patSrc.patternXform);
- members.addAll(patSrc.members);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
-
- String gradientUnits = attrs.getValue("gradientUnits");
-
- if (gradientUnits != null)
- {
- if (gradientUnits.toLowerCase().equals("userspaceonuse")) this.gradientUnits = GU_USER_SPACE_ON_USE;
- else this.gradientUnits = GU_OBJECT_BOUNDING_BOX;
- }
-
- String patternTransform = attrs.getValue("patternTransform");
- if (patternTransform != null)
- {
- patternXform = parseTransform(patternTransform);
- }
-
- String x = attrs.getValue("x");
- String y = attrs.getValue("y");
- String width = attrs.getValue("width");
- String height = attrs.getValue("height");
-
- if (x != null) this.x = XMLParseUtil.parseFloat(x);
- if (y != null) this.y = XMLParseUtil.parseFloat(y);
- if (width != null) this.width = XMLParseUtil.parseFloat(width);
- if (height != null) this.height = XMLParseUtil.parseFloat(height);
-
- String viewBoxStrn = attrs.getValue("viewBox");
- if (viewBoxStrn != null)
- {
- float[] dim = XMLParseUtil.parseFloatList(viewBoxStrn);
- viewBox = new Rectangle2D.Float(dim[0], dim[1], dim[2], dim[3]);
- }
- }
- */
/**
* Called after the start element but before the end element to indicate
* each child tag that has been processed
@@ -179,7 +117,8 @@ public class PatternSVG extends FillElement {
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not parse xlink:href", e);
}
}
diff --git a/src/main/java/com/kitfox/svg/SVGDiagram.java b/src/main/java/com/kitfox/svg/SVGDiagram.java
index 70171d8..a6942b7 100644
--- a/src/main/java/com/kitfox/svg/SVGDiagram.java
+++ b/src/main/java/com/kitfox/svg/SVGDiagram.java
@@ -46,6 +46,8 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
@@ -248,7 +250,8 @@ public class SVGDiagram implements Serializable
root.build();
} catch (SVGException ex)
{
- ex.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not build document", ex);
}
}
}
diff --git a/src/main/java/com/kitfox/svg/SVGDisplayPanel.java b/src/main/java/com/kitfox/svg/SVGDisplayPanel.java
index 92dee63..94d625d 100644
--- a/src/main/java/com/kitfox/svg/SVGDisplayPanel.java
+++ b/src/main/java/com/kitfox/svg/SVGDisplayPanel.java
@@ -39,6 +39,8 @@ package com.kitfox.svg;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
* @author Mark McKay
@@ -132,7 +134,8 @@ public class SVGDisplayPanel extends javax.swing.JPanel implements Scrollable
}
catch (SVGException e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not render diagram", e);
}
}
}
diff --git a/src/main/java/com/kitfox/svg/SVGLoader.java b/src/main/java/com/kitfox/svg/SVGLoader.java
index 66fcae7..93253eb 100644
--- a/src/main/java/com/kitfox/svg/SVGLoader.java
+++ b/src/main/java/com/kitfox/svg/SVGLoader.java
@@ -43,6 +43,8 @@ import org.xml.sax.*;
import org.xml.sax.helpers.DefaultHandler;
import com.kitfox.svg.animation.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
* @author Mark McKay
@@ -201,7 +203,8 @@ public class SVGLoader extends DefaultHandler
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not load", e);
throw new SAXException(e);
}
@@ -255,7 +258,8 @@ public class SVGLoader extends DefaultHandler
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not parse", e);
throw new SAXException(e);
}
}
diff --git a/src/main/java/com/kitfox/svg/SVGLoaderHelper.java b/src/main/java/com/kitfox/svg/SVGLoaderHelper.java
index 1634937..52dbc9e 100644
--- a/src/main/java/com/kitfox/svg/SVGLoaderHelper.java
+++ b/src/main/java/com/kitfox/svg/SVGLoaderHelper.java
@@ -67,20 +67,7 @@ public class SVGLoaderHelper
/** Creates a new instance of SVGLoaderHelper */
public SVGLoaderHelper(URI xmlBase, SVGUniverse universe, SVGDiagram diagram)
{
- /*
- URI docURI = null;
- try
- {
- docURI = new URI(docRoot.toString());
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- */
-
this.xmlBase = xmlBase;
-// this.docRoot = docURI;
this.universe = universe;
this.diagram = diagram;
}
diff --git a/src/main/java/com/kitfox/svg/SVGUniverse.java b/src/main/java/com/kitfox/svg/SVGUniverse.java
index df0b75c..398d85a 100644
--- a/src/main/java/com/kitfox/svg/SVGUniverse.java
+++ b/src/main/java/com/kitfox/svg/SVGUniverse.java
@@ -59,6 +59,8 @@ import java.net.URLConnection;
import java.net.URLStreamHandler;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import java.util.zip.GZIPInputStream;
import javax.imageio.ImageIO;
import org.xml.sax.EntityResolver;
@@ -218,7 +220,8 @@ public class SVGUniverse implements Serializable
return url;
} catch (IOException ex) {
- ex.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not decode inline image", ex);
}
}
return null;
@@ -230,7 +233,8 @@ public class SVGUniverse implements Serializable
registerImage(url);
return url;
} catch (MalformedURLException ex) {
- ex.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Bad url", ex);
}
return null;
}
@@ -264,8 +268,8 @@ public class SVGUniverse implements Serializable
}
catch (Exception e)
{
- System.err.println("Could not load image: " + imageURL);
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not load image: " + imageURL, e);
}
}
@@ -283,7 +287,10 @@ public class SVGUniverse implements Serializable
img = ImageIO.read(imageURL);
}
catch (Exception e)
- { e.printStackTrace(); }
+ {
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not load image", e);
+ }
ref = new SoftReference(img);
loadedImages.put(imageURL, ref);
}
@@ -309,7 +316,8 @@ public class SVGUniverse implements Serializable
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not parse url " + path, e);
}
return null;
}
@@ -344,7 +352,8 @@ public class SVGUniverse implements Serializable
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not parse path " + path, e);
return null;
}
}
@@ -387,7 +396,8 @@ public class SVGUniverse implements Serializable
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not parse", e);
}
return null;
@@ -450,11 +460,13 @@ public class SVGUniverse implements Serializable
}
catch (URISyntaxException ex)
{
- ex.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not parse", ex);
}
- catch (IOException ex)
+ catch (IOException e)
{
- ex.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not parse", e);
}
return null;
@@ -536,7 +548,8 @@ public class SVGUniverse implements Serializable
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not parse", e);
return null;
}
}
@@ -550,7 +563,6 @@ public class SVGUniverse implements Serializable
return cachedReader;
}
-// protected URI loadSVG(URI xmlBase, InputStream is)
protected URI loadSVG(URI xmlBase, InputSource is)
{
// Use an instance of ourselves as the SAX event handler
@@ -559,14 +571,8 @@ public class SVGUniverse implements Serializable
//Place this docment in the universe before it is completely loaded
// so that the load process can refer to references within it's current
// document
-//System.err.println("SVGUniverse: loading dia " + xmlBase);
loadedDocs.put(xmlBase, handler.getLoadedDiagram());
- // Use the default (non-validating) parser
-// SAXParserFactory factory = SAXParserFactory.newInstance();
-// factory.setValidating(false);
-// factory.setNamespaceAware(true);
-
try
{
// Parse the input
@@ -584,8 +590,6 @@ public class SVGUniverse implements Serializable
reader.setContentHandler(handler);
reader.parse(is);
-// SAXParser saxParser = factory.newSAXParser();
-// saxParser.parse(new InputSource(new BufferedReader(is)), handler);
handler.getLoadedDiagram().updateTime(curTime);
return xmlBase;
}
@@ -597,52 +601,54 @@ public class SVGUniverse implements Serializable
loadedDocs.remove(xmlBase);
return null;
}
- catch (Throwable t)
+ catch (Throwable e)
{
- t.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not load SVG " + xmlBase, e);
}
return null;
}
- public static void main(String argv[])
- {
- try
- {
- URL url = new URL("svgSalamander", "localhost", -1, "abc.svg",
- new URLStreamHandler()
- {
- protected URLConnection openConnection(URL u)
- {
- return null;
- }
- }
- );
-// URL url2 = new URL("svgSalamander", "localhost", -1, "abc.svg");
-
- //Investigate URI resolution
- URI uriA, uriB, uriC, uriD, uriE;
-
- uriA = new URI("svgSalamander", "/names/mySpecialName", null);
-// uriA = new URI("http://www.kitfox.com/salamander");
-// uriA = new URI("svgSalamander://mySpecialName/grape");
- System.err.println(uriA.toString());
- System.err.println(uriA.getScheme());
-
- uriB = uriA.resolve("#begin");
- System.err.println(uriB.toString());
-
- uriC = uriA.resolve("tree#boing");
- System.err.println(uriC.toString());
-
- uriC = uriA.resolve("../tree#boing");
- System.err.println(uriC.toString());
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
+// public static void main(String argv[])
+// {
+// try
+// {
+// URL url = new URL("svgSalamander", "localhost", -1, "abc.svg",
+// new URLStreamHandler()
+// {
+// protected URLConnection openConnection(URL u)
+// {
+// return null;
+// }
+// }
+// );
+//// URL url2 = new URL("svgSalamander", "localhost", -1, "abc.svg");
+//
+// //Investigate URI resolution
+// URI uriA, uriB, uriC, uriD, uriE;
+//
+// uriA = new URI("svgSalamander", "/names/mySpecialName", null);
+//// uriA = new URI("http://www.kitfox.com/salamander");
+//// uriA = new URI("svgSalamander://mySpecialName/grape");
+// System.err.println(uriA.toString());
+// System.err.println(uriA.getScheme());
+//
+// uriB = uriA.resolve("#begin");
+// System.err.println(uriB.toString());
+//
+// uriC = uriA.resolve("tree#boing");
+// System.err.println(uriC.toString());
+//
+// uriC = uriA.resolve("../tree#boing");
+// System.err.println(uriC.toString());
+// }
+// catch (Exception e)
+// {
+// Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+// "Could not parse", e);
+// }
+// }
public boolean isVerbose()
{
diff --git a/src/main/java/com/kitfox/svg/Use.java b/src/main/java/com/kitfox/svg/Use.java
index 1459028..f323154 100644
--- a/src/main/java/com/kitfox/svg/Use.java
+++ b/src/main/java/com/kitfox/svg/Use.java
@@ -62,42 +62,7 @@ public class Use extends ShapeElement {
/** Creates a new instance of LinearGradient */
public Use() {
}
-/*
- public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
- {
- //Load style string
- super.loaderStartElement(helper, attrs, parent);
-
- String x = attrs.getValue("x");
- String y = attrs.getValue("y");
- String width = attrs.getValue("width");
- String height = attrs.getValue("height");
- String href = attrs.getValue("xlink:href");
-
- if (x != null) this.x = (float)XMLParseUtil.parseRatio(x);
- if (y != null) this.y = (float)XMLParseUtil.parseRatio(y);
- if (width != null) this.width = (float)XMLParseUtil.parseRatio(width);
- if (height != null) this.height = (float)XMLParseUtil.parseRatio(height);
-
-
- if (href != null)
- {
- try {
- URI src = getXMLBase().resolve(href);
- this.href = helper.universe.getElement(src);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- //Determine use offset/scale
- refXform = new AffineTransform();
- refXform.translate(this.x, this.y);
- refXform.scale(this.width, this.height);
- }
-*/
protected void build() throws SVGException
{
super.build();
diff --git a/src/main/java/com/kitfox/svg/animation/AnimTimeParser.jjt b/src/main/java/com/kitfox/svg/animation/AnimTimeParser.jjt
index c7588e5..4b01b5c 100644
--- a/src/main/java/com/kitfox/svg/animation/AnimTimeParser.jjt
+++ b/src/main/java/com/kitfox/svg/animation/AnimTimeParser.jjt
@@ -42,9 +42,17 @@ PARSER_BEGIN(AnimTimeParser)
package com.kitfox.svg.animation.parser;
-import java.util.*;
-import java.io.*;
-import com.kitfox.svg.animation.*;
+import com.kitfox.svg.SVGConst;
+import com.kitfox.svg.animation.TimeBase;
+import com.kitfox.svg.animation.TimeCompound;
+import com.kitfox.svg.animation.TimeDiscrete;
+import com.kitfox.svg.animation.TimeIndefinite;
+import com.kitfox.svg.animation.TimeLookup;
+import com.kitfox.svg.animation.TimeSum;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.logging.Level;
+import java.util.logging.Logger;
public class AnimTimeParser
{
@@ -283,15 +291,25 @@ double Number() :
{
t=<FLOAT>
{
- try { return Double.parseDouble(t.image); }
- catch (Exception e) { e.printStackTrace(); }
+ try {
+ return Double.parseDouble(t.image);
+ }
+ catch (Exception e) {
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not parse double '" + t.image + "'", e);
+ }
return 0.0;
}
| t=<INTEGER>
{
- try { return Double.parseDouble(t.image); }
- catch (Exception e) { e.printStackTrace(); }
+ try {
+ return Double.parseDouble(t.image);
+ }
+ catch (Exception e) {
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not parse double '" + t.image + "'", e);
+ }
return 0.0;
}
@@ -304,8 +322,13 @@ int Integer() :
{
t=<INTEGER>
{
- try { return Integer.parseInt(t.image); }
- catch (Exception e) { e.printStackTrace(); }
+ try {
+ return Integer.parseInt(t.image);
+ }
+ catch (Exception e) {
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not parse int '" + t.image + "'", e);
+ }
return 0;
}
diff --git a/src/main/java/com/kitfox/svg/animation/AnimateBase.java b/src/main/java/com/kitfox/svg/animation/AnimateBase.java
index 0605f0e..047305d 100644
--- a/src/main/java/com/kitfox/svg/animation/AnimateBase.java
+++ b/src/main/java/com/kitfox/svg/animation/AnimateBase.java
@@ -36,6 +36,7 @@
package com.kitfox.svg.animation;
+import com.kitfox.svg.SVGConst;
import com.kitfox.svg.SVGElement;
import com.kitfox.svg.SVGException;
import com.kitfox.svg.SVGLoaderHelper;
@@ -43,6 +44,8 @@ import com.kitfox.svg.animation.parser.AnimTimeParser;
import com.kitfox.svg.animation.parser.ParseException;
import com.kitfox.svg.xml.StyleAttribute;
import java.io.StringReader;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@@ -114,10 +117,14 @@ abstract public class AnimateBase extends AnimationElement
if (strn != null)
{
animTimeParser.ReInit(new StringReader(strn));
- try {
+ try
+ {
this.repeatDur = animTimeParser.Expr();
- } catch (ParseException ex) {
- ex.printStackTrace();
+ }
+ catch (ParseException ex)
+ {
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not parse '" + strn + "'", ex);
}
}
}
diff --git a/src/main/java/com/kitfox/svg/animation/AnimationElement.java b/src/main/java/com/kitfox/svg/animation/AnimationElement.java
index ce49ffa..980a826 100644
--- a/src/main/java/com/kitfox/svg/animation/AnimationElement.java
+++ b/src/main/java/com/kitfox/svg/animation/AnimationElement.java
@@ -36,6 +36,7 @@
package com.kitfox.svg.animation;
+import com.kitfox.svg.SVGConst;
import com.kitfox.svg.SVGElement;
import com.kitfox.svg.SVGException;
import com.kitfox.svg.SVGLoaderHelper;
@@ -43,6 +44,8 @@ import com.kitfox.svg.animation.parser.AnimTimeParser;
import com.kitfox.svg.animation.parser.ParseException;
import com.kitfox.svg.xml.StyleAttribute;
import java.io.StringReader;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@@ -369,7 +372,8 @@ public abstract class AnimationElement extends SVGElement
try {
this.beginTime = animTimeParser.Expr();
} catch (ParseException ex) {
- ex.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not parse '" + newVal + "'", ex);
}
}
@@ -380,7 +384,8 @@ public abstract class AnimationElement extends SVGElement
try {
this.durTime = animTimeParser.Expr();
} catch (ParseException ex) {
- ex.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not parse '" + newVal + "'", ex);
}
}
@@ -391,7 +396,8 @@ public abstract class AnimationElement extends SVGElement
try {
this.endTime = animTimeParser.Expr();
} catch (ParseException ex) {
- ex.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not parse '" + newVal + "'", ex);
}
}
diff --git a/src/main/java/com/kitfox/svg/app/SVGPlayer.java b/src/main/java/com/kitfox/svg/app/SVGPlayer.java
index bd2a8ec..0d38798 100644
--- a/src/main/java/com/kitfox/svg/app/SVGPlayer.java
+++ b/src/main/java/com/kitfox/svg/app/SVGPlayer.java
@@ -37,6 +37,7 @@
package com.kitfox.svg.app;
+import com.kitfox.svg.SVGConst;
import com.kitfox.svg.SVGDiagram;
import com.kitfox.svg.SVGDisplayPanel;
import com.kitfox.svg.SVGElement;
@@ -55,6 +56,8 @@ import java.security.AccessControlException;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JFileChooser;
@@ -146,7 +149,8 @@ public class SVGPlayer extends javax.swing.JFrame
}
catch (SVGException ex)
{
- ex.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not pick", ex);
}
}
}
@@ -186,7 +190,7 @@ public class SVGPlayer extends javax.swing.JFrame
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
}
}
@@ -221,7 +225,7 @@ public class SVGPlayer extends javax.swing.JFrame
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
}
}
@@ -361,7 +365,7 @@ public class SVGPlayer extends javax.swing.JFrame
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
}
}//GEN-LAST:event_cm_loadUrlActionPerformed
@@ -405,7 +409,7 @@ public class SVGPlayer extends javax.swing.JFrame
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
}
}//GEN-LAST:event_cm_loadFileActionPerformed
diff --git a/src/main/java/com/kitfox/svg/app/SVGViewer.java b/src/main/java/com/kitfox/svg/app/SVGViewer.java
index 4a17eb9..35f9433 100644
--- a/src/main/java/com/kitfox/svg/app/SVGViewer.java
+++ b/src/main/java/com/kitfox/svg/app/SVGViewer.java
@@ -37,6 +37,7 @@
package com.kitfox.svg.app;
import com.kitfox.svg.SVGCache;
+import com.kitfox.svg.SVGConst;
import com.kitfox.svg.SVGDiagram;
import com.kitfox.svg.SVGDisplayPanel;
import com.kitfox.svg.SVGElement;
@@ -54,6 +55,8 @@ import java.security.AccessControlException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JFileChooser;
@@ -159,7 +162,7 @@ public class SVGViewer extends javax.swing.JFrame
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
return;
}
}
@@ -315,7 +318,7 @@ is.close();
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
}
}//GEN-LAST:event_cm_loadUrlActionPerformed
@@ -328,9 +331,9 @@ is.close();
{
pickedElements = diagram.pick(new Point(evt.getX(), evt.getY()), null);
}
- catch (SVGException ex)
+ catch (SVGException e)
{
- ex.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
return;
}
@@ -386,25 +389,9 @@ is.close();
loadURL(url);
}
}
- /*
- catch (IOException ioe)
- {
- try
- {
- //We may be in a WebStart app. Try again with a FileOpenService
- FileContents fc = fileOpenService.openFileDialog(null, new String[]{"svg"});
- InputStream is = fc.getInputStream();
- String name = fc.getName();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- */
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
}
}//GEN-LAST:event_cm_loadFileActionPerformed
diff --git a/src/main/java/com/kitfox/svg/app/VersionDialog.java b/src/main/java/com/kitfox/svg/app/VersionDialog.java
index 65f330e..80344fe 100644
--- a/src/main/java/com/kitfox/svg/app/VersionDialog.java
+++ b/src/main/java/com/kitfox/svg/app/VersionDialog.java
@@ -36,9 +36,12 @@
package com.kitfox.svg.app;
+import com.kitfox.svg.SVGConst;
import java.net.*;
import java.io.*;
import java.util.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.swing.event.*;
import javax.swing.*;
import javax.swing.text.html.*;
@@ -85,7 +88,7 @@ public class VersionDialog extends javax.swing.JDialog
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
}
}
diff --git a/src/main/java/com/kitfox/svg/app/data/Handler.java b/src/main/java/com/kitfox/svg/app/data/Handler.java
index 26c10f2..806dcd9 100644
--- a/src/main/java/com/kitfox/svg/app/data/Handler.java
+++ b/src/main/java/com/kitfox/svg/app/data/Handler.java
@@ -34,12 +34,15 @@
package com.kitfox.svg.app.data;
+import com.kitfox.svg.SVGConst;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
*
@@ -64,10 +67,13 @@ public class Handler extends URLStreamHandler
if (content.startsWith("base64,"))
{
content = content.substring(7);
- try {
+ try
+ {
buf = new sun.misc.BASE64Decoder().decodeBuffer(content);
- } catch (IOException ex) {
- ex.printStackTrace();
+ }
+ catch (IOException e)
+ {
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
}
}
}
diff --git a/src/main/java/com/kitfox/svg/batik/LinearGradientPaint.java b/src/main/java/com/kitfox/svg/batik/LinearGradientPaint.java
index 50ff7cc..a2d5c6d 100644
--- a/src/main/java/com/kitfox/svg/batik/LinearGradientPaint.java
+++ b/src/main/java/com/kitfox/svg/batik/LinearGradientPaint.java
@@ -8,6 +8,7 @@
package com.kitfox.svg.batik;
+import com.kitfox.svg.SVGConst;
import java.awt.Color;
import java.awt.PaintContext;
import java.awt.Rectangle;
@@ -17,6 +18,8 @@ import java.awt.geom.NoninvertibleTransformException;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.ColorModel;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
* The <code>LinearGradientPaint</code> class provides a way to fill
@@ -322,9 +325,9 @@ public final class LinearGradientPaint extends MultipleGradientPaint {
cycleMethod,
colorSpace);
}
-
- catch(NoninvertibleTransformException e) {
- e.printStackTrace();
+ catch(NoninvertibleTransformException e)
+ {
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
throw new IllegalArgumentException("transform should be" +
"invertible");
}
diff --git a/src/main/java/com/kitfox/svg/composite/AdobeComposite.java b/src/main/java/com/kitfox/svg/composite/AdobeComposite.java
index 254f396..2fc19f2 100644
--- a/src/main/java/com/kitfox/svg/composite/AdobeComposite.java
+++ b/src/main/java/com/kitfox/svg/composite/AdobeComposite.java
@@ -36,8 +36,11 @@
package com.kitfox.svg.composite;
+import com.kitfox.svg.SVGConst;
import java.awt.*;
import java.awt.image.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
* @author Mark McKay
@@ -60,12 +63,12 @@ public class AdobeComposite implements Composite
if (compositeType < 0 || compositeType >= CT_LAST)
{
- new Exception("Invalid composite type").printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "Invalid composite type");
}
if (extraAlpha < 0f || extraAlpha > 1f)
{
- new Exception("Invalid alpha").printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "Invalid alpha");
}
}
diff --git a/src/main/java/com/kitfox/svg/pattern/PatternPaintContext.java b/src/main/java/com/kitfox/svg/pattern/PatternPaintContext.java
index e468999..a0bdc92 100644
--- a/src/main/java/com/kitfox/svg/pattern/PatternPaintContext.java
+++ b/src/main/java/com/kitfox/svg/pattern/PatternPaintContext.java
@@ -36,9 +36,12 @@
package com.kitfox.svg.pattern;
+import com.kitfox.svg.SVGConst;
import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
* @author Mark McKay
@@ -74,7 +77,10 @@ public class PatternPaintContext implements PaintContext
xform = distortXform.createInverse();
xform.concatenate(userXform.createInverse());
}
- catch (Exception e) { e.printStackTrace(); }
+ catch (Exception e)
+ {
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
+ }
sourceWidth = source.getWidth();
sourceHeight = source.getHeight();
diff --git a/src/main/java/com/kitfox/svg/xml/StyleAttribute.java b/src/main/java/com/kitfox/svg/xml/StyleAttribute.java
index dd1fc3c..2566724 100644
--- a/src/main/java/com/kitfox/svg/xml/StyleAttribute.java
+++ b/src/main/java/com/kitfox/svg/xml/StyleAttribute.java
@@ -36,9 +36,12 @@
package com.kitfox.svg.xml;
+import com.kitfox.svg.SVGConst;
import java.awt.*;
import java.io.*;
import java.net.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import java.util.regex.*;
/**
@@ -202,7 +205,7 @@ public class StyleAttribute implements Serializable
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
return null;
}
}
@@ -217,7 +220,7 @@ public class StyleAttribute implements Serializable
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
return null;
}
}
@@ -275,7 +278,7 @@ public class StyleAttribute implements Serializable
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
return null;
}
}
@@ -296,7 +299,7 @@ public class StyleAttribute implements Serializable
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
}
}
}
diff --git a/src/main/java/com/kitfox/svg/xml/XMLParseUtil.java b/src/main/java/com/kitfox/svg/xml/XMLParseUtil.java
index c8900b9..6254279 100644
--- a/src/main/java/com/kitfox/svg/xml/XMLParseUtil.java
+++ b/src/main/java/com/kitfox/svg/xml/XMLParseUtil.java
@@ -36,12 +36,15 @@
package com.kitfox.svg.xml;
+import com.kitfox.svg.SVGConst;
import org.w3c.dom.*;
import java.awt.*;
import java.net.*;
import java.util.*;
import java.util.regex.*;
import java.lang.reflect.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
* @author Mark McKay
@@ -148,8 +151,8 @@ public class XMLParseUtil
}
catch (StringIndexOutOfBoundsException e)
{
- System.err.println("XMLParseUtil: regex parse problem: '" + val + "'");
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "XMLParseUtil: regex parse problem: '" + val + "'", e);
}
val = fpMatch.group(1);
@@ -545,8 +548,15 @@ public class XMLParseUtil
if (!ele.getTagName().equals(name)) continue;
ReadableXMLElement newObj = null;
- try { newObj = (ReadableXMLElement)classType.newInstance(); }
- catch (Exception e) { e.printStackTrace(); continue; }
+ try
+ {
+ newObj = (ReadableXMLElement)classType.newInstance();
+ }
+ catch (Exception e)
+ {
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
+ continue;
+ }
newObj.read(ele, docRoot);
if (newObj == null) continue;
@@ -575,13 +585,6 @@ public class XMLParseUtil
HashMap retMap = new HashMap();
-/*
- Class[] params = {Element.class, URL.class};
- Method loadMethod = null;
- try { loadMethod = classType.getMethod("load", params); }
- catch (Exception e) { e.printStackTrace(); return null; }
-
- */
NodeList nl = root.getChildNodes();
int size = nl.getLength();
for (int i = 0; i < size; i++)
@@ -592,16 +595,17 @@ public class XMLParseUtil
if (!ele.getTagName().equals(name)) continue;
ReadableXMLElement newObj = null;
- try { newObj = (ReadableXMLElement)classType.newInstance(); }
- catch (Exception e) { e.printStackTrace(); continue; }
+ try
+ {
+ newObj = (ReadableXMLElement)classType.newInstance();
+ }
+ catch (Exception e)
+ {
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
+ continue;
+ }
newObj.read(ele, docRoot);
-/*
- Object[] args = {ele, source};
- Object obj = null;
- try { obj = loadMethod.invoke(null, args); }
- catch (Exception e) { e.printStackTrace(); }
- */
if (newObj == null) continue;
String keyVal = getAttribString(ele, key);
@@ -623,13 +627,6 @@ public class XMLParseUtil
HashSet retSet = new HashSet();
- /*
- Class[] params = {Element.class, URL.class};
- Method loadMethod = null;
- try { loadMethod = classType.getMethod("load", params); }
- catch (Exception e) { e.printStackTrace(); return null; }
- */
-
NodeList nl = root.getChildNodes();
int size = nl.getLength();
for (int i = 0; i < size; i++)
@@ -640,17 +637,21 @@ public class XMLParseUtil
if (!ele.getTagName().equals(name)) continue;
ReadableXMLElement newObj = null;
- try { newObj = (ReadableXMLElement)classType.newInstance(); }
- catch (Exception e) { e.printStackTrace(); continue; }
+ try
+ {
+ newObj = (ReadableXMLElement)classType.newInstance();
+ }
+ catch (Exception e)
+ {
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
+ continue;
+ }
newObj.read(ele, docRoot);
- /*
- Object[] args = {ele, source};
- Object obj = null;
- try { obj = loadMethod.invoke(null, args); }
- catch (Exception e) { e.printStackTrace(); }
- */
- if (newObj == null) continue;
+ if (newObj == null)
+ {
+ continue;
+ }
retSet.add(newObj);
}
@@ -680,8 +681,15 @@ public class XMLParseUtil
if (!ele.getTagName().equals(name)) continue;
ReadableXMLElement newObj = null;
- try { newObj = (ReadableXMLElement)classType.newInstance(); }
- catch (Exception e) { e.printStackTrace(); continue; }
+ try
+ {
+ newObj = (ReadableXMLElement)classType.newInstance();
+ }
+ catch (Exception e)
+ {
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
+ continue;
+ }
newObj.read(ele, docRoot);
elementCache.addLast(newObj);
diff --git a/src/main/java/com/kitfox/svg/xml/cpx/CPXInputStream.java b/src/main/java/com/kitfox/svg/xml/cpx/CPXInputStream.java
index 5e453cd..1c1cae3 100644
--- a/src/main/java/com/kitfox/svg/xml/cpx/CPXInputStream.java
+++ b/src/main/java/com/kitfox/svg/xml/cpx/CPXInputStream.java
@@ -36,10 +36,13 @@
package com.kitfox.svg.xml.cpx;
+import com.kitfox.svg.SVGConst;
import java.io.*;
import java.util.*;
import java.util.zip.*;
import java.security.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.crypto.*;
/**
@@ -209,24 +212,26 @@ public class CPXInputStream extends FilterInputStream implements CPXConsts {
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
return -1;
}
if (!inflater.finished())
{
- new Exception("Inflation incomplete").printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Inflation imncomplete");
}
return numRead == 0 ? -1 : numRead;
}
- try {
+ try
+ {
return inflater.inflate(b, off, len);
}
catch (DataFormatException e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
return -1;
}
}
diff --git a/src/main/java/com/kitfox/svg/xml/cpx/CPXTest.java b/src/main/java/com/kitfox/svg/xml/cpx/CPXTest.java
index 5b84304..cf790a8 100644
--- a/src/main/java/com/kitfox/svg/xml/cpx/CPXTest.java
+++ b/src/main/java/com/kitfox/svg/xml/cpx/CPXTest.java
@@ -36,8 +36,10 @@
package com.kitfox.svg.xml.cpx;
+import com.kitfox.svg.SVGConst;
import java.io.*;
-import java.net.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
* @author Mark McKay
@@ -73,7 +75,7 @@ public class CPXTest {
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
}
}
@@ -95,14 +97,15 @@ public class CPXTest {
}
catch (Exception e)
{
- e.printStackTrace();
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
}
}
/**
* @param args the command line arguments
*/
- public static void main(String[] args) {
+ public static void main(String[] args)
+ {
new CPXTest();
}