xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Baron, Randy {PRG~Basel}" <RANDY.BA...@Roche.COM>
Subject RE: bbox.getWidth() problem
Date Thu, 30 Oct 2003 12:08:58 GMT
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:sly2616@yahoo.com] 
Sent: Thursday, October 30, 2003 12:18 PM
To: batik-users@xml.apache.org
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: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Mime
View raw message