当前位置: 首页>>代码示例>>Java>>正文


Java SVGGraphics2DIOException.printStackTrace方法代码示例

本文整理汇总了Java中org.apache.batik.svggen.SVGGraphics2DIOException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java SVGGraphics2DIOException.printStackTrace方法的具体用法?Java SVGGraphics2DIOException.printStackTrace怎么用?Java SVGGraphics2DIOException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.batik.svggen.SVGGraphics2DIOException的用法示例。


在下文中一共展示了SVGGraphics2DIOException.printStackTrace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: export

import org.apache.batik.svggen.SVGGraphics2DIOException; //导入方法依赖的package包/类
public void export(JComponent component, File file) {
    if (component == null || file == null)
        throw new IllegalArgumentException();

    String fileName = file.getAbsolutePath();

    if (!fileName.endsWith(".svg"))
        fileName += ".svg";

    // Get a DOMImplementation.
    DOMImplementation domImpl = GenericDOMImplementation
            .getDOMImplementation();

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

    SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(doc);
    ctx.setComment("Generated by MuLaViTo with Batik SVG");
    SVGGraphics2D svgGenerator = new SVGGraphics2D(ctx, false);

    // Prepare export: Exchange background color.
    Color c = component.getBackground();
    component.setBackground(Color.WHITE);
    component.paint(svgGenerator);
    component.setBackground(c);

    // Modify export.
    svgGenerator.setSVGCanvasSize(component.getSize());

    // Export.
    try {
        svgGenerator.stream(fileName);
    } catch (SVGGraphics2DIOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:liruixpc11,项目名称:crucian,代码行数:38,代码来源:SVGExporter.java

示例2: export

import org.apache.batik.svggen.SVGGraphics2DIOException; //导入方法依赖的package包/类
public void export(JComponent component, File file) {
	if (component == null || file == null)
		throw new IllegalArgumentException();

	String fileName = file.getAbsolutePath();

	if (!fileName.endsWith(".svg"))
		fileName += ".svg";

	// Get a DOMImplementation.
	DOMImplementation domImpl = GenericDOMImplementation
			.getDOMImplementation();

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

	SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(doc);
	ctx.setComment("Generated by MuLaViTo with Batik SVG");
	SVGGraphics2D svgGenerator = new SVGGraphics2D(ctx, false);

	// Prepare export: Exchange background color.
	Color c = component.getBackground();
	component.setBackground(Color.WHITE);
	component.paint(svgGenerator);
	component.setBackground(c);

	// Modify export.
	svgGenerator.setSVGCanvasSize(component.getSize());

	// Export.
	try {
		svgGenerator.stream(fileName);
	} catch (SVGGraphics2DIOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:fabe85,项目名称:Alevin,代码行数:38,代码来源:SVGExporter.java

示例3: convert

import org.apache.batik.svggen.SVGGraphics2DIOException; //导入方法依赖的package包/类
/**
     * Converts {@code RandomSignature} to {@code Signature}.
     * @param randomSignature    random signature
     * @return {@code Signature} object
     */
    private Signature convert(RandomSignature randomSignature) {
        Signature signature = new Signature();

        /* Birth date */
        Date tmpBirthDate = randomSignature.getPerson().dateOfBirth().toDate();
        LocalDate birthDate = tmpBirthDate
                .toInstant()
                .atZone(ZoneId.systemDefault())
                .toLocalDate();

        /* Address */
        Address adr = randomSignature.getPerson().getAddress();
        String address = adr.streetNumber() + ", " + adr.street() + ", "
                + adr.getPostalCode() + ", " + adr.getCity();

        /* Signature date */
        // TODO: fix signature date
//        Date tmpSignatureDate = randomSignature.getSignatureDate().toDate();
//        LocalDate signatureDate = tmpSignatureDate
//                .toInstant()
//                .atZone(ZoneId.systemDefault())
//                .toLocalDate();

        signature.setFirstName(randomSignature.getPerson().firstName());
        signature.setLastName(randomSignature.getPerson().lastName());
        signature.setBirthDate(birthDate);
        signature.setAddress(address);
        signature.setIdCardNumber(randomSignature.getPerson().nationalIdentityCardNumber());

        // TODO: set sign
        Document document = domImpl.createDocument(
                BatikConfig.SVG_NAMESPACE_URI, "svg", null);

        SVGGraphics2D graphics = new SVGGraphics2D(document);
        graphics.draw(randomSignature.getSign());

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        OutputStreamWriter writer = new OutputStreamWriter(out);

        String xml = "";

        try {
            graphics.stream(writer);
            xml = new String(out.toByteArray());
        } catch (SVGGraphics2DIOException e) {
            e.printStackTrace();
        }

        SignSvg sign = new SignSvg();
        sign.setData(xml);

        signature.setSign(sign);

        return signature;
    }
 
开发者ID:hosuaby,项目名称:signature-processing,代码行数:61,代码来源:SignatureInboxProducer.java


注:本文中的org.apache.batik.svggen.SVGGraphics2DIOException.printStackTrace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。