xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Bullock ...@dawnbreaks.net>
Subject Re: Copying/Cloning a GVT CompositeNode.
Date Wed, 26 May 2004 08:50:17 GMT
On Wed, 19 May 2004, Archie Cobbs wrote:

> David Bullock wrote:
> > [I just want to take a 'template shape' from an SVG file,
> > copy it a few times, translate each one, and print it out.
> > If there's a better way to do this than GVT, I'd love to
> > hear your suggestions.  ]
> I don't know if this is any better or worse, but I acomplish this
> same idea (I think) by editing the SVG DOM...
> In the SVG file are the icons which are just invisible nodes defined
> inside the <defs> tag and having "id" attributes with known values.
> Then, using the DOM API, I add append a new <use> to the top level
> <svg> tag like this:
>     SVGElement topNode = ...	// find the top <svg> node
>     ...
>     String iconId = ...		// id of the icon you want to display
>     SVGElement use = (SVGElement)svg.createElementNS(
> 	SVGDOMImplementation.SVG_NAMESPACE_URI, "use");
>     use.setAttributeNS(XPATH_NAMESPACE_URI, "href", "#" + iconId);
>     use.setAttribute("visibility", "visible");
>     use.setAttribute("x", "" + x);
>     use.setAttribute("y", "" + y);
>     topNode.appendChild(use);

Hi Archie,

This method worked well for me, thanks.

I suppose it works well to have a common semantic model (the
SVG DOM) for vector graphics.  I do find W3 DOM's awkward
to work with, but that's the price you pay for using only
IDL-compatible Java idioms, I guess.

The GVTBuilder code, upon encountering a <svg:use/> element,
simply builds a new GraphicsNode corresponding to the target
of the use and the use's translations, thus achieving the same
effect as I intended by cloning a GrahicsNode.


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

View raw message