how to capture graphics primitives from Graphics2D into SVG

徘徊边缘 提交于 2019-12-23 00:24:09

问题


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.


回答1:


I would have a look at the Batik project which provides an extension of Graphics2D to output SVG files.




回答2:


JFreeSVG is another option to consider, it provides a fast lightweight implementation of the Graphics2D API.



来源:https://stackoverflow.com/questions/9989256/how-to-capture-graphics-primitives-from-graphics2d-into-svg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!