Revision 24551 trunk/extensions/extAnnotations/src/com/iver/cit/gvsig/project/documents/gui/Annotation_Open.java

View differences:

Annotation_Open.java
72 72
import com.iver.cit.gvsig.fmap.core.FShape;
73 73
import com.iver.cit.gvsig.fmap.drivers.VectorialDriver;
74 74
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver;
75
import com.iver.cit.gvsig.fmap.layers.Annotation_LayerFactory;
75 76
import com.iver.cit.gvsig.fmap.layers.Annotation_Layer;
76 77
import com.iver.cit.gvsig.fmap.layers.Annotation_Mapping;
77 78
import com.iver.cit.gvsig.fmap.layers.FLayer;
......
462 463
     * @return boolean flag to report sucess of the operation
463 464
     */
464 465
    private boolean loadFileAnnotationLayer(MapControl mapControl, File file) {
465
        if (file == null) {
466
            return false;
467
        }
466
    	try {
467
    		Annotation_Layer al = Annotation_LayerFactory.createLayer(file.getName(), file, AddLayerDialog.getLastProjection(), getCmbUnits().getSelectedUnitIndex());
468 468

  
469
        FLayer lyr = null;
470
        IProjection proj = AddLayerDialog.getLastProjection();
471
        String driverName = "gvSIG shp driver";
472
        Driver driver = null; // Driver[driverNames.length];
469
            // A?adir capas al mapControl se trata como una transaccion
470
            mapControl.getMapContext().beginAtomicEvent();
473 471

  
474
        try {
475
            driver = LayerFactory.getDM().getDriver(driverName);
476
        } catch (DriverLoadException e) {
477
        	PluginServices.getLogger().error(e.getMessage(),e);
478
        	return false;
479
        }
472
            if (al != null) {
473
                al.setVisible(true);
474
                AddLayer.checkProjection(al, mapControl.getViewPort());
475
                mapControl.getMapContext().getLayers().addLayer(al);
476
            } // if
480 477

  
481
        // A?adir capas al mapControl se trata como una transaccion
482
        mapControl.getMapContext().beginAtomicEvent();
483

  
484
        String layerName = file.getName();
485
        lyr = LayerFactory.createLayer(layerName, (VectorialFileDriver) driver,
486
                file, proj);
487

  
488
        Annotation_Layer al = new Annotation_Layer();
489
        LayerListener[] layerListeners = lyr.getLayerListeners();
490

  
491
        for (int i = 0; i < layerListeners.length; i++) {
492
            al.addLayerListener(layerListeners[i]);
493
        }
494
AttrInTableLabelingStrategy at;
495
        al.setSource(((FLyrVect) lyr).getSource());
496
        al.setProjection(lyr.getProjection());
497
        al.setName(layerName);
498

  
499
        try {
500
            Annotation_Mapping.addAnnotationMapping(al);
501
        } catch (Exception e) {
502
			PluginServices.getLogger().error(e.getMessage(),e);
503
        	return false;
504
		}
505
//        AttrInTableLabelingStrategy labeling = new AttrInTableLabelingStrategy();
506
        ((Annotation_Legend)al.getLegend()).setUnits(getCmbUnits().getSelectedUnitIndex());
507
//    	labeling.setUnit(getCmbUnits().getSelectedUnitIndex());
508
//    	al.setLabelingStrategy(labeling);
509
//        ((Annotation_Legend)al.getLegend()).setFontInPixels(getCmbInPixels()
510
//                                                                              .getSelectedItem()
511
//                                                                              .equals(PluginServices.getText(
512
//                    this, "pixels")));
513

  
514
        if (lyr != null) {
515
            al.setVisible(true);
516
            AddLayer.checkProjection(al, mapControl.getViewPort());
517
            mapControl.getMapContext().getLayers().addLayer(al);
518
        } // if
519

  
520
        mapControl.getMapContext().endAtomicEvent();
521

  
522
        return true;
478
            mapControl.getMapContext().endAtomicEvent();
479
            return true;
480
    	}
481
    	catch (Exception ex) {
482
    		PluginServices.getLogger().error("", ex);
483
    		return false;
484
    	}
523 485
    }
524 486
}

Also available in: Unified diff