You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Tom Bates <to...@earthlink.net> on 2013/07/28 19:47:14 UTC

How to control grouping with SVGGraphics2D

Hello. First, I’m very impressed with Batik. Yesterday I added the svg generator pieces to a large custom Java graphics application I’ve been working on for years. After a bit of tracking down some where-in-the-jars issues it’s working nicely. Despite my rather complex draw code, I’m now writing out SVG files that I can read into Illustrator, which was my goal. Amazing.

I am having just one issue so far. When one draws say a filled and stroked ellipse in Java, these are two distinct calls to the usual Graphics2D, the drawX call to do the stroke and fillX call to do the fill. Not suprisingly, with these calls going to an SVGGraphics2D this results in two nice entries and Illustrator renders from the SVG file exactly what I see in my Java application. However, because both calls got automatically wrapped in their own group but are not themselves grouped together, Illustrator treats the stroke and the fill as separate objects unlike say an ellipse you draw directly in Illustrator.

So what I’m wondering is, is there a way during drawing to an SVGGraphics2D to insert group nodes around a set of draw calls to the generator so that things that are logically part of a single thing stay that way (Illustrator respects the groups and makes illustrator groups of them).

I see there is a DEFAULT_MAX_GC_OVERRIDES field but it doesn’t look like it is my ticket. I need a programatic way to say begin group/ end group distinct from draw orders to the generator, since obviously the generator itself knows nothing of what is logically one object. Maybe DOMTreeManager is my friend? I’m obviously a newbie to Batik so I’m not at all sure how to accomplish this but it must be possible, hopefully in straightforward way.

Ideally I would also like to be able to suppress the separate grouping of the draw and fill calls and just have a single group containing both.

Thanks,

Tom Bates