I need to capture the graphics primitives from calls to java.awt.Graphics2D. The calls are made through an Open Source toolkit (Apache's PDFBox) and normally rendered in a JPanel. I would like to intercept these calls and translate them to SVG so I can build a non-graphics data model (e.g. tables, graphs, etc.). I'll be happy for any type of hack at this stage, which might include:
- replacing the Graphics2D library with MyGraphics2D
- Finding a Graphics2D that supported SVG output and capturing that
- intercepting the calls to Graphics2D (I'd prefer not because I have to manage the affine transformations)
Subsidiary question: Does Graphics2D use the Graphics library? In which case if I capture at this level the transformations should have been applied.
JFreeSVG is another option to consider, it provides a fast lightweight implementation of the Graphics2D API.
I would have a look at the Batik project which provides an extension of Graphics2D to output SVG files.