aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/image/EPSImage.java
blob: 7bcf1e484e42517f5505643b2f4a3b2767148545 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
 * $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 java.net.URLConnection;
import java.io.InputStream;
import java.io.IOException;

// FOP
import org.apache.fop.apps.Driver;
import org.apache.fop.messaging.*;
import org.apache.fop.datatypes.ColorSpace;
import org.apache.fop.pdf.PDFColor;
import org.apache.fop.image.analyser.ImageReader;
import org.apache.fop.image.analyser.EPSReader;

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


/**
 * @see AbstractFopImage
 * @see FopImage
 */
public class EPSImage extends AbstractFopImage {
    private String docName;
    private int[] bbox;
    
    private byte[] epsImage = null;
    private EPSReader epsReader = null;
    
	/**
         * Initialize docName and bounding box
         */
    private void init(URL href) {
        bbox = new int[4];
        bbox[0] = 0;
        bbox[1] = 0;
        bbox[2] = 0;
        bbox[3] = 0;
        
        docName = href.toString();
    }
    
	/**
         * Return the name of the eps
         */
    public String getDocName() {
        return docName;
    }
    
	/**
         * Return the bounding box
         */
    public int[] getBBox() {
        return bbox;
    }
    
    public EPSImage(URL href) throws FopImageException {
        super(href);
        init(href);
    }
    
    public EPSImage(URL href,
                    ImageReader imgReader) throws FopImageException {
        super(href, imgReader);
        init(href);
        if (imgReader instanceof EPSReader) {
            EPSReader eimgReader = (EPSReader)imgReader;
            epsReader = eimgReader;
            epsImage = eimgReader.getEpsFile();
            m_bitmaps = epsImage;
            bbox = eimgReader.getBBox();
        }
    }
    
    protected void loadImage() throws FopImageException {
            // Image is loaded in reader
    }
    
    public byte[] getEPSImage() throws FopImageException {
       	if (epsImage == null) {
            //log.error("ERROR LOADING EXTERNAL EPS");
        }
        return epsImage;
    }
    
}