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


Java SVGDocument类代码示例

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


SVGDocument类属于org.w3c.dom.svg包,在下文中一共展示了SVGDocument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: execRowsSelected

import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
@Override
protected void execRowsSelected(List<? extends ITableRow> rows) {
	clearErrorStatus();
	try {
		Field field = (Field) rows.get(0).getCell(0).getValue();
		String svg = DocumentForm.this.getFieldByClass(SvgSourceField.class).getValue();
		SVGDocument doc = parseDocument(svg);
		DocumentForm.this.getFieldByClass(DocumentSvgField.class)
				.setSvgDocument(transformLeft(doc, field));
		DocumentForm.this.getFieldByClass(RightGroupBox.class).execDisplayField(field,
				transformRight(doc, field));
	} catch (Exception e) {
		e.printStackTrace();
		addErrorStatus(e.getMessage());
	}
}
 
开发者ID:boardend,项目名称:tabularius,代码行数:17,代码来源:DocumentForm.java

示例3: execInitField

import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
@Override
protected void execInitField() {
	setLabelVisible(false);
	setMultilineText(true);
	setMaxLength(1000000);

	clearErrorStatus();
	try {
		SVGDocument doc = generateDocument();
		ByteArrayOutputStream out = new ByteArrayOutputStream();
		SVGUtility.writeSVGDocument(doc, out, StandardCharsets.UTF_8.toString());
		setValue(prettyPrint(new String(out.toByteArray())));
	} catch (Exception e) {
		e.printStackTrace();
		addErrorStatus(e.getMessage());
	}
}
 
开发者ID:boardend,项目名称:tabularius,代码行数:18,代码来源:DocumentForm.java

示例4: getSvgDocument

