Revision 38206 branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/layers/vectorial/impl/DefaultGraphicLayer.java

View differences:

DefaultGraphicLayer.java
26 26
*/
27 27
package org.gvsig.fmap.mapcontext.layers.vectorial.impl;
28 28

  
29
import java.awt.geom.Point2D;
29 30
import java.util.Iterator;
30 31

  
32
import org.cresques.cts.ICoordTrans;
31 33
import org.cresques.cts.IProjection;
32
import org.slf4j.Logger;
33
import org.slf4j.LoggerFactory;
34

  
35 34
import org.gvsig.fmap.dal.DALLocator;
36 35
import org.gvsig.fmap.dal.DataManager;
37 36
import org.gvsig.fmap.dal.DataTypes;
38 37
import org.gvsig.fmap.dal.exception.DataException;
38
import org.gvsig.fmap.dal.exception.ReadException;
39 39
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
40 40
import org.gvsig.fmap.dal.feature.EditableFeature;
41 41
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
......
43 43
import org.gvsig.fmap.dal.feature.Feature;
44 44
import org.gvsig.fmap.dal.feature.FeatureSet;
45 45
import org.gvsig.fmap.dal.feature.FeatureStore;
46
import org.gvsig.fmap.dal.feature.FeatureType;
46 47
import org.gvsig.fmap.geom.Geometry;
47 48
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
48 49
import org.gvsig.fmap.geom.Geometry.TYPES;
50
import org.gvsig.fmap.geom.GeometryLocator;
51
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
52
import org.gvsig.fmap.geom.primitive.Envelope;
49 53
import org.gvsig.fmap.mapcontext.exceptions.LegendLayerException;
50 54
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
55
import org.gvsig.fmap.mapcontext.exceptions.ReprojectLayerException;
51 56
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
52 57
import org.gvsig.fmap.mapcontext.layers.vectorial.GraphicLayer;
53 58
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend;
......
55 60
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
56 61
import org.gvsig.tools.dispose.DisposableIterator;
57 62
import org.gvsig.tools.exception.BaseException;
63
import org.slf4j.Logger;
64
import org.slf4j.LoggerFactory;
58 65

  
59 66
/**
60 67
 * Default {@link GraphicLayer} implementation. 
......
70 77
	private long ids = 0;
71 78

  
72 79
	private int symbolId = -1;
80
	
81
	private int featureIdIndex;
82
	private int groupIdIndex;
83
	private int geomIndex;
84
	private int idsymIndex;
85
	private int labelIndex;
86
	private int tagIndex;
87
	private int priorityIndex;
73 88

  
74 89
	public DefaultGraphicLayer() {
75 90
		super();	
......
104 119

  
105 120
		store.update(editableFeatureType);	
106 121

  
107
		store.finishEditing();		
122
		store.finishEditing();
123
		
124
		FeatureType ftype = store.getDefaultFeatureType();
125
		featureIdIndex = ftype.getIndex(GraphicLayer.FEATURE_ATTR_FEATUREID);
126
		groupIdIndex = ftype.getIndex(GraphicLayer.FEATURE_ATTR_GROUPID);
127
		geomIndex = ftype.getIndex(GraphicLayer.FEATURE_ATTR_GEOMETRY);
128
		idsymIndex = ftype.getIndex(GraphicLayer.FEATURE_ATTR_IDSYMBOL);
129
		labelIndex = ftype.getIndex(GraphicLayer.FEATURE_ATTR_LABEL);
130
		tagIndex = ftype.getIndex(GraphicLayer.FEATURE_ATTR_TAG);
131
		priorityIndex = ftype.getIndex(GraphicLayer.FEATURE_ATTR_PRIORITY);
108 132

  
109 133
		this.setDataStore(store);
134
		
135
		setName("Graphic Layer");
110 136
	}
111 137

  
112 138
	public void addGraphic(String groupId, Geometry geom, int idsym) {
......
142 168
    private void insertGeometry(String groupId, Geometry geom, int idsym,
143 169
        String label, Object tag, int priority) throws DataException {
144 170
        EditableFeature feature = store.createNewFeature().getEditable();
145
        feature.setString(GraphicLayer.FEATURE_ATTR_GROUPID, groupId);
146
        feature.setGeometry(GraphicLayer.FEATURE_ATTR_GEOMETRY, geom);
147
        feature.setInt(GraphicLayer.FEATURE_ATTR_IDSYMBOL, idsym);	
148
        feature.setString(GraphicLayer.FEATURE_ATTR_LABEL, label);	
149
        feature.setLong(GraphicLayer.FEATURE_ATTR_FEATUREID, ids);
150
        feature.set(GraphicLayer.FEATURE_ATTR_TAG, tag);
151
        feature.setInt(GraphicLayer.FEATURE_ATTR_PRIORITY, priority);
171
        feature.setString(groupIdIndex, groupId);
172
        feature.setGeometry(geomIndex, geom);
173
        feature.setInt(idsymIndex, idsym);	
174
        feature.setString(labelIndex, label);	
175
        feature.setLong(featureIdIndex, ids);
176
        feature.set(tagIndex, tag);
177
        feature.setInt(priorityIndex, priority);
152 178

  
153 179
        ids++;
154 180

  
......
273 299
			logger.warn("The legend for the graphics layer must be a instance of IVectorialUniqueValueLegend");
274 300
		}
275 301
	}
302
	
303
    public Envelope getFullEnvelope() throws ReadException {
304
    	// Change parent implementation which creates an envelop by default
305
        Envelope rAux;
306
        try {
307
            rAux = getFeatureStore().getEnvelope();
308
        } catch (BaseException e) {
309
            throw new ReadException(getName(), e);
310
        }
311

  
312
        if (rAux == null) {
313
        	return null;
314
        }
315
        
316
        ICoordTrans ct = getCoordTrans();
317
        if (ct != null) {
318
        	rAux = rAux.convert(ct);
319
        }
320
        return rAux;
321
    }
276 322
}

Also available in: Unified diff