Re: create a JSVGCanvas from an inputstream
Hi Dao, dao dao.ho...@gmail.com wrote on 01/02/2010 05:33:04 PM: I understand, but how can I refer to that document in an other document? (see the xlink:href from my mail)? After you have created your document from an InputStream you can set the base URL for the document. There are two ways to do this, the 'xml:base' attribute or by calling batik.dom.svg.SVGOMDocument.setDocumentURI (or setURLObject, or setParsedURL). I would suggest setting that URL to a JAR file URL that points to a non-existent file in your JAR, that is in the same directory as your 'widgets.svg' file. Then if you use xlink:href=widgets.svg#blah it will resolve the reference to the file in your Jar file. On Sat, Jan 2, 2010 at 11:27 PM, jonathan wood jonathanshaww...@gmail.com wrote: Hi Dao, I also included a load from jar in the previous examples. The key is the line: InputStream templateStream = MyClass.class.getResourceAsStream(template.svg); getResourceAsStream will allow you to load from the classpath (including your jar). to recap: InputStream templateStream = MyClass.class.getResourceAsStream(template.svg); String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); SVGDocument doc = null; try { doc = f.createSVGDocument(null, templateStream); } catch (IOException ex) { } myCanvas.setSVGDocument(doc); On Sat, Jan 2, 2010 at 3:30 PM, dao dao.ho...@gmail.com wrote: to continue with this inputstream document: My document that I build from an inputstream references an other document by referencing some symbols (use xlink:href= widgets.svg#warningMask ...) How can I do to make this work: Either I create an other document I receive from my server which is widget.svg and tell me how I can reference it (is it necessary to create a file from the stream in the file widgets.svg?) Either I have the widgets.svg file in my application's jar. In that case, How can I reference a file in a jar? Do you suggest me an other way to process? 2010/1/1 Helder Magalhães helder.magalh...@gmail.com Hi dao, Response inline... Added in [2]. not sure of how to reference the thread Great! :-) I noticed an entry added to the how-to, but the actual page [1] doesn't exist yet...? To reference a thread, just copy a link from the archives [2]. While using the official archives, the trick seems to be selecting the desired thread or particular message and clicking on the Message view link in order to get the desired thread/message hyperlink. In this particular case, it would be [3]. As we're at it, given than navigation/search features are not very user friendly in the official archives IMHO, I frequently use the Nabble archive [4], specially for searches... ;-) Hope this helps, Helder [1] http://wiki.apache.org/xmlgraphics-batik/InputStreamInitialisation [2] http://mail-archives.apache.org/mod_mbox/ [3] http://mail-archives.apache.org/mod_mbox/xmlgraphics-batik- users/200912.mbox/% 3c272595f40912300947w60080f76ibdc29c7a1a702...@mail.gmail.com%3e [4] http://old.nabble.com/Batik-f308.html - To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org -- Dao Hodac -- Dao Hodac
RE: create a JSVGCanvas from an inputstream
Hi, I have tried your suggestion, but for the moment, it fails. I have created the document like this. Note that panel.svg does not exist: private static final String DOC_URI = jar:file://panel.svg; ... String xmlDocument = remoteEngine.getSvgDocument(); ByteArrayInputStream bais = new ByteArrayInputStream(xmlDocument.getBytes()); String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); return f.createDocument(DOC_URI, bais); In my jar (I run with: java -cp theJar.jar ...), I have a widget.svg file at the root if the folder structure. I get this error: Unable to make sense of URL for connection (since I want to use a symbol set in the file widget.svg) Is there a problem with the URI? De : thomas.dewe...@kodak.com [mailto:thomas.dewe...@kodak.com] Envoyé : lundi 4 janvier 2010 12:27 À : batik-users@xmlgraphics.apache.org Cc : batik-users@xmlgraphics.apache.org Objet : Re: create a JSVGCanvas from an inputstream Hi Dao, dao dao.ho...@gmail.com wrote on 01/02/2010 05:33:04 PM: I understand, but how can I refer to that document in an other document? (see the xlink:href from my mail)? After you have created your document from an InputStream you can set the base URL for the document. There are two ways to do this, the 'xml:base' attribute or by calling batik.dom.svg.SVGOMDocument.setDocumentURI (or setURLObject, or setParsedURL). I would suggest setting that URL to a JAR file URL that points to a non-existent file in your JAR, that is in the same directory as your 'widgets.svg' file. Then if you use xlink:href=widgets.svg#blah it will resolve the reference to the file in your Jar file. On Sat, Jan 2, 2010 at 11:27 PM, jonathan wood jonathanshaww...@gmail.com wrote: Hi Dao, I also included a load from jar in the previous examples. The key is the line: InputStream templateStream = MyClass.class.getResourceAsStream(template.svg); getResourceAsStream will allow you to load from the classpath (including your jar). to recap: InputStream templateStream = MyClass.class.getResourceAsStream(template.svg); String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); SVGDocument doc = null; try { doc = f.createSVGDocument(null, templateStream); } catch (IOException ex) { } myCanvas.setSVGDocument(doc); On Sat, Jan 2, 2010 at 3:30 PM, dao dao.ho...@gmail.com wrote: to continue with this inputstream document: My document that I build from an inputstream references an other document by referencing some symbols (use xlink:href= widgets.svg#warningMask ...) How can I do to make this work: Either I create an other document I receive from my server which is widget.svg and tell me how I can reference it (is it necessary to create a file from the stream in the file widgets.svg?) Either I have the widgets.svg file in my application's jar. In that case, How can I reference a file in a jar? Do you suggest me an other way to process? 2010/1/1 Helder Magalhães helder.magalh...@gmail.com Hi dao, Response inline... Added in [2]. not sure of how to reference the thread Great! :-) I noticed an entry added to the how-to, but the actual page [1] doesn't exist yet...? To reference a thread, just copy a link from the archives [2]. While using the official archives, the trick seems to be selecting the desired thread or particular message and clicking on the Message view link in order to get the desired thread/message hyperlink. In this particular case, it would be [3]. As we're at it, given than navigation/search features are not very user friendly in the official archives IMHO, I frequently use the Nabble archive [4], specially for searches... ;-) Hope this helps, Helder [1] http://wiki.apache.org/xmlgraphics-batik/InputStreamInitialisation http://wiki.apache.org/xmlgraphics-batik/InputStreamInitialisation [2] http://mail-archives.apache.org/mod_mbox/ http://mail-archives.apache.org/mod_mbox/ [3] http://mail-archives.apache.org/mod_mbox/xmlgraphics-batik- http://mail-archives.apache.org/mod_mbox/xmlgraphics-batik- users/200912.mbox/% 3c272595f40912300947w60080f76ibdc29c7a1a702...@mail.gmail.com%3e [4] http://old.nabble.com/Batik-f308.html http://old.nabble.com/Batik-f308.html - To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org -- Dao Hodac -- Dao Hodac This mail has originated outside your organization, either from an external partner or the Global Internet
RE: create a JSVGCanvas from an inputstream
Hi Olivier, HODAC, Olivier olivier.ho...@airbus.com wrote on 01/04/2010 07:22:05 AM: I have tried your suggestion, but for the moment, it fails. I have created the document like this. Note that panel.svg does not exist: private static final String DOC_URI = jar:file://panel.svg; This isn't a proper Jar file URL. Please check the syntax of a jar file URL. I get this error: Unable to make sense of URL for connection (since I want to use a symbol set in the file widget.svg) Is there a problem with the URI? Yes. De : thomas.dewe...@kodak.com [mailto:thomas.dewe...@kodak.com] Envoyé : lundi 4 janvier 2010 12:27 À : batik-users@xmlgraphics.apache.org Cc : batik-users@xmlgraphics.apache.org Objet : Re: create a JSVGCanvas from an inputstream Hi Dao, dao dao.ho...@gmail.com wrote on 01/02/2010 05:33:04 PM: I understand, but how can I refer to that document in an other document? (see the xlink:href from my mail)? After you have created your document from an InputStream you can set the base URL for the document. There are two ways to do this, the 'xml:base' attribute or by calling batik.dom.svg.SVGOMDocument.setDocumentURI (or setURLObject, or setParsedURL). I would suggest setting that URL to a JAR file URL that points to a non-existent file in your JAR, that is in the same directory as your 'widgets.svg' file. Then if you use xlink:href=widgets.svg#blah it will resolve the reference to the file in your Jar file. On Sat, Jan 2, 2010 at 11:27 PM, jonathan wood jonathanshaww...@gmail.com wrote: Hi Dao, I also included a load from jar in the previous examples. The key is the line: InputStream templateStream = MyClass.class.getResourceAsStream(template.svg); getResourceAsStream will allow you to load from the classpath (including your jar). to recap: InputStream templateStream = MyClass.class.getResourceAsStream(template.svg); String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); SVGDocument doc = null; try { doc = f.createSVGDocument(null, templateStream); } catch (IOException ex) { } myCanvas.setSVGDocument(doc); On Sat, Jan 2, 2010 at 3:30 PM, dao dao.ho...@gmail.com wrote: to continue with this inputstream document: My document that I build from an inputstream references an other document by referencing some symbols (use xlink:href= widgets.svg#warningMask ...) How can I do to make this work: Either I create an other document I receive from my server which is widget.svg and tell me how I can reference it (is it necessary to create a file from the stream in the file widgets.svg?) Either I have the widgets.svg file in my application's jar. In that case, How can I reference a file in a jar? Do you suggest me an other way to process? 2010/1/1 Helder Magalhães helder.magalh...@gmail.com Hi dao, Response inline... Added in [2]. not sure of how to reference the thread Great! :-) I noticed an entry added to the how-to, but the actual page [1] doesn't exist yet...? To reference a thread, just copy a link from the archives [2]. While using the official archives, the trick seems to be selecting the desired thread or particular message and clicking on the Message view link in order to get the desired thread/message hyperlink. In this particular case, it would be [3]. As we're at it, given than navigation/search features are not very user friendly in the official archives IMHO, I frequently use the Nabble archive [4], specially for searches... ;-) Hope this helps, Helder [1] http://wiki.apache.org/xmlgraphics-batik/InputStreamInitialisation [2] http://mail-archives.apache.org/mod_mbox/ [3] http://mail-archives.apache.org/mod_mbox/xmlgraphics-batik- users/200912.mbox/% 3c272595f40912300947w60080f76ibdc29c7a1a702...@mail.gmail.com%3e [4] http://old.nabble.com/Batik-f308.html - To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org -- Dao Hodac -- Dao Hodac This mail has originated outside your organization, either from an external partner or the Global Internet. Keep this in mind if you answer this message. The information in this e-mail is confidential. The contents may not be disclosed or used by anyone other than the addressee. Access to this e-mail by anyone else is unauthorised. If you are not the intended recipient, please notify Airbus immediately and delete this e-mail. Airbus cannot accept any responsibility for the accuracy or completeness
RE: create a JSVGCanvas from an inputstream
Sorry for the DOC_URI, it works fine now with jar:/file:/E:/ATOLE/gate/animator/MoowClient.jar!/panel.svg Just note that in a bat file, the ! is interpreted so the command line is like: java -Djava.rmi.server.codebase=file:///F:/ATOLE/gate/animator/MoowClient.jar -Dsvg.document.URI=jar:file:///F:/ATOLE/gate/animator/MoowClient.jar^!/panel.svg -Djava.rmi.server.hostname=TODA300038225 -Djava.security.policy=server.policy -cp MoowClient.jar com.moow.animator.engine.application.Main TODA300038225 %* I add this to the wiki. Thank's a lot for this thread De : thomas.dewe...@kodak.com [mailto:thomas.dewe...@kodak.com] Envoyé : lundi 4 janvier 2010 13:58 À : batik-users@xmlgraphics.apache.org Cc : batik-users@xmlgraphics.apache.org Objet : RE: create a JSVGCanvas from an inputstream Hi Olivier, HODAC, Olivier olivier.ho...@airbus.com wrote on 01/04/2010 07:22:05 AM: I have tried your suggestion, but for the moment, it fails. I have created the document like this. Note that panel.svg does not exist: private static final String DOC_URI = jar:file://panel.svg file:///\\panel.svg\ ; This isn't a proper Jar file URL. Please check the syntax of a jar file URL. I get this error: Unable to make sense of URL for connection (since I want to use a symbol set in the file widget.svg) Is there a problem with the URI? Yes. De : thomas.dewe...@kodak.com [mailto:thomas.dewe...@kodak.com mailto:thomas.dewe...@kodak.com ] Envoyé : lundi 4 janvier 2010 12:27 À : batik-users@xmlgraphics.apache.org Cc : batik-users@xmlgraphics.apache.org Objet : Re: create a JSVGCanvas from an inputstream Hi Dao, dao dao.ho...@gmail.com wrote on 01/02/2010 05:33:04 PM: I understand, but how can I refer to that document in an other document? (see the xlink:href from my mail)? After you have created your document from an InputStream you can set the base URL for the document. There are two ways to do this, the 'xml:base' attribute or by calling batik.dom.svg.SVGOMDocument.setDocumentURI (or setURLObject, or setParsedURL). I would suggest setting that URL to a JAR file URL that points to a non-existent file in your JAR, that is in the same directory as your 'widgets.svg' file. Then if you use xlink:href=widgets.svg#blah it will resolve the reference to the file in your Jar file. On Sat, Jan 2, 2010 at 11:27 PM, jonathan wood jonathanshaww...@gmail.com wrote: Hi Dao, I also included a load from jar in the previous examples. The key is the line: InputStream templateStream = MyClass.class.getResourceAsStream(template.svg); getResourceAsStream will allow you to load from the classpath (including your jar). to recap: InputStream templateStream = MyClass.class.getResourceAsStream(template.svg); String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); SVGDocument doc = null; try { doc = f.createSVGDocument(null, templateStream); } catch (IOException ex) { } myCanvas.setSVGDocument(doc); On Sat, Jan 2, 2010 at 3:30 PM, dao dao.ho...@gmail.com wrote: to continue with this inputstream document: My document that I build from an inputstream references an other document by referencing some symbols (use xlink:href= widgets.svg#warningMask ...) How can I do to make this work: Either I create an other document I receive from my server which is widget.svg and tell me how I can reference it (is it necessary to create a file from the stream in the file widgets.svg?) Either I have the widgets.svg file in my application's jar. In that case, How can I reference a file in a jar? Do you suggest me an other way to process? 2010/1/1 Helder Magalhães helder.magalh...@gmail.com Hi dao, Response inline... Added in [2]. not sure of how to reference the thread Great! :-) I noticed an entry added to the how-to, but the actual page [1] doesn't exist yet...? To reference a thread, just copy a link from the archives [2]. While using the official archives, the trick seems to be selecting the desired thread or particular message and clicking on the Message view link in order to get the desired thread/message hyperlink. In this particular case, it would be [3]. As we're at it, given than navigation/search features are not very user friendly in the official archives IMHO, I frequently use the Nabble archive [4], specially for searches... ;-) Hope this helps, Helder [1] http://wiki.apache.org/xmlgraphics-batik/InputStreamInitialisation http://wiki.apache.org/xmlgraphics-batik/InputStreamInitialisation [2] http://mail-archives.apache.org/mod_mbox/ http://mail
Re: create a JSVGCanvas from an inputstream
I don't know whether this code is (a) relevant, (b) useful -- :-) -- but this is how I generate an SVG for the JSVGCanvas. I generate maps by interrogating a spatial db (not shown), and placing the data into a Velocity context (not shown, but called ctx). I pipe the output from the Velocity engine into the createSVGDocument() method. The PipedWriter must write in a different Thread from the PipedReader. It works very well for me. I hope somebody finds it useful. public void buildMap(JSVGCanvas svg) { // missing code (lots!) PipedReader r = new PipedReader(); PipedWriter w = new PipedWriter(r); String prs = org.apache.xerces.parsers.SAXParser; SAXSVGDocumentFactory fac = new SAXSVGDocumentFactory(prs); String templateName = myTemplate.svg; new Thread( new Runnable() { public void run() { Velocity.mergeTemplate(templateName, UTF8, ctx, w); w.close(); } } ).start(); doc=fac.createSVGDocument(someURI, r); svg.setSVGDocument(doc); } Martin -- From my MacBook Pro - To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org
Re: create a JSVGCanvas from an inputstream
to continue with this inputstream document: My document that I build from an inputstream references an other document by referencing some symbols (use xlink:href=widgets.svg#warningMask ...) How can I do to make this work: Either I create an other document I receive from my server which is widget.svg and tell me how I can reference it (is it necessary to create a file from the stream in the file widgets.svg?) Either I have the widgets.svg file in my application's jar. In that case, How can I reference a file in a jar? Do you suggest me an other way to process? 2010/1/1 Helder Magalhães helder.magalh...@gmail.com Hi dao, Response inline... Added in [2]. not sure of how to reference the thread Great! :-) I noticed an entry added to the how-to, but the actual page [1] doesn't exist yet...? To reference a thread, just copy a link from the archives [2]. While using the official archives, the trick seems to be selecting the desired thread or particular message and clicking on the Message view link in order to get the desired thread/message hyperlink. In this particular case, it would be [3]. As we're at it, given than navigation/search features are not very user friendly in the official archives IMHO, I frequently use the Nabble archive [4], specially for searches... ;-) Hope this helps, Helder [1] http://wiki.apache.org/xmlgraphics-batik/InputStreamInitialisation [2] http://mail-archives.apache.org/mod_mbox/ [3] http://mail-archives.apache.org/mod_mbox/xmlgraphics-batik-users/200912.mbox/%3c272595f40912300947w60080f76ibdc29c7a1a702...@mail.gmail.com%3e [4] http://old.nabble.com/Batik-f308.html - To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org -- Dao Hodac
Re: create a JSVGCanvas from an inputstream
Hi Dao, I also included a load from jar in the previous examples. The key is the line: InputStream templateStream = MyClass.class.getResourceAsStream(template.svg); getResourceAsStream will allow you to load from the classpath (including your jar). to recap: InputStream templateStream = MyClass.class.getResourceAsStream(template.svg); String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); SVGDocument doc = null; try { doc = f.createSVGDocument(null, templateStream); } catch (IOException ex) { } myCanvas.setSVGDocument(doc); On Sat, Jan 2, 2010 at 3:30 PM, dao dao.ho...@gmail.com wrote: to continue with this inputstream document: My document that I build from an inputstream references an other document by referencing some symbols (use xlink:href=widgets.svg#warningMask ... ) How can I do to make this work: Either I create an other document I receive from my server which is widget.svg and tell me how I can reference it (is it necessary to create a file from the stream in the file widgets.svg?) Either I have the widgets.svg file in my application's jar. In that case, How can I reference a file in a jar? Do you suggest me an other way to process? 2010/1/1 Helder Magalhães helder.magalh...@gmail.com Hi dao, Response inline... Added in [2]. not sure of how to reference the thread Great! :-) I noticed an entry added to the how-to, but the actual page [1] doesn't exist yet...? To reference a thread, just copy a link from the archives [2]. While using the official archives, the trick seems to be selecting the desired thread or particular message and clicking on the Message view link in order to get the desired thread/message hyperlink. In this particular case, it would be [3]. As we're at it, given than navigation/search features are not very user friendly in the official archives IMHO, I frequently use the Nabble archive [4], specially for searches... ;-) Hope this helps, Helder [1] http://wiki.apache.org/xmlgraphics-batik/InputStreamInitialisation [2] http://mail-archives.apache.org/mod_mbox/ [3] http://mail-archives.apache.org/mod_mbox/xmlgraphics-batik-users/200912.mbox/%3c272595f40912300947w60080f76ibdc29c7a1a702...@mail.gmail.com%3e [4] http://old.nabble.com/Batik-f308.html - To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org -- Dao Hodac
Re: create a JSVGCanvas from an inputstream
I understand, but how can I refer to that document in an other document? (see the xlink:href from my mail)? On Sat, Jan 2, 2010 at 11:27 PM, jonathan wood jonathanshaww...@gmail.comwrote: Hi Dao, I also included a load from jar in the previous examples. The key is the line: InputStream templateStream = MyClass.class.getResourceAsStream(template.svg); getResourceAsStream will allow you to load from the classpath (including your jar). to recap: InputStream templateStream = MyClass.class.getResourceAsStream(template.svg); String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); SVGDocument doc = null; try { doc = f.createSVGDocument(null, templateStream); } catch (IOException ex) { } myCanvas.setSVGDocument(doc); On Sat, Jan 2, 2010 at 3:30 PM, dao dao.ho...@gmail.com wrote: to continue with this inputstream document: My document that I build from an inputstream references an other document by referencing some symbols (use xlink:href=widgets.svg#warningMask ...) How can I do to make this work: Either I create an other document I receive from my server which is widget.svg and tell me how I can reference it (is it necessary to create a file from the stream in the file widgets.svg?) Either I have the widgets.svg file in my application's jar. In that case, How can I reference a file in a jar? Do you suggest me an other way to process? 2010/1/1 Helder Magalhães helder.magalh...@gmail.com Hi dao, Response inline... Added in [2]. not sure of how to reference the thread Great! :-) I noticed an entry added to the how-to, but the actual page [1] doesn't exist yet...? To reference a thread, just copy a link from the archives [2]. While using the official archives, the trick seems to be selecting the desired thread or particular message and clicking on the Message view link in order to get the desired thread/message hyperlink. In this particular case, it would be [3]. As we're at it, given than navigation/search features are not very user friendly in the official archives IMHO, I frequently use the Nabble archive [4], specially for searches... ;-) Hope this helps, Helder [1] http://wiki.apache.org/xmlgraphics-batik/InputStreamInitialisation [2] http://mail-archives.apache.org/mod_mbox/ [3] http://mail-archives.apache.org/mod_mbox/xmlgraphics-batik-users/200912.mbox/%3c272595f40912300947w60080f76ibdc29c7a1a702...@mail.gmail.com%3e [4] http://old.nabble.com/Batik-f308.html - To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org -- Dao Hodac -- Dao Hodac
Re: create a JSVGCanvas from an inputstream
There may be a way to do this auto-magically, but I don't (yet) know it. Try the jar protocol (jar:file://nn/file.svg) ( http://docs.sun.com/source/819-0913/author/jar.html#jarprotocol) Override/extend the existing UserAgent.openLink() functionality. To save a bit of hunting on your part...The appropriate code can be found in JSVGComponent.BridgeUserAgent() ( You'll likely receive better guidance from the others on the list though. I'll update you if I see something better. On Sat, Jan 2, 2010 at 5:33 PM, dao dao.ho...@gmail.com wrote: I understand, but how can I refer to that document in an other document? (see the xlink:href from my mail)? On Sat, Jan 2, 2010 at 11:27 PM, jonathan wood jonathanshaww...@gmail.com wrote: Hi Dao, I also included a load from jar in the previous examples. The key is the line: InputStream templateStream = MyClass.class.getResourceAsStream(template.svg); getResourceAsStream will allow you to load from the classpath (including your jar). to recap: InputStream templateStream = MyClass.class.getResourceAsStream(template.svg); String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); SVGDocument doc = null; try { doc = f.createSVGDocument(null, templateStream); } catch (IOException ex) { } myCanvas.setSVGDocument(doc); On Sat, Jan 2, 2010 at 3:30 PM, dao dao.ho...@gmail.com wrote: to continue with this inputstream document: My document that I build from an inputstream references an other document by referencing some symbols (use xlink:href=widgets.svg#warningMask ...) How can I do to make this work: Either I create an other document I receive from my server which is widget.svg and tell me how I can reference it (is it necessary to create a file from the stream in the file widgets.svg?) Either I have the widgets.svg file in my application's jar. In that case, How can I reference a file in a jar? Do you suggest me an other way to process? 2010/1/1 Helder Magalhães helder.magalh...@gmail.com Hi dao, Response inline... Added in [2]. not sure of how to reference the thread Great! :-) I noticed an entry added to the how-to, but the actual page [1] doesn't exist yet...? To reference a thread, just copy a link from the archives [2]. While using the official archives, the trick seems to be selecting the desired thread or particular message and clicking on the Message view link in order to get the desired thread/message hyperlink. In this particular case, it would be [3]. As we're at it, given than navigation/search features are not very user friendly in the official archives IMHO, I frequently use the Nabble archive [4], specially for searches... ;-) Hope this helps, Helder [1] http://wiki.apache.org/xmlgraphics-batik/InputStreamInitialisation [2] http://mail-archives.apache.org/mod_mbox/ [3] http://mail-archives.apache.org/mod_mbox/xmlgraphics-batik-users/200912.mbox/%3c272595f40912300947w60080f76ibdc29c7a1a702...@mail.gmail.com%3e [4] http://old.nabble.com/Batik-f308.html - To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org -- Dao Hodac -- Dao Hodac
Re: create a JSVGCanvas from an inputstream
Added in [2]. not sure of how to reference the thread 2009/12/30 Helder Magalhães helder.magalh...@gmail.com Hi everyone, Response inline... (jonathan wood) Here are a couple of load routines I use frequently .. Hope they help you narrow your problem. (dao) Thank you, it works fine! I will keep those routine somewhere In the wiki [1], perhaps...? ;-) The how-to section [2] seemed appropriate, but for shorter, useful code snippets, a dedicated page (UsefulSnippets?) would also be great! :-) BTW: if one decides to go with it, including a taken from [link_to_mailing_list_thread here] would be great so that one can crawl for background information if is curious enough. Cheers, Helder [1] http://wiki.apache.org/xmlgraphics-batik/ [2] http://wiki.apache.org/xmlgraphics-batik/HowTo - To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org -- Dao Hodac
Re: create a JSVGCanvas from an inputstream
Hi dao, Response inline... Added in [2]. not sure of how to reference the thread Great! :-) I noticed an entry added to the how-to, but the actual page [1] doesn't exist yet...? To reference a thread, just copy a link from the archives [2]. While using the official archives, the trick seems to be selecting the desired thread or particular message and clicking on the Message view link in order to get the desired thread/message hyperlink. In this particular case, it would be [3]. As we're at it, given than navigation/search features are not very user friendly in the official archives IMHO, I frequently use the Nabble archive [4], specially for searches... ;-) Hope this helps, Helder [1] http://wiki.apache.org/xmlgraphics-batik/InputStreamInitialisation [2] http://mail-archives.apache.org/mod_mbox/ [3] http://mail-archives.apache.org/mod_mbox/xmlgraphics-batik-users/200912.mbox/%3c272595f40912300947w60080f76ibdc29c7a1a702...@mail.gmail.com%3e [4] http://old.nabble.com/Batik-f308.html - To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org
create a JSVGCanvas from an inputstream
hello, I am stucked in the process of creating a JSVGCanvas from a SVG XML content coming from an input stream. What is the best practice? Here is the way I do that: DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); String xmlDocument = remoteEngine.getSvgDocument(); System.out.println(xmlDocument); InputStream inStream = new ByteArrayInputStream(xmlDocument.getBytes()); return builder.parse(inStream); I get into a ClassCastEexception when batik tries to narrow the document to a SVG document (I suppose so...) -- Dao Hodac
Re: create a JSVGCanvas from an inputstream
Hi Dao, Here are a couple of load routines I use frequently .. Hope they help you narrow your problem. Load from a file on the classpath (templated) InputStream templateStream = Canvas.class.getResourceAsStream(template.svg); String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); SVGDocument doc = null; try { doc = f.createSVGDocument(null, templateStream); } catch (IOException ex) { } myCanvas.setSVGDocument(doc); Load from a byte array version: Element a = null; ByteArrayInputStream bais = new ByteArrayInputStream(myByteArray); String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); try { a = f.createDocument(null, bais).getDocumentElement(); } catch (IOException ex) { } a = (Element) document.importNode(a, true); On Wed, Dec 30, 2009 at 12:47 PM, dao dao.ho...@gmail.com wrote: hello, I am stucked in the process of creating a JSVGCanvas from a SVG XML content coming from an input stream. What is the best practice? Here is the way I do that: DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); String xmlDocument = remoteEngine.getSvgDocument(); System.out.println(xmlDocument); InputStream inStream = new ByteArrayInputStream(xmlDocument.getBytes()); return builder.parse(inStream); I get into a ClassCastEexception when batik tries to narrow the document to a SVG document (I suppose so...) -- Dao Hodac
Re: create a JSVGCanvas from an inputstream
Thank you, it works fine! I will keep those routine somewhere On Wed, Dec 30, 2009 at 7:16 PM, jonathan wood jonathanshaww...@gmail.comwrote: Hi Dao, Here are a couple of load routines I use frequently .. Hope they help you narrow your problem. Load from a file on the classpath (templated) InputStream templateStream = Canvas.class.getResourceAsStream(template.svg); String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); SVGDocument doc = null; try { doc = f.createSVGDocument(null, templateStream); } catch (IOException ex) { } myCanvas.setSVGDocument(doc); Load from a byte array version: Element a = null; ByteArrayInputStream bais = new ByteArrayInputStream(myByteArray); String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); try { a = f.createDocument(null, bais).getDocumentElement(); } catch (IOException ex) { } a = (Element) document.importNode(a, true); On Wed, Dec 30, 2009 at 12:47 PM, dao dao.ho...@gmail.com wrote: hello, I am stucked in the process of creating a JSVGCanvas from a SVG XML content coming from an input stream. What is the best practice? Here is the way I do that: DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); String xmlDocument = remoteEngine.getSvgDocument(); System.out.println(xmlDocument); InputStream inStream = new ByteArrayInputStream(xmlDocument.getBytes()); return builder.parse(inStream); I get into a ClassCastEexception when batik tries to narrow the document to a SVG document (I suppose so...) -- Dao Hodac -- Dao Hodac
Re: create a JSVGCanvas from an inputstream
Hi everyone, Response inline... (jonathan wood) Here are a couple of load routines I use frequently .. Hope they help you narrow your problem. (dao) Thank you, it works fine! I will keep those routine somewhere In the wiki [1], perhaps...? ;-) The how-to section [2] seemed appropriate, but for shorter, useful code snippets, a dedicated page (UsefulSnippets?) would also be great! :-) BTW: if one decides to go with it, including a taken from [link_to_mailing_list_thread here] would be great so that one can crawl for background information if is curious enough. Cheers, Helder [1] http://wiki.apache.org/xmlgraphics-batik/ [2] http://wiki.apache.org/xmlgraphics-batik/HowTo - To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org