當前位置: 首頁>>代碼示例>>Java>>正文


Java GenericDOMImplementation.getDOMImplementation方法代碼示例

本文整理匯總了Java中org.apache.batik.dom.GenericDOMImplementation.getDOMImplementation方法的典型用法代碼示例。如果您正苦於以下問題:Java GenericDOMImplementation.getDOMImplementation方法的具體用法?Java GenericDOMImplementation.getDOMImplementation怎麽用?Java GenericDOMImplementation.getDOMImplementation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.batik.dom.GenericDOMImplementation的用法示例。


在下文中一共展示了GenericDOMImplementation.getDOMImplementation方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeSVG

import org.apache.batik.dom.GenericDOMImplementation; //導入方法依賴的package包/類
private void writeSVG(OutputStream stream) throws IOException {
    DOMImplementation impl = GenericDOMImplementation
            .getDOMImplementation();
    String svgNS = "http://www.w3.org/2000/svg";
    Document myFactory = impl.createDocument(svgNS, "svg", null);

    SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(myFactory);
    ctx.setEmbeddedFontsOn(Options.getBoolean("EMBEDDED_SVG_FONTS", true));
    SVGGraphics2D svgGenerator = new SVGGraphics2D(ctx, Options.getBoolean(
            "EMBEDDED_SVG_FONTS", true));

    svgGenerator.setSVGCanvasSize(size);

    paint(svgGenerator, 0, 0);

    boolean useCSS = true;
    Writer out = new OutputStreamWriter(stream, "UTF-8");
    svgGenerator.stream(out, useCSS);

}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:21,代碼來源:PIDEF0painter.java

示例2: exportChartAsSVG

import org.apache.batik.dom.GenericDOMImplementation; //導入方法依賴的package包/類
/**
 * Exports a JFreeChart to a SVG file.
 *
 * @param chart JFreeChart to export
 * @param bounds the dimensions of the viewport
 * @param svgFile the output file.
 * @throws IOException if writing the svgFile fails.
 */
public static void exportChartAsSVG(
        JFreeChart chart,
        Rectangle bounds,
        File svgFile) throws IOException {
    // Get a DOMImplementation and create an XML document
    DOMImplementation domImpl
            = GenericDOMImplementation.getDOMImplementation();
    Document document = domImpl.createDocument(null, "svg", null);

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

    // draw the chart in the SVG generator
    chart.draw(svgGenerator, bounds);

    // Write svg file
    OutputStream outputStream = new FileOutputStream(svgFile);
    Writer out = new OutputStreamWriter(outputStream, "UTF-8");
    svgGenerator.stream(out, true /* use css */);
    outputStream.flush();
    outputStream.close();
}
 
開發者ID:IARC-CSU,項目名稱:CanReg5,代碼行數:31,代碼來源:Tools.java

示例3: exportAsSVG

import org.apache.batik.dom.GenericDOMImplementation; //導入方法依賴的package包/類
public static <T, U> void exportAsSVG(VennFigureParameters<T> parameters, File file, Dimension size) throws IOException {

        // 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);
        VennDrawGraphics2D.draw(VennFigureCreator.createVennFigure(parameters), svgGenerator, size);
        try (Writer writer = new FileWriter(file)) {
            svgGenerator.stream(writer, true);
        }
    }
 
開發者ID:informationsea,項目名稱:VennDraw,代碼行數:18,代碼來源:VennExporter.java

示例4: createTranscoderInput

import org.apache.batik.dom.GenericDOMImplementation; //導入方法依賴的package包/類
/**
 * Creates the <code>TranscoderInput</code>.
 */
protected TranscoderInput createTranscoderInput() {
    try {
        URL url = resolveURL(inputURI);
        String parser = XMLResourceDescriptor.getXMLParserClassName();
        DOMImplementation impl = 
            GenericDOMImplementation.getDOMImplementation();
        SAXDocumentFactory f = new SAXDocumentFactory(impl, parser);
        Document doc = f.createDocument(url.toString());
        TranscoderInput input = new TranscoderInput(doc);
        input.setURI(url.toString()); // Needed for external resources
        return input;
    } catch (IOException ex) {
        ex.printStackTrace();
        throw new IllegalArgumentException(inputURI);
    }
}
 
開發者ID:git-moss,項目名稱:Push2Display,代碼行數:20,代碼來源:GenericDocumentTest.java

示例5: canvasInit

