Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / RasterFileAdapter.java @ 573

History | View | Annotate | Download (3.19 KB)

1 567 luisw
/*
2
 * Created on 20-dic-2004
3
 */
4
package com.iver.cit.gvsig.fmap.layers;
5
6
import com.hardcode.driverManager.Driver;
7
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
8
import com.iver.cit.gvsig.fmap.drivers.RasterDriver;
9
10
import java.awt.geom.Rectangle2D;
11
12
import java.io.File;
13
import java.io.IOException;
14
15
16
/**
17
 * Adapta un driver de fichero vectorial a la interfaz vectorial, manteniendo
18
 * adem?s el estado necesario por una capa vectorial de fichero (el nombre del
19
 * fichero)
20
 */
21
public class RasterFileAdapter extends RasterAdapter {
22
        private boolean driverInitialized = false;
23
        private File file;
24
        //private FileWriterDriver writeDriver;
25
26
        /**
27
         * Crea un nuevo VectorialFileAdapter.
28
         *
29
         * @param file DOCUMENT ME!
30
         */
31
        public RasterFileAdapter(File file) {
32
                this.file = file;
33
        }
34
35
        /**
36
         * DOCUMENT ME!
37
         *
38
         * @return DOCUMENT ME!
39
         */
40
        private RasterDriver getFileDriver() {
41
                return (RasterDriver) getDriver();
42
        }
43
44
        /**
45
         * incrementa el contador de las veces que se ha abierto el fichero.
46
         * Solamente cuando el contador est? a cero pide al driver que abra el
47
         * fichero
48
         *
49
         * @throws DriverIOException
50
         */
51
        public void start() throws DriverIOException {
52
                try {
53
                        getFileDriver().open(file);
54
55
                        if (!driverInitialized) {
56
                                getFileDriver().initialize();
57
                                driverInitialized = true;
58
                        }
59
                } catch (IOException e) {
60
                        throw new DriverIOException(e);
61
                }
62
        }
63
64
        /**
65
         * decrementa el contador de n?mero de aperturas y cuando llega a cero pide
66
         * al driver que cierre el fichero
67
         *
68
         * @throws DriverIOException
69
         */
70
        public void stop() throws DriverIOException {
71
                try {
72
                        getFileDriver().close();
73
                } catch (IOException e) {
74
                        throw new DriverIOException(e);
75
                }
76
        }
77
78
        public int getNumBands() {
79
                return getFileDriver().getNumBands();
80
        }
81
82
        public Rectangle2D getFullExtent() {
83
                return getFileDriver().getFullExtent();
84
        }
85
86
        /**
87
         * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShapeType()
88
         */
89
        public int getRasterDataType() {
90
                return getFileDriver().getRasterDataType();
91
        }
92
93
    /**
94
     * Obtiene una muestra del pixel que se pasa como par?metro en la banda que se pasa como par?metro
95
     */
96
        public Object getData(int x, int y, int band) {
97
                return getFileDriver().getData(x, y, band);
98
        }
99
100
    /**
101
     * Obtiene una muestra del pixel que se pasa como par?metro en la banda que se pasa como par?metro
102
     */
103
        public int getDataAsInt(int x, int y, int band) {
104
                return getFileDriver().getDataAsInt(x, y, band);
105
        }
106
107
    /**
108
     * Obtiene una muestra del pixel que se pasa como par?metro en la banda que se pasa como par?metro
109
     */
110
        public byte getDataAsByte(int x, int y, int band) {
111
                return getFileDriver().getDataAsByte(x, y, band);
112
        }
113
114
    /**
115
     * Obtiene una muestra del pixel que se pasa como par?metro en la banda que se pasa como par?metro
116
     */
117
        public float getDataAsFloat(int x, int y, int band) {
118
                return getFileDriver().getDataAsFloat(x, y, band);
119
        }
120
121
    /**
122
     * Obtiene una muestra el pixel que se pasa como par?metro en la banda que se pasa como par?metro
123
     */
124
        public double getDataAsDouble(int x, int y, int band) {
125
                return getFileDriver().getDataAsDouble(x, y, band);
126
        }
127
        /**
128
         * DOCUMENT ME!
129
         *
130
         * @return DOCUMENT ME!
131
         */
132
        public File getFile() {
133
                return file;
134
        }
135
}