blob: 49e69865ea939c0d90f062496e3232902ffd1575 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
package org.apache.fop.image;
// Java
import java.net.URL;
import org.w3c.dom.svg.SVGDocument;
// FOP
import org.apache.fop.apps.Driver;
import org.apache.fop.image.analyser.ImageReader;
import org.apache.fop.image.analyser.SVGReader;
import org.apache.fop.fo.FOUserAgent;
import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
/**
* @see AbstractFopImage
* @see FopImage
*/
public class SVGImage extends AbstractFopImage {
SVGDocument doc;
public SVGImage(URL href, ImageReader imgReader) {
super(href, imgReader);
if(imgReader instanceof SVGReader) {
doc = (SVGDocument)((SVGReader)imgReader).getDocument();
}
}
/**
* creates a SAX parser, using the value of org.xml.sax.parser
* defaulting to org.apache.xerces.parsers.SAXParser
*
* @return the created SAX parser
*/
public static String getParserName() {
String parserClassName = Driver.getParserClassName();
return parserClassName;
}
protected boolean loadData(FOUserAgent ua) {
try {
SAXSVGDocumentFactory factory =
new SAXSVGDocumentFactory(SVGImage.getParserName());
doc = factory.createDocument(this.m_href.toExternalForm());
} catch (Exception e) {
ua.getLogger().error("Could not load external SVG: "
+ e.getMessage(), e);
return false;
}
return true;
}
public SVGDocument getSVGDocument() {
return doc;
}
}
|