Hi,
   Maybe you have to wait until the rendereing is completed in order to
call the getWidth() function?  I had a similar problem and solved it by
sticking the code inside a GVTTreeRendererAdapter, something like:
GVTTreeRendererAdapter gvtadap =  new GVTTreeRendererAdapter() {
       public void gvtRenderingCompleted(GVTTreeRendererEvent e) {
           RunnableQueue rq =
someCanvas.getUpdateManager().getUpdateRunnableQueue();
           if (rq != null) {
              rq.invokeLater(new Runnable() {
                 public void run() {
                      // do your getWidth call here.
                 }
              });
           }
       }
}

-Randy

-----Original Message-----
From: john doe [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 30, 2003 12:18 PM
To: [EMAIL PROTECTED]
Subject: bbox.getWidth() problem


Hello,

I'm developing a java web application which generates
svg using Batik's SVG DOM library. 
Therefore I need to get the width of text elements to
wrap text dynamically while generating the svg
document.
The problem is that when I try to get the bounding box
of a text element a NullPointerException is thrown.

Here is the part of my source code which throws the
exception:
...
if (textElement instanceof SVGLocatable) {
SVGRect bbox = ((SVGLocatable)textElement).getBBox();
System.out.println(bbox.getWidth()); // <-- exception
}
...

Here is the interesting part of the thrown exception:
java.lang.NullPointerException at
org.apache.batik.dom.svg.SVGLocatableSupport$1.getWidth(Unknown
Source)
....

Any help and suggestions to solve the problem is
greatly appreciated!

Thanks,
Stefan

__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/

---------------------------------------------------------------------
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]

Reply via email to