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


Java SVGGraphics2DIOException类代码示例

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


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

示例1: generateSVG

import org.apache.batik.svggen.SVGGraphics2DIOException; //导入依赖的package包/类
/**
 * Create a SVG image. The image handler will write all images files to
 * "res/images".
 *
 * @param p the drawable component.
 * @param outStream the the output stream.
 * @throws UnsupportedEncodingException error on unsupported encoding.
 * @throws SVGGraphics2DIOException error on error to conversion.
 */
private void generateSVG(Drawable p, OutputStream outStream) throws UnsupportedEncodingException, SVGGraphics2DIOException {
    DOMImplementation domImpl
            = GenericDOMImplementation.getDOMImplementation();
    String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
    Document myFactory = domImpl.createDocument(svgNS, "svg", null);
    SVGGeneratorContext ctx
            = SVGGeneratorContext.createDefault(myFactory);
    GenericImageHandler ihandler = new CachedImageHandlerPNGEncoder("res/images", null);
    ctx.setGenericImageHandler(ihandler);

    SVGGraphics2D svgGenerator = new SVGGraphics2D(ctx, false);

    TurtleState ts = new TurtleState();

    p.draw(svgGenerator, ts);
    // Create the SVG DOM tree.
    Writer out = new OutputStreamWriter(outStream, "UTF-8");
    svgGenerator.stream(out, true);
}
 
开发者ID:ZenHarbinger,项目名称:torgo,代码行数:29,代码来源:LogoMenuBar.java

示例2: Dimension

import org.apache.batik.svggen.SVGGraphics2DIOException; //导入依赖的package包/类
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;
}
 
开发者ID:sih4sing5hong5,项目名称:han3_ji7_tsoo1_kian3,代码行数:22,代码来源:IDSrendService.java

示例3: generateGIF

import org.apache.batik.svggen.SVGGraphics2DIOException; //导入依赖的package包/类
/**
 * Create an animated GIF.
 *
 * @param p the drawable component.
 * @param canvas the canvas.
 * @param filename the file to write to.
 * @throws UnsupportedEncodingException error on unsupported encoding.
 * @throws SVGGraphics2DIOException error on error to conversion.
 * @throws IOException error writing to file.
 */
private void generateGIF(final Drawable p, final BufferedImageProvider canvas, String filename) throws UnsupportedEncodingException, SVGGraphics2DIOException, IOException {
    final ImageOutputStream output = new FileImageOutputStream(new File(filename));
    final GifSequenceWriter writer = new GifSequenceWriter(output, canvas.getBufferedImage().getType(), 1, true);

    final BufferedImage image = canvas.getBufferedImage();

    final Graphics2D g2d = image.createGraphics();
    DrawListener dl = (Drawable sender) -> {
        try {
            writer.writeToSequence(image);
        } catch (IOException ex) {
        }
    };
    p.addListener(dl);

    TurtleState ts = new TurtleState();
    ts.width = image.getWidth();
    ts.height = image.getHeight();

    p.draw(g2d, ts);
    writer.close();

    p.removeListener(dl);
    org.tros.utils.logging.Logging.getLogFactory().getLogger(LogoMenuBar.class).info("{0} animation is complete!", filename);
    JOptionPane.showMessageDialog(parent, MessageFormat.format("{0} animation is complete!", filename), "Animated GIF Sequence Complete", JOptionPane.INFORMATION_MESSAGE);
}
 
开发者ID:ZenHarbinger,项目名称:torgo,代码行数:37,代码来源:LogoMenuBar.java

示例4: outputToSVG

import org.apache.batik.svggen.SVGGraphics2DIOException; //导入依赖的package包/类
/**
 *
 * @param file
 */
public void outputToSVG(File file) {

    // Get a DOMImplementation.
    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);

    // Create an instance of the SVG Generator.
    SVGGraphics2D svgGenerator = new SVGGraphics2D(document);

    // Ask the test to render into the SVG Graphics2D implementation.
    paint(svgGenerator);

    // Finally, stream out SVG to the standard output using
    // UTF-8 encoding.
    boolean useCSS = true; // we want to use CSS style attributes

    Writer out = null;
    try {
        out = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
    } catch (FileNotFoundException fileNotFoundException) {
    } catch (UnsupportedEncodingException unsupportedEncodingException) {
    }
    try {
        svgGenerator.stream(out, useCSS);
    } catch (SVGGraphics2DIOException sVGGraphics2DIOException) {
    }
}
 
开发者ID:CIRDLES,项目名称:ET_Redux,代码行数:36,代码来源:DateProbabilityDensityPanel.java

示例5: outputToSVG

import org.apache.batik.svggen.SVGGraphics2DIOException; //导入依赖的package包/类
/**
 *
 * @param file
 */
public void outputToSVG(File file) {

    // Get a DOMImplementation.
    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);

    // Create an instance of the SVG Generator.
    SVGGraphics2D svgGenerator = new SVGGraphics2D(document);

    // Ask the test to render into the SVG Graphics2D implementation.
    paint(svgGenerator, false);

    // Finally, stream out SVG to the standard output using
    // UTF-8 encoding.
    boolean useCSS = true; // we want to use CSS style attributes

    Writer out = null;
    try {
        out = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
    } catch (FileNotFoundException | UnsupportedEncodingException fileNotFoundException) {
    }
    try {
        svgGenerator.stream(out, useCSS);
    } catch (SVGGraphics2DIOException sVGGraphics2DIOException) {
        System.out.println(sVGGraphics2DIOException.getMessage());
    }

    // aug 2013
    // read svg file back in to add clip size to comments
}
 
开发者ID:CIRDLES,项目名称:ET_Redux,代码行数:39,代码来源:ConcordiaGraphPanel.java

示例6: outputToSVG

import org.apache.batik.svggen.SVGGraphics2DIOException; //导入依赖的package包/类
/**
 *
 * @param file
 */
public void outputToSVG(File file) {

    // Get a DOMImplementation.
    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);

    // Create an instance of the SVG Generator.
    SVGGraphics2D svgGenerator = new SVGGraphics2D(document);

    // Ask the test to render into the SVG Graphics2D implementation.
    paint(svgGenerator);

    // Finally, stream out SVG to the standard output using
    // UTF-8 encoding.
    boolean useCSS = true; // we want to use CSS style attributes

    Writer out = null;
    try {
        out = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
    } catch (FileNotFoundException | UnsupportedEncodingException fileNotFoundException) {
    }
    try {
        svgGenerator.stream(out, useCSS);
    } catch (SVGGraphics2DIOException sVGGraphics2DIOException) {
    }

    svgGenerator.dispose();
}
 
开发者ID:CIRDLES,项目名称:ET_Redux,代码行数:37,代码来源:ReportAliquotFractionsView.java

示例7: 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

示例8: 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

示例9: 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

示例10: write

import org.apache.batik.svggen.SVGGraphics2DIOException; //导入依赖的package包/类
/**
 * @param out
 * @throws SVGGraphics2DIOException
 */
public void write(Writer out) throws SVGGraphics2DIOException {
	this.svgGen.stream(out, true);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:8,代码来源:SVGRenderer.java


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