Revision 1679 branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/px/PxRaster.java
PxRaster.java | ||
---|---|---|
9 | 9 |
import java.awt.Image; |
10 | 10 |
import java.awt.geom.GeneralPath; |
11 | 11 |
import java.awt.geom.Point2D; |
12 |
import java.awt.image.DataBuffer; |
|
12 | 13 |
import java.awt.image.ImageObserver; |
13 | 14 |
import java.util.Date; |
14 | 15 |
import java.util.Vector; |
... | ... | |
17 | 18 |
import org.cresques.cts.IProjection; |
18 | 19 |
import org.cresques.geo.Projected; |
19 | 20 |
import org.cresques.geo.ViewPortData; |
20 |
//import org.cresques.io.GdalFile;
|
|
21 |
import org.cresques.io.GdalFile; |
|
21 | 22 |
import org.cresques.io.GeoRasterFile; |
22 |
//import org.cresques.io.raster.ComputeMinMaxFilter;
|
|
23 |
//import org.cresques.io.raster.ComputeMinMaxImageFilter;
|
|
24 |
//import org.cresques.io.raster.LinearEnhancementFilter;
|
|
25 |
//import org.cresques.io.raster.LinearEnhancementImageFilter;
|
|
26 |
//import org.cresques.io.raster.RasterBuf;
|
|
27 |
//import org.cresques.io.raster.RasterFilter;
|
|
28 |
//import org.cresques.io.raster.RasterStats;
|
|
23 |
import org.cresques.io.raster.ComputeMinMaxFilter; |
|
24 |
import org.cresques.io.raster.ComputeMinMaxImageFilter; |
|
25 |
import org.cresques.io.raster.LinearEnhancementFilter; |
|
26 |
import org.cresques.io.raster.LinearEnhancementImageFilter; |
|
27 |
import org.cresques.io.raster.RasterBuf; |
|
28 |
import org.cresques.io.raster.RasterStats;
|
|
29 |
import org.cresques.io.raster.RasterToImageFilter;
|
|
29 | 30 |
|
30 | 31 |
public class PxRaster extends PxObj implements Projected { |
31 | 32 |
protected GeoRasterFile geoFile = null; |
... | ... | |
35 | 36 |
protected GeoRasterFile [] colorBand = null; |
36 | 37 |
protected int rBand = 1, gBand = 2, bBand = 3; |
37 | 38 |
|
38 |
//RasterStats stats = new RasterStats();
|
|
39 |
RasterStats stats = new RasterStats(); |
|
39 | 40 |
int transparente = 0x10ffff80; |
40 | 41 |
|
41 | 42 |
String vName = null; |
... | ... | |
283 | 284 |
System.out.println("Dibujando PxRaster: pt0 = "+pt); |
284 | 285 |
vp.mat.transform(pt, pt); |
285 | 286 |
System.out.println("Dibujando PxRaster: pt1 = "+pt); |
286 |
/*if (colorBand == null && geoFile instanceof GdalFile &&
|
|
287 |
if (colorBand == null && geoFile instanceof GdalFile && |
|
287 | 288 |
(geoFile.getDataType() != DataBuffer.TYPE_BYTE)) { |
288 | 289 |
System.out.println("PxRaster: Has dado con un Raster de 16 bits"); |
289 | 290 |
System.out.println("Dibujando PxRaster sz=("+wImg+","+hImg+"..."); |
... | ... | |
297 | 298 |
g.drawImage(geoImage, (int) Math.round(pt.getX()), (int) Math.round(pt.getY()), component); |
298 | 299 |
t2 = new Date().getTime(); |
299 | 300 |
System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs. Dibujando"); |
300 |
} else */if (colorBand != null) { // multiBands
|
|
301 |
} else if (colorBand != null) { // multiBands |
|
301 | 302 |
System.out.println("Dibujando PxRaster (Multifile) ..."); |
302 | 303 |
//if (doTransparency) |
303 | 304 |
//geoImage = new BufferedImage(wImg, hImg, BufferedImage.TYPE_INT_ARGB); |
... | ... | |
307 | 308 |
geoImage = colorBand[gBand].updateImage(wImg, hImg, rp, geoImage, GeoRasterFile.GREEN_BAND); |
308 | 309 |
geoImage = colorBand[bBand].updateImage(wImg, hImg, rp, geoImage, GeoRasterFile.BLUE_BAND); |
309 | 310 |
|
310 |
//geoImage = renderizeRaster(geoImage);
|
|
311 |
geoImage = renderizeRaster(geoImage); |
|
311 | 312 |
g.drawImage(geoImage, (int) Math.round(pt.getX()), (int) Math.round(pt.getY()), component); |
312 | 313 |
t2 = new Date().getTime(); |
313 | 314 |
System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs."); |
... | ... | |
316 | 317 |
geoImage = geoFile.updateImage(wImg, hImg, rp); |
317 | 318 |
System.out.println("Dibujando PxRaster sz=("+wImg+","+hImg+"..."); |
318 | 319 |
|
319 |
//geoImage = renderizeRaster(geoImage);
|
|
320 |
geoImage = renderizeRaster(geoImage); |
|
320 | 321 |
g.drawImage(geoImage, (int) Math.round(pt.getX()), (int) Math.round(pt.getY()), component); |
321 | 322 |
t2 = new Date().getTime(); |
322 | 323 |
System.out.println("Dibujando PxRaster: "+(t2-t1)/1000D+", secs."); |
... | ... | |
334 | 335 |
|
335 | 336 |
|
336 | 337 |
|
337 |
/* |
|
338 |
/** |
|
339 |
* Renderiza el raster. |
|
340 |
* @author Luis W. Sevilla (sevilla_lui@gva.es) |
|
341 |
* / |
|
338 |
/* */ |
|
342 | 339 |
|
343 |
class RasterToImageFilter extends RasterFilter { |
|
344 |
private BufferedImage image; |
|
345 |
private int alpha; |
|
346 |
private int rgb; |
|
347 |
public RasterToImageFilter(RasterBuf raster, int a) { |
|
348 |
super(raster, null); |
|
349 |
this.alpha = (a & 0xff) << 24; |
|
350 |
image = new BufferedImage(raster.getWidth(), raster.getHeight(), BufferedImage.TYPE_INT_ARGB); |
|
351 |
execute(); |
|
352 |
} |
|
353 |
|
|
354 |
/* (non-Javadoc) |
|
355 |
* @see org.cresques.px.PxRaster.RasterFilter#process(int, int) |
|
356 |
* / |
|
357 |
public void process(int x, int y) { |
|
358 |
raster.getPixelInt(x, y, px); |
|
359 |
rgb = alpha | ((px[0] & 0xff) << 16) | |
|
360 |
((px[1] & 0xff) << 8) | (px[2] & 0xff); |
|
361 |
|
|
362 |
image.setRGB(x, y, rgb); |
|
363 |
} |
|
364 |
|
|
365 |
public Image getImage() { return image; } |
|
366 |
|
|
367 |
/* (non-Javadoc) |
|
368 |
* @see org.cresques.px.PxRaster.RasterFilter#processLines(int) |
|
369 |
* / |
|
370 |
public void processLine(int y) { |
|
371 |
for (int x=0; x<width; x++) { |
|
372 |
int [][] line = raster.getLineInt(y); |
|
373 |
rgb = alpha | ((line[x][0] & 0xff) << 16) | |
|
374 |
((line[x][1] & 0xff) << 8) | (line[x][2] & 0xff); |
|
375 |
|
|
376 |
image.setRGB(x, y, rgb); |
|
377 |
} |
|
378 |
} |
|
379 |
} |
|
380 |
|
|
381 | 340 |
public Image renderizeRaster(RasterBuf raster) { |
382 | 341 |
if (true) { |
383 | 342 |
ComputeMinMaxFilter filter = |
... | ... | |
414 | 373 |
stats.pinta(); |
415 | 374 |
return image; |
416 | 375 |
} |
417 |
*/ |
|
376 |
/* */
|
|
418 | 377 |
public void drawMarco(Graphics2D g, ViewPortData vp) { |
419 | 378 |
// Color color = new Color(255,222,165,128), fillColor = new Color(255,214,132,128); |
420 | 379 |
Color color = new Color(128,128,128), fillColor = new Color(255,220,220,0x20); |
Also available in: Unified diff