我有一个 SVG 图像(一个国家的地图),我正在尝试在其顶部添加一个 JfreeChart,它将在特定位置显示 3d 条。有人可以帮助指出我如何将 JfreeChart 添加到现有的 SVG 图像中。
以下是到目前为止的代码
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory sax = new SAXSVGDocumentFactory(parser);
String uri = "file:///F://WorldMap.svg";
SVGDocument doc = sax.createSVGDocument(uri);
SVGGraphics2D my_svg_generator = new SVGGraphics2D(doc);
// Create a converter for this document.
SVGGraphics2D g = new SVGGraphics2D(doc);
//got a JfreeChart from a static method depending on data
JFreeChart chart = createChart(createDataset());
//I can add up normal nodes
Element svgRoot = doc.getDocumentElement();
svgRoot.appendChild(doc.createElementNS("http://www.w3.org/2000/svg", "rect"));
我尝试将 Jfreechart 转换为 Bytes 并使用 g.drawBytes() 但它会在 SVG 顶部呈现一些垃圾。
如果有人可以提供帮助,将不胜感激。