I did find some references to these things in the archive, but could not
see a comprehensive discussion.

The background to this question is the desire to use Java2D to render
page layouts for an implementation of the XSL-FO Recommendation. What I
am hoping to do is take advantage of the Java2D facilities, especially
the text rendering facilities, to layout pages for a number of possible
output formats, the foremost of which is PDF, but including on-screen
display, Postscript, SVG, and possibly others. I am encouraged in this
by the availability of non-screen Java2D renditions in some existing
software.

Apache Batik provides SVGGraphics2D to generate SVG from J2D drawing and
text rendering primitives. SVGGraphics2D indirectly extends Graphics2D,
and in the process provides a FontRenderContext, which is generated
directly in a utility class.

To provide PDF output, Batik relies on a PDF transcoder in FOP. FOP
provides PDFGraphicsDevice (PDFGrDevice) extending GraphicsDevice,
PDFGraphicsConfiguration (PDFGrConfig) extending GraphicsConfiguration,
and PDFGraphics2D (PDFGr2D) extending Graphics2D.

PDFGrConfig has a default constructor. The PDFGrDevice constructor
requires an instance of PDFGrConfig, which it will return when queried.
PDFGrConfig returns a new instance of PDFGrDevice from the getDevice()
method.

When queried, PDFGr2D returns a new instance of PDFGrConfig. The
FontRenderContext it provides is the same one being provided by
SVGGraphics2D.

iText also provides a PdfGraphics2D class which extends Graphics2D, but
the implementation is simpler than Batik/FOP. It has a package-visible
constructor particular to iText's requirements. Internally,
PdfGraphics2D derives a Graphics2D object from a BufferedImage. This G2D
provides GraphicsConfiguration as requested. FontRenderContext is
generated directly.

When I was first looking at using Graphics2D for PDF and other
rendering, I was nonplussed by the seeming circularity of the
definitions.  There was apparently no way to introduce a new
GraphicsDevice, which is what I needed. I was equally startled to see
the way this was being done, ex nihilo, by Batik/FOP and iText, and in
quite different ways.

Are these methods kosher? What problems, if any, are they likely to
throw up? Is there a recommended way to extend these classes? If so,
where is it documented?

What strikes me about these examples and my own requirement is that they
represent a far broader vision of the use of 2D graphics in Java than
seems to be present at Sun.  And this broader vision is not restricted
to these examples.

Thanks
Peter
--
Peter B. West <http://cv.pbw.id.au/>
Folio <http://defoe.sourceforge.net/folio/>
---
[This E-mail has been scanned for viruses but it is your responsibility
to maintain up to date anti virus software on the device that you are
currently using to read this email. ]

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to