• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SAXSVGDocumentFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: renderSVG

import org.apache.batik.anim.dom.SAXSVGDocumentFactory; //导入依赖的package包/类
private void renderSVG(String name, final double scale) throws IOException {
	String uri = RenderSVGsTest.class.getResource(name).toString();

	// create the document
	String parser = XMLResourceDescriptor.getXMLParserClassName();
	SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
	Document document = f.createDocument(uri, RenderSVGsTest.class.getResourceAsStream(name));

	// create the GVT
	UserAgent userAgent = new UserAgentAdapter();
	DocumentLoader loader = new DocumentLoader(userAgent);
	BridgeContext bctx = new BridgeContext(userAgent, loader);
	bctx.setDynamicState(BridgeContext.STATIC);
	GVTBuilder builder = new GVTBuilder();
	final GraphicsNode gvtRoot = builder.build(bctx, document);

	this.exportGraphic("svg", name.replace(".svg", ""), new GraphicsExporter() {
		@Override
		public void draw(Graphics2D gfx) {
			gfx.scale(scale, scale);
			gvtRoot.paint(gfx);
		}
	});

}
 
开发者ID:rototor,项目名称:pdfbox-graphics2d,代码行数:26,代码来源:RenderSVGsTest.java


示例2: loadDocument

import org.apache.batik.anim.dom.SAXSVGDocumentFactory; //导入依赖的package包/类
public static Document loadDocument(String path)
    throws IOException, ParserConfigurationException, SAXException {
  File file = new File(path);
  FileInputStream svgInputStream = new FileInputStream(file);
  String parser = XMLResourceDescriptor.getXMLParserClassName();
  SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(parser);
  Document doc = factory.createDocument(parser, svgInputStream);
  return doc;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:10,代码来源:Main.java


示例3: SvgDataSniffer

import org.apache.batik.anim.dom.SAXSVGDocumentFactory; //导入依赖的package包/类
/**
 * 
 */
private SvgDataSniffer(JasperReportsContext jasperReportsContext)
{
	UserAgent userAgent = new BatikUserAgent(jasperReportsContext);
	documentFactory =
		new SAXSVGDocumentFactory(userAgent.getXMLParserClassName(), true);
	documentFactory.setValidating(userAgent.isXMLParserValidating());
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:11,代码来源:SvgDataSniffer.java


示例4: SvgFontProcessor

import org.apache.batik.anim.dom.SAXSVGDocumentFactory; //导入依赖的package包/类
/**
 * 
 */
protected SvgFontProcessor(
	JasperReportsContext jasperReportsContext,
	Locale locale
	)
{
	UserAgent userAgent = new BatikUserAgent(jasperReportsContext);
	documentFactory =
		new SAXSVGDocumentFactory(userAgent.getXMLParserClassName(), true);
	documentFactory.setValidating(userAgent.isXMLParserValidating());

	this.locale = locale;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:16,代码来源:SvgFontProcessor.java


示例5: loadDocument

import org.apache.batik.anim.dom.SAXSVGDocumentFactory; //导入依赖的package包/类
/**
 * Load the SVG image from an input stream and replaces its color. The SVG format is a XML
 * format.
 *
 * @param inputStream From which to load the image
 * @param color The replacement color
 * @return The loaded SVG image document
 * @throws SAXException Parsing error
 * @throws IOException Could not load the image
 * @throws ParserConfigurationException Problem with XML parser
 */
public Document loadDocument (final InputStream inputStream, final Color color) throws SAXException, IOException, ParserConfigurationException
{
    final String parser = XMLResourceDescriptor.getXMLParserClassName ();
    final SAXSVGDocumentFactory f = new SAXSVGDocumentFactory (parser);

    final SVGDocument document = f.createSVGDocument ("xxx", inputStream);

    changeColorOfElement (color, document, "polygon");
    changeColorOfElement (color, document, "circle");
    changeColorOfElement (color, document, "path");
    changeColorOfElement (color, document, "rect");

    return document;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:26,代码来源:SVGImage.java


示例6: DocumentLoader

import org.apache.batik.anim.dom.SAXSVGDocumentFactory; //导入依赖的package包/类
/**
 * Constructs a new <code>DocumentLoader</code> with the specified XML parser.
 * @param userAgent the user agent to use
 */
public DocumentLoader(UserAgent userAgent) {
    this.userAgent = userAgent;
    documentFactory = new SAXSVGDocumentFactory
        (userAgent.getXMLParserClassName(), true);
    documentFactory.setValidating(userAgent.isXMLParserValidating());
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:11,代码来源:DocumentLoader.java


示例7: createTranscoderInput

import org.apache.batik.anim.dom.SAXSVGDocumentFactory; //导入依赖的package包/类
/**
 * Creates the <code>TranscoderInput</code>.
 */
protected TranscoderInput createTranscoderInput() {
    try {
        String parser = XMLResourceDescriptor.getXMLParserClassName();
        SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
        Document doc = f.createDocument(resolveURL(inputURI).toString());
        return new TranscoderInput(doc);
    } catch (IOException ex) {
        throw new IllegalArgumentException(inputURI);
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:14,代码来源:ParametrizedDOMTest.java


示例8: runImpl

import org.apache.batik.anim.dom.SAXSVGDocumentFactory; //导入依赖的package包/类
public TestReport runImpl() throws Exception {
    DOMImplementation impl = new SVGDOMImplementation();
    Document doc = impl.createDocument(SVGConstants.SVG_NAMESPACE_URI,
                                       "svg", null);

    Element svg = doc.getDocumentElement();
    Element text = doc.createElementNS(SVGConstants.SVG_NAMESPACE_URI,
                                       "text");
    svg.appendChild(text);

    text.setAttributeNS(null, "id", "myText");
    String unescapedContent = "You should not escape: & # \" ...";
    CDATASection cdata = doc.createCDATASection(unescapedContent);

    text.appendChild(cdata);

    Writer stringWriter = new StringWriter();

    DOMUtilities.writeDocument(doc, stringWriter);
    
    String docString = stringWriter.toString();
    System.err.println(">>>>>>>>>>> Document content \n\n" + docString + "\n\n<<<<<<<<<<<<<<<<");

    String parser = XMLResourceDescriptor.getXMLParserClassName();
    SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
    doc = f.createDocument("http://xml.apache.org/batik/foo.svg", 
                           new StringReader(stringWriter.toString()));

    text = doc.getElementById("myText");
    cdata = (CDATASection)text.getFirstChild();
    if (cdata.getData().equals(unescapedContent)) {
        return reportSuccess();
    } 

    TestReport report = reportError("Unexpected CDATA read-back");
    report.addDescriptionEntry("expected cdata", unescapedContent);
    report.addDescriptionEntry("actual cdata", cdata.getData());
    return report;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:40,代码来源:DOMUtilitiesCharacterEscaping.java


示例9: runImpl

import org.apache.batik.anim.dom.SAXSVGDocumentFactory; //导入依赖的package包/类
public TestReport runImpl() throws Exception {
    ResourceBundle rb = 
        ResourceBundle.getBundle(SAXSVGDocumentFactory.DTDIDS,
                                 Locale.getDefault());
    String dtdids = rb.getString(SAXSVGDocumentFactory.KEY_PUBLIC_IDS);
    
    StringTokenizer st = new StringTokenizer(dtdids, "-");
    int nIds = st.countTokens();
    String missingIds = "";
    for (int i=0; i<nIds; i++) {
        String publicId = st.nextToken();
        publicId = "-" + publicId.trim();
        System.out.println("Testing public id: " + publicId);
        try {
            rb.getString(SAXSVGDocumentFactory.KEY_SYSTEM_ID 
                          + publicId.replace(' ', '_'));
        } catch (MissingResourceException e) {
            missingIds += "[" + publicId + "]  -- ";
        }
    }
    
    if (!"".equals(missingIds)) {
        DefaultTestReport report = new DefaultTestReport(this);
        report.setErrorCode(ERROR_MISSING_SYSTEM_ID);
        report.addDescriptionEntry(KEY_MISSING_IDS, missingIds);
        report.setPassed(false);
        return report;
    }

    return reportSuccess();
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:32,代码来源:SystemIdTest.java


示例10: getSvgFactory

import org.apache.batik.anim.dom.SAXSVGDocumentFactory; //导入依赖的package包/类
private static SAXSVGDocumentFactory getSvgFactory() {
  SAXSVGDocumentFactory factory = SVG_FACTORY_THREAD_LOCAL.get();
  if ( factory == null ) {
    factory = createFactory();
    SVG_FACTORY_THREAD_LOCAL.set( factory );
  }
  return factory;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:9,代码来源:SvgSupport.java


示例11: createIconFromSVG

import org.apache.batik.anim.dom.SAXSVGDocumentFactory; //导入依赖的package包/类
public static ImageIcon createIconFromSVG(String path, int height, int width, Color background) {
    try {
        System.setProperty("org.apache.batik.warn_destination", "false");
        Document document;

        String parser = XMLResourceDescriptor.getXMLParserClassName();
        SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);

        document = f.createDocument(ClassLoader.getSystemResource(path).toString());

        UserAgentAdapter userAgentAdapter = new UserAgentAdapter();
        BridgeContext bridgeContext = new BridgeContext(userAgentAdapter);
        GVTBuilder builder = new GVTBuilder();

        GraphicsNode graphicsNode = builder.build(bridgeContext, document);

        double sizeY = bridgeContext.getDocumentSize().getHeight();
        double sizeX = bridgeContext.getDocumentSize().getWidth();

        BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);

        Graphics2D g2d = (Graphics2D) bufferedImage.getGraphics();
        if (background != null) {
            g2d.setColor(background);
            g2d.fillRect(0, 0, width, height);
        }

        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
        g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);

        double scaleX = (width - 1) / sizeX;
        double scaleY = (height - 1) / sizeY;
        double scale = Math.min(scaleX, scaleY);
        g2d.scale(scale, scale);
        g2d.translate(0.5, 0.5);

        graphicsNode.paint(g2d);
        g2d.dispose();
        return new ImageIcon(bufferedImage);
    } catch (Throwable e) {
        System.err.println("Failed to load SVG file " + path);
        System.err.println(e);
        return null;
    }
}
 
开发者ID:workcraft,项目名称:workcraft,代码行数:50,代码来源:GUI.java


示例12: getRootNode

import org.apache.batik.anim.dom.SAXSVGDocumentFactory; //导入依赖的package包/类
protected synchronized GraphicsNode getRootNode(JasperReportsContext jasperReportsContext) throws JRException
{
	if (rootNodeRef == null || rootNodeRef.get() == null)
	{
		FontFamilyResolver fontFamilyResolver = BatikFontFamilyResolver.getInstance(jasperReportsContext);
		
		UserAgent userAgentForDoc = 
			new BatikUserAgent(
				fontFamilyResolver,
				BatikUserAgent.PIXEL_TO_MM_72_DPI
				);
		
		SVGDocumentFactory documentFactory =
			new SAXSVGDocumentFactory(userAgentForDoc.getXMLParserClassName(), true);
		documentFactory.setValidating(userAgentForDoc.isXMLParserValidating());

		SVGDocument document = getSvgDocument(jasperReportsContext, documentFactory);

		Node svgNode = document.getElementsByTagName("svg").item(0);
		Node svgWidthNode = svgNode.getAttributes().getNamedItem("width");
		Node svgHeightNode = svgNode.getAttributes().getNamedItem("height");
		String strSvgWidth = svgWidthNode == null ? null : svgWidthNode.getNodeValue().trim();
		String strSvgHeight = svgHeightNode == null ? null : svgHeightNode.getNodeValue().trim();
		
		float pixel2mm = BatikUserAgent.PIXEL_TO_MM_72_DPI;
		if (
			(strSvgWidth != null && strSvgWidth.endsWith("mm"))
			|| (strSvgHeight != null && strSvgHeight.endsWith("mm"))
			)
		{
			pixel2mm = BatikUserAgent.PIXEL_TO_MM_96_DPI;
		}
		
		UserAgent userAgentForCtx = 
			new BatikUserAgent(
				fontFamilyResolver,
				pixel2mm
				);
			
		BridgeContext ctx = new BridgeContext(userAgentForCtx);
		ctx.setDynamic(true);
		GVTBuilder builder = new GVTBuilder();
		GraphicsNode rootNode = builder.build(ctx, document);
		rootNodeRef = new SoftReference<GraphicsNode>(rootNode);
		
		//copying the document size object because it has a reference to SVGSVGElementBridge,
		//which prevents rootNodeRef from being cleared by the garbage collector
		Dimension2D svgSize = ctx.getDocumentSize();
		documentSize = new SimpleDimension2D(svgSize.getWidth(), svgSize.getHeight());
	}
	
	return rootNodeRef.get();
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:54,代码来源:AbstractSvgDataToGraphics2DRenderer.java


示例13: ensureSvg

import org.apache.batik.anim.dom.SAXSVGDocumentFactory; //导入依赖的package包/类
protected synchronized void ensureSvg(JasperReportsContext jasperReportsContext) throws JRException
{
	if (rootNode != null)
	{
		// already loaded
		return;
	}

	ensureData(jasperReportsContext);
	
	try
	{
		UserAgent userAgent = new BatikUserAgent(jasperReportsContext);
		
		SVGDocumentFactory documentFactory =
			new SAXSVGDocumentFactory(userAgent.getXMLParserClassName(), true);
		documentFactory.setValidating(userAgent.isXMLParserValidating());

		SVGDocument document;
		if (svgText != null)
		{
			document = documentFactory.createSVGDocument(null,
					new StringReader(svgText));
		}
		else
		{
			document = documentFactory.createSVGDocument(null,
					new ByteArrayInputStream(svgData));
		}

		BridgeContext ctx = new BridgeContext(userAgent);
		ctx.setDynamic(true);
		GVTBuilder builder = new GVTBuilder();
		rootNode = builder.build(ctx, document);
		documentSize = ctx.getDocumentSize();
	}
	catch (IOException e)
	{
		throw new JRRuntimeException(e);
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:42,代码来源:BatikRenderer.java


示例14: getSVGDocument

import org.apache.batik.anim.dom.SAXSVGDocumentFactory; //导入依赖的package包/类
private SVGDocument getSVGDocument(QualifiedSVGResource svg) throws IOException {
    String parser = XMLResourceDescriptor.getXMLParserClassName();
    SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
    return (SVGDocument) f.createDocument(svg.toURI().toURL().toString());
}
 
开发者ID:avianey,项目名称:androidsvgdrawable-plugin,代码行数:6,代码来源:QualifiedSVGResourceFactory.java


示例15: createFactory

import org.apache.batik.anim.dom.SAXSVGDocumentFactory; //导入依赖的package包/类
private static SAXSVGDocumentFactory createFactory() {
  return new SAXSVGDocumentFactory( PARSER );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:4,代码来源:SvgSupport.java


示例16: createDocumentFactory

import org.apache.batik.anim.dom.SAXSVGDocumentFactory; //导入依赖的package包/类
/**
 * Creates a <code>DocumentFactory</code> that is used to create an SVG DOM
 * tree. The specified DOM Implementation is ignored and the Batik
 * SVG DOM Implementation is automatically used.
 *
 * @param domImpl the DOM Implementation (not used)
 * @param parserClassname the XML parser classname
 */
protected DocumentFactory createDocumentFactory(DOMImplementation domImpl,
                                                String parserClassname) {
    return new SAXSVGDocumentFactory(parserClassname);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:13,代码来源:SVGAbstractTranscoder.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GetFuture类代码示例发布时间:2022-05-22
下一篇:
Java FormIndex类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap