Thomas DeWeese wrote:

Yes, but you need to build this with the associated GVT tree. Here you have two options.

1) Build it as a 'dynamic' document so as you
   append elements it will automatically build
   the rendering tree version and the geometric
   information will be immediately available.
2) Build the whole 'basic' document first then
   build the rendering tree as a whole and make
   a second pass through the DOM creating the
   rectangles.

#2 is faster but #1 is probably simpler code.
To find out how to build the associated rendering tree
(GVT) you should look at the slideshow application.
(batik.app.slideshow).

I was wondering, if I could use a simpler workaround, but ended up at another problem. First the workaround:
I create a java.awt.Font with the same (as far as I know) parameters, I give to the SVG DOM. After that, the variable "bounds" should contain the boundingbox of the Text, but in fact it is smaller. Here the code:


String title="something";
Font f = new Font("SansSerif",Font.PLAIN,12);
Rectangle2D bounds = f.getStringBounds(title,new FontRenderContext(null,true,true));


// the text-element
Element text = doc.createElementNS(svgNS,"text");
...
text.setAttributeNS(null,"font-family","sans-serif");
text.setAttributeNS(null,"font-size","12pt");
Text textNode = doc.createTextNode(title);
text.appendChild(textNode);

Can you guess why?

Thank you very much,

tjorven


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



Reply via email to