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