Hello Vincent thanks again, At the moment I've decided to call JSVGCanvas.setSVGDocument() only once, every next time I'm just getting an existing doc with JSVGCanvas.getSVGDocument() and updating it through DOM API, and JSVGCanvas is drawing ok. This is closer to our real use case, where JSVGCanvas will be asked periodically to load a layout from an external URI (or SVGGraphics2D will generate an initial SVGDocument), and then a resulting SVGDocument instance will be manipulated for finer updates.
Cheers Sergey Beryozkin ----- Original Message ----- From: "Vincent Hardy" <[EMAIL PROTECTED]> To: "Batik Users" <[EMAIL PROTECTED]> Sent: Thursday, December 12, 2002 3:07 PM Subject: Re: Basic question on JSvgCanvas > Hello Siarhei, > > I think you are running into a bug that Nicolas fixed on > SVGGElementBridge. Try updating with the later CVS (the fix was in > SVGGElementBridge and happened after beta4b). > > http://cvs.apache.org/viewcvs.cgi/xml-batik/sources/org/apache/batik/bridge/ SVGGElementBridge.java.diff?r1=1.20&r2=1.21 > > > Vincent. > > Siarhei Biarozkin wrote: > > Hello Vincent, > > > > Thank you for the help, I've already managed (:-)) to compile my code > > yesterday with the help of Randy, however, > > I'm (or my code :-)) now keep catching ClassCastExceptions exceptions : > > > > // complete class definition: > > public class SvgView extends JSVGCanvas { > > SVGDocument docSvg; > > SVGGraphics2D gSvg; > > public SvgView() { > > // create SvgDocument and SVGGraphics2D as shown in example > > DOMImplementation impl = > > SVGDOMImplementation.getDOMImplementation(); > > docSvg = (SVGDocument)impl.createDocument > > (SVGDOMImplementation.SVG_NAMESPACE_URI, > > "svg", null); > > gSvg = new SVGGraphics2D(docSvg); > > } > > > > // next method is called from elsewhere > > public void updateSvg(FileLayout layout) { > > //layout.draw(gSvg); > > Element root = docSvg.getDocumentElement(); > > gSvg.getRoot(root); > > setSVGDocument(docSvg); > > > > repaint() > > } > > } > > > > All I'm doing at this stage in updateSvg() method is repopulating an svg > > document's document element (it's empty at this stage) and resetting it in > > the canvas. > > The method the second time it runs on setSVGDocument(docSvg) with > > ClassCastException > > at org.apache.batik.bridge.SVGElementBridge.handleDOMNodeInsertedEvent... > > > > Perhaps I need to delete all children (and attributes ?) of SvgDocument's > > doc element every time before calling > > gSvg.getRoot(root); ? > > > > Any suggestions will be appreciated > > Cheers > > Sergey Beryozkin > > > > ----- Original Message ----- > > From: "Vincent Hardy" <[EMAIL PROTECTED]> > > To: "Batik Users" <[EMAIL PROTECTED]> > > Sent: Thursday, December 12, 2002 11:10 AM > > Subject: Re: Basic question on JSvgCanvas > > > > > > > >>Hello Sergey, > >> > >>You must be using an older version of Batik if you cannot compile the > >>version of getRoot() that takes an argument. That was added in Batik > >>1.4beta3: > >> > >> > > > > http://cvs.apache.org/viewcvs.cgi/xml-batik/sources/org/apache/batik/svggen/ > > SVGGraphics2D.java > > > >>If you update to using 1.5beta4b, you should be able to compile, > >>Vincent. > >> > >>Siarhei Biarozkin wrote: > >> > >>>Thanks Randy, > >>>Unfortunately, for some reasons beyond my understanding, the line (2) > >>>doesn't compile > >>> > >>>Element root = doc.getDocumentElement(); (1) > >>>g.getRoot(root); (2) > >>> > >>>I really have no idea why the compilation fails, there's only one Batik > >>>distribution on my system, I'm not using CLASSPATH at all, etc. > >>>Has someone else seen something similar before ? > >>>Cheers > >>>Sergey Beryozkin > >>> > >>> > >>>----- Original Message ----- > >>>From: "Baron, Randy {PRG~Basel}" <[EMAIL PROTECTED]> > >>>To: "Batik Users" <[EMAIL PROTECTED]> > >>>Sent: Wednesday, December 11, 2002 5:17 PM > >>>Subject: RE: Basic question on JSvgCanvas > >>> > >>> > >>>Hm, I have to admit I'm not exactly an svg or java guru. I just had > >>>been reading the archives because I'm working on svg too and thought > >>>that the article I mentioned to you might have helped. > >>> Otherwise, what about running the code > >>>http://xml.apache.org/batik/svggen.html#view ? It uses the same call. > >>>I just tried it on my machine (after sticking inside a 'main' method) > >>>and it ran without a problem; drew red,green and blue circles. If it > >>>doesn't work, maybe the problem is outside of your code somewhere. > >>> > >>>-Randy > >>> > >>> > >>> > >>>-----Original Message----- > >>>From: Siarhei Biarozkin [mailto:[EMAIL PROTECTED]] > >>>Sent: Wednesday, December 11, 2002 5:42 PM > >>>To: Batik Users > >>>Subject: Re: Basic question on JSvgCanvas > >>> > >>>Hi Randy > >>>Thanks for the help, that example is the one which I actually looked at > >>>http://xml.apache.org/batik/svggen.html#view when building my code. > >>>I think my code does follow the guidelines, the only missing step is the > >>>one > >>>where an SVGDocument's instance is populated with an svg dom , > >>>docSvg.getRoot(Element), because this method doesn't compile, any ideas > >>>why > >>>it doesn't ( please see below an error message) ? > >>>I'll try to populate SvgDocument using > >>>docSvg.importNode(SvgGraphics2D.getRoot()), may it will help. > >>>Cheers > >>>Sergey Beryozkin > >>> > >>>P.S. Below is an message on SVGGraphics2D.getRoot(Element); > >>>SVGGraphics2D.getRoot() compiles ok > >>> > >>>com/zandar//SVGView.java [41] getRoot() in > >>>org.apache.batik.svggen.SVGGraphics2D cannot be applied to > >>>(org.w3c.dom.Element) > >>> Element gRoot = gSvg.getRoot(docSvg.getDocumentElement()); > >>> ^ > >>>1 error > >>>build.xml [29] Compile failed, messages should have been provided. > >>> > >>>----- Original Message ----- > >>>From: "Baron, Randy {PRG~Basel}" <[EMAIL PROTECTED]> > >>>To: "Batik Users" <[EMAIL PROTECTED]> > >>>Sent: Wednesday, December 11, 2002 4:23 PM > >>>Subject: RE: Basic question on JSvgCanvas > >>> > >>> > >>>Hi Seregy, > >>> Maybe this thread from the archive is relevant to what you want?: > >>> > >>>http://koala.ilog.fr/batik/mlists/batik-users/archives/msg01828.html > >>> > >>>-Randy > >>> > >>>-----Original Message----- > >>>From: Siarhei Biarozkin [mailto:[EMAIL PROTECTED]] > >>>Sent: Wednesday, December 11, 2002 4:29 PM > >>>To: [EMAIL PROTECTED] > >>>Subject: Basic question on JSvgCanvas > >>> > >>>Hello > >>>Apologies if the question has been answered before, I've found no > >>>relevant > >>>info in archives. > >>>My basic question is how to make JSvgCanvas to show an svg content > >>>generated > >>>by SvgGraphics2D. I'm working at Windows XP, with JDK 1.4.1 > >>>Particularly, I'm using both classes the following way : > >>>I've a subclass of JSvgCanvas, and here its fragment : > >>> > >>>class SvgView extends JSvgCanvas { > >>> SVGGraphics2D gSvg; > >>> SVGDocument docSvg; > >>> > >>> public SvgView() { > >>> > >>> // initialize SVGGraphics2D, as shown at Batik's Generator page > >>> DOMImplementation impl = > >>>SVGDOMImplementation.getDOMImplementation(); > >>> docSvg = (SVGDocument)impl.createDocument > >>>(SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", null); > >>> gSvg = new SVGGraphics2D(docSvg); > >>> } > >>> > >>> public void paintComponent(Graphics g) { > >>> // first, let application components draw themselves as usual > >>>into > >>>SVGGraphics2D > >>> activeComponent.draw(gSvg); > >>> > >>> Element root = docSvg.getDocumentElement(); > >>> // the following line doesn't compile > >>> // getRoot() can't be applied to org.w3.dom.Element > >>> // looks like getRoot(Element) method doesn't exist ?? > >>> gSvg.getRoot(root); > >>> > >>> setSVGDocument(docSvg); > >>> > >>> // finally, draw itself > >>> super.paintComponent(g); > >>> } > >>>} > >>> > >>> > >>> } > >>>} > >>> > >>>The result is that Svg graphics is not drawn, > >>> > >>> > >>>Can you please tell me what am I missing in the code ? > >>>Thanks > >>>Seregy Beryozkin > >>> > >>> > >>>--------------------------------------------------------------------- > >>>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>>For additional commands, e-mail: [EMAIL PROTECTED] > >>> > >>> > >>>--------------------------------------------------------------------- > >>>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>>For additional commands, e-mail: [EMAIL PROTECTED] > >>> > >>> > >>> > >>> > >>> > >>>--------------------------------------------------------------------- > >>>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>>For additional commands, e-mail: [EMAIL PROTECTED] > >>> > >>> > >>>--------------------------------------------------------------------- > >>>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>>For additional commands, e-mail: [EMAIL PROTECTED] > >>> > >>> > >>> > >>> > >>> > >>>--------------------------------------------------------------------- > >>>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>>For additional commands, e-mail: [EMAIL PROTECTED] > >>> > >>> > >> > >> > >> > >>--------------------------------------------------------------------- > >>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > >> > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
