Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_1_RELEASE / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / RasterAdapter.java @ 9531

History | View | Annotate | Download (6.72 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.filter.RasterFilterStack;
55
import org.cresques.io.GeoRasterFile;
56
import org.cresques.io.data.Grid;
57

    
58
import com.hardcode.driverManager.Driver;
59
import com.iver.cit.gvsig.fmap.ViewPort;
60
import com.iver.cit.gvsig.fmap.core.ISymbol;
61
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
62
import com.iver.cit.gvsig.fmap.drivers.GeorreferencedRasterDriver;
63
import com.iver.cit.gvsig.fmap.drivers.RasterDriver;
64
import com.iver.utiles.swing.threads.Cancellable;
65

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

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

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