Revision 2301 org.gvsig.raster.mosaic/trunk/org.gvsig.raster.mosaic/org.gvsig.raster.mosaic.io/src/main/java/org/gvsig/raster/mosaic/io/MosaicProvider.java

View differences:

MosaicProvider.java
127 127
	private HashMap<String, MosaicTileServer>
128 128
	                                         tileServerMap            = new HashMap<String, MosaicTileServer>();
129 129
	private ArrayList<RasterProvider>        selectedProviders        = new ArrayList<RasterProvider>();
130
	private boolean                          bandCountCalculated      = false;
130 131
    
131 132
	public static void register() {
132 133
		DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager();
......
238 239
		uri = getParameters().getURI();
239 240
		providerList = getParameters().getProviders();
240 241
		pixelSize = getParameters().getPixelSize();
241
		ColorInterpretation ci = null;
242
		if(getBandCount() == 4)
243
			ci = DataStoreColorInterpretation.createARGBInterpretation();
244
		if(getBandCount() == 3)
245
			ci = DataStoreColorInterpretation.createRGBInterpretation();
246
		if(getBandCount() == 1)
247
			ci = DataStoreColorInterpretation.createGrayInterpretation();
248 242
		
249
		setColorInterpretation(ci);
250
		
251 243
		//Se le pone banda de transparencia siempre
252 244
		if(providerList.get(0).getDataType()[0] == Buffer.TYPE_BYTE) {
253 245
			transparency = new DataStoreTransparency();
......
278 270
		
279 271
		((MosaicDataParametersImpl)getParameters()).resetParamsChanged();
280 272
	}
273

  
274
	public ColorInterpretation getColorInterpretation() {
275
		if(super.getColorInterpretation() == null) {
276
			ColorInterpretation ci = null;
277
			for (int i = 0; i < providerList.size(); i++) {
278
				RasterProvider prv = providerList.get(i);
279
				if(prv.getBandCount() == getBandCount() && prv.getColorInterpretation() != null) {
280
					ci = prv.getColorInterpretation().cloneColorInterpretation();
281
				}
282
			}
283

  
284
			if(ci == null) {
285
				if(getDataType()[0] == Buffer.TYPE_BYTE) {
286
					if(getBandCount() == 4)
287
						ci = DataStoreColorInterpretation.createARGBInterpretation();
288
					if(getBandCount() == 3)
289
						ci = DataStoreColorInterpretation.createRGBInterpretation();
290
					if(getBandCount() == 1)
291
						ci = DataStoreColorInterpretation.createPaletteInterpretation();
292
				} else {
293
					if(getBandCount() == 1)
294
						ci = DataStoreColorInterpretation.createGrayInterpretation();
295
					else 
296
						ci = DataStoreColorInterpretation.createDefaultInterpretation();
297
				}
298
			}
299

  
300
			setColorInterpretation(ci);
301
		}
302
		return super.getColorInterpretation();
303
	}
281 304
	
282 305
	/**
283 306
	 * Loads the specific provider
......
408 431
	 * @return 
409 432
	 */
410 433
	public int getBandCount() {
411
		if(providerList.get(0).getDataType()[0] == Buffer.TYPE_BYTE)
412
			return providerList.get(0).getBandCount() + 1;
413
		return providerList.get(0).getBandCount();
434
		if(!bandCountCalculated) {
435
			bandCount = providerList.get(0).getBandCount();
436
			for (int i = 1; i < providerList.size(); i++) {
437
				if(providerList.get(i).getBandCount() > bandCount)
438
					bandCount = providerList.get(i).getBandCount();
439
			}
440
		}
441
		return bandCount;
414 442
	}
415 443
	
416 444
	public String[] getURIByProvider() {
......
681 709
			q.setDrawableBands(bandList.getDrawableBands());
682 710
			DefaultRasterStore store = new DefaultRasterStore();
683 711
			store.setProvider(provider);
684
			Buffer buf;
712
			Buffer buf = null;
685 713
			try {
686 714
				buf = store.query(q);
687 715
				buf.setDataExtent(extIntersection.toRectangle2D());

Also available in: Unified diff