aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/image/SVGImage.java
blob: 4fd0d1b7bcd2760be12a1c2af5b7244596a908bd (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
65
66
67
68
69
/*
 * $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.datatypes.ColorSpace;
import org.apache.fop.pdf.PDFColor;
import org.apache.fop.image.analyser.ImageReader;

import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;

import org.apache.batik.dom.svg.SAXSVGDocumentFactory;

/**
 * @see AbstractFopImage
 * @see FopImage
 */
public class SVGImage extends AbstractFopImage {
    SVGDocument doc;

    public SVGImage(URL href) throws FopImageException {
        super(href);
    }

    public SVGImage(URL href,
                    ImageReader imgReader) throws FopImageException {
        super(href, imgReader);
    }

    /**
     * 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 void loadImage() throws FopImageException {
        try {
            SAXSVGDocumentFactory factory =
                new SAXSVGDocumentFactory(SVGImage.getParserName());
            doc = factory.createDocument(this.m_href.toExternalForm());
        } catch (Exception e) {
            //log.error("Could not load external SVG: "
            //                       + e.getMessage());
        }
    }

    public SVGDocument getSVGDocument() throws FopImageException {
        if (doc == null)
            this.loadImage();
        return doc;
    }

}