import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
@Override
protected SVGDocument getSvgDocument(
	JasperReportsContext jasperReportsContext,
	SVGDocumentFactory documentFactory
	) throws JRException
{
	try
	{
		return 
			documentFactory.createSVGDocument(
				null, 
				new ByteArrayInputStream(
					dataRenderer.getData(jasperReportsContext)
					)
				);
	}
	catch (IOException e)
	{
		throw new JRRuntimeException(e);
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:22,代码来源:WrappingSvgDataToGraphics2DRenderer.java

示例5: getSvgInfo

import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
/**
 * 
 */
public SvgInfo getSvgInfo(byte[] data)
{
	try
	{
		SVGDocument document = 
			documentFactory.createSVGDocument(
				null,
				new ByteArrayInputStream(data)
				);
		
		return new SvgInfo(document.getInputEncoding());
	}
	catch (IOException e)
	{
		return null;
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:21,代码来源:SvgDataSniffer.java

示例6: getSVGDocument

import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
public SVGDocument getSVGDocument() {
  String xmlParser = XMLResourceDescriptor.getXMLParserClassName();
  SAXSVGDocumentFactory df = new SAXSVGDocumentFactory(xmlParser);
  SVGDocument doc = null;
  try {
    if (this.href != null) {
      if (!this.href.substring(0, 4).equalsIgnoreCase("file")) {

        URL res = ExternalGraphic.class.getResource(this.href);
        if (res != null) {
          doc = df.createSVGDocument(
              ExternalGraphic.class.getResource(this.href).toString());
        }
      } else {
        doc = df.createSVGDocument(this.href);
      }
    }
  } catch (IOException e) {
    e.printStackTrace();
  }
  return doc;
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:23,代码来源:ExternalGraphic.java

示例7: loadDocument

import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
/**
 * Returns a document from the specified uri.
 * @param uri the uri of the document
 * @exception IOException if an I/O error occured while loading
 * the document
 */
public Document loadDocument(String uri) throws IOException {
    Document ret = checkCache(uri);
    if (ret != null)
        return ret;

    SVGDocument document = documentFactory.createSVGDocument(uri);

    DocumentDescriptor desc = documentFactory.getDocumentDescriptor();
    DocumentState state = new DocumentState(uri, document, desc);
    synchronized (cacheMap) {
        cacheMap.put(uri, state);
    }

    return state.getDocument();
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:22,代码来源:DocumentLoader.java

示例8: getViewBoxRect

import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
protected Rectangle2D getViewBoxRect() {
    SVGDocument doc = canvas.getSVGDocument();
    if (doc == null) return null;
    SVGSVGElement el = doc.getRootElement();
    if (el == null) return null;

    String viewBoxStr = el.getAttributeNS
        (null, SVGConstants.SVG_VIEW_BOX_ATTRIBUTE);
    if (viewBoxStr.length() != 0) {
        float[] rect = ViewBox.parseViewBoxAttribute(el, viewBoxStr, null);
        return new Rectangle2D.Float(rect[0], rect[1],
                                     rect[2], rect[3]);
    }
    GraphicsNode gn = canvas.getGraphicsNode();
    if (gn == null) return null;

    Rectangle2D bounds = gn.getBounds();
    if (bounds == null) return null;

    return (Rectangle2D) bounds.clone();
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:22,代码来源:JSVGScrollPane.java

示例9: getBrokenLinkDocument

import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
/**
 * This Implementation simply forwards the request to the AWT thread.
 *
 * @param e   The <image> element that can't be loaded.
 * @param url The resolved url that can't be loaded.
 * @param msg As best as can be determined the reason it can't be
 *            loaded (not available, corrupt, unknown format,...).
 */
public SVGDocument getBrokenLinkDocument(final Element e,
                                         final String url,
                                         final String msg) {
    if (EventQueue.isDispatchThread())
        return userAgent.getBrokenLinkDocument(e, url, msg);

    class Query implements Runnable {
        SVGDocument doc;
        RuntimeException rex = null;
        public void run() {
            try {
                doc = userAgent.getBrokenLinkDocument(e, url, msg);
            } catch (RuntimeException re) { rex = re; }
        }
    }
    Query q = new Query();
    invokeAndWait(q);
    if (q.rex != null) throw q.rex;
    return q.doc;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:29,代码来源:JSVGComponent.java

示例10: setSVGDocument

import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
public void setSVGDocument(SVGDocument doc) {
    svgDocument = doc;
    UserAgent userAgent = new UserAgentAdapter();
    DocumentLoader loader = new DocumentLoader(userAgent);
    ctx = new BridgeContext(userAgent, loader);
    ctx.setDynamicState(BridgeContext.DYNAMIC);
    GVTBuilder builder = new GVTBuilder();
    setGraphicsNode(builder.build(ctx, getSvgDocument()));

    outlineElement = doc.getElementById("OUTLINE");
    if (outlineElement != null) {
        outlineShape = ((org.apache.batik.gvt.ShapeNode) ctx.getGraphicsNode(outlineElement)).getShape();
    }

    if ("OUTER".equals(doc.getRootElement().getAttribute("resizeType"))) {
        setResizeType(ResizeType.OUTER);
    }

    revalidate();
}
 
开发者ID:jeddict,项目名称:NBModeler,代码行数:21,代码来源:SvgWidget.java

示例11: drawSvgGraphics

import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
/**
 * Draws the selected component (assumed to be a Component) into the
 * provided SVGGraphics2D object.
 *
 * @param component
 * @param bounds
 */
private static SVGGraphics2D drawSvgGraphics(Object component, Rectangle bounds) {

    // Get a SVGDOMImplementation and create an XML document
    DOMImplementation domImpl = SVGDOMImplementation.getDOMImplementation();
    String svgNS = "http://www.w3.org/2000/svg";
    SVGDocument svgDocument = (SVGDocument) domImpl.createDocument(svgNS, "svg", null);

    // Create an instance of the SVG Generator
    SVGGraphics2D svgGenerator = new SVGGraphics2D(svgDocument);
    svgGenerator.setSVGCanvasSize(bounds.getSize());

    // draw the panel in the SVG generator
    if (component instanceof JFreeChart) {
        ((JFreeChart) component).draw(svgGenerator, bounds);
    } else if (component instanceof JComponent) {
        ((JComponent) component).paintAll(svgGenerator);
    }

    return svgGenerator;
}
 
开发者ID:compomics,项目名称:compomics-utilities,代码行数:28,代码来源:Export.java

示例12: elementCoordinatesFromEvent

import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
/**
 * Convert the coordinates of an DOM Event from screen into element
 * coordinates.
 *
 * @param doc Document context
 * @param tag Element containing the coordinate system
 * @param evt Event to interpret
 * @return coordinates
 */
public static SVGPoint elementCoordinatesFromEvent(Document doc, Element tag, Event evt) {
  try {
    DOMMouseEvent gnme = (DOMMouseEvent) evt;
    SVGMatrix mat = ((SVGLocatable) tag).getScreenCTM();
    SVGMatrix imat = mat.inverse();
    SVGPoint cPt = ((SVGDocument) doc).getRootElement().createSVGPoint();
    cPt.setX(gnme.getClientX());
    cPt.setY(gnme.getClientY());
    return cPt.matrixTransform(imat);
  }
  catch(Exception e) {
    LoggingUtil.warning("Error getting coordinates from SVG event.", e);
    return null;
  }
}
 
开发者ID:elki-project,项目名称:elki,代码行数:25,代码来源:SVGUtil.java

示例13: drawSvgGraphics

import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
/**
 * Draws the selected component (assumed to be a Component) into the provided
 * SVGGraphics2D object.
 *
 * @param component
 * @param bounds
 */
private static SVGGraphics2D drawSvgGraphics(Object component, Rectangle bounds) {

    // Get a SVGDOMImplementation and create an XML document
    DOMImplementation domImpl = SVGDOMImplementation.getDOMImplementation();
    String svgNS = "http://www.w3.org/2000/svg";
    SVGDocument svgDocument = (SVGDocument) domImpl.createDocument(svgNS, "svg", null);

    // Create an instance of the SVG Generator
    SVGGraphics2D svgGenerator = new SVGGraphics2D(svgDocument);
    svgGenerator.setSVGCanvasSize(bounds.getSize());

    // draw the panel in the SVG generator
    if (component instanceof JFreeChart) {
        ((JFreeChart) component).draw(svgGenerator, bounds);
    } else if (component instanceof JComponent) {
        ((JComponent) component).paintAll(svgGenerator);
    }

    return svgGenerator;
}
 
开发者ID:compomics,项目名称:mitraq,代码行数:28,代码来源:Export.java

示例14: loadDocument

import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
/**
 * Returns a document from the specified uri.
 * @param uri the uri of the document
 * @exception IOException if an I/O error occured while loading
 * the document
 */
public Document loadDocument(String uri, InputStream is) 
    throws IOException {
    Document ret = checkCache(uri);
    if (ret != null)
        return ret;

    SVGDocument document = documentFactory.createSVGDocument(uri, is);

    DocumentDescriptor desc = documentFactory.getDocumentDescriptor();
    DocumentState state = new DocumentState(uri, document, desc);
    synchronized (cacheMap) {
        cacheMap.put(uri, state);
    }

    return state.getDocument();
}
 
开发者ID:BowlerHatLLC,项目名称:feathers-sdk,代码行数:23,代码来源:DocumentLoader.java

示例15: execDisplayField

import org.w3c.dom.svg.SVGDocument; //导入依赖的package包/类
public void execDisplayField(Field field, SVGDocument svgDocument) {
	clearErrorStatus();
	try {
		FieldForm form = new FieldForm(field, svgDocument);
		DocumentForm.this.getFieldByClass(GroupFormField.class).setInnerForm(form);
	} catch (Exception e) {
		e.printStackTrace();
		addErrorStatus(e.getMessage());
	}
}
 
开发者ID:boardend,项目名称:tabularius,代码行数:11,代码来源:DocumentForm.java


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