My email client decided to send that off before I was ready.  I'm sorry.

I'm trying to load a SVGCanvas with SVG generated by the SVGGraphics2D
generator.  If there's an easier way, let me know!  However, I tried the
following two methods and while they look to be correct to me, the second
throws and odd error about emcascript.

If I use this method, everything works fine:

// two methods, the first uses SVGGraphics2D to generate the SVG

    public String generateSVG(org.w3c.dom.Document doc) throws Exception {

      DOMImplementation domImpl =
GenericDOMImplementation.getDOMImplementation();
      Document document = domImpl.createDocument(null, "svg", null);
      SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
    // do the actual Java2D in the paint() method...
      this.paint(svgGenerator,doc);
      StringWriter sw = new StringWriter();
      svgGenerator.stream(sw,true);
      return  sw.toString();
   }

   // okay I should now have the SVG as a string right? 

   // so if I throw it into a file, and then load the URL, everything is
fine...

   String svg = generateSVG(doc);  // calls the methods listed above
   File f = new File("test.svg");
   FileWriter fw = new FileWriter(f);
   fw.write(svg);
   fw.flush();
   fw.close();
   svgCanvas.setURI(f.toURL().toString());

This works perfectly (I understand it's a round about way to do things, but
hold on for a second...)

If I change that last snippet of code to this:

        String svg = generateSVG(doc);
        StringReader sr = new StringReader(svg);
        SAXSVGDocumentFactory df = new
SAXSVGDocumentFactory("org.apache.xerces.parsers.SAXParser");
        SVGOMDocument svgDoc = df.createDocument(null,sr);
        svgCanvas.setSVGDocument(svgDoc);

I get the following errors:

java.lang.Exception: Unknown language: text/ecmascript
        at
org.apache.batik.bridge.BaseScriptingEnvironment.dispatchSVGLoadEvent(Unknown
Source)
        at org.apache.batik.bridge.UpdateManager.dispatchSVGLoadEvent(Unknown Source)
        at org.apache.batik.swing.svg.SVGLoadEventDispatcher.run(Unknown Source)

java.lang.NullPointerException
        at java.net.URLClassLoader.getPermissions(URLClassLoader.java:422)
        at org.apache.batik.script.rhino.RhinoClassLoader.getPermissions(Unknown
Source)
        at org.apache.batik.script.rhino.RhinoClassLoader.<init>(Unknown Source)
        at org.apache.batik.script.rhino.RhinoInterpreter.<init>(Unknown Source)
        at
org.apache.batik.script.rhino.RhinoInterpreterFactory.createInterpreter(Unknown
Source)
        at org.apache.batik.script.InterpreterPool.createInterpreter(Unknown Source)
        at org.apache.batik.bridge.BridgeContext.getInterpreter(Unknown Source)
        at
org.apache.batik.bridge.BaseScriptingEnvironment.dispatchSVGLoadEvent(Unknown
Source)
        at org.apache.batik.bridge.UpdateManager.dispatchSVGLoadEvent(Unknown Source)
        at org.apache.batik.swing.svg.SVGLoadEventDispatcher.run(Unknown Source)

I'm running with the lastest Batik version (1.5 beta 3).  Anyone have any
thoughts?

Thanks!
J Aaron Farr

PS- sorry about the earlier message.  First time posting on this list and I
send a half edited message. :)

__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to