I havent touched SVG in java for a while. But a couple
years ago, when i had problems getting the canvas to
be dynamic, I just reset the canvas with dynamic doc I
was building
svgCanvas.setSVGDocument((SVGDocument)doc);

Maybe thats a quick fix just to get results.



--- "Mark A. Jordan" <[EMAIL PROTECTED]> wrote:

> Hello.
> 
> I have successfully created a Java application using
> the sample provided on the
> Batik website (JSVGCanvas tutorial --
> http://xml.apache.org/batik/svgcanvas.html).  Upon
> button click, I have added
> code to get a specific element (by id) and then I
> use the setAttribute method
> to change the "display" attribute to "none" or
> "inline" accordingly (I'm
> toggling between the two values to prove a point).
> 
> My problem is that I don't know how to force the SVG
> image to re-render.  If I
> move the mouse over the SVG, the change is reflected
> in the image, i.e., my
> element appears or disappears accordingly.  I'm
> looking for the magic function
> call to force the render without further action from
> the user.
> 
> I have previously set the document state
> (setDocumentState) of the canvas
> object to ALWAYS_DYNAMIC.
> 
> Here's my code:
> 
> ======================
>                 System.out.println("Rock on...");
>                 Document doc =
> svgCanvas.getSVGDocument();
>                 if(null == doc) {
>                     System.out.println("Didn't get
> the document.");
>                     return;
>                 }
> 
>                 String idToGet = "green";
>                 Element elementToChange =
> svgCanvas.getSVGDocument().getElementById( idToGet
> );
> 
>                 if(null == elementToChange) {
>                     System.out.println("Didn't get
> the '" + idToGet + "'
> elements.");
>                     return;
>                 }
> 
>                 String displayAttr =
> elementToChange.getAttribute("display");
>                 // if attribute is "inline", then
> set to "none"
>                
> if(displayAttr.compareToIgnoreCase("inline") == 0) {
>                     System.out.println("Setting
> display='none' for the '" +
> idToGet + "' element.");
>                    
> elementToChange.setAttribute("display", "none");
>                    
> //elementToChange.removeAttribute("display");
>                 } else {
>                     System.out.println("Setting
> display='inline' for the '" +
> idToGet + "' element.");
>                    
> elementToChange.setAttribute("display", "inline");
>                 }
>                 // this doesn't cause the image to
> appear --
> svgCanvas.repaint();
>                 //svgCanvas.getUpdateManager(). 
> probably something here
> ======================
> 
> Thanks in advance,
> Mark Jordan
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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

Reply via email to