Revision 11072 trunk/libraries/libRaster/src/org/gvsig/raster/dataaccess/cache/PageBuffer.java

View differences:

PageBuffer.java
426 426
				for (int row = 0; row < getWidth(); row++) 
427 427
					hist.incrementPxValue(iBand, getElemByte(row, col, iBand));
428 428
				if (isCanceled()) return null;
429
				percent = ((iBand * getHeight() + col) * 100) / (getBandCount() * getHeight());
429 430
			}
430 431
		percent = 100;
431 432
		return hist;
......
436 437
	 * @see org.gvsig.raster.driver.datasetproperties.IHistogramable#getHistogramUsingClasses(org.gvsig.raster.shared.DataClassList)
437 438
 	 */
438 439
	public Histogram getHistogramUsingClasses(DataClassList classes) throws HistogramException {
440
		percent = 0;
439 441
		Histogram hist = new Histogram(getBandCount(), classes.length());
440 442
		for (int iBand = 0; iBand < getBandCount(); iBand++) { 
441 443
			for (int col = 0; col < getHeight(); col++) {
442 444
				for (int row = 0; row < getWidth(); row++) {
443 445
					int pixelValue = -1;
444
					switch(this.getDataType()){
445
					case IBuffer.TYPE_BYTE: pixelValue = classes.getClassPosition((double)getElemByte(row, col, iBand)); break;
446
					case IBuffer.TYPE_SHORT: pixelValue = classes.getClassPosition((double)getElemShort(row, col, iBand)); break;
447
					case IBuffer.TYPE_INT: pixelValue = classes.getClassPosition((double)getElemInt(row, col, iBand)); break;
448
					case IBuffer.TYPE_FLOAT: pixelValue = classes.getClassPosition((double)getElemFloat(row, col, iBand)); break;
449
					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;
450 462
					}		 
451
					if(pixelValue >= 0)
452
						hist.incrementPxValue(iBand, pixelValue);
453
				}		
463
					if (pixelValue >= 0) hist.incrementPxValue(iBand, pixelValue);
464
				}	
465
				if (isCanceled()) return null;
466
				percent = ((iBand * getHeight() + col) * 100) / (getBandCount() * getHeight());
454 467
			}
455 468
		}
469
		percent = 100;
456 470
		return hist;
457 471
	}
458 472

  

Also available in: Unified diff