import org.apache.batik.dom.GenericDOMImplementation; //導入方法依賴的package包/類
public boolean canvasInit(JSVGCanvas canvas) {
    DOMImplementation impl = 
        GenericDOMImplementation.getDOMImplementation();
    Document doc = impl.createDocument(SVGConstants.SVG_NAMESPACE_URI, 
                                       SVGConstants.SVG_SVG_TAG, null);
    Element e = doc.createElementNS(SVGConstants.SVG_NAMESPACE_URI, 
                                    SVGConstants.SVG_RECT_TAG);
    e.setAttribute("x", "10");
    e.setAttribute("y", "10");
    e.setAttribute("width", "100");
    e.setAttribute("height", "50");
    e.setAttribute("fill", "crimson");
    doc.getDocumentElement().appendChild(e);

    e = doc.createElementNS(SVGConstants.SVG_NAMESPACE_URI, 
                            SVGConstants.SVG_CIRCLE_TAG);
    e.setAttribute("cx", "55");
    e.setAttribute("cy", "35");
    e.setAttribute("r", "30");
    e.setAttribute("fill", "gold");
    doc.getDocumentElement().appendChild(e);
    
    canvas.setDocument(doc);
    return false; // We didn't trigger a load event.
}
 
開發者ID:git-moss,項目名稱:Push2Display,代碼行數:26,代碼來源:SetSVGDocumentTest.java

示例6: exportToStream

import org.apache.batik.dom.GenericDOMImplementation; //導入方法依賴的package包/類
@Override
public void exportToStream(Component aComponent, OutputStream aStream) throws IOException {
    DOMImplementation theDomImpl = GenericDOMImplementation.getDOMImplementation();
    Document theDocument = theDomImpl.createDocument(null, "svg", null);
    SVGGraphics2D theSvgGenerator = new SVGGraphics2D(theDocument);
    RepaintManager theRepaintManager = RepaintManager.currentManager(aComponent);
    theRepaintManager.setDoubleBufferingEnabled(false);

    Dimension theSize = aComponent.getPreferredSize();
    aComponent.setSize(theSize);

    aComponent.paint(theSvgGenerator);
    Writer theWriter = new OutputStreamWriter(aStream, PlatformConfig.getXMLEncoding());
    theSvgGenerator.stream(theWriter, false);
    theRepaintManager.setDoubleBufferingEnabled(true);

    theWriter.flush();
    theWriter.close();
}
 
開發者ID:mirkosertic,項目名稱:ERDesignerNG,代碼行數:20,代碼來源:SVGExporter.java

示例7: test2

import org.apache.batik.dom.GenericDOMImplementation; //導入方法依賴的package包/類
private static void test2() {

        File selecteddFile = new File("test2.svg");
         try {

             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.
             org.apache.batik.svggen.SVGGraphics2D svgGenerator = new SVGGraphics2D(document);

             draw(svgGenerator);

             Writer out = new BufferedWriter(new FileWriter(selecteddFile));
             //logger.info("Writing output");
             svgGenerator.stream(out, false);
             //logger.info("Done");
         } catch (Exception e) {
             MessageUtils.showMessage("Error encountered creating SVG file: " + e.toString());
         }
     }
 
開發者ID:hyounesy,項目名稱:ALEA,代碼行數:27,代碼來源:SVGTest.java

示例8: generateSVG

import org.apache.batik.dom.GenericDOMImplementation; //導入方法依賴的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

示例9: exportChartAsSVG

import org.apache.batik.dom.GenericDOMImplementation; //導入方法依賴的package包/類
/**
    * Export chart as svg.
    *
    * @param chart the chart
    * @param bounds the bounds
    * @param svgFile the svg file
    * @throws IOException Signals that an I/O exception has occurred.
    */
   private void exportChartAsSVG(JFreeChart chart, Rectangle bounds, File svgFile) throws IOException {
       // Get a DOMImplementation and create an XML document
       DOMImplementation domImpl =
           GenericDOMImplementation.getDOMImplementation();
       Document document = domImpl.createDocument(null, "svg", null);

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

       // draw the chart in the SVG generator
       chart.draw(svgGenerator, bounds);

       // Write svg file
       OutputStream outputStream = new FileOutputStream(svgFile);
       Writer out = new OutputStreamWriter(outputStream, "UTF-8");
       svgGenerator.stream(out, true /* use css */);						
       outputStream.flush();
       outputStream.close();
}
 
開發者ID:mattmagic149,項目名稱:AnSoMia,代碼行數:28,代碼來源:NewsHistogram.java

示例10: createGraphicsContext

import org.apache.batik.dom.GenericDOMImplementation; //導入方法依賴的package包/類
public Graphics2D createGraphicsContext(int width, int height)
{
	// 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.
	svgGenerator = new SVGGraphics2D(document);
	svgGenerator.setSVGCanvasSize(new Dimension(width, height));

	return svgGenerator;
}
 
開發者ID:donkirkby,項目名稱:donkirkby,代碼行數:17,代碼來源:PaintWriter.java

示例11: createGraphicsContext

