Statistics
| Revision:

root / branches / FMap_03_raster / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / RasterAdapter.java @ 1930

History | View | Annotate | Download (5.39 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

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

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

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

    
101
        public void setTransparency(int trans) {
102
                ((RasterDriver) driver).setTransparency(trans);
103
        }
104

    
105
        /**
106
         * @see com.iver.cit.gvsig.fmap.layers.LayerOperations#draw(java.awt.image.BufferedImage, java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort)
107
         */
108
        public void draw(BufferedImage image, Graphics2D g, ViewPort vp, Cancellable cancel) throws DriverIOException {
109
                ((RasterDriver) driver).draw(image,g, vp);
110
        }
111

    
112
        public ArrayList getAttributes() {
113
                return ((RasterDriver) driver).getAttributes();
114
        }
115

    
116
        /**
117
         * Devuelve el colorBand activo en la banda especificada.
118
         * @param flag banda.
119
         * @return color de banda activo
120
         */
121
        public int getBand(int flag){
122
                return ((RasterDriver) driver).getBand(flag);
123
        }
124
        
125
        /**
126
         * Devuelve la posici?n del fichero para la banda especificada.
127
         * @param flag banda.
128
         * @return posici?n del fichero
129
         */
130
        public int getPosFile(int flag){
131
                return ((RasterDriver) driver).getPosFile(flag);
132
        }
133
                
134
        /**
135
         * Activa o desactiva la transparencia
136
         * @param t        true activa la transparencia y false la desactiva
137
         */
138
        public void setTransparency(boolean t){
139
                ((RasterDriver) driver).setTransparency(t);
140
        }
141
        
142
        /**
143
         * Asocia un colorBand al rojo, verde o azul.
144
         * @param flag cual (o cuales) de las bandas.
145
         * @param nBand        que colorBand
146
         */
147
        public void setBand(int flag, int nBand){
148
                ((RasterDriver) driver).setBand(flag, nBand);
149
        }
150
        
151
        /**
152
         * Obtiene el tipo de dato de la imagen
153
         * @return entero que representa el tipo de dato. La clase RasterBuf 
154
         * tiene accesible de forma est?tica todos los tipos de datos permitidos
155
         */
156
        public int getDataType(){
157
                return ((RasterDriver) driver).getRasterDataType();
158
        }
159
        
160
        /**
161
         * Obtiene la pila de filtros 
162
         * @return pila de filtros
163
         */
164
        public RasterFilterStack getFilterStack(){
165
                return ((RasterDriver) driver).getFilterStack();
166
        }
167
        
168
        /**
169
         * 
170
         * @return
171
         */
172
        public GeoRasterFile[] getFiles(){
173
                return ((RasterDriver) driver).getFiles();
174
        }
175
        
176
        /**
177
         * Obtiene el n?mero de bandas de la imagen
178
         * @return n?mero de bandas
179
         */
180
        public int getNumBands(){
181
                return ((RasterDriver)driver).getNumBands();
182
        }
183
        
184
        /**
185
         * Obtiene el extent de la vista
186
         * @return extent
187
         */
188
        public Rectangle2D getFullExtent(){
189
                return ((RasterDriver)driver).getFullExtent();
190
        }
191
        
192
        /**
193
         * Asigna un fichero al PxRaster
194
         * @param fileName Nombre del fichero
195
         */
196
        public void addFile(String fileName){
197
                ((RasterDriver)driver).addFile(fileName);
198
        }
199
        
200
        /**
201
         * Elimina un fichero al PxRaster
202
         * @param fileName Nombre del fichero
203
         */
204
        public void delFile(String fileName){
205
                ((RasterDriver)driver).delFile(fileName);
206
        }
207
}