Revision 10666 branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/LayerFactory.java

View differences:

LayerFactory.java
118 118
	 * Crea un RandomVectorialFile con el driver que se le pasa como par?metro y
119 119
	 * guard?ndose el nombre del fichero para realizar los accesos, la capa
120 120
	 * tendr? asociada la proyecci?n que se pasa como parametro tambi?n
121
	 * 
121
	 *
122 122
	 * @param layerName Nombre de la capa. @param driverName Nombre del driver.
123 123
	 * @param f fichero. @param proj Proyecci?n.
124
	 * 
124
	 *
125 125
	 * @return FLayer. @throws DriverException
126
	 * 
126
	 *
127 127
	 * @throws DriverException @throws DriverIOException
128 128
	 */
129 129
	public static FLayer createLayer(String layerName, String driverName,
......
146 146
			//las excepciones de este metodo se dejan subir todas, puesto
147 147
			//que las excepciones de los dos otros metodos createLayer si que
148 148
			//se atrapan
149
			DriverNotLoadedExceptionType exceptionType = 
149
			DriverNotLoadedExceptionType exceptionType =
150 150
				new DriverNotLoadedExceptionType();
151 151
			exceptionType.setDriverName(driverName);
152
			DriverException exception = 
153
				new DriverException(e, exceptionType);		
152
			DriverException exception =
153
				new DriverException(e, exceptionType);
154 154
			throw exception;
155 155
		}
156 156

  
......
160 160
	/**
161 161
	 * It creates a FLayer (FLyrVect) which reads its data from a file driver,
162 162
	 * projected in the specified projection.
163
	 * 
163
	 *
164 164
	 * @param layerName
165 165
	 *            name of the layer
166 166
	 * @param d
......
169 169
	 *            file associated to the driver
170 170
	 * @param proj
171 171
	 *            layer projection
172
	 * 
172
	 *
173 173
	 * @return FLayer new vectorial layer
174
	 * 
174
	 *
175 175
	 * @throws DriverException
176 176
	 */
177 177
	public static FLayer createLayer(String layerName, VectorialFileDriver d,
178
			File f, IProjection proj) 
179
	
178
			File f, IProjection proj)
179

  
180 180
	/*throws DriverException*/ {
181 181

  
182 182
		// TODO Comprobar si hay un adaptador ya
......
206 206
				capa.setLegend(LegendFactory.createSingleSymbolLegend(capa
207 207
						.getShapeType()));
208 208
			}
209
			
209

  
210 210
		} catch (FieldNotFoundException e) {
211 211
			//this exception is caused in legend creation
212
			LegendDriverExceptionType excepType = 
213
				new LegendDriverExceptionType("Error al construir la leyenda"); 
212
			LegendDriverExceptionType excepType =
213
				new LegendDriverExceptionType("Error al construir la leyenda");
214 214
			//TODO Para hacer esto extensible tiene que usarse puntos
215 215
			//de extension, y comparar las clases de leyendas registradas
216
			VectorialLegend legend = (VectorialLegend) 
216
			VectorialLegend legend = (VectorialLegend)
217 217
				((WithDefaultLegend)d).getDefaultLegend();
218
			
218

  
219 219
			excepType.setLegendLabelField(legend.getLabelField());
220 220
			excepType.setLegendHeightField(legend.getLabelHeightField());
221 221
			excepType.setLegendRotationField(legend.getLabelRotationField());
222 222
			DriverException exception = new DriverException(e, excepType);
223 223
			capa.setAvailable(false);
224 224
			capa.addError(exception);
225
			
225

  
226 226
		} catch (DriverIOException e) {
227 227
			//this error is caused for file IO problems
228
			DriverIOExceptionType excepType = 
228
			DriverIOExceptionType excepType =
229 229
				new DriverIOExceptionType();
230 230
			excepType.setFile(f);
231 231
			DriverException exception = new DriverException(e, excepType);
232 232
			capa.setAvailable(false);
233 233
			capa.addError(exception);
234 234
		}
235
		
235

  
236 236
		/*
237 237
		 * catch(DriverException e){
238 238
		 * ESTO HAY QUE CAPTURARLO,DE FORMA QUE CREATELAYER NO LANCE NINGUNA
......
251 251
	/**
252 252
	 * Creates a new vectorial layer from a generic layer (by generic whe mean
253 253
	 * that we dont know a priory its origin: file, memory, jdbc database, etc.
254
	 * 
254
	 *
255 255
	 * @param layerName
256 256
	 * @param d
257 257
	 * @param proj
......
259 259
	 * @throws DriverException
260 260
	 */
