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


Java SVGDocument.getDocumentElement方法代码示例

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


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

示例1: createImage

import org.w3c.dom.svg.SVGDocument; //导入方法依赖的package包/类
private byte[] createImage(ImageTranscoder t) throws Exception {
    //*** get the SVG document ***
    SVGDocument doc = this.getSvgDoc();
    org.w3c.dom.Element root = doc.getDocumentElement();
    this.getRoot(root);
    
    //*** set the transcoder input and output ***
    TranscoderInput input = new TranscoderInput(doc);
    ByteArrayOutputStream ostream = new ByteArrayOutputStream();
    TranscoderOutput output = new TranscoderOutput(ostream);

    //*** perform the transcoding ***
    t.transcode(input, output);
    ostream.flush();
    ostream.close();
    return ostream.toByteArray();
}
 
开发者ID:glycoinfo,项目名称:eurocarbdb,代码行数:18,代码来源:SvgFactory.java

示例2: display

import org.w3c.dom.svg.SVGDocument; //导入方法依赖的package包/类
public void display() {
    SVGDocument doc = this.getSvgDoc();
    JSVGCanvas canvas = new JSVGCanvas();
    org.w3c.dom.Element root = doc.getDocumentElement();
    this.getRoot(root);
    JFrame f = new JFrame();
    f.getContentPane().add(canvas);
    canvas.setSVGDocument(doc);
    f.pack();
    f.setVisible(true);
    //f.dispose();
}
 
开发者ID:glycoinfo,项目名称:eurocarbdb,代码行数:13,代码来源:SvgFactory.java

示例3: SVGPlot

import org.w3c.dom.svg.SVGDocument; //导入方法依赖的package包/类
/**
 * Create a new plotting document.
 */
public SVGPlot() {
  super();
  // Get a DOMImplementation.
  DOMImplementation domImpl = getDomImpl();
  DocumentType dt = domImpl.createDocumentType(SVGConstants.SVG_SVG_TAG, SVGConstants.SVG_PUBLIC_ID, SVGConstants.SVG_SYSTEM_ID);
  // Workaround: sometimes DocumentType doesn't work right, which
  // causes problems with
  // serialization...
  if(dt.getName() == null) {
    dt = null;
  }

  document = (SVGDocument) domImpl.createDocument(SVGConstants.SVG_NAMESPACE_URI, SVGConstants.SVG_SVG_TAG, dt);

  root = document.getDocumentElement();
  // setup common SVG namespaces
  root.setAttribute(SVGConstants.XMLNS_PREFIX, SVGConstants.SVG_NAMESPACE_URI);
  root.setAttributeNS(SVGConstants.XMLNS_NAMESPACE_URI, SVGConstants.XMLNS_PREFIX + ":" + SVGConstants.XLINK_PREFIX, SVGConstants.XLINK_NAMESPACE_URI);

  // create element for SVG definitions
  defs = svgElement(SVGConstants.SVG_DEFS_TAG);
  root.appendChild(defs);

  // create element for Stylesheet information.
  style = SVGUtil.makeStyleElement(document);
  root.appendChild(style);

  // create a CSS class manager.
  cssman = new CSSClassManager();
}
 
开发者ID:elki-project,项目名称:elki,代码行数:34,代码来源:SVGPlot.java

示例4: createAndAdd

import org.w3c.dom.svg.SVGDocument; //导入方法依赖的package包/类
public static EdgeLine createAndAdd(SVGDocument svgDocument, SVGGraphController graphController) {
	EdgeLine edgeLine = new EdgeLine(graphController);
	edgeLine.line = svgDocument.createElementNS(svgNS, SVG_LINE_TAG);
	edgeLine.line.setAttribute(SVG_STYLE_ATTRIBUTE,
			"fill:none;stroke:black");
	edgeLine.line.setAttribute("pointer-events", "none");
	edgeLine.line.setAttribute("visibility", "hidden");
	edgeLine.line.setAttribute(SVG_X1_ATTRIBUTE, "0");
	edgeLine.line.setAttribute(SVG_Y1_ATTRIBUTE, "0");
	edgeLine.line.setAttribute(SVG_X2_ATTRIBUTE, "0");
	edgeLine.line.setAttribute(SVG_Y2_ATTRIBUTE, "0");

	edgeLine.pointer = svgDocument.createElementNS(svgNS, SVG_POLYGON_TAG);
	edgeLine.pointer.setAttribute(SVG_STYLE_ATTRIBUTE,
			"fill:black;stroke:black");
	edgeLine.pointer.setAttribute(SVG_POINTS_ATTRIBUTE, "0,0 "
			+ -arrowLength + "," + arrowWidth + " " + -arrowLength + ","
			+ -arrowWidth + " 0,0");
	edgeLine.pointer.setAttribute("pointer-events", "none");
	edgeLine.pointer.setAttribute("visibility", "hidden");

	Element svgRoot = svgDocument.getDocumentElement();
	svgRoot.insertBefore(edgeLine.line, null);
	svgRoot.insertBefore(edgeLine.pointer, null);

	return edgeLine;
}
 
开发者ID:apache,项目名称:incubator-taverna-workbench,代码行数:28,代码来源:SVGGraphController.java

示例5: runImpl

import org.w3c.dom.svg.SVGDocument; //导入方法依赖的package包/类
public TestReport runImpl() throws Exception {

        DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
        String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
        SVGDocument doc = (SVGDocument)impl.createDocument(svgNS, "svg", null);
        
        SVGGraphics2D g = new SVGGraphics2D(doc);

        Shape circle = new Ellipse2D.Double(0,0,50,50);
        g.setPaint(Color.red);
        g.fill(circle);
        g.translate(60,0);
        g.setPaint(Color.green);
        g.fill(circle);
        g.translate(60,0);
        g.setPaint(Color.blue);
        g.fill(circle);
        g.setSVGCanvasSize(new Dimension(180,50));

        Element root = doc.getDocumentElement();

        // The following populates the document root with the 
        // generated SVG content.
        g.getRoot(root);

        root.setAttribute("onload", "System.out.println('hello')");

        // Now that the SVG file has been loaded, build
        // a GVT Tree from it
        TestUserAgent userAgent = new TestUserAgent();
        GVTBuilder builder = new GVTBuilder();
        BridgeContext ctx = new BridgeContext(userAgent);
        ctx.setDynamic(true);

        builder.build(ctx, doc);
        BaseScriptingEnvironment scriptEnvironment 
            = new BaseScriptingEnvironment(ctx);
        scriptEnvironment.loadScripts();
        scriptEnvironment.dispatchSVGLoadEvent();

        if (!userAgent.failed) {
            return reportSuccess();
        } else {
            return reportError("Got exception while processing document");
        }
    }
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:47,代码来源:ShowGraphics2DOutput.java


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