xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dylan Browne" <dy...@mango-solutions.com>
Subject RE: Using getBBox()
Date Wed, 11 Apr 2007 08:21:18 GMT
Thanks Tonny, that was it exactly. Just for anyone's future reference, the
working code is included below.

Thanks again.

---------------------------------

    public BBoxTest() {
    	DOMImplementation impl =
SVGDOMImplementation.getDOMImplementation();
    	SVGDocument doc = (SVGDocument)
impl.createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", null);
    	UserAgent userAgent = new UserAgentAdapter();
    	DocumentLoader loader    = new DocumentLoader(userAgent);
    	BridgeContext ctx       = new BridgeContext(userAgent, loader);
        ctx.setDynamicState(BridgeContext.DYNAMIC);
        GVTBuilder builder   = new GVTBuilder();
        builder.build(ctx, doc);
      
        Text header = doc.createTextNode("Hello");
        Element text =
doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
SVG12Constants.SVG_TEXT_TAG);
        text.setAttributeNS(null, "x", "100");
        text.setAttributeNS(null, "y", "100");
        text.setAttributeNS(null, "fill", "orange");
        text.setAttributeNS(null, "font-family", "verdana");
        text.setAttributeNS(null, "font-weight", "bold");
        text.setAttributeNS(null, "font-size", "20");
        text.appendChild(header);
        doc.getDocumentElement().appendChild(text);
                
        SVGRect rect = ((SVGLocatable)text).getBBox();
    
        System.out.println("X: " + rect.getX() + "\nY: " + rect.getY() +
"\nHeight: " + rect.getHeight() + "\nWidth: " + rect.getWidth());    
    }


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


Mime
View raw message