261 261
	public static FLayer createLayer(String layerName, VectorialDriver d,
262
			IProjection proj) 
262
			IProjection proj)
263 263
	/*
264
	throws DriverException 
264
	throws DriverException
265 265
	*/{
266 266
		VectorialAdapter adapter = null;
267 267
		if (d instanceof VectorialFileDriver) {
......
296 296
			}
297 297
		} catch (FieldNotFoundException e) {
298 298
//			this exception is caused in legend creation
299
			LegendDriverExceptionType excepType = 
299
			LegendDriverExceptionType excepType =
300 300
				new LegendDriverExceptionType("error al construir la leyenda, campo no encontrado");
301 301

  
302 302
			//TODO Para hacer esto extensible tiene que usarse puntos
303 303
			//de extension, y comparar las clases de leyendas registradas
304
			VectorialLegend legend = (VectorialLegend) 
304
			VectorialLegend legend = (VectorialLegend)
305 305
				((WithDefaultLegend)d).getDefaultLegend();
306 306
			excepType.setDriverName(d.getName());
307 307
			excepType.setLegendLabelField(legend.getLabelField());
308 308
			excepType.setLegendHeightField(legend.getLabelHeightField());
309 309
			excepType.setLegendRotationField(legend.getLabelRotationField());
310
			
310

  
311 311
			DriverException exception = new DriverException(e, excepType);
312 312
			capa.setAvailable(false);
313 313
			capa.addError(exception);
314 314
		} catch (DriverIOException e) {
315 315
			//by design, start and stop calls to adapter could
316 316
			//cause this exception.
317
			
317

  
318 318
			//but JDBC implementations catchs all exceptions,
319
			//and rest of layers (WFSLayer, etc.) dont use LayerFactory	
319
			//and rest of layers (WFSLayer, etc.) dont use LayerFactory
320 320
			ExceptionDescription type = null;
321 321
			if (d instanceof VectorialFileDriver) {
322 322
				File f = ((VectorialFileDriver)adapter).getFile();
323
				type = 
324
					new DriverIOExceptionType(); 
323
				type =
324
					new DriverIOExceptionType();
325 325
				((DriverIOExceptionType)type).setFile(f);
326
				
326

  
327 327
			}else{
328 328
				type = new GenericDriverExceptionType();
329 329
			}
......
342 342

  
343 343
	/**
344 344
	 * Crea una capa Raster a partir del nombre driver, fichero y proyecci?n.
345
	 * 
345
	 *
346 346
	 * @param layerName
347 347
	 *            Nombre de la capa.
348 348
	 * @param d
......
351 351
	 *            Fichero.
352 352
	 * @param proj
353 353
	 *            Proyecci?n.
354
	 * 
354
	 *
355 355
	 * @return Nueva capa de tipo raster.
356
	 * 
356
	 *
357 357
	 * @throws DriverIOException
358 358
	 */
359 359
	public static FLyrRaster createLayer(String layerName, RasterDriver d,
......
384 384
	 * coordenadas de georeferenciaci?n. Esta funci?n es para georeferenciar
385 385
	 * capas raster. Para imagenes que no tienen georeferenciaci?n hay que
386 386
	 * asignarle una temporal, normalmente a partir de la vista activa.
387
	 * 
387
	 *
388 388
	 * @param layerName
389 389
	 *            Nombre de la capa.
390 390
	 * @param d
......
395 395
	 *            Proyecci?n.
396 396
	 * @param extent
397 397
	 *            Extent de la vista activa
398
	 * 
398
	 *
399 399
	 * @return Nueva capa de tipo raster.
400
	 * 
400
	 *
401 401
	 * @throws DriverIOException
402 402
	 */
403 403
	public static FLyrRaster createLayer(String layerName, RasterDriver d,
......
423 423

  
424 424
		return capa;
425 425
	}
426
	
426

  
427 427
	/**
428 428
	 * Creates a new raster layer in memory. To create this layer type we have to set a data
429 429
	 * buffer and a bounding box instead of a file. Don't use without CMS raster library that
......
431 431
	 * @param layerName Layer name
432 432
	 * @param d raster driver
433 433
	 * @param buf data buffer
434
	 * @param ext bounding box 
435
	 * @param proj projection 
434
	 * @param ext bounding box
435
	 * @param proj projection
436 436
	 * @return raster layer
437 437
	 * @throws DriverException
438 438
	 */
......
443 443

  
444 444
		FLyrRaster capa = new FLyrRaster();
445 445
		capa.setName(layerName);
446
		
446

  
447 447
		// TODO Meter esto dentro de la comprobaci?n de si hay memoria
448 448
		if (false) {
449 449
		} else {
......
504 504
	/**
505 505
	 * Crea un RandomVectorialWFS con el driver que se le pasa como par?metro y
506 506
	 * guard?ndose la URL del servidor que se pasa como par?metro
507
	 * 
507
	 *
508 508
	 * @param driver
509 509
	 * @param host
510 510
	 * @param port
......
513 513
	 * @param dbName
514 514
	 * @param tableName
515 515
	 * @param proj
516
	 * 
516
	 *
517 517
	 * @return Capa creada.
518
	 * 
518
	 *
519 519
	 * @throws UnsupportedOperationException
520 520
	 */
521 521
	public static FLayer createLayer(VectorialDatabaseDriver driver,
......
552 552
				// que implementan IDelayedDriver, el driver es responsable
553 553
				// de avisar cu?ndo est? listo
554 554
				capa.getFLayerStatus().setDriverLoaded(false);
555
				((IDelayedDriver) driver).addDriverEventListener(new DefaultDelayedDriverListener(capa)); 
555
				((IDelayedDriver) driver).addDriverEventListener(new DefaultDelayedDriverListener(capa));
556 556
			}
557 557
			// PARCHE: Llamamos a getXmlEntity del driver para que se rellenen
558 558
			// los valores de host, port, etc, necesarios para un posible reload
559 559
			driver.setXMLEntity(driver.getXMLEntity());
560 560

  
561 561
		} catch (FieldNotFoundException e) {
562
			LegendDriverExceptionType excepType = 
562
			LegendDriverExceptionType excepType =
563 563
				new LegendDriverExceptionType("Error al construir la leyenda, campo no encontrado");
564 564
			//TODO Para hacer esto extensible tiene que usarse puntos
565 565
			//de extension, y comparar las clases de leyendas registradas
566
			VectorialLegend legend = (VectorialLegend) 
566
			VectorialLegend legend = (VectorialLegend)
567 567
				((WithDefaultLegend)driver).getDefaultLegend();
568
			
568

  
569 569
			excepType.setLegendLabelField(legend.getLabelField());
570 570
			excepType.setLegendHeightField(legend.getLabelHeightField());
571 571
			excepType.setLegendRotationField(legend.getLabelRotationField());
......
575 575
			return capa;
576 576
			// throw new UnsupportedOperationException(e.getMessage());
577 577
		} catch (DriverException e) {
578
			DBDriverExceptionType excepType = 
578
			DBDriverExceptionType excepType =
579 579
				new DBDriverExceptionType();
580 580
			excepType.setDriverName(driver.getName());
581 581
			excepType.setTableName(driver.getTableName());
......
697 697
	/**
698 698
	 * Crea una FLyrComplexRaster que ataca al driver que se pasa como
699 699
	 * par?metro.
700
	 * 
700
	 *
701 701
	 * @param driver
702 702
	 * @param f
703 703
	 * @param proj
704
	 * 
704
	 *
705 705
	 * @throws IllegalArgumentException
706 706
	 *             Si se pasa un driver que no implementa
707 707
	 *             GeorreferencedRasterDriver o NotGeorreferencedRasterDriver
......
712 712

  
713 713
	/**
714 714
	 * Devuelve el DriverManager.
715
	 * 
715
	 *
716 716
	 * @return DriverManager.
717 717
	 */
718 718
	public static DriverManager getDM() {
......
723 723

  
724 724
	/**
725 725
	 * Devuelve el WriterManager.
726
	 * 
726
	 *
727 727
	 * @return WriterManager.
728 728
	 */
729 729
	public static WriterManager getWM() {
......
774 774

  
775 775
	/**
776 776
	 * sets drivers Directory
777
	 * 
777
	 *
778 778
	 * @param path
779 779
	 */
780 780
	public static void setDriversPath(String path) {
......
784 784

  
785 785
	/**
786 786
	 * sets writers Directory
787
	 * 
787
	 *
788 788
	 * @param path
789 789
	 */
790 790
	public static void setWritersPath(String path) {

Also available in: Unified diff