Revision 1928 branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/px/PxRaster.java
PxRaster.java | ||
---|---|---|
12 | 12 |
import java.awt.image.DataBuffer; |
13 | 13 |
import java.awt.image.ImageObserver; |
14 | 14 |
import java.lang.reflect.InvocationTargetException; |
15 |
import java.util.ArrayList; |
|
15 | 16 |
import java.util.Date; |
16 | 17 |
import java.util.Vector; |
17 | 18 |
|
... | ... | |
35 | 36 |
import org.cresques.io.raster.TransparencyImageFilter; |
36 | 37 |
|
37 | 38 |
public class PxRaster extends PxObj implements Projected { |
38 |
protected GeoRasterFile[] geoFile = null; |
|
39 |
protected ImageObserver component = null; |
|
40 |
Vector pts = null; |
|
39 |
protected GeoRasterFile[] geoFile = null;
|
|
40 |
protected ImageObserver component = null;
|
|
41 |
Vector pts = null;
|
|
41 | 42 |
// Soporte para n bandas, visibles de 3 en 3, en ficheros separados |
42 | 43 |
//protected GeoRasterFile [] colorBand = null; |
43 |
protected int rBand = 1, gBand = 2, bBand = 3; |
|
44 |
protected int rBand = 1, gBand = 2, bBand = 3;
|
|
44 | 45 |
|
45 |
public RasterStats stats = new RasterStats(); |
|
46 |
int transparente = 0x10ffff80; |
|
46 |
public RasterStats stats = new RasterStats();
|
|
47 |
int transparente = 0x10ffff80;
|
|
47 | 48 |
|
48 |
String vName = null; |
|
49 |
protected boolean pintaMarco = false; //true; |
|
50 |
IProjection proj = null; |
|
51 |
protected Extent extentOrig = null; |
|
52 |
ICoordTrans rp = null; |
|
49 |
String vName = null;
|
|
50 |
protected boolean pintaMarco = false; //true;
|
|
51 |
IProjection proj = null;
|
|
52 |
protected Extent extentOrig = null;
|
|
53 |
ICoordTrans rp = null;
|
|
53 | 54 |
|
54 | 55 |
public RasterFilterStack filterStack = new RasterFilterStack(stats); |
56 |
private BandSwitch bandSwitch = new BandSwitch(); |
|
57 |
/** |
|
58 |
* Estructura que representa la relaci?n entre un fichero y la banda que se |
|
59 |
* utiliza de este. |
|
60 |
* @author Nacho Brodin <brodin_ign@gva.es> |
|
61 |
*/ |
|
62 |
class FileBands{ |
|
63 |
GeoRasterFile grf; //Fichero |
|
64 |
int band; //Banda asinada |
|
65 |
int filePos; //posici?n del fichero |
|
66 |
|
|
67 |
|
|
68 |
/** |
|
69 |
* @return Returns the band. |
|
70 |
*/ |
|
71 |
public int getBand() { |
|
72 |
return band; |
|
73 |
} |
|
74 |
/** |
|
75 |
* @param band The band to set. |
|
76 |
*/ |
|
77 |
public void setBand(int band) { |
|
78 |
this.band = band; |
|
79 |
} |
|
80 |
/** |
|
81 |
* @return Returns the band. |
|
82 |
*/ |
|
83 |
public int getPos() { |
|
84 |
return filePos; |
|
85 |
} |
|
86 |
/** |
|
87 |
* @param band The band to set. |
|
88 |
*/ |
|
89 |
public void setPos(int pos) { |
|
90 |
this.filePos = pos; |
|
91 |
} |
|
92 |
/** |
|
93 |
* @return Returns the grf. |
|
94 |
*/ |
|
95 |
public GeoRasterFile getGeoRasterFile() { |
|
96 |
return grf; |
|
97 |
} |
|
98 |
/** |
|
99 |
* @param grf The grf to set. |
|
100 |
*/ |
|
101 |
public void setGeoRasterFile(GeoRasterFile grf) { |
|
102 |
this.grf = grf; |
|
103 |
} |
|
104 |
} |
|
55 | 105 |
|
106 |
/** |
|
107 |
* Clase que lleva la gesti?n entre la relaci?n de ficheros representados |
|
108 |
* por un GeoRasterFile y el n?mero de bandas que contienen. Esto es necesario |
|
109 |
* para la actualizaci?n de la vista ya que para un Image dado podemos tener |
|
110 |
* multiples bandas que pueden ser leidas desde diferentes ficheros. |
|
111 |
* |
|
112 |
* @author Nacho Brodin <brodin_ign@gva.es> |
|
113 |
*/ |
|
114 |
class BandSwitch{ |
|
115 |
private ArrayList geoFiles = new ArrayList(); //Lista de GeoRasterFile con los ficheros raster cargados |
|
116 |
private FileBands[] listBands = new FileBands[3]; |
|
117 |
private boolean debug = false; |
|
118 |
|
|
119 |
BandSwitch(){ |
|
120 |
for(int i=0;i<listBands.length;i++) |
|
121 |
listBands[i] = new FileBands(); |
|
122 |
} |
|
123 |
|
|
124 |
/** |
|
125 |
* A?ade un fichero |
|
126 |
* @param grf |
|
127 |
*/ |
|
128 |
public void addFile(GeoRasterFile grf){ |
|
129 |
geoFiles.add(grf); |
|
130 |
if(debug) |
|
131 |
this.show("addFile"); |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* Elimina un fichero |
|
136 |
* @param grf |
|
137 |
*/ |
|
138 |
public void removeFile(GeoRasterFile grf){ |
|
139 |
for(int iFile=0;iFile<geoFiles.size();iFile++){ |
|
140 |
if(grf.equals(geoFiles.get(iFile))){ |
|
141 |
geoFiles.remove(iFile); |
|
142 |
iFile--; |
|
143 |
} |
|
144 |
} |
|
145 |
|
|
146 |
if(debug) |
|
147 |
this.show("removeFile"); |
|
148 |
} |
|
149 |
|
|
150 |
/** |
|
151 |
* |
|
152 |
* @param flag |
|
153 |
* @param grf |
|
154 |
* @param nBand |
|
155 |
*/ |
|
156 |
public void setBand(int flag, GeoRasterFile grf, int nBand){ |
|
157 |
if ((flag & GeoRasterFile.RED_BAND) == GeoRasterFile.RED_BAND){ |
|
158 |
listBands[0].setBand(nBand); |
|
159 |
listBands[0].setGeoRasterFile(grf); |
|
160 |
}else if ((flag & GeoRasterFile.GREEN_BAND) == GeoRasterFile.GREEN_BAND){ |
|
161 |
listBands[1].setBand(nBand); |
|
162 |
listBands[1].setGeoRasterFile(grf); |
|
163 |
}else if ((flag & GeoRasterFile.BLUE_BAND) == GeoRasterFile.BLUE_BAND){ |
|
164 |
listBands[2].setBand(nBand); |
|
165 |
listBands[2].setGeoRasterFile(grf); |
|
166 |
}else |
|
167 |
return; |
|
168 |
grf.setBand(flag, nBand); |
|
169 |
} |
|
170 |
|
|
171 |
/** |
|
172 |
* Asigna las bandas |
|
173 |
* @param flag |
|
174 |
* @param nBand |
|
175 |
*/ |
|
176 |
public void setBand(int flag, int nBand){ |
|
177 |
int cont = 0; |
|
178 |
for(int iGrf=0;iGrf<geoFiles.size();iGrf++){ |
|
179 |
for(int iBand=0;iBand<((GeoRasterFile)geoFiles.get(iGrf)).getBandCount();iBand++){ |
|
180 |
if ( ((flag & GeoRasterFile.RED_BAND) == GeoRasterFile.RED_BAND) && |
|
181 |
cont == nBand){ |
|
182 |
listBands[0].setGeoRasterFile(((GeoRasterFile)geoFiles.get(iGrf))); |
|
183 |
listBands[0].setBand(iBand); |
|
184 |
listBands[0].setPos(iGrf); |
|
185 |
((GeoRasterFile)geoFiles.get(iGrf)).setBand(flag, iBand); |
|
186 |
//System.out.println("==>Asignando banda R FILE="+iGrf+" BANDA="+iBand); |
|
187 |
}else if ( ((flag & GeoRasterFile.GREEN_BAND) == GeoRasterFile.GREEN_BAND) && |
|
188 |
cont == nBand){ |
|
189 |
listBands[1].setGeoRasterFile(((GeoRasterFile)geoFiles.get(iGrf))); |
|
190 |
listBands[1].setBand(iBand); |
|
191 |
listBands[1].setPos(iGrf); |
|
192 |
((GeoRasterFile)geoFiles.get(iGrf)).setBand(flag, iBand); |
|
193 |
//System.out.println("==>Asignando banda G FILE="+iGrf+" BANDA="+iBand); |
|
194 |
}else if ( ((flag & GeoRasterFile.BLUE_BAND) == GeoRasterFile.BLUE_BAND) && |
|
195 |
cont == nBand){ |
|
196 |
listBands[2].setGeoRasterFile(((GeoRasterFile)geoFiles.get(iGrf))); |
|
197 |
listBands[2].setBand(iBand); |
|
198 |
listBands[2].setPos(iGrf); |
|
199 |
((GeoRasterFile)geoFiles.get(iGrf)).setBand(flag, iBand); |
|
200 |
//System.out.println("==>Asignando banda B FILE="+iGrf+" BANDA="+iBand); |
|
201 |
} |
|
202 |
cont++; |
|
203 |
} |
|
204 |
} |
|
205 |
if(debug) |
|
206 |
this.show("setBand"); |
|
207 |
} |
|
208 |
|
|
209 |
/** |
|
210 |
* Obtiene el n?mero de bandas |
|
211 |
* @return |
|
212 |
*/ |
|
213 |
public int getBandCount(){ |
|
214 |
int nbandas = 0; |
|
215 |
for(int iGrf=0;iGrf<geoFiles.size();iGrf++) |
|
216 |
nbandas += ((GeoRasterFile)geoFiles.get(iGrf)).getBandCount(); |
|
217 |
return nbandas; |
|
218 |
} |
|
219 |
|
|
220 |
/** |
|
221 |
* Obtiene el GeoRasterFile que hay que leer para cargar la banda del rojo |
|
222 |
* y la banda de este fichero que se utiliza para esta asignaci?n. |
|
223 |
* @return Estructura FileBand con la relaci?n fichero-banda |
|
224 |
*/ |
|
225 |
public FileBands getBandR(){ |
|
226 |
return listBands[0]; |
|
227 |
} |
|
228 |
|
|
229 |
/** |
|
230 |
* Obtiene el GeoRasterFile que hay que leer para cargar la banda del verde |
|
231 |
* y la banda de este fichero que se utiliza para esta asignaci?n. |
|
232 |
* @return Estructura FileBand con la relaci?n fichero-banda |
|
233 |
*/ |
|
234 |
public FileBands getBandG(){ |
|
235 |
return listBands[1]; |
|
236 |
} |
|
237 |
|
|
238 |
/** |
|
239 |
* Obtiene el GeoRasterFile que hay que leer para cargar la banda del azul |
|
240 |
* y la banda de este fichero que se utiliza para esta asignaci?n. |
|
241 |
* @return Estructura FileBand con la relaci?n fichero-banda |
|
242 |
*/ |
|
243 |
public FileBands getBandB(){ |
|
244 |
return listBands[2]; |
|
245 |
} |
|
246 |
|
|
247 |
public void show(String op){ |
|
248 |
String banda = null; |
|
249 |
System.out.println("** "+op+" **"); |
|
250 |
for(int i=0;i<3;i++){ |
|
251 |
if(i==0) |
|
252 |
banda = new String("Rojo"); |
|
253 |
else if(i==1) |
|
254 |
banda = new String("Verde"); |
|
255 |
else if(i==2) |
|
256 |
banda = new String("Azul"); |
|
257 |
|
|
258 |
System.out.println("** BANDA IMAGE="+banda+" FILEPOS="+listBands[i].getBand()+" BANDA DEL FICHERO="+listBands[i].getBand()); |
|
259 |
} |
|
260 |
} |
|
261 |
} |
|
262 |
|
|
56 | 263 |
/*public boolean transparencyFilterEnabled = false; |
57 | 264 |
public boolean enhancedFilterEnabled = false; |
58 | 265 |
public boolean tailFilterEnabled = false;*/ |
... | ... | |
80 | 287 |
setExtent(geoFile[0].getExtent()); |
81 | 288 |
geoFile[0].setView(geoFile[0].getExtent()); |
82 | 289 |
extentOrig = extent; |
83 |
if (geoFile[0].getBandCount()>2) { |
|
290 |
bandSwitch.addFile(geoFile[0]); |
|
291 |
if (geoFile[0].getBandCount()>=3) { |
|
84 | 292 |
setBand(GeoRasterFile.RED_BAND, 0); |
85 | 293 |
setBand(GeoRasterFile.GREEN_BAND, 1); |
86 | 294 |
setBand(GeoRasterFile.BLUE_BAND, 2); |
87 |
} else { |
|
88 |
setBand(GeoRasterFile.RED_BAND|GeoRasterFile.GREEN_BAND|GeoRasterFile.BLUE_BAND, 0); |
|
295 |
} else if (geoFile[0].getBandCount()==2) { |
|
296 |
setBand(GeoRasterFile.RED_BAND, 0); |
|
297 |
setBand(GeoRasterFile.GREEN_BAND, 1); |
|
298 |
setBand(GeoRasterFile.BLUE_BAND, 1); |
|
299 |
} else if (geoFile[0].getBandCount()==1) { |
|
300 |
//setBand(GeoRasterFile.RED_BAND|GeoRasterFile.GREEN_BAND|GeoRasterFile.BLUE_BAND, 0); |
|
301 |
setBand(GeoRasterFile.RED_BAND, 0); |
|
302 |
setBand(GeoRasterFile.GREEN_BAND, 0); |
|
303 |
setBand(GeoRasterFile.BLUE_BAND, 0); |
|
89 | 304 |
} |
90 | 305 |
} |
91 |
|
|
92 |
/*public PxRaster(String fname, ImageObserver component, Extent view) { |
|
93 |
geoFile = GeoRasterFile.openFile(null, fname);//loadECW(fname); |
|
94 |
this.component = component; |
|
95 |
setExtent(geoFile.getExtent()); |
|
96 |
geoFile.setView(view); |
|
97 |
extentOrig = extent; |
|
98 | 306 |
|
99 |
//double x = 680800,y = 4128600; |
|
100 |
//setView(new Extent(x, y, x+4200, y-4200),"Huelva capital"); |
|
101 |
}*/ |
|
102 |
/*public void setImageBand(){ |
|
103 |
GeoRasterFile [] colorBandCpy = colorBand; |
|
104 |
|
|
105 |
}*/ |
|
106 |
|
|
107 | 307 |
/** |
108 | 308 |
* Constructor para multiples ficheros |
109 | 309 |
*/ |
... | ... | |
116 | 316 |
geoFile[i].setUpdatable((Component) component); |
117 | 317 |
setExtent(geoFile[i].getExtent()); |
118 | 318 |
geoFile[i].setView(geoFile[i].getExtent()); |
319 |
bandSwitch.addFile(geoFile[i]); |
|
119 | 320 |
} |
120 | 321 |
//geoFile = geoFile[0]; |
121 | 322 |
extentOrig = extent; |
... | ... | |
141 | 342 |
listFiles[geoFile.length].setUpdatable((Component) component); |
142 | 343 |
setExtent(listFiles[geoFile.length].getExtent()); |
143 | 344 |
listFiles[geoFile.length].setView(listFiles[geoFile.length].getExtent()); |
345 |
bandSwitch.addFile(listFiles[geoFile.length]); |
|
144 | 346 |
geoFile = listFiles; |
145 | 347 |
}else { |
146 | 348 |
System.err.println("PxRaster.addFile(): Imagen no cargada."); |
... | ... | |
149 | 351 |
} |
150 | 352 |
|
151 | 353 |
/** |
354 |
* Devuelve el Extent de un fichero son necesidad de a?adirlo |
|
355 |
* al PxRaster |
|
356 |
* @param fileName |
|
357 |
* @return |
|
358 |
*/ |
|
359 |
public Extent testExtentFile(String fileName){ |
|
360 |
GeoRasterFile grf = GeoRasterFile.openFile(proj, fileName); |
|
361 |
return grf.getExtent(); |
|
362 |
} |
|
363 |
|
|
364 |
/** |
|
152 | 365 |
* Elimina un GeoRasterFile al PxRaster |
153 | 366 |
* @param finaName Nombre del fichero |
154 | 367 |
*/ |
... | ... | |
156 | 369 |
if(geoFile!=null){ |
157 | 370 |
Vector grfTemp = new Vector(); |
158 | 371 |
for(int i=0;i<geoFile.length;i++){ |
159 |
if(!fileName.endsWith(geoFile[i].getName())){
|
|
372 |
if(!fileName.endsWith(geoFile[i].getName())) |
|
160 | 373 |
grfTemp.add(geoFile[i]); |
161 |
//System.out.println("PxRaster:L161 Se queda"+geoFile[i].getName()); |
|
162 |
} |
|
163 | 374 |
} |
164 | 375 |
GeoRasterFile[] listFiles = new GeoRasterFile[grfTemp.size()]; |
165 |
for(int i=0;i<listFiles.length;i++){
|
|
376 |
for(int i=0;i<listFiles.length;i++) |
|
166 | 377 |
listFiles[i] = (GeoRasterFile)grfTemp.get(i); |
167 |
//System.out.println("A?ADIDO Al BORRAR A PXRASTER "+listFiles[i].getName()); |
|
378 |
|
|
379 |
//Lo eliminamos del bandSwitch |
|
380 |
|
|
381 |
for(int i=0;i<geoFile.length;i++){ |
|
382 |
if(fileName.endsWith(geoFile[i].getName())){ |
|
383 |
bandSwitch.removeFile(geoFile[i]); |
|
384 |
} |
|
168 | 385 |
} |
386 |
|
|
169 | 387 |
geoFile = listFiles; |
170 |
if(geoFile!=null) |
|
171 |
setExtent(geoFile[0].getExtent()); |
|
388 |
/*if(geoFile!=null) |
|
389 |
setExtent(geoFile[0].getExtent());*/ |
|
390 |
|
|
172 | 391 |
}else { |
173 | 392 |
System.err.println("PxRaster.addFile(): Imagen no cargada."); |
174 | 393 |
return; |
... | ... | |
185 | 404 |
setExtent(geoFile[0].getExtent()); |
186 | 405 |
geoFile[0].setView(view); //geoFile.getExtent()); |
187 | 406 |
extentOrig = extent; |
188 |
if (geoFile[0].getBandCount()>2) { |
|
407 |
bandSwitch.addFile(eFile); |
|
408 |
if (geoFile[0].getBandCount()>=3) { |
|
189 | 409 |
setBand(GeoRasterFile.RED_BAND, 0); |
190 | 410 |
setBand(GeoRasterFile.GREEN_BAND, 1); |
191 | 411 |
setBand(GeoRasterFile.BLUE_BAND, 2); |
192 |
} else { |
|
193 |
setBand(GeoRasterFile.RED_BAND|GeoRasterFile.GREEN_BAND|GeoRasterFile.BLUE_BAND, 0); |
|
412 |
} else if (geoFile[0].getBandCount()==2) { |
|
413 |
setBand(GeoRasterFile.RED_BAND, 0); |
|
414 |
setBand(GeoRasterFile.GREEN_BAND, 1); |
|
415 |
setBand(GeoRasterFile.BLUE_BAND, 1); |
|
416 |
} else if (geoFile[0].getBandCount()==1) { |
|
417 |
//setBand(GeoRasterFile.RED_BAND|GeoRasterFile.GREEN_BAND|GeoRasterFile.BLUE_BAND, 0); |
|
418 |
setBand(GeoRasterFile.RED_BAND, 0); |
|
419 |
setBand(GeoRasterFile.GREEN_BAND, 0); |
|
420 |
setBand(GeoRasterFile.BLUE_BAND, 0); |
|
194 | 421 |
} |
195 | 422 |
} |
196 | 423 |
|
... | ... | |
222 | 449 |
* @return N?mero de bandas |
223 | 450 |
*/ |
224 | 451 |
public int getBandCount() { |
225 |
if(geoFile.length == 1) |
|
226 |
return geoFile[0].getBandCount(); |
|
227 |
else{ |
|
228 |
int nBands = 0; |
|
229 |
for(int i=0;i<geoFile.length;i++){ |
|
230 |
nBands+=geoFile[i].getBandCount(); |
|
231 |
} |
|
232 |
return nBands; |
|
233 |
} |
|
452 |
return bandSwitch.getBandCount(); |
|
234 | 453 |
} |
235 | 454 |
|
236 | 455 |
/** |
... | ... | |
258 | 477 |
* @param nBand que colorBand |
259 | 478 |
*/ |
260 | 479 |
public void setBand(int flag, int nBand) { |
261 |
if (geoFile.length > 1) { |
|
262 |
if ((flag & GeoRasterFile.RED_BAND) == GeoRasterFile.RED_BAND) |
|
263 |
rBand = nBand; |
|
264 |
else if ((flag & GeoRasterFile.GREEN_BAND) == GeoRasterFile.GREEN_BAND) |
|
265 |
gBand = nBand; |
|
266 |
else if ((flag & GeoRasterFile.BLUE_BAND) == GeoRasterFile.BLUE_BAND) |
|
267 |
bBand = nBand; |
|
268 |
} else |
|
269 |
geoFile[0].setBand(flag, nBand); |
|
480 |
bandSwitch.setBand(flag, nBand); |
|
270 | 481 |
} |
271 |
|
|
482 |
|
|
272 | 483 |
/** |
484 |
* Obtiene la posici?n del fichero asignado a la banda |
|
485 |
* que se le pasa por par?metro |
|
486 |
* @return |
|
487 |
*/ |
|
488 |
public int getPosFile(int flag){ |
|
489 |
if (flag == GeoRasterFile.RED_BAND){ |
|
490 |
return bandSwitch.getBandR().getPos(); |
|
491 |
}else if (flag == GeoRasterFile.GREEN_BAND){ |
|
492 |
return bandSwitch.getBandG().getPos(); |
|
493 |
}else if (flag == GeoRasterFile.BLUE_BAND){ |
|
494 |
return bandSwitch.getBandB().getPos(); |
|
495 |
}else |
|
496 |
return -1; |
|
497 |
} |
|
498 |
|
|
499 |
/** |
|
273 | 500 |
* Devuelve el colorBand activo en la banda especificada. |
274 | 501 |
* @param flag banda. |
275 | 502 |
*/ |
276 |
|
|
277 | 503 |
public int getBand(int flag) { |
278 |
if (geoFile.length > 1) { |
|
279 |
if (flag == GeoRasterFile.RED_BAND) |
|
280 |
return rBand; |
|
281 |
else if (flag == GeoRasterFile.GREEN_BAND) |
|
282 |
return gBand; |
|
283 |
else if (flag == GeoRasterFile.BLUE_BAND) |
|
284 |
return bBand; |
|
285 |
else |
|
286 |
return -1; |
|
287 |
} else |
|
288 |
return geoFile[0].getBand(flag); |
|
504 |
if (flag == GeoRasterFile.RED_BAND){ |
|
505 |
return bandSwitch.getBandR().getBand(); |
|
506 |
}else if (flag == GeoRasterFile.GREEN_BAND){ |
|
507 |
return bandSwitch.getBandG().getBand(); |
|
508 |
}else if (flag == GeoRasterFile.BLUE_BAND){ |
|
509 |
return bandSwitch.getBandB().getBand(); |
|
510 |
}else |
|
511 |
return -1; |
|
289 | 512 |
} |
290 | 513 |
|
291 | 514 |
/** |
... | ... | |
524 | 747 |
public void draw(Graphics2D g, ViewPortData vp) { |
525 | 748 |
Image geoImage = null; |
526 | 749 |
long t2, t1 = new Date().getTime(); |
527 |
System.out.println("PxRaster.draw(): vp.extent = "+ vp.getExtent()); |
|
528 |
System.out.println("PxRaster.draw(): extent = "+ getExtent()); |
|
750 |
//System.out.println("PxRaster.draw(): vp.extent = "+ vp.getExtent());
|
|
751 |
//System.out.println("PxRaster.draw(): extent = "+ getExtent());
|
|
529 | 752 |
if (vp.getExtent().minX()> extent.maxX()) return; |
530 | 753 |
if (vp.getExtent().minY()> extent.maxY()) return; |
531 | 754 |
if (vp.getExtent().maxX()< extent.minX()) return; |
... | ... | |
536 | 759 |
double y = v.minY(); |
537 | 760 |
double w = v.width(); |
538 | 761 |
double h = v.height(); |
539 |
System.out.println("Pinto PxRaster:" + v); |
|
762 |
//System.out.println("Pinto PxRaster:" + v);
|
|
540 | 763 |
|
541 | 764 |
double scalex = vp.mat.getScaleX() /* g.getTransform().getScaleX()*/ , |
542 | 765 |
scaley = vp.mat.getScaleY() /* g.getTransform().getScaleY() */; |
543 | 766 |
int wImg = (int) Math.abs(w*scalex)+1, hImg = (int) Math.abs(h*scaley)+1; |
544 |
System.out.println("Sz=("+wImg+","+hImg+"); scale=("+scalex+","+scaley+")"); |
|
767 |
//System.out.println("Sz=("+wImg+","+hImg+"); scale=("+scalex+","+scaley+")");
|
|
545 | 768 |
if (wImg <= 0 || hImg <= 0) return; |
546 | 769 |
|
547 | 770 |
Point2D.Double pt = new Point2D.Double(x, y+h); |
548 | 771 |
try { |
549 |
System.out.println("Dibujando PxRaster: pt0 = "+pt); |
|
772 |
//System.out.println("Dibujando PxRaster: pt0 = "+pt);
|
|
550 | 773 |
vp.mat.transform(pt, pt); |
551 |
System.out.println("Dibujando PxRaster: pt1 = "+pt); |
|
774 |
//System.out.println("Dibujando PxRaster: pt1 = "+pt);
|
|
552 | 775 |
if (geoFile != null && geoFile[0] instanceof GdalFile && |
553 | 776 |
(geoFile[0].getDataType() != DataBuffer.TYPE_BYTE)) { |
554 |
System.out.println("PxRaster: Has dado con un Raster de 16 bits"); |
|
555 |
System.out.println("Dibujando PxRaster sz=("+wImg+","+hImg+"..."); |
|
777 |
//System.out.println("PxRaster: Has dado con un Raster de 16 bits");
|
|
778 |
//System.out.println("Dibujando PxRaster sz=("+wImg+","+hImg+"...");
|
|
556 | 779 |
RasterBuf raster = ((GdalFile) geoFile[0]).getRaster(wImg, hImg, rp); |
557 | 780 |
t2 = new Date().getTime(); |
558 |
System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs. Obteniendo"); t1 = t2; |
|
781 |
//System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs. Obteniendo"); t1 = t2;
|
|
559 | 782 |
geoImage = renderizeRaster(raster); |
560 | 783 |
t2 = new Date().getTime(); |
561 | 784 |
System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs. Filtrando/Renderizando");t1 = t2; |
... | ... | |
567 | 790 |
t2 = new Date().getTime(); |
568 | 791 |
System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs. Dibujando"); |
569 | 792 |
} else if (geoFile != null && geoFile.length > 1) { // multiFiles |
570 |
System.out.println("Dibujando PxRaster (Multifile) ... Bands"+geoFile.length);
|
|
793 |
//System.out.println("Dibujando PxRaster (Multifile) ... Bands "+geoFile.length);
|
|
571 | 794 |
|
572 |
/*int nFich = geoFile.length; |
|
573 |
int[] nBandas = new int[nFich]; |
|
574 |
for(int i=0;i<nFich;i++) |
|
575 |
nBandas[i] = geoFile[i].getBandCount(); |
|
576 |
*/ |
|
577 |
|
|
578 |
if( geoFile[rBand].getBandCount() == 1 && |
|
579 |
geoFile[gBand].getBandCount() == 1 && |
|
580 |
geoFile[bBand].getBandCount() == 1 ){ |
|
581 |
geoImage = geoFile[rBand].updateImage(wImg, hImg, rp); //, geoImage, GeoRasterFile.RED_BAND); |
|
582 |
geoImage = geoFile[gBand].updateImage(wImg, hImg, rp, geoImage, GeoRasterFile.GREEN_BAND); |
|
583 |
geoImage = geoFile[bBand].updateImage(wImg, hImg, rp, geoImage, GeoRasterFile.BLUE_BAND); |
|
584 |
} |
|
585 |
|
|
586 |
|
|
795 |
geoImage = bandSwitch.getBandR().getGeoRasterFile().updateImage |
|
796 |
(wImg, hImg, rp, null, 0, 0); |
|
797 |
geoImage = bandSwitch.getBandG().getGeoRasterFile().updateImage |
|
798 |
(wImg, hImg, rp, geoImage, bandSwitch.getBandG().getBand(), GeoRasterFile.GREEN_BAND); |
|
799 |
geoImage = bandSwitch.getBandB().getGeoRasterFile().updateImage |
|
800 |
(wImg, hImg, rp, geoImage, bandSwitch.getBandB().getBand(), GeoRasterFile.BLUE_BAND); |
|
801 |
|
|
587 | 802 |
filterStack.setInitRasterBuf(geoImage); |
588 | 803 |
|
589 | 804 |
geoImage = renderizeRaster(geoImage); |
... | ... | |
592 | 807 |
System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs."); |
593 | 808 |
|
594 | 809 |
} else if (geoFile != null && geoFile.length == 1) { // Una solo fichero |
595 |
geoImage = geoFile[0].updateImage(wImg, hImg, rp); |
|
596 |
System.out.println("Dibujando PxRaster sz=("+wImg+","+hImg+"..."); |
|
810 |
|
|
811 |
geoImage = bandSwitch.getBandR().getGeoRasterFile().updateImage |
|
812 |
(wImg, hImg, rp, null, 0, 0); |
|
813 |
//System.out.println("Dibujando PxRaster sz=("+wImg+","+hImg+"..."); |
|
597 | 814 |
|
598 | 815 |
filterStack.setInitRasterBuf(geoImage); |
599 | 816 |
|
Also available in: Unified diff