Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / RasterAdapter.java @ 2183

History | View | Annotate | Download (5.86 KB)

1
/*
2
 * Created on 20-dic-2004
3
 */
4
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
package com.iver.cit.gvsig.fmap.layers;
45

    
46
import java.awt.Dimension;
47
import java.awt.Graphics2D;
48
import java.awt.Image;
49
import java.awt.geom.Rectangle2D;
50
import java.awt.image.BufferedImage;
51
import java.util.ArrayList;
52

    
53
import org.cresques.cts.ICoordTrans;
54
import org.cresques.io.GeoRasterFile;
55
import org.cresques.io.raster.RasterFilterStack;
56
import org.cresques.px.Extent;
57

    
58
import com.hardcode.driverManager.Driver;
59
import com.iver.cit.gvsig.fmap.ViewPort;
60
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
61
import com.iver.cit.gvsig.fmap.drivers.RasterDriver;
62
import com.iver.cit.gvsig.fmap.operations.Cancellable;
63

    
64
/**
65
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
66
 */
67
public class RasterAdapter {
68
        private boolean driverInitialized = false;
69
        private RasterDriver driver;
70
        
71
    /**
72
     * Establece el driver sobre el que act?a el adaptador 
73
     */
74
    public void setDriver(Driver driver) {
75
            this.driver = (RasterDriver) driver;
76
    }
77

    
78
        /**
79
     * Obtiene una referencia al objeto que implementa la interfaz vectorial con
80
     *  el fin de que las Strategy puedan optimizar en funci?n del driver.
81
     */
82
    public Driver getDriver(){
83
            return driver;
84
    }
85
    
86
        /**
87
         * Obtiene una imagen de tama?o especificado, de la zona (en
88
         * coordenadas de usuario) que se le pide.
89
         * @param size        Tama?o (en p?xeles de im?gen).
90
         * @param userSize Zona especificada (en coordenadas de usuario).
91
         * @param rp Reproyecci?n.
92
         * @return La imagen.
93
         */
94
        public Image getImage(Dimension size, Rectangle2D userSize, ICoordTrans rp) {
95
                return ((RasterDriver) driver).getImage(size, userSize, rp);
96
        }
97
        
98
        /**
99
         * Obtiene el valor de transparencia
100
         * @return entero que representa el valor de transparencia
101
         */
102
        public int getTransparency() {
103
                return ((RasterDriver) driver).getTransparency();
104
        }
105
        
106
        /**
107
         * Asigna el valor de transparencia
108
         * @param trans        entero que representa el valor de transparencia
109
         */
110
        public void setTransparency(int trans) {
111
                ((RasterDriver) driver).setTransparency(trans);
112
        }
113

    
114
        /**
115
         * @see com.iver.cit.gvsig.fmap.layers.LayerOperations#draw(java.awt.image.BufferedImage, java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort)
116
         */
117
        public void draw(BufferedImage image, Graphics2D g, ViewPort vp, Cancellable cancel) throws DriverIOException {
118
                ((RasterDriver) driver).draw(image,g, vp);
119
        }
120
        
121
        /**
122
         * Obtiene la lista de atributos de raster
123
         * @return        lista de atributos. Cada elmento de la lista es un array Object
124
         * con dos elementos. El primero el nombre del atributo y el segundo el valor
125
         * del mismo.
126
         */
127
        public ArrayList getAttributes() {
128
                return ((RasterDriver) driver).getAttributes();
129
        }
130
        
131
        /**
132
         * Devuelve el colorBand activo en la banda especificada.
133
         * @param flag banda.
134
         * @return color de banda activo
135
         */
136
        public int getBand(int flag){
137
                return ((RasterDriver) driver).getBand(flag);
138
        }
139
        
140
        /**
141
         * Devuelve la posici?n del fichero para la banda especificada.
142
         * @param flag banda.
143
         * @return posici?n del fichero
144
         */
145
        public int getPosFile(int flag){
146
                return ((RasterDriver) driver).getPosFile(flag);
147
        }
148
                
149
        /**
150
         * Activa o desactiva la transparencia
151
         * @param t        true activa la transparencia y false la desactiva
152
         */
153
        public void setTransparency(boolean t){
154
                ((RasterDriver) driver).setTransparency(t);
155
        }
156
        
157
        /**
158
         * Asocia un colorBand al rojo, verde o azul.
159
         * @param flag cual (o cuales) de las bandas.
160
         * @param nBand        que colorBand
161
         */
162
        public void setBand(int flag, int nBand){
163
                ((RasterDriver) driver).setBand(flag, nBand);
164
        }
165
        
166
        /**
167
         * Obtiene el tipo de dato de la imagen
168
         * @return entero que representa el tipo de dato. La clase RasterBuf 
169
         * tiene accesible de forma est?tica todos los tipos de datos permitidos
170
         */
171
        public int getDataType(){
172
                return ((RasterDriver) driver).getRasterDataType();
173
        }
174
        
175
        /**
176
         * Obtiene la pila de filtros 
177
         * @return pila de filtros
178
         */
179
        public RasterFilterStack getFilterStack(){
180
                return ((RasterDriver) driver).getFilterStack();
181
        }
182
        
183
        /**
184
         * 
185
         * @return
186
         */
187
        public GeoRasterFile[] getFiles(){
188
                return ((RasterDriver) driver).getFiles();
189
        }
190
        
191
        /**
192
         * Obtiene el n?mero de bandas de la imagen
193
         * @return n?mero de bandas
194
         */
195
        public int getNumBands(){
196
                return ((RasterDriver)driver).getNumBands();
197
        }
198
        
199
        /**
200
         * Obtiene el extent de la vista
201
         * @return extent
202
         */
203
        public Rectangle2D getFullExtent(){
204
                return ((RasterDriver)driver).getFullExtent();
205
        }
206
        
207
        /**
208
         * Asigna un fichero al PxRaster
209
         * @param fileName Nombre del fichero
210
         */
211
        public void addFile(String fileName){
212
                ((RasterDriver)driver).addFile(fileName);
213
        }
214
        
215
        /**
216
         * Elimina un fichero al PxRaster
217
         * @param fileName Nombre del fichero
218
         */
219
        public void delFile(String fileName){
220
                ((RasterDriver)driver).delFile(fileName);
221
        }
222
}