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 Larry Riedel <la...@saturn.sdsu.edu> on 2002/07/09 22:36:09 UTC

Question: SVG -> Batik -> ??? Vector Format

I want to find the best place to hook a new class into
Batik so it can output a representation of the shapes in an
SVG document in a different vector style format, with any
hierarchical transformations already applied before the new
class gets involved.

I am hoping to hook in at a place where the new class can
be most decoupled from knowledge of SVG and the architecture
of Batik, but get the most out of Batik's facilities
for interpreting an SVG document and generating a graphical
representation of it

I am hoping Batik can take care of the hierarchy of
transformations that may need to be applied to an object
before it is drawn, so perhaps all I would need to do is
implement an interface which has operations like
drawPolygon(xpoints, ypoints, flattenedTransform)
drawRect(x, y, width, height, flattenedTransform).

The class producing the output might do something like
represent every shape as a list of x,y coordinates which
can be used to draw a polygonal approximation of the
outline of the shape.


Larry


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


Re: Question: SVG -> Batik -> ??? Vector Format

Posted by Vincent Hardy <vi...@sun.com>.
Larry,

I think a good way to go about what you want to do is to implement a
new version of the Graphics2D abstract class. Batik offers a 
number of helper classes for this (see the org.apache.batik.ext.awt.g2d
package). This is what Keiron's FOP PDFGraphics2D (in
org.apache.fop.svg) uses these helper classes:

http://cvs.apache.org/viewcvs.cgi/xml-fop/src/org/apache/fop/svg/PDFGraphics2D.java

and this is what we use for the SVG generator:

http://cvs.apache.org/viewcvs.cgi/xml-batik/sources/org/apache/batik/svggen/SVGGraphics2D.java

Implementing a new Graphics2D has the advantage of not requiring any
SVG work. Then, you can render an SVG document into your Graphics2D
implementation, which in effect will convert your SVG document to 
whatever format you are outputing (to do this, you'll have to load
the SVG document, use the GVT builder to turn the SVG document into
a GVT tree, and render that tree into your Graphics2D).

Good luck,
Vincent.

Larry Riedel wrote:
> 
> I want to find the best place to hook a new class into
> Batik so it can output a representation of the shapes in an
> SVG document in a different vector style format, with any
> hierarchical transformations already applied before the new
> class gets involved.
> 
> I am hoping to hook in at a place where the new class can
> be most decoupled from knowledge of SVG and the architecture
> of Batik, but get the most out of Batik's facilities
> for interpreting an SVG document and generating a graphical
> representation of it
> 
> I am hoping Batik can take care of the hierarchy of
> transformations that may need to be applied to an object
> before it is drawn, so perhaps all I would need to do is
> implement an interface which has operations like
> drawPolygon(xpoints, ypoints, flattenedTransform)
> drawRect(x, y, width, height, flattenedTransform).
> 
> The class producing the output might do something like
> represent every shape as a list of x,y coordinates which
> can be used to draw a polygonal approximation of the
> outline of the shape.
> 
> Larry
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org

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