本文整理汇总了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();
}
示例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);
}
});
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
}
示例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;
}
示例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;
}
示例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("<!-", "<!--")
.replace("->", "-->") + "</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();
}
}