import org.apache.batik.dom.GenericDOMImplementation; //導入方法依賴的package包/類
public Graphics2D createGraphicsContext()
{
	// 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.
	svgGenerator = new SVGGraphics2D(document);
	svgGenerator.setSVGCanvasSize(new Dimension(300, 300));

	return svgGenerator;
}
 
開發者ID:donkirkby,項目名稱:donkirkby,代碼行數:17,代碼來源:PaintWriter.java

示例12: createSvgGraphics2D

import org.apache.batik.dom.GenericDOMImplementation; //導入方法依賴的package包/類
public SVGGraphics2D createSvgGraphics2D() {
	DOMImplementation impl = GenericDOMImplementation
			.getDOMImplementation();
	String namespaceURI = SVGConstants.SVG_NAMESPACE_URI;
	Document domFactory = impl.createDocument(namespaceURI, "svg", null);
	SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(domFactory);
	ctx.setEmbeddedFontsOn(true);
	GraphicContextDefaults defaults = new GraphicContextDefaults();
	defaults.setFont(new Font("Arial", Font.PLAIN, 12));
	ctx.setGraphicContextDefaults(defaults);
	ctx.setPrecision(12);

	SVGGraphics2D g2d = new SVGGraphics2D(ctx, false);
	// This prevents the
	// "null incompatible with text-specific antialiasing enable key" error
	g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
			RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);
	g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
			RenderingHints.VALUE_ANTIALIAS_DEFAULT);
	return g2d;
}
 
開發者ID:iwabuchiken,項目名稱:freemind_1.0.0_20140624_214725,代碼行數:22,代碼來源:ExportVectorGraphic.java

示例13: exportSVGImage

import org.apache.batik.dom.GenericDOMImplementation; //導入方法依賴的package包/類
public static void exportSVGImage(PrintWriter pr, Component c) throws IOException {

        // 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);
        c.paint(svgGenerator);

        // Finally, stream out SVG to the standard output using
        // UTF-8 encoding.
        svgGenerator.stream(pr, false);
    }
 
開發者ID:REDetector,項目名稱:RED,代碼行數:18,代碼來源:SvgGenerator.java

示例14: export

import org.apache.batik.dom.GenericDOMImplementation; //導入方法依賴的package包/類
@Override
public boolean export(RepresentableNetwork net, NetworkStyle style, File output) throws IOException {
	//Initializes SVG file
	DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
	String svgNS = "http://www.w3.org/2000/svg";
	Document document = domImpl.createDocument(svgNS, "svg", null);
	SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
	
	/*
	 * Convert canvas
	 */
	//Canvas style
	renderCanvas(net, style, svgGenerator);
	
	//Render edges and nodes
	renderEdges(net, style, svgGenerator);
	renderNodes(net, style, svgGenerator);
	
	//Write the SVG file
	Writer out = new OutputStreamWriter(new FileOutputStream(output), "UTF-8");
	svgGenerator.stream(out, false);
	
	return true;
}
 
開發者ID:PanierAvide,項目名稱:OpenNetworkMap,代碼行數:25,代碼來源:SVGExporter.java

示例15: exportChartAsSVG

import org.apache.batik.dom.GenericDOMImplementation; //導入方法依賴的package包/類
/**
 * Exports a JFreeChart to a SVG file using the
 * <a href= "http://xmlgraphics.apache.org/batik/" target="_blank">Batik SVG
 * Toolkit</a>, bundled with Fiji. This method is taken from
 * {@literal http://dolf.trieschnigg.nl/jfreechart/}
 *
 * @param chart
 *            the <a href= "http://javadoc.imagej.net/JFreeChart/" target=
 *            "_blank">JFreeChart </a> to export.
 * @param bounds
 *            the Rectangle delimiting the boundaries within which the chart
 *            should be drawn.
 * @param file
 *            the output (destination) file.
 * @throws IOException
 *             if writing to output file fails.
 * @see #exportChartAsSVG(JFreeChart, Rectangle)
 * @see #exportChartAsPDF(JFreeChart, Rectangle)
 * @see #exportChartAsPDF(JFreeChart, Rectangle, File)
 */
public static void exportChartAsSVG(final JFreeChart chart, final Rectangle bounds, final File file)
		throws IOException {

	// Get a DOMImplementation and create an XML document
	final DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
	final org.w3c.dom.Document document = domImpl.createDocument(null, "svg", null);

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

	// draw the chart in the SVG generator
	chart.draw(svgGenerator, bounds);

	// Write svg file
	final OutputStream outputStream = new FileOutputStream(file);
	final Writer out = new OutputStreamWriter(outputStream, "UTF-8");
	svgGenerator.stream(out, true /* use css */);
	outputStream.flush();
	outputStream.close();
}
 
開發者ID:tferr,項目名稱:Scripts,代碼行數:41,代碼來源:PlotUtils.java


注:本文中的org.apache.batik.dom.GenericDOMImplementation.getDOMImplementation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。