Revision 9634 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/LayerFactory.java
LayerFactory.java | ||
---|---|---|
120 | 120 |
* Crea un RandomVectorialFile con el driver que se le pasa como par?metro y |
121 | 121 |
* guard?ndose el nombre del fichero para realizar los accesos, la capa |
122 | 122 |
* tendr? asociada la proyecci?n que se pasa como parametro tambi?n |
123 |
*
|
|
123 |
* |
|
124 | 124 |
* @param layerName Nombre de la capa. @param driverName Nombre del driver. |
125 | 125 |
* @param f fichero. @param proj Proyecci?n. |
126 |
*
|
|
126 |
* |
|
127 | 127 |
* @return FLayer. @throws DriverException |
128 |
*
|
|
128 |
* |
|
129 | 129 |
* @throws DriverException @throws DriverIOException |
130 | 130 |
*/ |
131 | 131 |
public static FLayer createLayer(String layerName, String driverName, |
... | ... | |
148 | 148 |
//las excepciones de este metodo se dejan subir todas, puesto |
149 | 149 |
//que las excepciones de los dos otros metodos createLayer si que |
150 | 150 |
//se atrapan |
151 |
DriverNotLoadedExceptionType exceptionType =
|
|
151 |
DriverNotLoadedExceptionType exceptionType = |
|
152 | 152 |
new DriverNotLoadedExceptionType(); |
153 | 153 |
exceptionType.setDriverName(driverName); |
154 |
DriverException exception =
|
|
155 |
new DriverException(e, exceptionType);
|
|
154 |
DriverException exception = |
|
155 |
new DriverException(e, exceptionType); |
|
156 | 156 |
throw exception; |
157 | 157 |
} |
158 | 158 |
|
... | ... | |
162 | 162 |
/** |
163 | 163 |
* It creates a FLayer (FLyrVect) which reads its data from a file driver, |
164 | 164 |
* projected in the specified projection. |
165 |
*
|
|
165 |
* |
|
166 | 166 |
* @param layerName |
167 | 167 |
* name of the layer |
168 | 168 |
* @param d |
... | ... | |
171 | 171 |
* file associated to the driver |
172 | 172 |
* @param proj |
173 | 173 |
* layer projection |
174 |
*
|
|
174 |
* |
|
175 | 175 |
* @return FLayer new vectorial layer |
176 |
*
|
|
176 |
* |
|
177 | 177 |
* @throws DriverException |
178 | 178 |
*/ |
179 | 179 |
public static FLayer createLayer(String layerName, VectorialFileDriver d, |
180 |
File f, IProjection proj)
|
|
181 |
|
|
180 |
File f, IProjection proj) |
|
181 |
|
|
182 | 182 |
/*throws DriverException*/ { |
183 | 183 |
|
184 | 184 |
// TODO Comprobar si hay un adaptador ya |
... | ... | |
208 | 208 |
capa.setLegend(LegendFactory.createSingleSymbolLegend(capa |
209 | 209 |
.getShapeType())); |
210 | 210 |
} |
211 |
|
|
211 |
|
|
212 | 212 |
} catch (FieldNotFoundException e) { |
213 | 213 |
//this exception is caused in legend creation |
214 |
LegendDriverExceptionType excepType =
|
|
215 |
new LegendDriverExceptionType("Error al construir la leyenda");
|
|
214 |
LegendDriverExceptionType excepType = |
|
215 |
new LegendDriverExceptionType("Error al construir la leyenda"); |
|
216 | 216 |
//TODO Para hacer esto extensible tiene que usarse puntos |
217 | 217 |
//de extension, y comparar las clases de leyendas registradas |
218 |
VectorialLegend legend = (VectorialLegend)
|
|
218 |
VectorialLegend legend = (VectorialLegend) |
|
219 | 219 |
((WithDefaultLegend)d).getDefaultLegend(); |
220 |
|
|
220 |
|
|
221 | 221 |
excepType.setLegendLabelField(legend.getLabelField()); |
222 | 222 |
excepType.setLegendHeightField(legend.getLabelHeightField()); |
223 | 223 |
excepType.setLegendRotationField(legend.getLabelRotationField()); |
224 | 224 |
DriverException exception = new DriverException(e, excepType); |
225 | 225 |
capa.setAvailable(false); |
226 | 226 |
capa.addError(exception); |
227 |
|
|
227 |
|
|
228 | 228 |
} catch (DriverIOException e) { |
229 | 229 |
//this error is caused for file IO problems |
230 |
DriverIOExceptionType excepType =
|
|
230 |
DriverIOExceptionType excepType = |
|
231 | 231 |
new DriverIOExceptionType(); |
232 | 232 |
excepType.setFile(f); |
233 | 233 |
DriverException exception = new DriverException(e, excepType); |
234 | 234 |
capa.setAvailable(false); |
235 | 235 |
capa.addError(exception); |
236 | 236 |
} |
237 |
|
|
237 |
|
|
238 | 238 |
/* |
239 | 239 |
* catch(DriverException e){ |
240 | 240 |
* ESTO HAY QUE CAPTURARLO,DE FORMA QUE CREATELAYER NO LANCE NINGUNA |
... | ... | |
253 | 253 |
/** |
254 | 254 |
* Creates a new vectorial layer from a generic layer (by generic whe mean |
255 | 255 |
* that we dont know a priory its origin: file, memory, jdbc database, etc. |
256 |
*
|
|
256 |
* |
|
257 | 257 |
* @param layerName |
258 | 258 |
* @param d |
259 | 259 |
* @param proj |
... | ... | |
261 | 261 |
* @throws DriverException |
262 | 262 |
*/ |
263 | 263 |
public static FLayer createLayer(String layerName, VectorialDriver d, |
264 |
IProjection proj)
|
|
264 |
IProjection proj) |
|
265 | 265 |
/* |
266 |
throws DriverException
|
|
266 |
throws DriverException |
|
267 | 267 |
*/{ |
268 | 268 |
VectorialAdapter adapter = null; |
269 | 269 |
if (d instanceof VectorialFileDriver) { |
... | ... | |
298 | 298 |
} |
299 | 299 |
} catch (FieldNotFoundException e) { |
300 | 300 |
// this exception is caused in legend creation |
301 |
LegendDriverExceptionType excepType =
|
|
301 |
LegendDriverExceptionType excepType = |
|
302 | 302 |
new LegendDriverExceptionType("error al construir la leyenda, campo no encontrado"); |
303 | 303 |
|
304 | 304 |
//TODO Para hacer esto extensible tiene que usarse puntos |
305 | 305 |
//de extension, y comparar las clases de leyendas registradas |
306 |
VectorialLegend legend = (VectorialLegend)
|
|
306 |
VectorialLegend legend = (VectorialLegend) |
|
307 | 307 |
((WithDefaultLegend)d).getDefaultLegend(); |
308 | 308 |
excepType.setDriverName(d.getName()); |
309 | 309 |
excepType.setLegendLabelField(legend.getLabelField()); |
310 | 310 |
excepType.setLegendHeightField(legend.getLabelHeightField()); |
311 | 311 |
excepType.setLegendRotationField(legend.getLabelRotationField()); |
312 |
|
|
312 |
|
|
313 | 313 |
DriverException exception = new DriverException(e, excepType); |
314 | 314 |
capa.setAvailable(false); |
315 | 315 |
capa.addError(exception); |
316 | 316 |
} catch (DriverIOException e) { |
317 | 317 |
//by design, start and stop calls to adapter could |
318 | 318 |
//cause this exception. |
319 |
|
|
319 |
|
|
320 | 320 |
//but JDBC implementations catchs all exceptions, |
321 |
//and rest of layers (WFSLayer, etc.) dont use LayerFactory
|
|
321 |
//and rest of layers (WFSLayer, etc.) dont use LayerFactory |
|
322 | 322 |
ExceptionDescription type = null; |
323 | 323 |
if (d instanceof VectorialFileDriver) { |
324 | 324 |
File f = ((VectorialFileDriver)adapter).getFile(); |
325 |
type =
|
|
326 |
new DriverIOExceptionType();
|
|
325 |
type = |
|
326 |
new DriverIOExceptionType(); |
|
327 | 327 |
((DriverIOExceptionType)type).setFile(f); |
328 |
|
|
328 |
|
|
329 | 329 |
}else{ |
330 | 330 |
type = new GenericDriverExceptionType(); |
331 | 331 |
} |
... | ... | |
344 | 344 |
|
345 | 345 |
/** |
346 | 346 |
* Crea una capa Raster a partir del nombre driver, fichero y proyecci?n. |
347 |
*
|
|
347 |
* |
|
348 | 348 |
* @param layerName |
349 | 349 |
* Nombre de la capa. |
350 | 350 |
* @param d |
... | ... | |
353 | 353 |
* Fichero. |
354 | 354 |
* @param proj |
355 | 355 |
* Proyecci?n. |
356 |
*
|
|
356 |
* |
|
357 | 357 |
* @return Nueva capa de tipo raster. |
358 |
*
|
|
358 |
* |
|
359 | 359 |
* @throws DriverIOException |
360 | 360 |
*/ |
361 | 361 |
public static FLyrRaster createLayer(String layerName, RasterDriver d, |
... | ... | |
386 | 386 |
* coordenadas de georeferenciaci?n. Esta funci?n es para georeferenciar |
387 | 387 |
* capas raster. Para imagenes que no tienen georeferenciaci?n hay que |
388 | 388 |
* asignarle una temporal, normalmente a partir de la vista activa. |
389 |
*
|
|
389 |
* |
|
390 | 390 |
* @param layerName |
391 | 391 |
* Nombre de la capa. |
392 | 392 |
* @param d |
... | ... | |
397 | 397 |
* Proyecci?n. |
398 | 398 |
* @param extent |
399 | 399 |
* Extent de la vista activa |
400 |
*
|
|
400 |
* |
|
401 | 401 |
* @return Nueva capa de tipo raster. |
402 |
*
|
|
402 |
* |
|
403 | 403 |
* @throws DriverIOException |
404 | 404 |
*/ |
405 | 405 |
public static FLyrRaster createLayer(String layerName, RasterDriver d, |
... | ... | |
469 | 469 |
/** |
470 | 470 |
* Crea un RandomVectorialWFS con el driver que se le pasa como par?metro y |
471 | 471 |
* guard?ndose la URL del servidor que se pasa como par?metro |
472 |
*
|
|
472 |
* |
|
473 | 473 |
* @param driver |
474 | 474 |
* @param host |
475 | 475 |
* @param port |
... | ... | |
478 | 478 |
* @param dbName |
479 | 479 |
* @param tableName |
480 | 480 |
* @param proj |
481 |
*
|
|
481 |
* |
|
482 | 482 |
* @return Capa creada. |
483 |
*
|
|
483 |
* |
|
484 | 484 |
* @throws UnsupportedOperationException |
485 | 485 |
*/ |
486 | 486 |
public static FLayer createLayer(VectorialDatabaseDriver driver, |
... | ... | |
511 | 511 |
.getShapeType())); |
512 | 512 |
} |
513 | 513 |
} catch (FieldNotFoundException e) { |
514 |
LegendDriverExceptionType excepType =
|
|
514 |
LegendDriverExceptionType excepType = |
|
515 | 515 |
new LegendDriverExceptionType("Error al construir la leyenda, campo no encontrado"); |
516 | 516 |
//TODO Para hacer esto extensible tiene que usarse puntos |
517 | 517 |
//de extension, y comparar las clases de leyendas registradas |
518 |
VectorialLegend legend = (VectorialLegend)
|
|
518 |
VectorialLegend legend = (VectorialLegend) |
|
519 | 519 |
((WithDefaultLegend)driver).getDefaultLegend(); |
520 |
|
|
520 |
|
|
521 | 521 |
excepType.setLegendLabelField(legend.getLabelField()); |
522 | 522 |
excepType.setLegendHeightField(legend.getLabelHeightField()); |
523 | 523 |
excepType.setLegendRotationField(legend.getLabelRotationField()); |
... | ... | |
527 | 527 |
return capa; |
528 | 528 |
// throw new UnsupportedOperationException(e.getMessage()); |
529 | 529 |
} catch (DriverException e) { |
530 |
DBDriverExceptionType excepType =
|
|
530 |
DBDriverExceptionType excepType = |
|
531 | 531 |
new DBDriverExceptionType(); |
532 | 532 |
excepType.setDriverName(driver.getName()); |
533 | 533 |
excepType.setTableName(driver.getTableName()); |
... | ... | |
649 | 649 |
/** |
650 | 650 |
* Crea una FLyrComplexRaster que ataca al driver que se pasa como |
651 | 651 |
* par?metro. |
652 |
*
|
|
652 |
* |
|
653 | 653 |
* @param driver |
654 | 654 |
* @param f |
655 | 655 |
* @param proj |
656 |
*
|
|
656 |
* |
|
657 | 657 |
* @throws IllegalArgumentException |
658 | 658 |
* Si se pasa un driver que no implementa |
659 | 659 |
* GeorreferencedRasterDriver o NotGeorreferencedRasterDriver |
... | ... | |
664 | 664 |
|
665 | 665 |
/** |
666 | 666 |
* Devuelve el DriverManager. |
667 |
*
|
|
667 |
* |
|
668 | 668 |
* @return DriverManager. |
669 | 669 |
*/ |
670 | 670 |
public static DriverManager getDM() { |
... | ... | |
675 | 675 |
|
676 | 676 |
/** |
677 | 677 |
* Devuelve el WriterManager. |
678 |
*
|
|
678 |
* |
|
679 | 679 |
* @return WriterManager. |
680 | 680 |
*/ |
681 | 681 |
public static WriterManager getWM() { |
... | ... | |
726 | 726 |
|
727 | 727 |
/** |
728 | 728 |
* sets drivers Directory |
729 |
*
|
|
729 |
* |
|
730 | 730 |
* @param path |
731 | 731 |
*/ |
732 | 732 |
public static void setDriversPath(String path) { |
... | ... | |
736 | 736 |
|
737 | 737 |
/** |
738 | 738 |
* sets writers Directory |
739 |
*
|
|
739 |
* |
|
740 | 740 |
* @param path |
741 | 741 |
*/ |
742 | 742 |
public static void setWritersPath(String path) { |
... | ... | |
753 | 753 |
} |
754 | 754 |
return dataSourceFactory; |
755 | 755 |
} |
756 |
|
|
757 |
public static void initialize() { |
|
758 |
initializeDriverManager(); |
|
759 |
initializeWriterManager(); |
|
760 |
} |
|
756 | 761 |
} |
Also available in: Unified diff