Revision 11082 trunk/libraries/libRaster/src/org/gvsig/raster/buffer/cache/PageBuffer.java

View differences:

PageBuffer.java
35 35
 * @author Nacho Brodin (nachobrodin@gmail.com)
36 36
 *
37 37
 */
38
public class PageBuffer implements IBuffer{
38
public class PageBuffer implements IBuffer {
39 39

  
40
	private PageBandBuffer[] pageBandBuffer = null;
41
	private int	percent = 0;
40
	private PageBandBuffer[]	pageBandBuffer = null;
41

  
42
	private int								percent = 0;
43
	private boolean						canceled = false;
42 44
	
43 45
	/**
44 46
	 * Constructor
......
420 422
			return null;
421 423
		Histogram hist = new Histogram(getBandCount(), 256);
422 424
		for (int iBand = 0; iBand < getBandCount(); iBand++) 
423
			for (int col = 0; col < getHeight(); col++) 
425
			for (int col = 0; col < getHeight(); col++) { 
424 426
				for (int row = 0; row < getWidth(); row++) 
425 427
					hist.incrementPxValue(iBand, getElemByte(row, col, iBand));
428
				if (isCanceled()) return null;
429
				percent = ((iBand * getHeight() + col) * 100) / (getBandCount() * getHeight());
430
			}
426 431
		percent = 100;
427 432
		return hist;
428 433
	}
......
432 437
	 * @see org.gvsig.raster.driver.datasetproperties.IHistogramable#getHistogramUsingClasses(org.gvsig.raster.shared.DataClassList)
433 438
 	 */
434 439
	public Histogram getHistogramUsingClasses(DataClassList classes) throws HistogramException {
440
		percent = 0;
435 441
		Histogram hist = new Histogram(getBandCount(), classes.length());
436 442
		for (int iBand = 0; iBand < getBandCount(); iBand++) { 
437 443
			for (int col = 0; col < getHeight(); col++) {
438 444
				for (int row = 0; row < getWidth(); row++) {
439 445
					int pixelValue = -1;
440
					switch(this.getDataType()){
441
					case IBuffer.TYPE_BYTE: pixelValue = classes.getClassPosition((double)getElemByte(row, col, iBand)); break;
442
					case IBuffer.TYPE_SHORT: pixelValue = classes.getClassPosition((double)getElemShort(row, col, iBand)); break;
443
					case IBuffer.TYPE_INT: pixelValue = classes.getClassPosition((double)getElemInt(row, col, iBand)); break;
444
					case IBuffer.TYPE_FLOAT: pixelValue = classes.getClassPosition((double)getElemFloat(row, col, iBand)); break;
445
					case IBuffer.TYPE_DOUBLE: pixelValue = classes.getClassPosition((double)getElemDouble(row, col, iBand)); break;
446
					switch (this.getDataType()) {
447
						case IBuffer.TYPE_BYTE:
448
							pixelValue = classes.getClassPosition((double)getElemByte(row, col, iBand));
449
							break;
450
						case IBuffer.TYPE_SHORT:
451
							pixelValue = classes.getClassPosition((double)getElemShort(row, col, iBand));
452
							break;
453
						case IBuffer.TYPE_INT:
454
							pixelValue = classes.getClassPosition((double)getElemInt(row, col, iBand));
455
							break;
456
						case IBuffer.TYPE_FLOAT:
457
							pixelValue = classes.getClassPosition((double)getElemFloat(row, col, iBand));
458
							break;
459
						case IBuffer.TYPE_DOUBLE:
460
							pixelValue = classes.getClassPosition((double)getElemDouble(row, col, iBand));
461
							break;
446 462
					}		 
447
					if(pixelValue >= 0)
448
						hist.incrementPxValue(iBand, pixelValue);
449
				}		
463
					if (pixelValue >= 0) hist.incrementPxValue(iBand, pixelValue);
464
				}	
465
				if (isCanceled()) return null;
466
				percent = ((iBand * getHeight() + col) * 100) / (getBandCount() * getHeight());
450 467
			}
451 468
		}
469
		percent = 100;
452 470
		return hist;
453 471
	}
454 472

  
455 473
	/*
456 474
	 * (non-Javadoc)
457
	 * @see org.gvsig.raster.driver.datasetproperties.IHistogramable#getPercent()
475
	 * @see org.gvsig.raster.util.IHistogramable#resetPercent()
458 476
	 */
477
	public void resetPercent() {
478
		percent = 0;
479
	}
480

  
481
	/*
482
	 * (non-Javadoc)
483
	 * @see org.gvsig.raster.util.IHistogramable#getPercent()
484
	 */
459 485
	public int getPercent() {
460 486
		return percent;
461 487
	}
462 488

  
463
	public void resetPercent() {
464
	}
465

  
489
	/*
490
	 * (non-Javadoc)
491
	 * @see org.gvsig.raster.util.ICancellable#isCanceled()
492
	 */
466 493
	public boolean isCanceled() {
467
		return false;
494
		return canceled;
468 495
	}
469 496

  
497
	/*
498
	 * (non-Javadoc)
499
	 * @see org.gvsig.raster.util.ICancellable#setCanceled(boolean)
500
	 */
470 501
	public void setCanceled(boolean value) {
502
		canceled = value;
471 503
	}
472 504
}

Also available in: Unified diff