Antipin wrote:

//I have a class
//that opens file hz.svg
//I use sVGTextElement.getBBox() to get text Rectangle
//but get incorrect

Hi Antipin,


   I get the correct value.  I suggest you update your
version of Batik (probably to 1.5.1rc2).



package svgeditor.smalleditor;

import javax.swing.*;
import org.apache.batik.swing.gvt.*;
import org.apache.batik.swing.svg.*;
import org.w3c.dom.*;
import org.w3c.dom.svg.*;


public class Debug {


JSVGComponent svgCanvas = new JSVGComponent(null,true,false);

    public Debug(){
                svgCanvas.setDocumentState(JSVGComponent.ALWAYS_DYNAMIC);
                open();
    }

        public static void main(String[] args){
                JFrame frame = new JFrame("SVG");
                Debug deb = new Debug();
                frame.getContentPane().add(deb.svgCanvas);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.pack();
                frame.show();


}


protected void open(){

                svgCanvas.addGVTTreeRendererListener(new GVTTreeRendererAdapter(){
                        public void gvtRenderingCompleted(GVTTreeRendererEvent ev){
                                SVGSVGElement root = 
svgCanvas.getSVGDocument().getRootElement();
                                NodeList list = root.getChildNodes();
                                for(int i = 0; i < list.getLength(); i++){
                                        if(list.item(i) instanceof SVGTextElement){

//must be X:200 !!! but we have X:0
//I think it is bag


                                                System.out.println("X:" + 
((SVGTextElement)list.item(i)).getBBox().getX());
                                        }
                                }
                        }
                });

                svgCanvas.loadSVGDocument("file:hz.svg");
        }
}

//----------------------------------------file:hz.xml------------------------

<svg contentScriptType="text/ecmascript" width="5000"
xmlns:xlink="http://www.w3.org/1999/xlink";
zoomAndPan="magnify" contentStyleType="text/css"
height="300" preserveAspectRatio="xMidYMid meet"
xmlns="http://www.w3.org/2000/svg"; version="1.0">

<text x="201" font-size="12" y="105" font-family="monospaced" xml:space="preserve"><tspan dx="0.0" 
dy="13.0"><tspan>asdasd
</tspan></tspan><tspan dx="-50.408203" dy="17.0"><tspan>asdasd</tspan><tspan>
</tspan></tspan></text></svg>



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