Revision 11366

View differences:

trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrVect.java
523 523
			return this.orgXMLEntity;
524 524
		}
525 525
		XMLEntity xml = super.getXMLEntity();
526
		xml.addChild(getLegend().getXMLEntity());
526
		if (getLegend()!=null)
527
			xml.addChild(getLegend().getXMLEntity());
527 528
		try {
528
			xml.addChild(getRecordset().getSelectionSupport().getXMLEntity());
529

  
529
			if (getRecordset()!=null)
530
				xml.addChild(getRecordset().getSelectionSupport().getXMLEntity());
530 531
		} catch (ReadDriverException e1) {
531 532
			e1.printStackTrace();
532 533
			throw new XMLException(e1);
533 534
		}
534 535
		// Repongo el mismo ReadableVectorial m?s abajo para cuando se guarda el proyecto.
535 536
		ReadableVectorial rv=getSource();
536
		if (getSource() instanceof VectorialEditableAdapter) {
537
		xml.putProperty("type", "vectorial");
538
		if (source instanceof VectorialEditableAdapter) {
537 539
			setSource(((VectorialEditableAdapter) source).getOriginalAdapter());
538 540
		}
539
		if (getSource() instanceof VectorialFileAdapter) {
541
		if (source instanceof VectorialFileAdapter) {
540 542
			xml.putProperty("type", "vectorial");
541
			xml.putProperty("file", ((VectorialFileAdapter) getSource())
543
			xml.putProperty("file", ((VectorialFileAdapter) source)
542 544
					.getFile());
543 545
			try {
544
				xml.putProperty("recordset-name", getSource().getRecordset()
546
				xml.putProperty("recordset-name", source.getRecordset()
545 547
						.getName());
546 548
			} catch (ReadDriverException e) {
547 549
				throw new XMLException(e);
550
			} catch (RuntimeException e) {
551
				e.printStackTrace();
548 552
			}
549 553
		} else if (source instanceof VectorialDBAdapter) {
550 554
			xml.putProperty("type", "vectorial");
551 555

  
552
			VectorialDatabaseDriver dbDriver = (VectorialDatabaseDriver) getSource()
556
			VectorialDatabaseDriver dbDriver = (VectorialDatabaseDriver) source
553 557
					.getDriver();
554 558

  
555 559
			// Guardamos el nombre del driver para poder recuperarlo
556 560
			// con el DriverManager de Fernando.
557 561
			xml.putProperty("db", dbDriver.getName());
558 562
			try {
559
				xml.putProperty("recordset-name", getSource().getRecordset()
563
				xml.putProperty("recordset-name", source.getRecordset()
560 564
						.getName());
561 565
			} catch (ReadDriverException e) {
562 566
				throw new XMLException(e);
567
			} catch (RuntimeException e) {
568
				e.printStackTrace();
563 569
			}
564 570
			xml.addChild(dbDriver.getXMLEntity()); // Tercer child. Antes hemos
565 571
													// metido la leyenda y el
......
568 574
			// Se supone que hemos hecho algo gen?rico.
569 575
			xml.putProperty("type", "vectorial");
570 576

  
571
			VectorialDriver driver = getSource().getDriver();
577
			VectorialDriver driver = source.getDriver();
572 578

  
573 579
			// Guardamos el nombre del driver para poder recuperarlo
574 580
			// con el DriverManager de Fernando.
575 581
			xml.putProperty("other", driver.getName());
576 582
			// try {
577 583
			try {
578
				xml.putProperty("recordset-name", getSource().getRecordset()
584
				xml.putProperty("recordset-name", source.getRecordset()
579 585
						.getName());
580 586
			} catch (ReadDriverException e) {
581 587
				throw new XMLException(e);
588
			} catch (RuntimeException e) {
589
				e.printStackTrace();
582 590
			}
583 591
			if (driver instanceof IPersistance) {
584 592
				// xml.putProperty("className", driver.getClass().getName());
......
589 597
														// selection support
590 598
			}
591 599
		}
592
		setSource(rv);
593
		xml.putProperty("driverName", getSource().getDriver().getName());
600
		if (rv!=null)
601
			setSource(rv);
602
		xml.putProperty("driverName", source.getDriver().getName());
594 603
		if (bHasJoin)
595 604
			xml.putProperty("hasJoin", "true");
596 605

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLayers.java
429 429

  
430 430
   			///// CHEMA ComposedLayer
431 431
		    long tg1 = System.currentTimeMillis();
432
   			///// CHEMA ComposedLayer
432
			///// CHEMA ComposedLayer
433 433

  
434 434

  
435 435

  
......
442 442
    			FLayer lyr = (FLayer) layers.get(i);
443 443

  
444 444

  
445

  
446

  
447
    		/*	if (lyr instanceof FLyrVect && ((FLyrVect)lyr).isBroken()){
445
       		/*	if (lyr instanceof FLyrVect && ((FLyrVect)lyr).isBroken()){
448 446
    				continue;
449 447
    			}
450 448
    		*/
451 449
    			LayerDrawEvent beforeEvent = new LayerDrawEvent(lyr, g, viewPort, LayerDrawEvent.LAYER_BEFORE_DRAW);
452 450
    			fmap.fireLayerDrawingEvent(beforeEvent);
453
    			if ((lyr.isDirty()) || (lyr.isCachingDrawnLayers() == false))
454
    				bNeedRecalculateCache = true;
451
        		if ((lyr.isDirty()) || (lyr.isCachingDrawnLayers() == false))
452
        			bNeedRecalculateCache = true;
455 453

  
456 454
    			if (lyr.isVisible()) {
457 455

  
......
480 478
    							//if (bNeedRecalculateCache)
481 479
    							// {
482 480

  
483
    							///// CHEMA ComposedLayer
481
       			        			///// CHEMA ComposedLayer
484 482
    							if (group != null) {
485 483
    								//si tenemos un grupo pendiente de pintar, pintamos
486 484
    								// para que la cache sea fiable
......
490 488
    							///// CHEMA ComposedLayer
491 489

  
492 490

  
493
    							// Copiamos la imagen actual
491
    			        		
492

  
493

  
494
	    			        			   							// Copiamos la imagen actual
494 495
    							BufferedImage buff = new BufferedImage(image.getWidth(), image.getHeight(), image.getType());
495 496
    							WritableRaster w = buff.getRaster();
496 497
    							image.copyData(w);
......
509 510
    							{
510 511

  
511 512

  
512
    								///// CHEMA ComposedLayer
513
   		   			        									///// CHEMA ComposedLayer
513 514
    								// Checks for draw group (ComposedLayer)
514 515
    								if (group != null) {
515 516
    									// it's going to load a cache image,
......
518 519
    								}
519 520
    								///// CHEMA ComposedLayer
520 521

  
521

  
522
    								g.drawImage(lyr.getCacheImageDrawnLayers(), 0, 0, null);
522
	g.drawImage(lyr.getCacheImageDrawnLayers(), 0, 0, null);
523 523
    								System.err.println("Pinto con acelerado lo que hab?a antes de " + lyr.getName());
524 524
    							}
525 525
    						}
......
624 624
    						+ (t2-t1) + " milisecs.");
625 625
    				lyr.setDirty(false);
626 626
    			}
627
    			
627 628
    		 }
628
    		 ///// CHEMA ComposedLayer
629
		 ///// CHEMA ComposedLayer
629 630
    		if (group != null && this.getParentLayer() == null) {
630 631
 				//si tenemos un grupo pendiente de pintar, pintamos
631 632
 				group.draw(image, g, viewPort, cancel,scale);
......
647 648

  
648 649
			System.out.println("Draw all layer " +this.getName() + " " +
649 650
			        + (tg2-tg1) + " milisecs.");
650
    		///// CHEMA ComposedLayer
651
			///// CHEMA ComposedLayer
651 652
    		return group;
652 653
    		///// CHEMA ComposedLayer
653

  
654 654
	}
655

  
656 655
	/**
657 656
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#print(java.awt.Graphics2D,
658 657
	 * 		com.iver.cit.gvsig.fmap.ViewPort,
......
802 801
		xml.putProperty("LayerNames", s);
803 802

  
804 803
		for (int i = 0; i < layers.size(); i++) {
805
			xml.addChild(((FLayer) layers.get(i)).getXMLEntity());
804
			try {
805
				xml.addChild(((FLayer) layers.get(i)).getXMLEntity());
806
			}catch (XMLException e) {
807
				e.printStackTrace();
808
			}
806 809
		}
807 810

  
808 811
		return xml;
......
1185 1188

  
1186 1189

  
1187 1190
		String className = xml.getStringProperty("className");
1188

  
1189
		if (className.equals(FLyrVect.class.getName())) {
1191
		//TODO VCN FLyrAnnotation es un parche para no tener que duplicar todo el c?digo de aq? y de los diferentes m?todos de LayerFactory,
1192
		//ya que los drivers de una FLyrAnnotation no sabemos cual es puede ser cualquier Driver Vectorial.
1193
		if (className.equals(FLyrVect.class.getName()) || className.equals(FLyrAnnotation.class.getName())) {
1190 1194
			String type = xml.getStringProperty("type");
1191 1195
			if ("vectorial".equals(type)){
1192 1196
				//String recordsetName = xml.getChild(i).getStringProperty("recordset-name");
......
1286 1290
                    layer = LayerFactory.createLayer(name, driver, proj);
1287 1291
                }
1288 1292

  
1293
			}
1289 1294

  
1290
			} else if ("raster".equals(type)) {
1291
/*						if (xml.getChild(i).contains("file")) {
1292
					Driver d = LayerFactory.getDM().getDriver(xml.getChild(i).getStringProperty("driverName"));
1293
											layer = LayerFactory.createLayer(s[i],
1294
													,
1295
													new File(xml.getChild(i).getStringProperty("file")),
1296
													this.getFMap().getViewPort().getProjection());
1295
			//TODO VCN FLyrAnnotation es un parche para no tener que duplicar todo el c?digo de aq? y de los diferentes m?todos de LayerFactory,
1296
			//ya que los drivers de una FLyrAnnotation no sabemos cual es puede ser cualquier Driver Vectorial.
1297
			if (className.equals(FLyrAnnotation.class.getName())){
1298
				layer=FLyrAnnotation.createLayerFromVect((FLyrVect)layer);
1299
			}
1297 1300

  
1298
				}
1299
*/					}
1300 1301

  
1301 1302
			layer.setXMLEntity(xml);
1302 1303

  
......
1392 1393
		} catch (IllegalAccessException e) {
1393 1394
			fmap.addLayerError(xml.getStringProperty("name"));
1394 1395
			throw new LoadLayerException(name,e);
1395
//			jaume
1396
//		} catch (ReadDriverException e) {
1397
//			fmap.addLayerError(xml.getStringProperty("name"));
1398
//			throw new LoadLayerException(name,e);
1396
		} catch (ReadDriverException e) {
1397
			fmap.addLayerError(xml.getStringProperty("name"));
1398
			throw new LoadLayerException(name,e);
1399 1399
		} catch (LoadLayerException e){
1400 1400
			fmap.addLayerError(xml.getStringProperty("name"));
1401 1401
			throw e;

Also available in: Unified diff