org.apache.batik.svggen.SVGGraphics2DIOException Java Examples

The following examples show how to use org.apache.batik.svggen.SVGGraphics2DIOException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ParseTreeContextualMenu.java    From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void exportToSvg(UberTreeViewer parseTreeViewer, File file, boolean useTransparentBackground) {
    DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
    Document document = domImpl.createDocument("http://www.w3.org/2000/svg", "svg", null);
    SVGGraphics2D svgGenerator = new SVGGraphics2D(document);

    if (!useTransparentBackground) {
        svgGenerator.setColor(JBColor.WHITE);
        svgGenerator.fillRect(0, 0, parseTreeViewer.getWidth(), parseTreeViewer.getHeight());
    }
    parseTreeViewer.paint(svgGenerator);

    try {
        svgGenerator.stream(file.getAbsolutePath(), true);
    } catch (SVGGraphics2DIOException e) {
        Logger.getInstance(ParseTreeContextualMenu.class)
                .error("Error while exporting parse tree to SVG file " + file.getAbsolutePath(), e);
    }
}
 
Example #2
Source File: IDSrendService.java    From han3_ji7_tsoo1_kian3 with GNU Affero General Public License v3.0 6 votes vote down vote up
public void 字組成svg(String 組字式, OutputStream 輸出檔案)
		throws UnsupportedEncodingException, SVGGraphics2DIOException
{
	DOMImplementation domImpl = GenericDOMImplementation
			.getDOMImplementation();

	// Create an instance of org.w3c.dom.Document.
	String svgNS = "http://www.w3.org/2000/svg";
	Document document = domImpl.createDocument(svgNS, "svg", null);

	boolean useCSS = true; // we want to use CSS style
							// attributes
	// Create an instance of the SVG Generator.
	SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
	svgGenerator.setSVGCanvasSize(new Dimension(字型大細, 字型大細));
	組字(組字式, svgGenerator);
	OutputStreamWriter svgOutput = new java.io.OutputStreamWriter(輸出檔案,
			"UTF-8");
	svgGenerator.stream(svgOutput, useCSS);
	return;
}