Hi all, I ran into a small mistery for me as batik-beginner (batik 1.7). In order to center and fully display the SVG I use the bounding box.
I use the getBoundsFromDoc() method shown below to determine the bounding box of a given SVGDocument. The code is not mine, I got inspired by the info on this page here<http://my2iu.blogspot.com/2006/05/getting-svg-bounding-box-out-of-batik.html>. I found similar code in this mailing list as well. Much to my delight this worked perfectly. Well... except that sometimes it doesn't. One out of two runs throws a NPE (see below). So I wonder why, given identical input some runs fail and others don't. It looks a threading issue. But I don't use any threading in my own code. There is only the EDT I guess going about its business (I use a JSVGCanvas). Questions: 1) Am I doing this the right way? Maybe there is a better way to determine the bounding box. 2) Why do I get this strange behaviour? Much in need of your help. Best regards, Johan ps: Sorry if these are FAQs. Rectangle2D getBoundsFromDoc(Document doc) { // GVTBuilder builder = new GVTBuilder(); BridgeContext ctx = new BridgeContext(new UserAgentAdapter()); GraphicsNode gvtRoot = builder.build(ctx, doc); return gvtRoot.getSensitiveBounds(); } ***** CSSEngine: exception property.syntax.error:java.lang.NullPointerException AttrValue:black Exception:java.lang.NullPointerException java.lang.NullPointerException at org.apache.batik.css.parser.Parser.parseTerm(Unknown Source) at org.apache.batik.css.parser.Parser.parseExpression(Unknown Source) at org.apache.batik.css.parser.Parser.parsePropertyValueInternal(Unknown Source) at org.apache.batik.css.parser.Parser.parsePropertyValue(Unknown Source) at org.apache.batik.css.engine.CSSEngine.getCascadedStyleMap(Unknown Source) at org.apache.batik.css.engine.CSSEngine.getComputedStyle(Unknown Source) at org.apache.batik.bridge.CSSUtilities.getComputedStyle(Unknown Source) at org.apache.batik.bridge.CSSUtilities.convertVisibility(Unknown Source) at org.apache.batik.bridge.SVGSVGElementBridge.createGraphicsNode(Unknown Source) at org.apache.batik.bridge.GVTBuilder.build(Unknown Source) at viewer.gui.MainPanel.getBoundsFromDoc(MainPanel.java:144)
