root / tags / v1_0_2_Build_896 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / RasterAdapter.java @ 10391
History | View | Annotate | Download (7.12 KB)
1 | 567 | luisw | /*
|
---|---|---|---|
2 | * Created on 20-dic-2004
|
||
3 | */
|
||
4 | 1100 | fjp | /* 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 | 567 | luisw | package com.iver.cit.gvsig.fmap.layers; |
45 | |||
46 | 659 | luisw | import java.awt.Dimension; |
47 | 671 | luisw | import java.awt.Graphics2D; |
48 | 659 | luisw | import java.awt.Image; |
49 | import java.awt.geom.Rectangle2D; |
||
50 | 671 | luisw | import java.awt.image.BufferedImage; |
51 | 1680 | luisw | import java.util.ArrayList; |
52 | 659 | luisw | |
53 | import org.cresques.cts.ICoordTrans; |
||
54 | 5979 | nacho | import org.cresques.filter.RasterFilterStack; |
55 | 2183 | fernando | import org.cresques.io.GeoRasterFile; |
56 | 9056 | nacho | import org.cresques.io.data.Grid; |
57 | 10195 | nacho | import org.cresques.io.data.RasterBuf; |
58 | import org.cresques.px.Extent; |
||
59 | 659 | luisw | |
60 | 567 | luisw | import com.hardcode.driverManager.Driver; |
61 | 671 | luisw | import com.iver.cit.gvsig.fmap.ViewPort; |
62 | 8765 | jjdelcerro | import com.iver.cit.gvsig.fmap.core.ISymbol; |
63 | 671 | luisw | import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
64 | 9056 | nacho | import com.iver.cit.gvsig.fmap.drivers.GeorreferencedRasterDriver; |
65 | 567 | luisw | import com.iver.cit.gvsig.fmap.drivers.RasterDriver; |
66 | 5317 | fjp | import com.iver.utiles.swing.threads.Cancellable; |
67 | 567 | luisw | |
68 | /**
|
||
69 | * @author Luis W. Sevilla (sevilla_lui@gva.es)
|
||
70 | */
|
||
71 | public class RasterAdapter { |
||
72 | 1120 | luisw | private boolean driverInitialized = false; |
73 | 567 | luisw | private RasterDriver driver;
|
74 | |||
75 | 10195 | nacho | /**
|
76 | * Set data buffer to create a memory raster driver
|
||
77 | * @param buf data buffer
|
||
78 | */
|
||
79 | public void setBuffer(RasterBuf buf){ |
||
80 | ((RasterDriver) driver).setBuffer(buf); |
||
81 | } |
||
82 | |||
83 | /**
|
||
84 | * Set extent to create a memory raster driver
|
||
85 | * @param ext Extent
|
||
86 | */
|
||
87 | public void setExtent(Extent ext){ |
||
88 | ((RasterDriver) driver).setExtent(ext); |
||
89 | } |
||
90 | |||
91 | 567 | luisw | /**
|
92 | * Establece el driver sobre el que act?a el adaptador
|
||
93 | */
|
||
94 | public void setDriver(Driver driver) { |
||
95 | this.driver = (RasterDriver) driver;
|
||
96 | } |
||
97 | |||
98 | /**
|
||
99 | * Obtiene una referencia al objeto que implementa la interfaz vectorial con
|
||
100 | * el fin de que las Strategy puedan optimizar en funci?n del driver.
|
||
101 | */
|
||
102 | public Driver getDriver(){ |
||
103 | return driver;
|
||
104 | } |
||
105 | 659 | luisw | |
106 | /**
|
||
107 | * Obtiene una imagen de tama?o especificado, de la zona (en
|
||
108 | * coordenadas de usuario) que se le pide.
|
||
109 | * @param size Tama?o (en p?xeles de im?gen).
|
||
110 | * @param userSize Zona especificada (en coordenadas de usuario).
|
||
111 | * @param rp Reproyecci?n.
|
||
112 | * @return La imagen.
|
||
113 | */
|
||
114 | public Image getImage(Dimension size, Rectangle2D userSize, ICoordTrans rp) { |
||
115 | return ((RasterDriver) driver).getImage(size, userSize, rp);
|
||
116 | } |
||
117 | 1455 | luisw | |
118 | 2183 | fernando | /**
|
119 | * Obtiene el valor de transparencia
|
||
120 | * @return entero que representa el valor de transparencia
|
||
121 | */
|
||
122 | 1455 | luisw | public int getTransparency() { |
123 | return ((RasterDriver) driver).getTransparency();
|
||
124 | } |
||
125 | 2183 | fernando | |
126 | /**
|
||
127 | * Asigna el valor de transparencia
|
||
128 | * @param trans entero que representa el valor de transparencia
|
||
129 | */
|
||
130 | 1455 | luisw | public void setTransparency(int trans) { |
131 | ((RasterDriver) driver).setTransparency(trans); |
||
132 | } |
||
133 | |||
134 | 671 | luisw | /**
|
135 | 8765 | jjdelcerro | * @see com.iver.cit.gvsig.fmap.layers.LayerOperations#draw(java.awt.image.BufferedImage, java.awt.Graphics2D, ISymbol)
|
136 | 671 | luisw | */
|
137 | public void draw(BufferedImage image, Graphics2D g, ViewPort vp, Cancellable cancel) throws DriverIOException { |
||
138 | ((RasterDriver) driver).draw(image,g, vp); |
||
139 | } |
||
140 | 2183 | fernando | |
141 | /**
|
||
142 | * Obtiene la lista de atributos de raster
|
||
143 | * @return lista de atributos. Cada elmento de la lista es un array Object
|
||
144 | * con dos elementos. El primero el nombre del atributo y el segundo el valor
|
||
145 | * del mismo.
|
||
146 | */
|
||
147 | 1680 | luisw | public ArrayList getAttributes() { |
148 | return ((RasterDriver) driver).getAttributes();
|
||
149 | } |
||
150 | 2183 | fernando | |
151 | /**
|
||
152 | * Devuelve el colorBand activo en la banda especificada.
|
||
153 | * @param flag banda.
|
||
154 | * @return color de banda activo
|
||
155 | */
|
||
156 | public int getBand(int flag){ |
||
157 | return ((RasterDriver) driver).getBand(flag);
|
||
158 | } |
||
159 | |||
160 | /**
|
||
161 | * Devuelve la posici?n del fichero para la banda especificada.
|
||
162 | * @param flag banda.
|
||
163 | * @return posici?n del fichero
|
||
164 | */
|
||
165 | public int getPosFile(int flag){ |
||
166 | return ((RasterDriver) driver).getPosFile(flag);
|
||
167 | } |
||
168 | |||
169 | /**
|
||
170 | * Activa o desactiva la transparencia
|
||
171 | * @param t true activa la transparencia y false la desactiva
|
||
172 | */
|
||
173 | public void setTransparency(boolean t){ |
||
174 | ((RasterDriver) driver).setTransparency(t); |
||
175 | } |
||
176 | |||
177 | /**
|
||
178 | * Asocia un colorBand al rojo, verde o azul.
|
||
179 | * @param flag cual (o cuales) de las bandas.
|
||
180 | * @param nBand que colorBand
|
||
181 | */
|
||
182 | public void setBand(int flag, int nBand){ |
||
183 | ((RasterDriver) driver).setBand(flag, nBand); |
||
184 | } |
||
185 | |||
186 | /**
|
||
187 | * Obtiene el tipo de dato de la imagen
|
||
188 | * @return entero que representa el tipo de dato. La clase RasterBuf
|
||
189 | * tiene accesible de forma est?tica todos los tipos de datos permitidos
|
||
190 | */
|
||
191 | public int getDataType(){ |
||
192 | return ((RasterDriver) driver).getRasterDataType();
|
||
193 | } |
||
194 | |||
195 | /**
|
||
196 | * Obtiene la pila de filtros
|
||
197 | * @return pila de filtros
|
||
198 | */
|
||
199 | public RasterFilterStack getFilterStack(){
|
||
200 | return ((RasterDriver) driver).getFilterStack();
|
||
201 | } |
||
202 | |||
203 | /**
|
||
204 | 2623 | nacho | * Asigna la pila de filtros
|
205 | * @param pila de filtros
|
||
206 | */
|
||
207 | public void setFilterStack(RasterFilterStack stack){ |
||
208 | ((RasterDriver) driver).setFilterStack(stack); |
||
209 | } |
||
210 | |||
211 | /**
|
||
212 | 2183 | fernando | *
|
213 | * @return
|
||
214 | */
|
||
215 | public GeoRasterFile[] getFiles(){ |
||
216 | return ((RasterDriver) driver).getFiles();
|
||
217 | } |
||
218 | |||
219 | /**
|
||
220 | * Obtiene el n?mero de bandas de la imagen
|
||
221 | * @return n?mero de bandas
|
||
222 | */
|
||
223 | public int getNumBands(){ |
||
224 | return ((RasterDriver)driver).getNumBands();
|
||
225 | } |
||
226 | |||
227 | /**
|
||
228 | * Obtiene el extent de la vista
|
||
229 | * @return extent
|
||
230 | */
|
||
231 | public Rectangle2D getFullExtent(){ |
||
232 | return ((RasterDriver)driver).getFullExtent();
|
||
233 | } |
||
234 | |||
235 | /**
|
||
236 | * Asigna un fichero al PxRaster
|
||
237 | * @param fileName Nombre del fichero
|
||
238 | */
|
||
239 | public void addFile(String fileName){ |
||
240 | ((RasterDriver)driver).addFile(fileName); |
||
241 | } |
||
242 | |||
243 | /**
|
||
244 | * Elimina un fichero al PxRaster
|
||
245 | * @param fileName Nombre del fichero
|
||
246 | */
|
||
247 | public void delFile(String fileName){ |
||
248 | ((RasterDriver)driver).delFile(fileName); |
||
249 | } |
||
250 | 2322 | igbrotru | |
251 | /**
|
||
252 | * Obtiene el valor del pixel del Image en la posici?n x,y
|
||
253 | * @param x Posici?n x
|
||
254 | * @param y Posici?n y
|
||
255 | * @return valor de pixel
|
||
256 | */
|
||
257 | 2347 | igbrotru | public int[] getPixel(double wcx, double wcy){ |
258 | return ((RasterDriver)driver).getPixel(wcx, wcy);
|
||
259 | 2322 | igbrotru | } |
260 | 6037 | nacho | |
261 | /**
|
||
262 | * Obtiene el flag que dice si la imagen est? o no georreferenciada
|
||
263 | * @return true si est? georreferenciada y false si no lo est?.
|
||
264 | */
|
||
265 | public boolean isGeoreferenced() { |
||
266 | 9056 | nacho | return ((GeorreferencedRasterDriver)driver).isGeoreferenced();
|
267 | 6037 | nacho | } |
268 | 9056 | nacho | |
269 | /**
|
||
270 | * Obtiene el grid asociado
|
||
271 | * @return grid
|
||
272 | */
|
||
273 | public Grid getGrid(){
|
||
274 | return ((RasterDriver)driver).getGrid();
|
||
275 | } |
||
276 | 567 | luisw | } |