Revision 2669 branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/px/PxRaster.java
PxRaster.java | ||
---|---|---|
1 | 1 |
/* |
2 | 2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications. |
3 |
* |
|
4 |
* Copyright (C) 2004-5. |
|
5 | 3 |
* |
4 |
* Copyright (C) 2004-5. |
|
5 |
* |
|
6 | 6 |
* This program is free software; you can redistribute it and/or |
7 | 7 |
* modify it under the terms of the GNU General Public License |
8 | 8 |
* as published by the Free Software Foundation; either version 2 |
... | ... | |
18 | 18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
19 | 19 |
* |
20 | 20 |
* For more information, contact: |
21 |
*
|
|
21 |
* |
|
22 | 22 |
* cresques@gmail.com |
23 | 23 |
*/ |
24 | 24 |
package org.cresques.px; |
25 | 25 |
|
26 |
import org.cresques.cts.ICoordTrans; |
|
27 |
import org.cresques.cts.IProjection; |
|
28 |
|
|
29 |
import org.cresques.geo.Projected; |
|
30 |
import org.cresques.geo.ViewPortData; |
|
31 |
|
|
32 |
import org.cresques.io.EcwFile; |
|
33 |
import org.cresques.io.GdalFile; |
|
34 |
import org.cresques.io.GeoRasterFile; |
|
35 |
import org.cresques.io.raster.RasterBuf; |
|
36 |
import org.cresques.io.raster.RasterFilterStack; |
|
37 |
import org.cresques.io.raster.RasterFilterStackManager; |
|
38 |
import org.cresques.io.raster.RasterStats; |
|
39 |
import org.cresques.io.raster.RasterToImageFilter; |
|
40 |
|
|
26 | 41 |
import java.awt.Color; |
27 | 42 |
import java.awt.Component; |
28 | 43 |
import java.awt.Graphics2D; |
... | ... | |
32 | 47 |
import java.awt.image.BufferedImage; |
33 | 48 |
import java.awt.image.DataBuffer; |
34 | 49 |
import java.awt.image.ImageObserver; |
50 |
|
|
35 | 51 |
import java.util.ArrayList; |
36 | 52 |
import java.util.Date; |
37 | 53 |
import java.util.Vector; |
38 | 54 |
|
39 |
import org.cresques.cts.ICoordTrans; |
|
40 |
import org.cresques.cts.IProjection; |
|
41 |
import org.cresques.geo.Projected; |
|
42 |
import org.cresques.geo.ViewPortData; |
|
43 |
import org.cresques.io.EcwFile; |
|
44 |
import org.cresques.io.GdalFile; |
|
45 |
import org.cresques.io.GeoRasterFile; |
|
46 |
import org.cresques.io.raster.RasterBuf; |
|
47 |
import org.cresques.io.raster.RasterFilterStack; |
|
48 |
import org.cresques.io.raster.RasterFilterStackManager; |
|
49 |
import org.cresques.io.raster.RasterStats; |
|
50 |
import org.cresques.io.raster.RasterToImageFilter; |
|
51 | 55 |
|
52 | 56 |
/** |
53 |
*
|
|
57 |
* |
|
54 | 58 |
* @author Luis W. Sevilla (sevilla_lui@gva.es) |
55 | 59 |
* @author Nacho Brodin (brodin_ign@gva.es) |
56 | 60 |
* |
57 | 61 |
*/ |
58 | 62 |
public class PxRaster extends PxObj implements Projected { |
59 |
protected GeoRasterFile[] geoFile = null; |
|
60 |
protected ImageObserver component = null; |
|
61 |
Vector pts = null; |
|
62 |
// Soporte para n bandas, visibles de 3 en 3, en ficheros separados |
|
63 |
//protected GeoRasterFile [] colorBand = null; |
|
64 |
protected int rBand = 1, gBand = 2, bBand = 3; |
|
65 |
|
|
66 |
public RasterStats stats = new RasterStats(); |
|
67 |
int transparente = 0x10ffff80; |
|
63 |
protected GeoRasterFile[] geoFile = null; |
|
64 |
protected ImageObserver component = null; |
|
65 |
Vector pts = null; |
|
68 | 66 |
|
69 |
String vName = null; |
|
70 |
protected boolean pintaMarco = false; //true; |
|
71 |
IProjection proj = null; |
|
72 |
protected Extent extentOrig = null; |
|
73 |
ICoordTrans rp = null; |
|
74 |
|
|
75 |
public RasterFilterStack filterStack = new RasterFilterStack(stats); |
|
76 |
private BandSwitch bandSwitch = new BandSwitch(); |
|
77 |
private boolean firstPxRaster = true; |
|
78 |
private final double percentFilterInit = 0.02; |
|
79 |
private RasterFilterStackManager stackManager = null; |
|
80 |
private Image geoImage = null; |
|
81 |
private ViewPortData lastViewPort = null; |
|
82 |
|
|
83 |
/** |
|
84 |
* Estructura que representa la relaci?n entre un fichero y la banda que se |
|
85 |
* utiliza de este. |
|
86 |
* @author Nacho Brodin <brodin_ign@gva.es> |
|
87 |
*/ |
|
88 |
class FileBands{ |
|
89 |
GeoRasterFile grf; //Fichero |
|
90 |
int band; //Banda asinada |
|
91 |
int filePos; //posici?n del fichero |
|
92 |
|
|
93 |
|
|
94 |
/** |
|
95 |
* @return Returns the band. |
|
96 |
*/ |
|
97 |
public int getBand() { |
|
98 |
return band; |
|
99 |
} |
|
100 |
/** |
|
101 |
* @param band The band to set. |
|
102 |
*/ |
|
103 |
public void setBand(int band) { |
|
104 |
this.band = band; |
|
105 |
} |
|
106 |
/** |
|
107 |
* @return Returns the band. |
|
108 |
*/ |
|
109 |
public int getPos() { |
|
110 |
return filePos; |
|
111 |
} |
|
112 |
/** |
|
113 |
* @param band The band to set. |
|
114 |
*/ |
|
115 |
public void setPos(int pos) { |
|
116 |
this.filePos = pos; |
|
117 |
} |
|
118 |
/** |
|
119 |
* @return Returns the grf. |
|
120 |
*/ |
|
121 |
public GeoRasterFile getGeoRasterFile() { |
|
122 |
return grf; |
|
123 |
} |
|
124 |
/** |
|
125 |
* @param grf The grf to set. |
|
126 |
*/ |
|
127 |
public void setGeoRasterFile(GeoRasterFile grf) { |
|
128 |
this.grf = grf; |
|
129 |
} |
|
130 |
} |
|
131 |
|
|
132 |
/** |
|
133 |
* Clase que lleva la gesti?n entre la relaci?n de ficheros representados |
|
134 |
* por un GeoRasterFile y el n?mero de bandas que contienen. Esto es necesario |
|
135 |
* para la actualizaci?n de la vista ya que para un Image dado podemos tener |
|
136 |
* multiples bandas que pueden ser leidas desde diferentes ficheros. |
|
137 |
* |
|
138 |
* @author Nacho Brodin <brodin_ign@gva.es> |
|
139 |
*/ |
|
140 |
class BandSwitch{ |
|
141 |
private ArrayList geoFiles = new ArrayList(); //Lista de GeoRasterFile con los ficheros raster cargados |
|
142 |
private FileBands[] listBands = new FileBands[3]; |
|
143 |
private boolean debug = false; |
|
144 |
|
|
145 |
BandSwitch(){ |
|
146 |
for(int i=0;i<listBands.length;i++) |
|
147 |
listBands[i] = new FileBands(); |
|
148 |
} |
|
149 |
|
|
150 |
/** |
|
151 |
* A?ade un fichero |
|
152 |
* @param grf |
|
153 |
*/ |
|
154 |
public void addFile(GeoRasterFile grf){ |
|
155 |
geoFiles.add(grf); |
|
156 |
if(debug) |
|
157 |
this.show("addFile"); |
|
158 |
} |
|
159 |
|
|
160 |
/** |
|
161 |
* Elimina un fichero |
|
162 |
* @param grf |
|
163 |
*/ |
|
164 |
public void removeFile(GeoRasterFile grf){ |
|
165 |
for(int iFile=0;iFile<geoFiles.size();iFile++){ |
|
166 |
if(grf.equals(geoFiles.get(iFile))){ |
|
167 |
geoFiles.remove(iFile); |
|
168 |
iFile--; |
|
169 |
} |
|
170 |
} |
|
171 |
|
|
172 |
if(debug) |
|
173 |
this.show("removeFile"); |
|
174 |
} |
|
175 |
|
|
176 |
/** |
|
177 |
* |
|
178 |
* @param flag |
|
179 |
* @param grf |
|
180 |
* @param nBand |
|
181 |
*/ |
|
182 |
public void setBand(int flag, GeoRasterFile grf, int nBand){ |
|
183 |
if ((flag & GeoRasterFile.RED_BAND) == GeoRasterFile.RED_BAND){ |
|
184 |
listBands[0].setBand(nBand); |
|
185 |
listBands[0].setGeoRasterFile(grf); |
|
186 |
}else if ((flag & GeoRasterFile.GREEN_BAND) == GeoRasterFile.GREEN_BAND){ |
|
187 |
listBands[1].setBand(nBand); |
|
188 |
listBands[1].setGeoRasterFile(grf); |
|
189 |
}else if ((flag & GeoRasterFile.BLUE_BAND) == GeoRasterFile.BLUE_BAND){ |
|
190 |
listBands[2].setBand(nBand); |
|
191 |
listBands[2].setGeoRasterFile(grf); |
|
192 |
}else |
|
193 |
return; |
|
194 |
grf.setBand(flag, nBand); |
|
195 |
} |
|
196 |
|
|
197 |
/** |
|
198 |
* Asigna las bandas |
|
199 |
* @param flag |
|
200 |
* @param nBand |
|
201 |
*/ |
|
202 |
public void setBand(int flag, int nBand){ |
|
203 |
int cont = 0; |
|
204 |
for(int iGrf=0;iGrf<geoFiles.size();iGrf++){ |
|
205 |
for(int iBand=0;iBand<((GeoRasterFile)geoFiles.get(iGrf)).getBandCount();iBand++){ |
|
206 |
if ( ((flag & GeoRasterFile.RED_BAND) == GeoRasterFile.RED_BAND) && |
|
207 |
cont == nBand){ |
|
208 |
listBands[0].setGeoRasterFile(((GeoRasterFile)geoFiles.get(iGrf))); |
|
209 |
listBands[0].setBand(iBand); |
|
210 |
listBands[0].setPos(iGrf); |
|
211 |
((GeoRasterFile)geoFiles.get(iGrf)).setBand(flag, iBand); |
|
212 |
//System.out.println("==>Asignando banda R FILE="+iGrf+" BANDA="+iBand); |
|
213 |
}else if ( ((flag & GeoRasterFile.GREEN_BAND) == GeoRasterFile.GREEN_BAND) && |
|
214 |
cont == nBand){ |
|
215 |
listBands[1].setGeoRasterFile(((GeoRasterFile)geoFiles.get(iGrf))); |
|
216 |
listBands[1].setBand(iBand); |
|
217 |
listBands[1].setPos(iGrf); |
|
218 |
((GeoRasterFile)geoFiles.get(iGrf)).setBand(flag, iBand); |
|
219 |
//System.out.println("==>Asignando banda G FILE="+iGrf+" BANDA="+iBand); |
|
220 |
}else if ( ((flag & GeoRasterFile.BLUE_BAND) == GeoRasterFile.BLUE_BAND) && |
|
221 |
cont == nBand){ |
|
222 |
listBands[2].setGeoRasterFile(((GeoRasterFile)geoFiles.get(iGrf))); |
|
223 |
listBands[2].setBand(iBand); |
|
224 |
listBands[2].setPos(iGrf); |
|
225 |
((GeoRasterFile)geoFiles.get(iGrf)).setBand(flag, iBand); |
|
226 |
//System.out.println("==>Asignando banda B FILE="+iGrf+" BANDA="+iBand); |
|
227 |
} |
|
228 |
cont++; |
|
229 |
} |
|
230 |
} |
|
231 |
|
|
232 |
if(debug) |
|
233 |
this.show("setBand"); |
|
234 |
} |
|
235 |
|
|
236 |
/** |
|
237 |
* Obtiene el n?mero de bandas |
|
238 |
* @return |
|
239 |
*/ |
|
240 |
public int getBandCount(){ |
|
241 |
int nbandas = 0; |
|
242 |
for(int iGrf=0;iGrf<geoFiles.size();iGrf++) |
|
243 |
nbandas += ((GeoRasterFile)geoFiles.get(iGrf)).getBandCount(); |
|
244 |
return nbandas; |
|
245 |
} |
|
246 |
|
|
247 |
/** |
|
248 |
* Obtiene el GeoRasterFile que hay que leer para cargar la banda del rojo |
|
249 |
* y la banda de este fichero que se utiliza para esta asignaci?n. |
|
250 |
* @return Estructura FileBand con la relaci?n fichero-banda |
|
251 |
*/ |
|
252 |
public FileBands getBandR(){ |
|
253 |
return listBands[0]; |
|
254 |
} |
|
255 |
|
|
256 |
/** |
|
257 |
* Obtiene el GeoRasterFile que hay que leer para cargar la banda del verde |
|
258 |
* y la banda de este fichero que se utiliza para esta asignaci?n. |
|
259 |
* @return Estructura FileBand con la relaci?n fichero-banda |
|
260 |
*/ |
|
261 |
public FileBands getBandG(){ |
|
262 |
return listBands[1]; |
|
263 |
} |
|
264 |
|
|
265 |
/** |
|
266 |
* Obtiene el GeoRasterFile que hay que leer para cargar la banda del azul |
|
267 |
* y la banda de este fichero que se utiliza para esta asignaci?n. |
|
268 |
* @return Estructura FileBand con la relaci?n fichero-banda |
|
269 |
*/ |
|
270 |
public FileBands getBandB(){ |
|
271 |
return listBands[2]; |
|
272 |
} |
|
273 |
|
|
274 |
public void show(String op){ |
|
275 |
String banda = null; |
|
276 |
System.out.println("** "+op+" **"); |
|
277 |
for(int i=0;i<3;i++){ |
|
278 |
if(i==0) |
|
279 |
banda = new String("Rojo"); |
|
280 |
else if(i==1) |
|
281 |
banda = new String("Verde"); |
|
282 |
else if(i==2) |
|
283 |
banda = new String("Azul"); |
|
284 |
|
|
285 |
System.out.println("** BANDA IMAGE="+banda+" FILEPOS="+listBands[i].getBand()+" BANDA DEL FICHERO="+listBands[i].getBand()); |
|
286 |
} |
|
287 |
} |
|
288 |
} |
|
289 |
|
|
290 |
/*public boolean transparencyFilterEnabled = false; |
|
291 |
public boolean enhancedFilterEnabled = false; |
|
292 |
public boolean tailFilterEnabled = false;*/ |
|
293 |
|
|
294 |
/** |
|
295 |
* Constructor. |
|
296 |
* @param component |
|
297 |
*/ |
|
298 |
public PxRaster(ImageObserver component) { |
|
299 |
this.component = component; |
|
300 |
} |
|
301 |
|
|
302 |
/** |
|
303 |
* Contructor para un solo fichero |
|
304 |
* @param proj Proyeccci?n |
|
305 |
* @param fname Nombre del fichero |
|
306 |
* @param component |
|
307 |
*/ |
|
308 |
public PxRaster(IProjection proj, String fname, ImageObserver component) { |
|
309 |
geoFile = new GeoRasterFile[1]; |
|
310 |
geoFile[0] = GeoRasterFile.openFile(proj, fname);//loadECW(fname); |
|
311 |
geoFile[0].setUpdatable((Component) component); |
|
312 |
this.proj = proj; |
|
313 |
this.component = component; |
|
314 |
setExtent(geoFile[0].getExtent()); |
|
315 |
geoFile[0].setView(geoFile[0].getExtent()); |
|
316 |
extentOrig = extent; |
|
317 |
bandSwitch.addFile(geoFile[0]); |
|
318 |
if (geoFile[0].getBandCount()>=3) { |
|
319 |
setBand(GeoRasterFile.RED_BAND, 0); |
|
320 |
setBand(GeoRasterFile.GREEN_BAND, 1); |
|
321 |
setBand(GeoRasterFile.BLUE_BAND, 2); |
|
322 |
} else if (geoFile[0].getBandCount()==2) { |
|
323 |
setBand(GeoRasterFile.RED_BAND, 0); |
|
324 |
setBand(GeoRasterFile.GREEN_BAND, 1); |
|
325 |
setBand(GeoRasterFile.BLUE_BAND, 1); |
|
326 |
} else if (geoFile[0].getBandCount()==1) { |
|
327 |
//setBand(GeoRasterFile.RED_BAND|GeoRasterFile.GREEN_BAND|GeoRasterFile.BLUE_BAND, 0); |
|
328 |
setBand(GeoRasterFile.RED_BAND, 0); |
|
329 |
setBand(GeoRasterFile.GREEN_BAND, 0); |
|
330 |
setBand(GeoRasterFile.BLUE_BAND, 0); |
|
331 |
} |
|
332 |
} |
|
333 |
|
|
334 |
/** |
|
335 |
* Constructor para multiples ficheros |
|
336 |
*/ |
|
337 |
public PxRaster(IProjection proj, String [] fnames, ImageObserver component) { |
|
338 |
this.proj = proj; |
|
339 |
this.component = component; |
|
340 |
geoFile = new GeoRasterFile[fnames.length]; |
|
341 |
for (int i=0; i<geoFile.length; i++) { |
|
342 |
geoFile[i] = GeoRasterFile.openFile(proj, fnames[i]);//loadECW(fname); |
|
343 |
geoFile[i].setUpdatable((Component) component); |
|
344 |
setExtent(geoFile[i].getExtent()); |
|
345 |
geoFile[i].setView(geoFile[i].getExtent()); |
|
346 |
bandSwitch.addFile(geoFile[i]); |
|
347 |
} |
|
348 |
//geoFile = geoFile[0]; |
|
349 |
extentOrig = extent; |
|
350 |
if (fnames.length >= 3 || geoFile[0].getBandCount()>2) { |
|
351 |
setBand(GeoRasterFile.RED_BAND, 0); |
|
352 |
setBand(GeoRasterFile.GREEN_BAND, 1); |
|
353 |
setBand(GeoRasterFile.BLUE_BAND, 2); |
|
354 |
} else { |
|
355 |
setBand(GeoRasterFile.RED_BAND|GeoRasterFile.GREEN_BAND|GeoRasterFile.BLUE_BAND, 0); |
|
356 |
} |
|
357 |
} |
|
358 |
|
|
359 |
/** |
|
360 |
* A?ade un GeoRasterFile al PxRaster |
|
361 |
* @param fileName Nombre del fichero |
|
362 |
*/ |
|
363 |
public void addFile(String fileName){ |
|
364 |
if(geoFile!=null){ |
|
365 |
GeoRasterFile[] listFiles = new GeoRasterFile[geoFile.length+1]; |
|
366 |
for(int i=0;i<geoFile.length;i++) |
|
367 |
listFiles[i] = geoFile[i]; |
|
368 |
listFiles[geoFile.length] = GeoRasterFile.openFile(proj, fileName); |
|
369 |
listFiles[geoFile.length].setUpdatable((Component) component); |
|
370 |
setExtent(listFiles[geoFile.length].getExtent()); |
|
371 |
listFiles[geoFile.length].setView(listFiles[geoFile.length].getExtent()); |
|
372 |
bandSwitch.addFile(listFiles[geoFile.length]); |
|
373 |
geoFile = listFiles; |
|
374 |
}else { |
|
375 |
System.err.println("PxRaster.addFile(): Imagen no cargada."); |
|
376 |
return; |
|
377 |
} |
|
378 |
} |
|
379 |
|
|
380 |
/** |
|
381 |
* Devuelve el Extent de un fichero son necesidad de a?adirlo |
|
382 |
* al PxRaster |
|
383 |
* @param fileName |
|
384 |
* @return |
|
385 |
*/ |
|
386 |
public Extent testExtentFile(String fileName){ |
|
387 |
GeoRasterFile grf = GeoRasterFile.openFile(proj, fileName); |
|
388 |
return grf.getExtent(); |
|
389 |
} |
|
390 |
|
|
391 |
/** |
|
392 |
* Obtiene el valor del pixel del Image en la posici?n wcx,wcy |
|
393 |
* @param wcx Posici?n x |
|
394 |
* @param wcx Posici?n y |
|
395 |
* @return valor de pixel |
|
396 |
*/ |
|
397 |
public int[] getPixel(double wcx, double wcy){ |
|
398 |
if(geoImage != null){ |
|
399 |
int ptox = 0, ptoy = 0; |
|
400 |
try{ |
|
401 |
//Extent de la imagen completa |
|
402 |
|
|
403 |
Extent extOrtofoto = geoFile[0].getExtent(); |
|
404 |
|
|
405 |
//Variables q definen el extent del objeto image |
|
406 |
double minx = 0, miny = 0, maxx = 0, maxy = 0; |
|
407 |
|
|
408 |
if(lastViewPort.getExtent().getMin().getX() < extOrtofoto.minX()) |
|
409 |
minx = extOrtofoto.minX(); |
|
410 |
else |
|
411 |
minx = lastViewPort.getExtent().getMin().getX(); |
|
412 |
if(lastViewPort.getExtent().getMax().getX() > extOrtofoto.maxX()) |
|
413 |
maxx = extOrtofoto.maxX(); |
|
414 |
else |
|
415 |
maxx = lastViewPort.getExtent().getMax().getX(); |
|
416 |
if(lastViewPort.getExtent().getMin().getY() < extOrtofoto.minY()) |
|
417 |
miny = extOrtofoto.minY(); |
|
418 |
else |
|
419 |
miny = lastViewPort.getExtent().getMin().getY(); |
|
420 |
if(lastViewPort.getExtent().getMax().getY() > extOrtofoto.maxY()) |
|
421 |
maxy = extOrtofoto.maxY(); |
|
422 |
else |
|
423 |
maxy = lastViewPort.getExtent().getMax().getY(); |
|
424 |
|
|
425 |
//Comprobamos que estemos dentro del extent del Image |
|
426 |
if(wcx < minx || wcx > maxx || wcy < miny || wcy > maxy){ |
|
427 |
int[] res = {-1, -1, -1, -1}; |
|
428 |
return res; |
|
429 |
} |
|
430 |
|
|
431 |
//Pasamos a coordenadas del Image las coordenadas del mundo real |
|
432 |
int w = ((BufferedImage)geoImage).getWidth(); |
|
433 |
int h = ((BufferedImage)geoImage).getHeight(); |
|
434 |
double wcw = maxx-minx; |
|
435 |
double wch = maxy-miny; |
|
436 |
ptox = (int)(((wcx-minx)*w)/wcw); |
|
437 |
ptoy = (int)(((wcy-miny)*h)/wch); |
|
438 |
|
|
439 |
//Obtenemos el pto seleccionado del Image y extraemos el RGB |
|
440 |
int px = ((BufferedImage)geoImage).getRGB(ptox, h-ptoy); |
|
441 |
int[] values = new int[4]; |
|
442 |
values[0] = ((px & 0xff000000) >> 24); |
|
443 |
values[1] = ((px & 0x00ff0000) >> 16); |
|
444 |
values[2] = ((px & 0x0000ff00) >> 8); |
|
445 |
values[3] = (px & 0x000000ff); |
|
446 |
return values; |
|
447 |
}catch(ArrayIndexOutOfBoundsException e){ |
|
448 |
e.printStackTrace(); |
|
449 |
} |
|
450 |
} |
|
451 |
return null; |
|
452 |
} |
|
453 |
|
|
454 |
/** |
|
455 |
* Elimina un GeoRasterFile al PxRaster |
|
456 |
* @param finaName Nombre del fichero |
|
457 |
*/ |
|
458 |
public void delFile(String fileName){ |
|
459 |
if(geoFile!=null){ |
|
460 |
Vector grfTemp = new Vector(); |
|
461 |
for(int i=0;i<geoFile.length;i++){ |
|
462 |
if(!fileName.endsWith(geoFile[i].getName())) |
|
463 |
grfTemp.add(geoFile[i]); |
|
464 |
} |
|
465 |
GeoRasterFile[] listFiles = new GeoRasterFile[grfTemp.size()]; |
|
466 |
for(int i=0;i<listFiles.length;i++) |
|
467 |
listFiles[i] = (GeoRasterFile)grfTemp.get(i); |
|
468 |
|
|
469 |
//Lo eliminamos del bandSwitch |
|
470 |
|
|
471 |
for(int i=0;i<geoFile.length;i++){ |
|
472 |
if(fileName.endsWith(geoFile[i].getName())){ |
|
473 |
bandSwitch.removeFile(geoFile[i]); |
|
474 |
} |
|
475 |
} |
|
476 |
|
|
477 |
geoFile = listFiles; |
|
478 |
/*if(geoFile!=null) |
|
479 |
setExtent(geoFile[0].getExtent());*/ |
|
480 |
|
|
481 |
}else { |
|
482 |
System.err.println("PxRaster.addFile(): Imagen no cargada."); |
|
483 |
return; |
|
484 |
} |
|
485 |
} |
|
486 |
|
|
487 |
public PxRaster(GeoRasterFile eFile, ImageObserver component, Extent view) { |
|
488 |
geoFile = new GeoRasterFile[1]; |
|
489 |
geoFile[0] = eFile;//loadECW(fname); |
|
490 |
geoFile[0].setUpdatable((Component) component); |
|
491 |
setProjection(geoFile[0].getProjection()); |
|
492 |
this.component = component; |
|
67 |
// Soporte para n bandas, visibles de 3 en 3, en ficheros separados |
|
68 |
//protected GeoRasterFile [] colorBand = null; |
|
69 |
protected int rBand = 1; |
|
493 | 70 |
|
494 |
setExtent(geoFile[0].getExtent()); |
|
495 |
geoFile[0].setView(view); //geoFile.getExtent()); |
|
496 |
extentOrig = extent; |
|
497 |
bandSwitch.addFile(eFile); |
|
498 |
if (geoFile[0].getBandCount()>=3) { |
|
499 |
setBand(GeoRasterFile.RED_BAND, 0); |
|
500 |
setBand(GeoRasterFile.GREEN_BAND, 1); |
|
501 |
setBand(GeoRasterFile.BLUE_BAND, 2); |
|
502 |
} else if (geoFile[0].getBandCount()==2) { |
|
503 |
setBand(GeoRasterFile.RED_BAND, 0); |
|
504 |
setBand(GeoRasterFile.GREEN_BAND, 1); |
|
505 |
setBand(GeoRasterFile.BLUE_BAND, 1); |
|
506 |
} else if (geoFile[0].getBandCount()==1) { |
|
507 |
//setBand(GeoRasterFile.RED_BAND|GeoRasterFile.GREEN_BAND|GeoRasterFile.BLUE_BAND, 0); |
|
508 |
setBand(GeoRasterFile.RED_BAND, 0); |
|
509 |
setBand(GeoRasterFile.GREEN_BAND, 0); |
|
510 |
setBand(GeoRasterFile.BLUE_BAND, 0); |
|
511 |
} |
|
512 |
} |
|
513 |
|
|
514 |
/** |
|
515 |
* Obtiene el tama?o de bloque |
|
516 |
* @return |
|
517 |
*/ |
|
518 |
public int getBlockSize(){ |
|
519 |
return geoFile[0].getBlockSize(); |
|
520 |
} |
|
521 |
|
|
522 |
/** |
|
523 |
* |
|
524 |
* @return |
|
525 |
*/ |
|
526 |
public GeoRasterFile[] getGeoFiles(){ |
|
527 |
return geoFile; |
|
528 |
} |
|
529 |
|
|
530 |
public GeoRasterFile getGeoFile(){ |
|
531 |
return geoFile[0]; |
|
532 |
} |
|
533 |
|
|
534 |
/** |
|
535 |
* Obtiene el n?mero de bandas del PxRaster. Si ls longitud de geoFile es 1 quiere |
|
536 |
* decir que hay un solo fichero que contiene todas las bandas. Si hay m?s de un geoFile |
|
537 |
* el n?mero de bandas ser? la suma de todas las bandas de las im?genes que forman |
|
538 |
* el geoFile |
|
539 |
* @return N?mero de bandas |
|
540 |
*/ |
|
541 |
public int getBandCount() { |
|
542 |
return bandSwitch.getBandCount(); |
|
543 |
} |
|
544 |
|
|
545 |
/** |
|
546 |
* Obtiene el tipo de dato del primer GeoRasterFile |
|
547 |
* @return |
|
548 |
*/ |
|
549 |
public int getDataType(){ |
|
550 |
if(geoFile!=null){ |
|
551 |
return geoFile[0].getDataType(); |
|
552 |
}else |
|
553 |
System.err.println("PxRaster.getDataType(): Imagen no cargada."); |
|
554 |
return 0; |
|
555 |
} |
|
556 |
/** |
|
557 |
* Obtiene el vector de GeoRasterFile que componen el PxRaster |
|
558 |
* @return vector GeoRasterFile |
|
559 |
*/ |
|
560 |
public GeoRasterFile [] getFiles() { |
|
561 |
return geoFile; |
|
562 |
} |
|
563 |
|
|
564 |
/** |
|
565 |
* Asocia un colorBand al rojo, verde o azul. |
|
566 |
* @param flag cual (o cuales) de las bandas. |
|
567 |
* @param nBand que colorBand |
|
568 |
*/ |
|
569 |
public void setBand(int flag, int nBand) { |
|
570 |
bandSwitch.setBand(flag, nBand); |
|
571 |
} |
|
572 |
|
|
573 |
/** |
|
574 |
* Obtiene la posici?n del fichero asignado a la banda |
|
575 |
* que se le pasa por par?metro |
|
576 |
* @return |
|
577 |
*/ |
|
578 |
public int getPosFile(int flag){ |
|
579 |
if (flag == GeoRasterFile.RED_BAND){ |
|
580 |
return bandSwitch.getBandR().getPos(); |
|
581 |
}else if (flag == GeoRasterFile.GREEN_BAND){ |
|
582 |
return bandSwitch.getBandG().getPos(); |
|
583 |
}else if (flag == GeoRasterFile.BLUE_BAND){ |
|
584 |
return bandSwitch.getBandB().getPos(); |
|
585 |
}else |
|
586 |
return -1; |
|
587 |
} |
|
588 |
|
|
589 |
/** |
|
590 |
* Devuelve el colorBand activo en la banda especificada. |
|
591 |
* @param flag banda. |
|
592 |
*/ |
|
593 |
public int getBand(int flag) { |
|
594 |
if (flag == GeoRasterFile.RED_BAND){ |
|
595 |
return bandSwitch.getBandR().getBand(); |
|
596 |
}else if (flag == GeoRasterFile.GREEN_BAND){ |
|
597 |
return bandSwitch.getBandG().getBand(); |
|
598 |
}else if (flag == GeoRasterFile.BLUE_BAND){ |
|
599 |
return bandSwitch.getBandB().getBand(); |
|
600 |
}else |
|
601 |
return -1; |
|
602 |
} |
|
71 |
// Soporte para n bandas, visibles de 3 en 3, en ficheros separados |
|
72 |
//protected GeoRasterFile [] colorBand = null; |
|
73 |
protected int gBand = 2; |
|
603 | 74 |
|
604 |
/** |
|
605 |
* @param pm |
|
606 |
*/ |
|
607 |
public void setDrawBorder(boolean pm) { |
|
608 |
pintaMarco = pm; |
|
609 |
} |
|
610 |
|
|
611 |
/** |
|
612 |
* Obtiene el nombre del fichero si solo hay uno |
|
613 |
* @return Nombre del fichero |
|
614 |
*/ |
|
615 |
public String getFName() { |
|
616 |
return geoFile[0].getName(); |
|
617 |
} |
|
618 |
|
|
619 |
/** |
|
620 |
* Obtiene el nombre del fichero GeoRasterFile seleccionado |
|
621 |
* @param i posici?n del GeoRasterFile |
|
622 |
* @return Nombre del fichero |
|
623 |
*/ |
|
624 |
public String getFName(int i){ |
|
625 |
if(geoFile!=null){ |
|
626 |
if(i<geoFile.length) |
|
627 |
return geoFile[i].getName(); |
|
628 |
else |
|
629 |
return null; |
|
630 |
}else { |
|
631 |
System.err.println("PxRaster.getFName(): Imagen no cargada."); |
|
632 |
return null; |
|
633 |
} |
|
634 |
} |
|
635 |
|
|
636 |
/** |
|
637 |
* Obtiene una lista de Strings con los nombres de todos los ficheros |
|
638 |
* que tiene el PxRaster |
|
639 |
* @return Lista de nombres |
|
640 |
*/ |
|
641 |
public String[] getLisName(){ |
|
642 |
if(geoFile!=null){ |
|
643 |
String[] list = new String[geoFile.length]; |
|
644 |
for(int i=0;i<geoFile.length;i++) |
|
645 |
list[i] = geoFile[i].getName(); |
|
646 |
return list; |
|
647 |
}else { |
|
648 |
System.err.println("PxRaster.getListName(): Imagen no cargada."); |
|
649 |
return null; |
|
650 |
} |
|
651 |
} |
|
652 |
|
|
653 |
/** |
|
654 |
* Devuelve la anchura total del fichero, en pixeles. |
|
655 |
* @return ancho en pixeles |
|
656 |
*/ |
|
657 |
public int getFWidth() { |
|
658 |
if(geoFile!=null) |
|
659 |
return geoFile[0].getWidth(); |
|
660 |
else { |
|
661 |
System.err.println("PxRaster.getFWidth(): Imagen no cargada."); |
|
662 |
return 0; |
|
663 |
} |
|
664 |
} |
|
665 |
|
|
666 |
|
|
667 |
/** |
|
668 |
* Devuelve la anchura total del fichero, en pixeles. |
|
669 |
* @return ancho en pixeles |
|
670 |
*/ |
|
671 |
public int getFWidth(int i) { |
|
672 |
if(i<geoFile.length) |
|
673 |
return geoFile[i].getWidth(); |
|
674 |
else { |
|
675 |
System.err.println("PxRaster.getFWidth(): Imagen no cargada."); |
|
676 |
return 0; |
|
677 |
} |
|
678 |
} |
|
679 |
|
|
680 |
/** |
|
681 |
* Devuelve la altura total del fichero, en pixeles. |
|
682 |
* @return alto en pixeles |
|
683 |
*/ |
|
684 |
public int getFHeight() { |
|
685 |
if(geoFile!=null) |
|
686 |
return geoFile[0].getHeight(); |
|
687 |
else { |
|
688 |
System.err.println("PxRaster.getFHeight(): Imagen no cargada."); |
|
689 |
return 0; |
|
690 |
} |
|
691 |
} |
|
692 |
|
|
693 |
/** |
|
694 |
* Devuelve la altura total del fichero, en pixeles. |
|
695 |
* @return alto en pixeles |
|
696 |
*/ |
|
697 |
public int getFHeight(int i) { |
|
698 |
if(i<geoFile.length) |
|
699 |
return geoFile[i].getHeight(); |
|
700 |
else { |
|
701 |
System.err.println("PxRaster.getFHeight(): Imagen no cargada."); |
|
702 |
return 0; |
|
703 |
} |
|
704 |
} |
|
705 |
|
|
706 |
/** |
|
707 |
* Devuelve el n?mero de ficheros que componen el PxRaster |
|
708 |
* @return N?mero de ficheros |
|
709 |
*/ |
|
710 |
public int nFiles(){ |
|
711 |
if(geoFile!=null) |
|
712 |
return geoFile.length; |
|
713 |
else |
|
714 |
return 0; |
|
715 |
} |
|
716 |
|
|
717 |
/** |
|
718 |
* Activa o desactiva la transparencia de los ficheros que forman el PxRaster |
|
719 |
* @param t true o false para activar o desactivar transparencia |
|
720 |
*/ |
|
721 |
public void setTransparency(boolean t) { |
|
722 |
if(geoFile!=null){ |
|
723 |
for(int i=0;i<geoFile.length;i++){ |
|
724 |
geoFile[i].setTransparency(t); |
|
725 |
} |
|
726 |
}else { |
|
727 |
System.err.println("PxRaster.setTransparency(): Imagen no cargada."); |
|
728 |
return; |
|
729 |
} |
|
730 |
} |
|
731 |
|
|
732 |
/** |
|
733 |
* Pone la transparencia de los ficheros de la imagen a un valor |
|
734 |
* @param t Valor para la transparencia |
|
735 |
*/ |
|
736 |
public void setTransparency(int t) { |
|
737 |
if(geoFile!=null){ |
|
738 |
for(int i=0;i<geoFile.length;i++){ |
|
739 |
geoFile[i].setTransparency(t); |
|
740 |
} |
|
741 |
}else { |
|
742 |
System.err.println("PxRaster.setTransparency(): Imagen no cargada."); |
|
743 |
return; |
|
744 |
} |
|
745 |
} |
|
746 |
|
|
747 |
/** |
|
748 |
* Obtiene el alpha del primer fichero. Han de ser iguales en todos |
|
749 |
* los ficheros de la imagen. |
|
750 |
* @return alpha |
|
751 |
*/ |
|
752 |
public int getAlpha() { |
|
753 |
if(geoFile!=null) |
|
754 |
return geoFile[0].getAlpha(); |
|
755 |
else { |
|
756 |
System.err.println("PxRaster.getAlpha(): Imagen no cargada."); |
|
757 |
return 0; |
|
758 |
} |
|
759 |
} |
|
760 |
|
|
761 |
/** |
|
762 |
* Asigna el extent |
|
763 |
* @param e extent |
|
764 |
*/ |
|
765 |
public void setExtent(Extent e) { |
|
766 |
super.extent = e; |
|
767 |
pts = new Vector(); |
|
768 |
pts.add(proj.createPoint(e.minX(), e.minY())); |
|
769 |
pts.add(proj.createPoint(e.maxX(), e.minY())); |
|
770 |
pts.add(proj.createPoint(e.maxX(), e.maxY())); |
|
771 |
pts.add(proj.createPoint(e.minX(), e.maxY())); |
|
772 |
} |
|
773 |
|
|
774 |
/** |
|
775 |
* Cambia la vista (viewport) sobre el raster. |
|
776 |
* |
|
777 |
* @param v extent |
|
778 |
* @param vName nombre |
|
779 |
*/ |
|
780 |
public void setView(Extent v, String vName) { |
|
781 |
if(geoFile!=null){ |
|
782 |
for(int i=0;i<geoFile.length;i++){ |
|
783 |
geoFile[i].setView(v); |
|
784 |
} |
|
785 |
}else { |
|
786 |
System.err.println("PxRaster.setView(): Imagen no cargada."); |
|
787 |
return; |
|
788 |
} |
|
789 |
this.vName = vName; |
|
790 |
} |
|
791 |
|
|
792 |
/** |
|
793 |
* Obtiene la escala. |
|
794 |
* |
|
795 |
* @param width |
|
796 |
* @param height |
|
797 |
* @return |
|
798 |
*/ |
|
799 |
|
|
800 |
public double[] getScale(int width, int height) { |
|
801 |
double scale[] = new double[2]; |
|
802 |
if(geoFile!=null){ |
|
803 |
scale[0] = ((double) width) /geoFile[0].getView().width(); |
|
804 |
scale[1] = ((double) height)/geoFile[0].getView().height(); |
|
805 |
return scale; |
|
806 |
}else { |
|
807 |
System.err.println("PxRaster.getScale(): Imagen no cargada."); |
|
808 |
return null; |
|
809 |
} |
|
810 |
} |
|
811 |
|
|
812 |
/** |
|
813 |
* 'Normaliza' la vista en funci?n del extent del raster. |
|
814 |
* |
|
815 |
* @param mat |
|
816 |
* @param sz |
|
817 |
*/ |
|
75 |
// Soporte para n bandas, visibles de 3 en 3, en ficheros separados |
|
76 |
//protected GeoRasterFile [] colorBand = null; |
|
77 |
protected int bBand = 3; |
|
78 |
public RasterStats stats = new RasterStats(); |
|
79 |
int transparente = 0x10ffff80; |
|
80 |
String vName = null; |
|
81 |
protected boolean pintaMarco = false; //true; |
|
82 |
IProjection proj = null; |
|
83 |
protected Extent extentOrig = null; |
|
84 |
ICoordTrans rp = null; |
|
85 |
public RasterFilterStack filterStack = new RasterFilterStack(stats); |
|
86 |
private BandSwitch bandSwitch = new BandSwitch(); |
|
87 |
private boolean firstPxRaster = true; |
|
88 |
private final double percentFilterInit = 0.02; |
|
89 |
private RasterFilterStackManager stackManager = null; |
|
90 |
private Image geoImage = null; |
|
91 |
private ViewPortData lastViewPort = null; |
|
818 | 92 |
|
819 |
protected void calculateNewView(Extent sz) { |
|
820 |
double vx = sz.minX(), vy = sz.minY(), vx2 = sz.maxX(), vy2 = sz.maxY(); |
|
821 |
if (sz.minX() < extent.minX()) vx = extent.minX(); |
|
822 |
if (sz.minY() < extent.minY()) vy = extent.minY(); |
|
823 |
if (sz.maxX() > extent.maxX()) vx2 = extent.maxX(); |
|
824 |
if (sz.maxY() > extent.maxY()) vy2 = extent.maxY(); |
|
825 |
if (geoFile != null) { |
|
826 |
for (int i=0; i<geoFile.length; i++) |
|
827 |
geoFile[i].setView(new Extent(vx, vy, vx2, vy2)); |
|
828 |
} else { |
|
829 |
System.err.println("PxRaster.calculateNewView(): Imagen no cargada."); |
|
830 |
} |
|
831 |
} |
|
93 |
/*public boolean transparencyFilterEnabled = false; |
|
94 |
public boolean enhancedFilterEnabled = false; |
|
95 |
public boolean tailFilterEnabled = false;*/ |
|
832 | 96 |
|
833 |
/** |
|
834 |
* Dibuja el raster |
|
835 |
*/ |
|
97 |
/** |
|
98 |
* Constructor. |
|
99 |
* @param component |
|
100 |
*/ |
|
101 |
public PxRaster(ImageObserver component) { |
|
102 |
this.component = component; |
|
103 |
} |
|
836 | 104 |
|
837 |
public void draw(Graphics2D g, ViewPortData vp) { |
|
838 |
geoImage = null; |
|
839 |
long t2, t1 = new Date().getTime(); |
|
840 |
lastViewPort = vp; |
|
841 |
//System.out.println("PxRaster.draw(): vp.extent = "+ vp.getExtent()); |
|
842 |
//System.out.println("PxRaster.draw(): extent = "+ getExtent()); |
|
843 |
if ((vp.getExtent().minX()> extent.maxX()) || |
|
844 |
(vp.getExtent().minY()> extent.maxY()) || |
|
845 |
(vp.getExtent().maxX()< extent.minX()) || |
|
846 |
(vp.getExtent().maxY()< extent.minY())) return; |
|
847 |
calculateNewView(vp.getExtent()); |
|
848 |
Extent v = geoFile[0].getView(); |
|
849 |
double x = v.minX(); |
|
850 |
double y = v.minY(); |
|
851 |
double w = v.width(); |
|
852 |
double h = v.height(); |
|
853 |
//System.out.println("Pinto PxRaster:" + v); |
|
854 |
|
|
855 |
double scalex = vp.mat.getScaleX() /* g.getTransform().getScaleX()*/ , |
|
856 |
scaley = vp.mat.getScaleY() /* g.getTransform().getScaleY() */; |
|
857 |
int wImg = (int)Math.ceil(Math.abs(w*scalex)+1), hImg = (int)Math.ceil(Math.abs(h*scaley)+1); |
|
858 |
//System.out.println("Sz=("+wImg+","+hImg+"); scale=("+scalex+","+scaley+")"); |
|
859 |
if (wImg <= 0 || hImg <= 0) return; |
|
860 |
|
|
861 |
Point2D.Double pt = new Point2D.Double(x, y+h); |
|
862 |
try { |
|
863 |
//System.out.println("Dibujando PxRaster: pt0 = "+pt); |
|
864 |
vp.mat.transform(pt, pt); |
|
865 |
//System.out.println("Dibujando PxRaster: pt1 = "+pt); |
|
866 |
if (geoFile != null && geoFile[0] instanceof GdalFile && |
|
867 |
(geoFile[0].getDataType() != DataBuffer.TYPE_BYTE)) { |
|
868 |
//System.out.println("PxRaster: Has dado con un Raster de 16 bits"); |
|
869 |
|
|
870 |
RasterBuf raster = ((GdalFile) geoFile[0]).getRaster(wImg, hImg, rp); |
|
871 |
t2 = new Date().getTime(); |
|
872 |
|
|
873 |
t2 = new Date().getTime(); |
|
874 |
System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs. Filtrando/Renderizando");t1 = t2; |
|
875 |
|
|
876 |
filterStack.setInitRasterBuf(raster); |
|
877 |
|
|
878 |
//Si la imagen es de 16 bits lleva un filtro de realce por defecto |
|
879 |
if(stackManager == null){ |
|
880 |
stackManager = new RasterFilterStackManager(filterStack); |
|
881 |
stackManager.addEnhancedFilter(false, geoFile[0].getName()); |
|
882 |
stackManager.removeFilter(stackManager.getTypeFilter("computeminmax")); |
|
883 |
stackManager.addTailFilter( this.percentFilterInit, 0D, false); |
|
884 |
} |
|
885 |
|
|
886 |
geoImage = renderizeRaster(raster); |
|
887 |
g.drawImage(geoImage, (int) Math.round(pt.getX()), (int) Math.round(pt.getY()), component); |
|
888 |
|
|
889 |
t2 = new Date().getTime(); |
|
890 |
System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs. Dibujando"); |
|
891 |
} else if (geoFile != null && geoFile.length > 1) { // multiFiles |
|
892 |
System.out.println("Dibujando PxRaster (Multifile) ... Bands "+geoFile.length); |
|
893 |
|
|
894 |
if(bandSwitch.getBandR().getGeoRasterFile() instanceof EcwFile) |
|
895 |
((EcwFile)bandSwitch.getBandR().getGeoRasterFile()).setMultifile(true); |
|
896 |
|
|
897 |
if(bandSwitch.getBandG().getGeoRasterFile() instanceof EcwFile) |
|
898 |
((EcwFile)bandSwitch.getBandG().getGeoRasterFile()).setMultifile(true); |
|
899 |
|
|
900 |
if(bandSwitch.getBandB().getGeoRasterFile() instanceof EcwFile) |
|
901 |
((EcwFile)bandSwitch.getBandB().getGeoRasterFile()).setMultifile(true); |
|
902 |
|
|
903 |
geoImage = bandSwitch.getBandR().getGeoRasterFile().updateImage |
|
904 |
(wImg, hImg, rp, null, 0, 0); |
|
905 |
geoImage = bandSwitch.getBandG().getGeoRasterFile().updateImage |
|
906 |
(wImg, hImg, rp, geoImage, bandSwitch.getBandG().getBand(), GeoRasterFile.GREEN_BAND); |
|
907 |
geoImage = bandSwitch.getBandB().getGeoRasterFile().updateImage |
|
908 |
(wImg, hImg, rp, geoImage, bandSwitch.getBandB().getBand(), GeoRasterFile.BLUE_BAND); |
|
909 |
|
|
910 |
filterStack.setInitRasterBuf(geoImage); |
|
911 |
|
|
912 |
geoImage = renderizeRaster(geoImage); |
|
913 |
g.drawImage(geoImage, (int) Math.round(pt.getX()), (int) Math.round(pt.getY()), component); |
|
914 |
t2 = new Date().getTime(); |
|
915 |
System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs."); |
|
916 |
|
|
917 |
} else if (geoFile != null && geoFile.length == 1) { // Una solo fichero |
|
918 |
|
|
919 |
geoImage = bandSwitch.getBandR().getGeoRasterFile().updateImage |
|
920 |
(wImg, hImg, rp, null, 0, 0); |
|
921 |
//System.out.println("Dibujando PxRaster sz=("+wImg+","+hImg+"..."); |
|
922 |
|
|
923 |
filterStack.setInitRasterBuf(geoImage); |
|
924 |
|
|
925 |
geoImage = renderizeRaster(geoImage); |
|
926 |
g.drawImage(geoImage, (int) Math.round(pt.getX()), (int) Math.round(pt.getY()), component); |
|
927 |
t2 = new Date().getTime(); |
|
928 |
System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs."); |
|
929 |
} else { // no cargada |
|
930 |
System.err.println("Dibujando PxRaster: Foto no cargada."); |
|
931 |
} |
|
932 |
} catch (Exception e) { |
|
933 |
e.printStackTrace(); |
|
934 |
}; |
|
935 |
|
|
936 |
if (pintaMarco) { |
|
937 |
drawMarco(g, vp); |
|
938 |
} |
|
939 |
} |
|
940 |
|
|
941 |
/** |
|
942 |
* Aplica la pila de fitros sobre el RasterBuf pasado como par?metro |
|
943 |
* y lo devuelve en Image |
|
944 |
* @param raster RasterBuf con la imagen sobre la que se aplicaran filtros |
|
945 |
* @return Image con la imagen con los filtros puestos |
|
946 |
*/ |
|
947 |
public Image renderizeRaster(RasterBuf raster) { |
|
948 |
if (filterStack != null){ |
|
949 |
filterStack.execute(raster); |
|
950 |
} |
|
951 |
|
|
952 |
//Aplicamos el filtro para convertir a Image |
|
953 |
RasterToImageFilter rti = new RasterToImageFilter(); |
|
954 |
rti.addParam("raster", raster); |
|
955 |
rti.addParam("alpha", new Integer(this.getAlpha())); |
|
956 |
rti.execute(); |
|
957 |
raster = null; |
|
958 |
return (Image)rti.getResult("raster"); |
|
959 |
} |
|
960 |
|
|
961 |
/** |
|
962 |
* Aplica la pila de filtros sobre el Image pasado como par?metro y lo devuelve. |
|
963 |
* Si la salida del ?ltimo filtro es un RasterBuf lo convertir? a Image |
|
964 |
* @param image Image con la imagen sobre la que se aplicaran filtros |
|
965 |
* @return Image con la imagen con los filtros puestos |
|
966 |
*/ |
|
967 |
public Image renderizeRaster(Image image) { |
|
968 |
if (filterStack != null){ |
|
969 |
filterStack.execute(image); |
|
970 |
} |
|
971 |
|
|
972 |
if(filterStack.getOutDataType() != RasterBuf.TYPE_IMAGE){ |
|
973 |
//Aplicamos el filtro para convertir a Image |
|
974 |
RasterToImageFilter rti = new RasterToImageFilter(); |
|
975 |
rti.addParam("raster", (RasterBuf)filterStack.getResult()); |
|
976 |
rti.addParam("alpha", new Integer(this.getAlpha())); |
|
977 |
rti.execute(); |
|
978 |
return (Image)rti.getResult("raster"); |
|
979 |
} |
|
980 |
return image; |
|
981 |
} |
|
982 |
|
|
983 |
/** |
|
984 |
* |
|
985 |
* @param g |
|
986 |
* @param vp |
|
987 |
*/ |
|
988 |
public void drawMarco(Graphics2D g, ViewPortData vp) { |
|
989 |
// Color color = new Color(255,222,165,128), fillColor = new Color(255,214,132,128); |
|
990 |
Color color = new Color(128,128,128), fillColor = new Color(255,220,220,0x20); |
|
991 |
GeneralPath gp = newGP(vp); |
|
992 |
g.setColor(fillColor); |
|
993 |
g.fill(gp); |
|
994 |
g.setColor(color); |
|
995 |
g.draw(gp); |
|
996 |
} |
|
997 |
|
|
998 |
private GeneralPath newGP(ViewPortData vp) { |
|
999 |
//if (gp != null) return; |
|
1000 |
GeneralPath gp = new GeneralPath(); |
|
1001 |
Point2D.Double pt0 = new Point2D.Double(0.0, 0.0); |
|
1002 |
Point2D.Double pt1 = new Point2D.Double(0.0, 0.0); |
|
1003 |
Point2D.Double pt2 = new Point2D.Double(0.0, 0.0); |
|
1004 |
Point2D.Double pt3 = new Point2D.Double(0.0, 0.0); |
|
1005 |
vp.mat.transform((Point2D) pts.get(0), pt0); |
|
1006 |
vp.mat.transform((Point2D) pts.get(1), pt1); |
|
1007 |
vp.mat.transform((Point2D) pts.get(2), pt2); |
|
1008 |
vp.mat.transform((Point2D) pts.get(3), pt3); |
|
1009 |
// Aspa desde el extent |
|
1010 |
gp.moveTo( (float) pt0.getX(), (float) pt0.getY() ); |
|
1011 |
gp.lineTo( (float) pt2.getX(), (float) pt2.getY() ); |
|
1012 |
gp.moveTo( (float) pt1.getX(), (float) pt1.getY() ); |
|
1013 |
gp.lineTo( (float) pt3.getX(), (float) pt3.getY() ); |
|
1014 |
// Extent |
|
1015 |
gp.moveTo( (float) pt0.getX(), (float) pt0.getY() ); |
|
1016 |
gp.lineTo( (float) pt1.getX(), (float) pt1.getY() ); |
|
1017 |
gp.lineTo( (float) pt2.getX(), (float) pt2.getY() ); |
|
1018 |
gp.lineTo( (float) pt3.getX(), (float) pt3.getY() ); |
|
1019 |
if (extentOrig != extent) { |
|
1020 |
gp.lineTo( (float) pt0.getX(), (float) pt0.getY() ); |
|
1021 |
Vector pts = new Vector(); |
|
1022 |
pts.add(proj.createPoint(extentOrig.minX(), extentOrig.minY())); |
|
1023 |
pts.add(proj.createPoint(extentOrig.maxX(), extentOrig.minY())); |
|
1024 |
pts.add(proj.createPoint(extentOrig.maxX(), extentOrig.maxY())); |
|
1025 |
pts.add(proj.createPoint(extentOrig.minX(), extentOrig.maxY())); |
|
105 |
/** |
|
106 |
* Contructor para un solo fichero |
|
107 |
* @param proj Proyeccci?n |
|
108 |
* @param fname Nombre del fichero |
|
109 |
* @param component |
|
110 |
*/ |
|
111 |
public PxRaster(IProjection proj, String fname, ImageObserver component) { |
|
112 |
geoFile = new GeoRasterFile[1]; |
|
113 |
geoFile[0] = GeoRasterFile.openFile(proj, fname); //loadECW(fname); |
|
114 |
geoFile[0].setUpdatable((Component) component); |
|
115 |
this.proj = proj; |
|
116 |
this.component = component; |
|
117 |
setExtent(geoFile[0].getExtent()); |
|
118 |
geoFile[0].setView(geoFile[0].getExtent()); |
|
119 |
extentOrig = extent; |
|
120 |
bandSwitch.addFile(geoFile[0]); |
|
1026 | 121 |
|
1027 |
vp.mat.transform((Point2D) pts.get(0), pt0); |
|
1028 |
vp.mat.transform((Point2D) pts.get(1), pt1); |
|
1029 |
vp.mat.transform((Point2D) pts.get(2), pt2); |
|
1030 |
vp.mat.transform((Point2D) pts.get(3), pt3); |
|
1031 |
gp.moveTo( (float) pt0.getX(), (float) pt0.getY() ); |
|
1032 |
gp.lineTo( (float) pt1.getX(), (float) pt1.getY() ); |
|
1033 |
gp.lineTo( (float) pt2.getX(), (float) pt2.getY() ); |
|
1034 |
gp.lineTo( (float) pt3.getX(), (float) pt3.getY() ); |
|
1035 |
} |
|
1036 |
gp.closePath(); |
|
1037 |
return gp; |
|
1038 |
} |
|
122 |
if (geoFile[0].getBandCount() >= 3) { |
|
123 |
setBand(GeoRasterFile.RED_BAND, 0); |
|
124 |
setBand(GeoRasterFile.GREEN_BAND, 1); |
|
125 |
setBand(GeoRasterFile.BLUE_BAND, 2); |
|
126 |
} else if (geoFile[0].getBandCount() == 2) { |
|
127 |
setBand(GeoRasterFile.RED_BAND, 0); |
|
128 |
setBand(GeoRasterFile.GREEN_BAND, 1); |
|
129 |
setBand(GeoRasterFile.BLUE_BAND, 1); |
|
130 |
} else if (geoFile[0].getBandCount() == 1) { |
|
131 |
//setBand(GeoRasterFile.RED_BAND|GeoRasterFile.GREEN_BAND|GeoRasterFile.BLUE_BAND, 0); |
|
132 |
setBand(GeoRasterFile.RED_BAND, 0); |
|
133 |
setBand(GeoRasterFile.GREEN_BAND, 0); |
|
134 |
setBand(GeoRasterFile.BLUE_BAND, 0); |
|
135 |
} |
|
136 |
} |
|
1039 | 137 |
|
1040 |
public IProjection getProjection() { return proj; } |
|
1041 |
public void setProjection(IProjection p) { proj = p; } |
|
138 |
/** |
|
139 |
* Constructor para multiples ficheros |
|
140 |
*/ |
|
141 |
public PxRaster(IProjection proj, String[] fnames, ImageObserver component) { |
|
142 |
this.proj = proj; |
|
143 |
this.component = component; |
|
144 |
geoFile = new GeoRasterFile[fnames.length]; |
|
1042 | 145 |
|
1043 |
public void reProject(ICoordTrans rp) { |
|
1044 |
this.rp = rp.getInverted(); |
|
1045 |
System.out.println("PxRaster: reProject()"); |
|
1046 |
//geoFile.reProject(rp); |
|
1047 |
Vector savePts = pts; |
|
146 |
for (int i = 0; i < geoFile.length; i++) { |
|
147 |
geoFile[i] = GeoRasterFile.openFile(proj, fnames[i]); //loadECW(fname); |
|
148 |
geoFile[i].setUpdatable((Component) component); |
|
149 |
setExtent(geoFile[i].getExtent()); |
|
150 |
geoFile[i].setView(geoFile[i].getExtent()); |
|
151 |
bandSwitch.addFile(geoFile[i]); |
|
152 |
} |
|
1048 | 153 |
|
1049 |
pts = new Vector(); |
|
1050 |
extent = new Extent(); |
|
1051 |
Point2D ptDest = null; |
|
1052 |
for (int i=0; i<savePts.size(); i++) { |
|
1053 |
ptDest = rp.getPDest().createPoint(0.0,0.0); |
|
1054 |
ptDest = rp.convert((Point2D) savePts.get(i), ptDest); |
|
1055 |
pts.add(ptDest); |
|
1056 |
extent.add(ptDest); |
|
1057 |
} |
|
1058 |
setProjection(rp.getPDest()); |
|
1059 |
} |
|
1060 |
|
|
1061 |
/** |
|
1062 |
* Obtiene el Stack Manager |
|
1063 |
* @return |
|
1064 |
*/ |
|
1065 |
public RasterFilterStackManager getStackManager(){ |
|
1066 |
return this.stackManager; |
|
1067 |
} |
|
1068 |
|
|
1069 |
/** |
|
1070 |
* Asigna el Stack Manager |
|
1071 |
* @return |
|
1072 |
*/ |
|
1073 |
public void setStackManager(RasterFilterStackManager sm){ |
|
1074 |
this.stackManager = sm; |
|
1075 |
} |
|
154 |
//geoFile = geoFile[0]; |
|
155 |
extentOrig = extent; |
|
156 |
|
|
157 |
if ((fnames.length >= 3) || (geoFile[0].getBandCount() > 2)) { |
|
158 |
setBand(GeoRasterFile.RED_BAND, 0); |
|
159 |
setBand(GeoRasterFile.GREEN_BAND, 1); |
|
160 |
setBand(GeoRasterFile.BLUE_BAND, 2); |
|
161 |
} else { |
|
162 |
setBand(GeoRasterFile.RED_BAND | GeoRasterFile.GREEN_BAND | |
|
163 |
GeoRasterFile.BLUE_BAND, 0); |
|
164 |
} |
|
165 |
} |
|
166 |
|
|
167 |
public PxRaster(GeoRasterFile eFile, ImageObserver component, Extent view) { |
|
168 |
geoFile = new GeoRasterFile[1]; |
|
169 |
geoFile[0] = eFile; //loadECW(fname); |
|
170 |
geoFile[0].setUpdatable((Component) component); |
|
171 |
setProjection(geoFile[0].getProjection()); |
|
172 |
this.component = component; |
|
173 |
|
|
174 |
setExtent(geoFile[0].getExtent()); |
|
175 |
geoFile[0].setView(view); //geoFile.getExtent()); |
|
176 |
extentOrig = extent; |
|
177 |
bandSwitch.addFile(eFile); |
|
178 |
|
|
179 |
if (geoFile[0].getBandCount() >= 3) { |
|
180 |
setBand(GeoRasterFile.RED_BAND, 0); |
|
181 |
setBand(GeoRasterFile.GREEN_BAND, 1); |
|
182 |
setBand(GeoRasterFile.BLUE_BAND, 2); |
|
183 |
} else if (geoFile[0].getBandCount() == 2) { |
|
184 |
setBand(GeoRasterFile.RED_BAND, 0); |
|
185 |
setBand(GeoRasterFile.GREEN_BAND, 1); |
|
186 |
setBand(GeoRasterFile.BLUE_BAND, 1); |
|
187 |
} else if (geoFile[0].getBandCount() == 1) { |
|
188 |
//setBand(GeoRasterFile.RED_BAND|GeoRasterFile.GREEN_BAND|GeoRasterFile.BLUE_BAND, 0); |
|
189 |
setBand(GeoRasterFile.RED_BAND, 0); |
|
190 |
setBand(GeoRasterFile.GREEN_BAND, 0); |
|
191 |
setBand(GeoRasterFile.BLUE_BAND, 0); |
|
192 |
} |
|
193 |
} |
|
194 |
|
|
195 |
/** |
|
196 |
* A?ade un GeoRasterFile al PxRaster |
|
197 |
* @param fileName Nombre del fichero |
|
198 |
*/ |
|
199 |
public void addFile(String fileName) { |
|
200 |
if (geoFile != null) { |
|
201 |
GeoRasterFile[] listFiles = new GeoRasterFile[geoFile.length + 1]; |
|
202 |
|
|
203 |
for (int i = 0; i < geoFile.length; i++) |
|
204 |
listFiles[i] = geoFile[i]; |
|
205 |
|
|
206 |
listFiles[geoFile.length] = GeoRasterFile.openFile(proj, fileName); |
|
207 |
listFiles[geoFile.length].setUpdatable((Component) component); |
|
208 |
setExtent(listFiles[geoFile.length].getExtent()); |
|
209 |
listFiles[geoFile.length].setView(listFiles[geoFile.length].getExtent()); |
|
210 |
bandSwitch.addFile(listFiles[geoFile.length]); |
|
211 |
geoFile = listFiles; |
|
212 |
} else { |
|
213 |
System.err.println("PxRaster.addFile(): Imagen no cargada."); |
|
214 |
|
|
215 |
return; |
|
216 |
} |
|
217 |
} |
|
218 |
|
|
219 |
/** |
|
220 |
* Devuelve el Extent de un fichero son necesidad de a?adirlo |
|
221 |
* al PxRaster |
|
222 |
* @param fileName |
|
223 |
* @return |
|
224 |
*/ |
|
225 |
public Extent testExtentFile(String fileName) { |
|
226 |
GeoRasterFile grf = GeoRasterFile.openFile(proj, fileName); |
|
227 |
|
|
228 |
return grf.getExtent(); |
|
229 |
} |
|
230 |
|
|
231 |
/** |
|
232 |
* Obtiene el valor del pixel del Image en la posici?n wcx,wcy |
|
233 |
* @param wcx Posici?n x |
|
234 |
* @param wcx Posici?n y |
|
235 |
* @return valor de pixel |
|
236 |
*/ |
|
237 |
public int[] getPixel(double wcx, double wcy) { |
|
238 |
if (geoImage != null) { |
|
239 |
int ptox = 0; |
|
240 |
int ptoy = 0; |
|
241 |
|
|
242 |
try { |
|
243 |
//Extent de la imagen completa |
|
244 |
Extent extOrtofoto = geoFile[0].getExtent(); |
|
245 |
|
|
246 |
//Variables q definen el extent del objeto image |
|
247 |
double minx = 0; |
|
248 |
|
|
249 |
//Variables q definen el extent del objeto image |
|
250 |
double miny = 0; |
|
251 |
|
|
252 |
//Variables q definen el extent del objeto image |
|
253 |
double maxx = 0; |
|
254 |
|
|
255 |
//Variables q definen el extent del objeto image |
|
256 |
double maxy = 0; |
|
257 |
|
|
258 |
if (lastViewPort.getExtent().getMin().getX() < extOrtofoto.minX()) { |
|
259 |
minx = extOrtofoto.minX(); |
|
260 |
} else { |
|
261 |
minx = lastViewPort.getExtent().getMin().getX(); |
|
262 |
} |
|
263 |
|
|
264 |
if (lastViewPort.getExtent().getMax().getX() > extOrtofoto.maxX()) { |
|
265 |
maxx = extOrtofoto.maxX(); |
|
266 |
} else { |
|
267 |
maxx = lastViewPort.getExtent().getMax().getX(); |
|
268 |
} |
|
269 |
|
|
270 |
if (lastViewPort.getExtent().getMin().getY() < extOrtofoto.minY()) { |
|
271 |
miny = extOrtofoto.minY(); |
|
272 |
} else { |
|
273 |
miny = lastViewPort.getExtent().getMin().getY(); |
|
274 |
} |
|
275 |
|
|
276 |
if (lastViewPort.getExtent().getMax().getY() > extOrtofoto.maxY()) { |
|
277 |
maxy = extOrtofoto.maxY(); |
|
278 |
} else { |
|
279 |
maxy = lastViewPort.getExtent().getMax().getY(); |
|
280 |
} |
|
281 |
|
|
282 |
//Comprobamos que estemos dentro del extent del Image |
|
283 |
if ((wcx < minx) || (wcx > maxx) || (wcy < miny) || |
|
284 |
(wcy > maxy)) { |
|
285 |
int[] res = { -1, -1, -1, -1 }; |
|
286 |
|
|
287 |
return res; |
|
288 |
} |
|
289 |
|
|
290 |
//Pasamos a coordenadas del Image las coordenadas del mundo real |
|
291 |
int w = ((BufferedImage) geoImage).getWidth(); |
|
292 |
int h = ((BufferedImage) geoImage).getHeight(); |
|
293 |
double wcw = maxx - minx; |
|
294 |
double wch = maxy - miny; |
|
295 |
ptox = (int) (((wcx - minx) * w) / wcw); |
|
296 |
ptoy = (int) (((wcy - miny) * h) / wch); |
|
297 |
|
|
298 |
//Obtenemos el pto seleccionado del Image y extraemos el RGB |
|
299 |
int px = ((BufferedImage) geoImage).getRGB(ptox, h - ptoy); |
|
300 |
int[] values = new int[4]; |
|
301 |
values[0] = ((px & 0xff000000) >> 24); |
|
302 |
values[1] = ((px & 0x00ff0000) >> 16); |
|
303 |
values[2] = ((px & 0x0000ff00) >> 8); |
|
304 |
values[3] = (px & 0x000000ff); |
|
305 |
|
|
306 |
return values; |
|
307 |
} catch (ArrayIndexOutOfBoundsException e) { |
|
308 |
e.printStackTrace(); |
|
309 |
} |
|
310 |
} |
|
311 |
|
|
312 |
return null; |
|
313 |
} |
|
314 |
|
|
315 |
/** |
|
316 |
* Elimina un GeoRasterFile al PxRaster |
|
317 |
* @param finaName Nombre del fichero |
|
318 |
*/ |
|
319 |
public void delFile(String fileName) { |
|
320 |
if (geoFile != null) { |
|
321 |
Vector grfTemp = new Vector(); |
|
322 |
|
|
323 |
for (int i = 0; i < geoFile.length; i++) { |
|
324 |
if (!fileName.endsWith(geoFile[i].getName())) { |
|
325 |
grfTemp.add(geoFile[i]); |
|
326 |
} |
|
327 |
} |
|
328 |
|
|
329 |
GeoRasterFile[] listFiles = new GeoRasterFile[grfTemp.size()]; |
|
330 |
|
|
331 |
for (int i = 0; i < listFiles.length; i++) |
|
332 |
listFiles[i] = (GeoRasterFile) grfTemp.get(i); |
|
333 |
|
|
334 |
//Lo eliminamos del bandSwitch |
|
335 |
for (int i = 0; i < geoFile.length; i++) { |
|
336 |
if (fileName.endsWith(geoFile[i].getName())) { |
|
337 |
bandSwitch.removeFile(geoFile[i]); |
|
338 |
} |
|
339 |
} |
|
340 |
|
|
341 |
geoFile = listFiles; |
|
342 |
|
|
343 |
/*if(geoFile!=null) |
|
344 |
setExtent(geoFile[0].getExtent());*/ |
|
345 |
} else { |
|
346 |
System.err.println("PxRaster.addFile(): Imagen no cargada."); |
|
347 |
|
|
348 |
return; |
|
349 |
} |
|
350 |
} |
|
351 |
|
|
352 |
/** |
|
353 |
* Obtiene el tama?o de bloque |
|
354 |
* @return |
|
355 |
*/ |
|
356 |
public int getBlockSize() { |
|
357 |
return geoFile[0].getBlockSize(); |
|
358 |
} |
|
359 |
|
|
360 |
/** |
|
361 |
* |
|
362 |
* @return |
|
363 |
*/ |
|
364 |
public GeoRasterFile[] getGeoFiles() { |
|
365 |
return geoFile; |
|
366 |
} |
|
367 |
|
|
368 |
public GeoRasterFile getGeoFile() { |
|
369 |
return geoFile[0]; |
|
370 |
} |
|
371 |
|
|
372 |
/** |
|
373 |
* Obtiene el n?mero de bandas del PxRaster. Si ls longitud de geoFile es 1 quiere |
|
374 |
* decir que hay un solo fichero que contiene todas las bandas. Si hay m?s de un geoFile |
|
375 |
* el n?mero de bandas ser? la suma de todas las bandas de las im?genes que forman |
|
376 |
* el geoFile |
|
377 |
* @return N?mero de bandas |
|
378 |
*/ |
|
379 |
public int getBandCount() { |
|
380 |
return bandSwitch.getBandCount(); |
|
381 |
} |
|
382 |
|
|
383 |
/** |
|
384 |
* Obtiene el tipo de dato del primer GeoRasterFile |
|
385 |
* @return |
|
386 |
*/ |
|
387 |
public int getDataType() { |
|
388 |
if (geoFile != null) { |
|
389 |
return geoFile[0].getDataType(); |
|
390 |
} else { |
|
391 |
System.err.println("PxRaster.getDataType(): Imagen no cargada."); |
|
392 |
} |
|
393 |
|
|
394 |
return 0; |
|
395 |
} |
|
396 |
|
|
397 |
/** |
|
398 |
* Obtiene el vector de GeoRasterFile que componen el PxRaster |
|
399 |
* @return vector GeoRasterFile |
|
400 |
*/ |
|
401 |
public GeoRasterFile[] getFiles() { |
|
402 |
return geoFile; |
|
403 |
} |
|
404 |
|
|
405 |
/** |
|
406 |
* Asocia un colorBand al rojo, verde o azul. |
|
407 |
* @param flag cual (o cuales) de las bandas. |
|
408 |
* @param nBand que colorBand |
|
409 |
*/ |
|
410 |
public void setBand(int flag, int nBand) { |
|
411 |
bandSwitch.setBand(flag, nBand); |
|
412 |
} |
|
413 |
|
|
414 |
/** |
|
415 |
* Obtiene la posici?n del fichero asignado a la banda |
|
416 |
* que se le pasa por par?metro |
|
417 |
* @return |
|
418 |
*/ |
|
419 |
public int getPosFile(int flag) { |
|
420 |
if (flag == GeoRasterFile.RED_BAND) { |
|
421 |
return bandSwitch.getBandR().getPos(); |
|
422 |
} else if (flag == GeoRasterFile.GREEN_BAND) { |
|
423 |
return bandSwitch.getBandG().getPos(); |
|
424 |
} else if (flag == GeoRasterFile.BLUE_BAND) { |
|
425 |
return bandSwitch.getBandB().getPos(); |
|
426 |
} else { |
|
427 |
return -1; |
|
428 |
} |
|
429 |
} |
|
430 |
|
|
431 |
/** |
|
432 |
* Devuelve el colorBand activo en la banda especificada. |
|
433 |
* @param flag banda. |
|
434 |
*/ |
|
435 |
public int getBand(int flag) { |
|
436 |
if (flag == GeoRasterFile.RED_BAND) { |
|
437 |
return bandSwitch.getBandR().getBand(); |
|
438 |
} else if (flag == GeoRasterFile.GREEN_BAND) { |
|
439 |
return bandSwitch.getBandG().getBand(); |
|
440 |
} else if (flag == GeoRasterFile.BLUE_BAND) { |
|
441 |
return bandSwitch.getBandB().getBand(); |
|
442 |
} else { |
|
443 |
return -1; |
|
444 |
} |
|
445 |
} |
|
446 |
|
|
447 |
/** |
|
448 |
* @param pm |
|
449 |
*/ |
|
450 |
public void setDrawBorder(boolean pm) { |
|
451 |
pintaMarco = pm; |
|
452 |
} |
|
453 |
|
|
454 |
/** |
|
455 |
* Obtiene el nombre del fichero si solo hay uno |
|
456 |
* @return Nombre del fichero |
|
457 |
*/ |
|
458 |
public String getFName() { |
|
459 |
return geoFile[0].getName(); |
|
460 |
} |
|
461 |
|
|
462 |
/** |
|
463 |
* Obtiene el nombre del fichero GeoRasterFile seleccionado |
|
464 |
* @param i posici?n del GeoRasterFile |
|
465 |
* @return Nombre del fichero |
|
466 |
*/ |
|
467 |
public String getFName(int i) { |
|
468 |
if (geoFile != null) { |
|
469 |
if (i < geoFile.length) { |
|
470 |
return geoFile[i].getName(); |
|
471 |
} else { |
|
472 |
return null; |
|
473 |
} |
|
474 |
} else { |
|
475 |
System.err.println("PxRaster.getFName(): Imagen no cargada."); |
|
476 |
|
|
477 |
return null; |
|
478 |
} |
|
479 |
} |
|
480 |
|
|
481 |
/** |
|
482 |
* Obtiene una lista de Strings con los nombres de todos los ficheros |
|
483 |
* que tiene el PxRaster |
Also available in: Unified diff