Hi Ruben,
   Sorry w/o knowing what SvgUtil.setSvgAttribute does it's hard to know for 
sure but the
raw 'setAttributeNS' version looks good to me so if the SvgUtil version was 
different that may be it.

   Thomas

On Oct 18, 2012, at 6:57 AM, rm <ruben.malc...@googlemail.com> wrote:

> 
> 
> ***cough*** it seems to work now … if somebody knows why? this is the same 
> code after fiddling with it:
> 
> something about attribute namespaces?
> 
> 
>                       DOMImplementation domImpl = new SVGDOMImplementation();
>                       SVGDocument svg = (SVGDocument) domImpl.createDocument(
>                                       SvgNamespaceContext.SVG_NS_URI,
>                                       SvgNamespaceContext.SVG_NS_PREFIX, 
> null);
> 
>                       SVGGraphics2D graphics = new SVGGraphics2D(svg);
>                       UserAgent userAgent = new UserAgentAdapter();
>                       DocumentLoader loader = new DocumentLoader(userAgent);
>                       BridgeContext ctx = new BridgeContext(userAgent, 
> loader);
>                       ctx.setDynamicState(BridgeContext.DYNAMIC);
>                       GVTBuilder builder = new GVTBuilder();
>                       GraphicsNode rootGN = builder.build(ctx, svg);
> 
>                       // create a G node
>                       Element g = 
> svg.createElementNS(SvgNamespaceContext.SVG_NS_URI,SVG12Constants.SVG_G_TAG);
>                       g.setAttributeNS(null,"id", "test-g");
>                       svg.getDocumentElement().appendChild(g);
>                       
>                       Element n = 
> svg.createElementNS(SvgNamespaceContext.SVG_NS_URI,SVG12Constants.SVG_RECT_TAG);
>                       n.setAttributeNS(null,"id", "test-rect");
>                       n.setAttributeNS(null,"x", "5");
>                       n.setAttributeNS(null,"y", "15");
>                       n.setAttributeNS(null,"width", "300");
>                       n.setAttributeNS(null,"height", "150");
>                       n.setAttributeNS(null,"fill", "orange");
>                       n.setAttributeNS(null,"transform", "rotate(10,4,2)");
>                       g.appendChild(n);
> 
>                       System.err.println(" ========> g 
> "+((SVGLocatable)g).getBBox().getWidth());
>                       System.err.println(" ========> g 
> "+((SVGLocatable)g).getBBox().getHeight());
>                       System.err.println(" ========> r 
> "+((SVGLocatable)n).getBBox().getWidth());
>                       System.err.println(" ========> r 
> "+((SVGLocatable)n).getBBox().getHeight());
> 
>                       System.err.println();
>                       XmlUtil.transform(svg, System.err);
>                       System.err.println();
>                       
>                       ByteArrayOutputStream baos = new 
> ByteArrayOutputStream();
>                       XmlUtil.transform(ctx.getDocument(), baos);
>                       
>                       dByte = baos.toByteArray();
>                       
>                       
>                       System.err.flush(); 

Reply via email to