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


Java XMLResourceDescriptor.getXMLParserClassName方法代码示例

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


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

示例1: relativizeExternalReferences

import org.apache.batik.util.XMLResourceDescriptor; //导入方法依赖的package包/类
/**
 * Rewrites external references contained in SVG files.
 *
 * @param path the path of the file to be processed
 */
public static byte[] relativizeExternalReferences(String path)
                                                         throws IOException {
  // use the GenericDOMImplementation here because
  // SVGDOMImplementation adds unwanted attributes to SVG elements
  final SAXDocumentFactory fac = new SAXDocumentFactory(
    new GenericDOMImplementation(),
    XMLResourceDescriptor.getXMLParserClassName());

  final URL here = new URL("file", null, new File(path).getCanonicalPath());
  final StringWriter sw = new StringWriter();

  try {
    final Document doc = fac.createDocument(here.toString());
    relativizeElement(doc.getDocumentElement());
    DOMUtilities.writeDocument(doc, sw);
  }
  catch (DOMException e) {
    throw (IOException) new IOException().initCause(e);
  }

  sw.flush();
  return sw.toString().getBytes();
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:29,代码来源:SVGImageUtils.java

示例2: renderSVG

import org.apache.batik.util.XMLResourceDescriptor; //导入方法依赖的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

示例3: getSVGDocument

import org.apache.batik.util.XMLResourceDescriptor; //导入方法依赖的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

示例4: createTranscoderInput

import org.apache.batik.util.XMLResourceDescriptor; //导入方法依赖的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: loadDiagramFromStream

import org.apache.batik.util.XMLResourceDescriptor; //导入方法依赖的package包/类
private static GraphicsNode loadDiagramFromStream (final InputStream in, final Dimension2D docSize) throws IOException {
  final String parser = XMLResourceDescriptor.getXMLParserClassName();
  final SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(parser);
  final SVGDocument doc = factory.createSVGDocument("http://www.igormaznitsa.com/jhexed/svg", in);

  String strDocWidth = doc.getRootElement().getAttribute("width");
  String strDocHeight = doc.getRootElement().getAttribute("height");

  final GVTBuilder bldr = new GVTBuilder();

  final UserAgent userAgent = new UserAgentAdapter();
  final DocumentLoader loader = new DocumentLoader(userAgent);
  final BridgeContext ctx = new BridgeContext(userAgent, loader);

  final GraphicsNode result = bldr.build(ctx, doc);

  strDocWidth = strDocWidth.isEmpty() ? Double.toString(result.getSensitiveBounds().getWidth()) : strDocWidth;
  strDocHeight = strDocHeight.isEmpty() ? Double.toString(result.getSensitiveBounds().getHeight()) : strDocHeight;

  docSize.setSize(Double.parseDouble(strDocWidth.trim()), Double.parseDouble(strDocHeight.trim()));

  return result;
}
 
开发者ID:raydac,项目名称:jhexed,代码行数:24,代码来源:SVGImage.java

示例6: loadDocument

import org.apache.batik.util.XMLResourceDescriptor; //导入方法依赖的package包/类
private void loadDocument() {
	transcoder = null;
	failedToLoadDocument = true;
	if (uri == null) {
		return;
	}
	String parser = XMLResourceDescriptor.getXMLParserClassName();
	SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(parser);
	try {
		Document document;
		if (documentsMap.containsKey(uri))
			document = documentsMap.get(uri);
		else {
			document = factory.createDocument(uri);
			documentsMap.put(uri, document);
		}
		transcoder = new SimpleImageTranscoder(document);
		failedToLoadDocument = false;
	} catch (IOException e) {
		JaspersoftStudioPlugin.getInstance().logError("Error loading SVG file", e);
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:23,代码来源:SVGFigure.java

示例7: loadDocument

import org.apache.batik.util.XMLResourceDescriptor; //导入方法依赖的package包/类
private void loadDocument() {
  transcoder = null;
  failedToLoadDocument = true;
  if (uri == null) {
    return;
  }
  String parser = XMLResourceDescriptor.getXMLParserClassName();
  parser = parser != null ? parser : "org.apache.xerces.parsers.SAXParser";
  SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(parser);
  try {
    Document document;
    if (documentsMap.containsKey(uri))
      document = documentsMap.get(uri);
    else {
      document = factory.createDocument(uri);
      documentsMap.put(uri, document);
    }
    transcoder = new SimpleImageTranscoder(document, translateX, translateY);
    failedToLoadDocument = false;
  } catch (IOException e) {
    TriqEditorPlugin.logError("Error loading SVG file", e);
  }
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:24,代码来源:SVGFigure.java

示例8: createNode

import org.apache.batik.util.XMLResourceDescriptor; //导入方法依赖的package包/类
private GraphicsNode createNode(String svgContent) throws GeomajasException {
	// batik magic
	String parser = XMLResourceDescriptor.getXMLParserClassName();
	SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
	SVGDocument document;
	try {
		document = f.createSVGDocument("", new StringReader(svgContent));
	} catch (IOException e) {
		throw new RasterException(e, RasterException.BAD_SVG, "Cannot parse SVG");
	}
	UserAgent userAgent = new UserAgentAdapter();
	DocumentLoader loader = new DocumentLoader(userAgent);
	BridgeContext bridgeContext = new BridgeContext(userAgent, loader);
	bridgeContext.setDynamic(true);
	GVTBuilder builder = new GVTBuilder();
	return builder.build(bridgeContext, document);
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:18,代码来源:SvgLayerFactory.java

示例9: loadDocument

import org.apache.batik.util.XMLResourceDescriptor; //导入方法依赖的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

示例10: loadDocument

import org.apache.batik.util.XMLResourceDescriptor; //导入方法依赖的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

示例11: getXMLParserClassName

import org.apache.batik.util.XMLResourceDescriptor; //导入方法依赖的package包/类
/**
 * Returns the class name of the XML parser.
 */
public String getXMLParserClassName() {
    if (svgUserAgent != null) {
        return svgUserAgent.getXMLParserClassName();
    }
    return XMLResourceDescriptor.getXMLParserClassName();
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:10,代码来源:JSVGComponent.java

示例12: createTranscoderInput

import org.apache.batik.util.XMLResourceDescriptor; //导入方法依赖的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

示例13: runImpl

import org.apache.batik.util.XMLResourceDescriptor; //导入方法依赖的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

示例14: addPage

import org.apache.batik.util.XMLResourceDescriptor; //导入方法依赖的package包/类
public ThinReport addPage(String file, Map<String, Object> map)
			throws IOException {
		readTlf(file);
//		System.out.println(thinReport.getSvg());

		Document document = null;
		String parser = XMLResourceDescriptor.getXMLParserClassName();
		SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
		// f.setValidating(true);
		// String uri = SVGDOMImplementation.SVG_NAMESPACE_URI;
		document = f.createSVGDocument(file, new ByteArrayInputStream(
				thinReport.getSvg().getBytes("UTF-8")));

		if (document != null) {
			traceNodes(document, map);
			TransformerFactory transFactory = TransformerFactory.newInstance();
			try {
				Transformer transformer = transFactory.newTransformer();
				Source src = new DOMSource(document);
				ByteArrayOutputStream out = new ByteArrayOutputStream();
				Result result = new StreamResult(out);
				transformer.transform(src, result);
				TranscoderInput input = new TranscoderInput();
				input.setInputStream(new ByteArrayInputStream(out.toByteArray()));
				thinReport.addDocument(input);
				out.close();
				// } catch (TransformerConfigurationException e) {
				// e.printStackTrace();
			} catch (TransformerException e) {
				e.printStackTrace();
			}
		}

		lineNo = 0;
		return thinReport;
	}
 
开发者ID:naofum,项目名称:thinreports-java,代码行数:37,代码来源:ThinReportsGenerator.java

示例15: generateLineBlock

import org.apache.batik.util.XMLResourceDescriptor; //导入方法依赖的package包/类
protected void generateLineBlock(Node node, Map<String, Object> map,
		JSONObject json, int line, double translateY) {
	double height = 0;
	if (json.get("height") instanceof Integer) {
		height = (Integer) json.get("height");
	} else {
		height = (Double) json.get("height");
	}
	JSONObject svg = json.getJSONObject("svg");
	String content = "<svg xmlns=\"http://www.w3.org/2000/svg\"><g>"
			+ svg.getString("content").replace("&lt;!-", "<!--")
					.replace("-&gt;", "-->") + "</g></svg>";
	System.out.println(content);
	String parser = XMLResourceDescriptor.getXMLParserClassName();
	try {
		SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
		Document doc = f.createSVGDocument("g", new ByteArrayInputStream(
				content.getBytes("UTF-8")));
		// DocumentBuilderFactory dbfactory =
		// DocumentBuilderFactory.newInstance();
		// DocumentBuilder docbuilder = dbfactory.newDocumentBuilder();
		// Document doc = docbuilder.parse(new
		// ByteArrayInputStream(content.getBytes("UTF-8")));
		traceNodes(doc, map);
		Document document = node.getOwnerDocument();
		Element g = document.createElement("g");
		g.setAttribute("transform", "translate(0,"
				+ (height * line + translateY) + ")");
		Node newnode = document.importNode(doc.getFirstChild(), true);
		Node parent = node.getParentNode();
		parent.insertBefore(g, node);
		g.appendChild(newnode);
	} catch (IOException e) {
		e.printStackTrace();
		// } catch (ParserConfigurationException e) {
		// e.printStackTrace();
		// } catch (SAXException e) {
		// e.printStackTrace();
	}
}
 
开发者ID:naofum,项目名称:thinreports-java,代码行数:41,代码来源:ThinReportsGenerator.java


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