Revision 11363 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrAnnotation.java

View differences:

FLyrAnnotation.java
6 6
import java.awt.geom.Point2D;
7 7
import java.awt.geom.Rectangle2D;
8 8
import java.awt.image.BufferedImage;
9
import java.io.File;
10 9
import java.util.ArrayList;
10
import java.util.Iterator;
11 11

  
12 12
import javax.print.attribute.PrintRequestAttributeSet;
13 13

  
14 14
import org.cresques.cts.ICoordTrans;
15 15
import org.cresques.cts.IProjection;
16 16

  
17
import com.hardcode.driverManager.Driver;
18
import com.hardcode.driverManager.DriverLoadException;
19 17
import com.hardcode.gdbms.driver.exceptions.InitializeDriverException;
20 18
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
21 19
import com.hardcode.gdbms.engine.data.driver.DriverException;
......
39 37
import com.iver.cit.gvsig.fmap.crs.CRSFactory;
40 38
import com.iver.cit.gvsig.fmap.drivers.BoundedShapes;
41 39
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes;
42
import com.iver.cit.gvsig.fmap.drivers.VectorialDriver;
43 40
import com.iver.cit.gvsig.fmap.edition.AnnotationEditableAdapter;
44 41
import com.iver.cit.gvsig.fmap.operations.strategies.AnnotationStrategy;
45 42
import com.iver.cit.gvsig.fmap.operations.strategies.Strategy;
46 43
import com.iver.cit.gvsig.fmap.operations.strategies.StrategyManager;
44
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend;
47 45
import com.iver.cit.gvsig.fmap.rendering.VectorialUniqueValueLegend;
48 46
import com.iver.cit.gvsig.fmap.spatialindex.QuadtreeJts;
49 47
import com.iver.utiles.XMLEntity;
......
115 113
				try {
116 114
					g.setColor(Color.black);
117 115
					strategy.draw(image, g, viewPort, cancel);
118
					if (getISpatialIndex()==null) {
116
					if (getISpatialIndex()==null && !isEditing()) {
119 117
						createSpatialIndex();
120 118
					}
121 119
				} catch (ReadDriverException e) {
......
241 239
	 * @see com.iver.cit.gvsig.fmap.layers.FLyrDefault#setXMLEntity(com.iver.utiles.XMLEntity)
242 240
	 */
243 241
	public void setXMLEntity(XMLEntity xml) throws XMLException {
244
		mapping = MappingAnnotation.createFromXML(xml.getChild(2));//getIntArrayProperty("mapping");
242
		Iterator iter=xml.findChildren("className",MappingAnnotation.class.getName());
243
		if (iter.hasNext())
244
			mapping = MappingAnnotation.createFromXML((XMLEntity)iter.next());
245
		else{
246
			//Este else para versiones anteriores a la 1.0.2.(908)
247
			if (xml.getChildrenCount()==3)
248
				mapping = MappingAnnotation.createFromXML(xml.getChild(2));
249
			else
250
				mapping = MappingAnnotation.createFromXML(xml.getChild(3));
251
		}
245 252
		setInPixels(xml.getBooleanProperty("isInPixels"));
246 253

  
247 254
		IProjection proj = null;
......
250 257
			proj = CRSFactory.getCRS(xml.getStringProperty("proj"));
251 258
		}
252 259

  
253
		VectorialFileAdapter adapter = new VectorialFileAdapter(new File(xml
254
				.getStringProperty("file")));
255
		Driver d;
260
//		VectorialAdapter adapter=null;
261
//		if (xml.contains("file")){
262
//			adapter = new VectorialFileAdapter(new File(xml
263
//					.getStringProperty("file")));
264
//		}else if (xml.contains("db")){
265
//			adapter = new VectorialDBAdapter();
266
//		}
267
//		Driver d;
268
//
269
//		try {
270
//			d = LayerFactory.getDM().getDriver(
271
//					xml.getStringProperty("driverName"));
272
//		} catch (DriverLoadException e1) {
273
//			throw new XMLException(e1);
274
//		}
275
//
276
//		adapter.setDriver((VectorialDriver) d);
277
//		// TODO Meter esto dentro de la comprobaci?n de si hay memoria
278
//		if (false) {
279
//		} else {
280
//			setSource(adapter);
281
//			setProjection(proj);
282
//		}
256 283

  
257
		try {
258
			d = LayerFactory.getDM().getDriver(
259
					xml.getStringProperty("driverName"));
260
		} catch (DriverLoadException e1) {
261
			throw new XMLException(e1);
262
		}
263

  
264
		adapter.setDriver((VectorialDriver) d);
265
		// TODO Meter esto dentro de la comprobaci?n de si hay memoria
266
		if (false) {
267
		} else {
268
			setSource(adapter);
269
			setProjection(proj);
270
		}
271

  
272 284
		// Le asignamos tambi?n una legenda por defecto acorde con
273 285
		// el tipo de shape que tenga. Tampoco s? si es aqu? el
274 286
		// sitio adecuado, pero en fin....
......
561 573
	}
562 574
	public void setEditing(boolean b) throws StartEditionLayerException {
563 575
		super.setEditing(b);
564
		setISpatialIndex(null);
576
		deleteSpatialIndex();
565 577
	}
578

  
579
	public static FLayer createLayerFromVect(FLyrVect layer) throws ReadDriverException, LegendLayerException{
580
		FLyrAnnotation la=new FLyrAnnotation();
581
		la.setSource(layer.getSource());
582
		la.setRecordset(layer.getRecordset());
583
		la.setProjection(layer.getProjection());
584
		la.setLegend((VectorialLegend)layer.getLegend());
585
		return la;
586
	}
566 587
}

Also available in: Unified diff