Hello,

I'm just trying to do the same as Claire, but the file I must reffer is on my hard disk.
I actually use setURI(String), but it seems the encoding of the file would be wrong (althought It can be displayed directly in my browser with adobe viewer).
Here is the little code I use to access my file

JSVGCanvas svgCanvas = new JSVGCanvas();
JPanel expo = new JPanel();
File f = new File("C:\\des02bis.svg");
try{
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory df = new SAXSVGDocumentFactory(parser);
SVGDocument doc = df.createDocument(f.toURL().toString());

And the errors

java.io.UnsupportedEncodingException: UFT-16

at sun.io.Converters.getConverterClass(Converters.java:107)

at sun.io.Converters.newConverter(Converters.java:138)

at sun.io.ByteToCharConverter.getConverter(ByteToCharConverter.java:67)

at java.io.InputStreamReader.<init>(InputStreamReader.java:78)

at org.apache.crimson.parser.XmlReader.createReader(XmlReader.java:161)

at org.apache.crimson.parser.XmlReader.setEncoding(XmlReader.java:475)

at org.apache.crimson.parser.XmlReader.useEncodingDecl(XmlReader.java:456)

at org.apache.crimson.parser.XmlReader.<init>(XmlReader.java:287)

at org.apache.crimson.parser.XmlReader.createReader(XmlReader.java:125)

at org.apache.crimson.parser.InputEntity.init(InputEntity.java:215)

at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:471)

at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)

at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:433)

at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown Source)

at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown Source)

at org.apache.batik.bridge.DocumentLoader.loadDocument(Unknown Source)

at org.apache.batik.swing.svg.SVGDocumentLoader.run(Unknown Source)

It seems like it was due to encoding of the file, but it's strange to me...
If someone could help, 'd be wonderful :)




The method you want is setURI( String url ) on the JSVGCanvas
object.

If you have a JSVGCanvas object named can, you can do the following:

can.setURI( "http://www.example.com/really_cool.svg"; );

to retrieve the svg file listed. There may be some difficulty with >where
you can retrieve the files in an applet. (I've just been testing >locally
at present.)

If I've missed some details, someone will probably correct me.<grin/>

G. Wade

Claire WALL wrote:

so how do we import/use an svg file for use on an applet? the only
way i've seen to do it is via writing the code line by line to draw >>the
desired svg graphic onto an applet/application (the examples that
are on the batik site).

if anybody has some sample code that would show me how to do
this then that would be really helpful as there is nothing at the
Apache site.

- claire :)


_________________________________________________________________
MSN Search, le moteur de recherche qui pense comme vous ! http://search.fr.msn.be


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

Reply via email to