Revision 27398

View differences:

branches/v2_0_0_prep/extensions/extEditing/src/com/iver/cit/gvsig/gui/cad/DefaultCADTool.java
65 65
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
66 66
import org.gvsig.fmap.geom.Geometry.TYPES;
67 67
import org.gvsig.fmap.geom.aggregate.MultiPrimitive;
68
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
68 69
import org.gvsig.fmap.geom.handler.Handler;
69 70
import org.gvsig.fmap.geom.operation.Draw;
70 71
import org.gvsig.fmap.geom.operation.DrawOperationContext;
......
130 131

  
131 132
	public void addTemporalCache(Geometry geom) {
132 133
		temporalCache.add(geom);
133
		insertSpatialCache(geom);
134
		try {
135
			insertSpatialCache(geom);
136
		} catch (CreateEnvelopeException e) {
137
			logger.error("Error adding the spatial cache", e);
138
		}
134 139
	}
135 140

  
136 141
	public void clearTemporalCache() {
137 142
		Geometry[] geoms = (Geometry[]) temporalCache.toArray(new Geometry[0]);
138 143
		for (int i = 0; i < geoms.length; i++) {
139
			removeSpatialCache(geoms[i]);
144
			try {
145
				removeSpatialCache(geoms[i]);
146
			} catch (CreateEnvelopeException e) {
147
				logger.error("Error removing the temporal cache", e);
148
			}
140 149
		}
141 150
		temporalCache.clear();
142 151
	}
143 152

  
144
	private void insertSpatialCache(Geometry geom) {
153
	private void insertSpatialCache(Geometry geom) throws CreateEnvelopeException {
145 154
		VectorialLayerEdited vle = getVLE();
146 155
		SpatialCache spatialCache = ((FLyrVect) vle.getLayer())
147 156
				.getSpatialCache();
148 157
		Envelope r = geom.getEnvelope();
149 158
		if (geom.getType() == Geometry.TYPES.POINT) {
150
			r = UtilFunctions.createEnvelope(r.getMinimum(0), r.getMinimum(1), r
151
					.getMinimum(0) + 1, r.getMinimum(1) + 1);// Rectangle2D.Double(r.getX(),r.getY(),1,1);
159
			r = geomManager.createEnvelope(r.getMinimum(0), r.getMinimum(1), r
160
					.getMinimum(0) + 1, r.getMinimum(1) + 1, SUBTYPES.GEOM2D);// Rectangle2D.Double(r.getX(),r.getY(),1,1);
152 161
		}
153 162
		spatialCache.insert(r, geom);
154 163

  
155 164
	}
156 165

  
157
	private void removeSpatialCache(Geometry geom) {
166
	private void removeSpatialCache(Geometry geom) throws CreateEnvelopeException {
158 167
		VectorialLayerEdited vle = getVLE();
159 168
		SpatialCache spatialCache = ((FLyrVect) vle.getLayer())
160 169
				.getSpatialCache();
161 170
		Envelope r = geom.getEnvelope();
162 171
		if (geom.getType() == Geometry.TYPES.POINT) {
163
			r = UtilFunctions.createEnvelope(r.getMinimum(0), r.getMinimum(1), r
164
					.getMinimum(0) + 1, r.getMinimum(1) + 1);// Rectangle2D.Double(r.getX(),r.getY(),1,1);
172
			r = geomManager.createEnvelope(r.getMinimum(0), r.getMinimum(1), r
173
					.getMinimum(0) + 1, r.getMinimum(1) + 1, SUBTYPES.GEOM2D);// Rectangle2D.Double(r.getX(),r.getY(),1,1);
165 174
		}
166 175
		spatialCache.remove(r, geom);
167 176

  
......
241 250
			e.printStackTrace();
242 251
		} catch (GeometryOperationException e) {
243 252
			e.printStackTrace();
244
		} catch (InstantiationException e) {
253
		} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
245 254
			e.printStackTrace();
246
		} catch (IllegalAccessException e) {
247
			e.printStackTrace();
248
		}
255
		} 
249 256
		// draw(g,
250 257
		// getCadToolAdapter().getMapControl().getViewPort(),
251 258
		// symbol);
......
279 286
		} catch (DataException e) {
280 287
			NotificationManager.addError(e.getMessage(), e);
281 288
			return null;
289
		} catch (CreateEnvelopeException e) {
290
			NotificationManager.addError(e.getMessage(), e);
291
			return null;
282 292
		}
283 293
	}
284 294
	public Feature insertAndSelectGeometry(Geometry geometry){
......
321 331
		} catch (DataException e) {
322 332
			NotificationManager.addError(e.getMessage(), e);
323 333
			return null;
334
		} catch (CreateEnvelopeException e) {
335
			NotificationManager.addError(e.getMessage(), e);
336
			return null;
324 337
		}
325 338

  
326 339
	}
......
354 367
//		vle.drawHandlers(geometry.cloneGeometry(), gh, vp);
355 368
//		vle.setHandlersImage(handlersImage);
356 369
//		vle.setSelectionImage(selectionImage);
357
		insertSpatialCache(geometry);
370
		try {
371
			insertSpatialCache(geometry);
372
		} catch (CreateEnvelopeException e) {
373
			logger.error("Error creating the envelope", e);
374
		}
358 375

  
359 376
	}
360 377

  
......
631 648
		try {
632 649
			curve = (Curve)geomManager.create(TYPES.CURVE, SUBTYPES.GEOM2D);
633 650
			curve.setGeneralPath(gpx);
634
		} catch (InstantiationException e) {
651
		} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
635 652
			logger.error(new CreateGeometryException(TYPES.CURVE, SUBTYPES.GEOM2D, e));
636
		} catch (IllegalAccessException e) {
637
			logger.error(new CreateGeometryException(TYPES.CURVE, SUBTYPES.GEOM2D, e));
638 653
		}
639 654
		return curve;
640 655
	}
......
653 668
		try {
654 669
			surface = (Surface)geomManager.create(TYPES.SURFACE, SUBTYPES.GEOM2D);
655 670
			surface.setGeneralPath(gpx);
656
		} catch (InstantiationException e) {
671
		} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
657 672
			logger.error(new CreateGeometryException(TYPES.SURFACE, SUBTYPES.GEOM2D, e));
658
		} catch (IllegalAccessException e) {
659
			logger.error(new CreateGeometryException(TYPES.SURFACE, SUBTYPES.GEOM2D, e));
660 673
		}
661 674
		return surface;
662 675
	}
......
691 704
			point = (Point)geomManager.create(TYPES.POINT, SUBTYPES.GEOM2D);
692 705
			point.setX(x);
693 706
			point.setY(y);
694
		} catch (InstantiationException e) {
707
		} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
695 708
			logger.error(new CreateGeometryException(TYPES.POINT, SUBTYPES.GEOM2D, e));
696
		} catch (IllegalAccessException e) {
697
			logger.error(new CreateGeometryException(TYPES.POINT, SUBTYPES.GEOM2D, e));
698
		}
709
		} 
699 710
		return point;
700 711
	}
701 712

  
......
728 739
		try {
729 740
			arc = (Arc)geomManager.create(TYPES.ARC, SUBTYPES.GEOM2D);
730 741
			arc.setPoints(p1, p2, p3);
731
		} catch (InstantiationException e) {
742
	    } catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
732 743
			logger.error(new CreateGeometryException(TYPES.ARC, SUBTYPES.GEOM2D, e));
733
		} catch (IllegalAccessException e) {
734
			logger.error(new CreateGeometryException(TYPES.ARC, SUBTYPES.GEOM2D, e));
735
		}
736
		return arc;
744
		} 
745
	    return arc;
737 746
	}
738 747

  
739 748
	/**
......
751 760
		try {
752 761
			circle = (Circle)geomManager.create(TYPES.CIRCLE, SUBTYPES.GEOM2D);
753 762
			circle.setPoints(p1, p2, p3);
754
		} catch (InstantiationException e) {
763
		} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
755 764
			logger.error(new CreateGeometryException(TYPES.CIRCLE, SUBTYPES.GEOM2D, e));
756
		} catch (IllegalAccessException e) {
757
			logger.error(new CreateGeometryException(TYPES.CIRCLE, SUBTYPES.GEOM2D, e));
758
		}
765
		} 
759 766
		return circle;
760 767
	}
761 768

  
......
786 793
		try {
787 794
			circle = (Circle)geomManager.create(TYPES.CIRCLE, SUBTYPES.GEOM2D);
788 795
			circle.setPoints(p1, p2);
789
		} catch (InstantiationException e) {
796
		} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
790 797
			logger.error(new CreateGeometryException(TYPES.CIRCLE, SUBTYPES.GEOM2D, e));
791
		} catch (IllegalAccessException e) {
792
			logger.error(new CreateGeometryException(TYPES.CIRCLE, SUBTYPES.GEOM2D, e));
793
		}
798
		} 
794 799
		return circle;
795 800
	}
796 801

  
......
821 826
		try {
822 827
			circle = (Circle)geomManager.create(TYPES.CIRCLE, SUBTYPES.GEOM2D);
823 828
			circle.setPoints(p1, radious);
824
		} catch (InstantiationException e) {
829
		} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
825 830
			logger.error(new CreateGeometryException(TYPES.CIRCLE, SUBTYPES.GEOM2D, e));
826
		} catch (IllegalAccessException e) {
827
			logger.error(new CreateGeometryException(TYPES.CIRCLE, SUBTYPES.GEOM2D, e));
828 831
		}
829 832
		return circle;
830 833
	}
......
858 861
		try {
859 862
			ellipse = (Ellipse)geomManager.create(TYPES.ELLIPSE, SUBTYPES.GEOM2D);
860 863
			ellipse.setPoints(p1, p2, d);
861
		} catch (InstantiationException e) {
864
		} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
862 865
			logger.error(new CreateGeometryException(TYPES.ELLIPSE, SUBTYPES.GEOM2D, e));
863
		} catch (IllegalAccessException e) {
864
			logger.error(new CreateGeometryException(TYPES.ELLIPSE, SUBTYPES.GEOM2D, e));
865
		}
866
		} 
866 867
		return ellipse;
867 868
	}
868 869

  
......
881 882
			for (int i=0 ; i<points.length ; i++){
882 883
				spline.addVertex(createPoint(points[i]));
883 884
			}
884
		} catch (InstantiationException e) {
885
		} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
885 886
			logger.error(new CreateGeometryException(TYPES.SPLINE, SUBTYPES.GEOM2D, e));
886
		} catch (IllegalAccessException e) {
887
			logger.error(new CreateGeometryException(TYPES.SPLINE, SUBTYPES.GEOM2D, e));
888 887
		}
889 888
		return spline;
890 889
	}
......
903 902
			for (int i=0 ; i<geometries.length ; i++){
904 903
				multiPrimitive.addPrimitive((Primitive)geometries[i]);
905 904
			}
906
		} catch (InstantiationException e) {
905
		} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
907 906
			logger.error(new CreateGeometryException(TYPES.SPLINE, SUBTYPES.GEOM2D, e));
908
		} catch (IllegalAccessException e) {
909
			logger.error(new CreateGeometryException(TYPES.SPLINE, SUBTYPES.GEOM2D, e));
910 907
		}
911 908
		return multiPrimitive;
912 909
	}
branches/v2_0_0_prep/extensions/extEditing/src/com/iver/cit/gvsig/gui/cad/tools/MultiPointCADTool.java
167 167
			e.printStackTrace();
168 168
		} catch (GeometryOperationException e) {
169 169
			e.printStackTrace();
170
		} catch (InstantiationException e) {
170
		} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
171 171
			logger.error(new CreateGeometryException(TYPES.MULTIPOINT, SUBTYPES.GEOM2D, e));
172
			e.printStackTrace();
173
		} catch (IllegalAccessException e) {
174
			logger.error(new CreateGeometryException(TYPES.MULTIPOINT, SUBTYPES.GEOM2D, e));
175
			e.printStackTrace();
176 172
		}
177 173

  
178 174
		//		geomFactory.createMultipoint2D(xs,ys).draw((Graphics2D) g,
......
233 229
				multiPoint.addPoint(pointsAux[i]);
234 230
			}
235 231
			insertAndSelectGeometry(multiPoint);
236
		} catch (InstantiationException e) {
232
		} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
237 233
			logger.error(new CreateGeometryException(TYPES.MULTIPOINT, SUBTYPES.GEOM2D, e));
238
		} catch (IllegalAccessException e) {
239
			logger.error(new CreateGeometryException(TYPES.MULTIPOINT, SUBTYPES.GEOM2D, e));
240 234
		}
241 235
		end();
242 236
	}
branches/v2_0_0_prep/extensions/extEditing/src/com/iver/cit/gvsig/layers/VectorialLayerEdited.java
20 20
import org.gvsig.fmap.geom.GeometryManager;
21 21
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
22 22
import org.gvsig.fmap.geom.Geometry.TYPES;
23
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
24
import org.gvsig.fmap.geom.exception.CreateGeometryException;
23 25
import org.gvsig.fmap.geom.handler.Handler;
24 26
import org.gvsig.fmap.geom.operation.Draw;
25 27
import org.gvsig.fmap.geom.operation.DrawOperationContext;
......
48 50
import org.gvsig.tools.evaluator.Evaluator;
49 51
import org.gvsig.tools.observer.Observable;
50 52
import org.gvsig.tools.observer.Observer;
53
import org.slf4j.Logger;
54
import org.slf4j.LoggerFactory;
51 55

  
52 56
import com.iver.andami.PluginServices;
53 57
import com.iver.andami.messages.NotificationManager;
......
63 67

  
64 68
public class VectorialLayerEdited extends DefaultLayerEdited implements
65 69
		LayerDrawingListener, Observer {
70
	private static final GeometryManager geomManager = GeometryLocator.getGeometryManager();
71
	private static final Logger logger = LoggerFactory.getLogger(VectorialLayerEdited.class);
66 72
	private ArrayList selectedHandler = new ArrayList();
67 73
	private Point2D lastPoint;
68 74
	private Point2D firstPoint;
......
109 115
			Point center = (org.gvsig.fmap.geom.primitive.Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D);
110 116
			center.setX(x);
111 117
			center.setY(y);
112
			Circle circle = (Circle)manager.create(TYPES.CIRCLE, SUBTYPES.GEOM2D);
118
			Circle circle = (Circle)geomManager.create(TYPES.CIRCLE, SUBTYPES.GEOM2D);
113 119
			circle.setPoints(center, tol);
114 120

  
115 121
			FeatureQuery fq=new FeatureQuery();
......
126 132
			NotificationManager.addError(e.getMessage(), e);
127 133
		} catch (DataException e) {
128 134
			NotificationManager.addError(e.getMessage(), e);
129
		} catch (InstantiationException e) {
135
		} catch (CreateGeometryException e) {
130 136
			NotificationManager.addError(e.getMessage(), e);
131
		} catch (IllegalAccessException e) {
132
			NotificationManager.addError(e.getMessage(), e);
133 137
		}
134 138
	}
135 139

  
......
159 163
				h1 = firstPoint.getY() - lastPoint.getY();
160 164
			}
161 165

  
162
			Envelope envelope = UtilFunctions.createEnvelope(x1, y1, x1 + w1, y1 + h1);
166
			Envelope envelope = geomManager.createEnvelope(x1, y1, x1 + w1, y1 + h1, SUBTYPES.GEOM2D);
163 167

  
164 168
			FeatureQuery fq=new FeatureQuery();
165 169
			fq.setAttributeNames(new String[]{featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()});
......
180 184
			NotificationManager.addError(e.getMessage(), e);
181 185
		} catch (DataException e) {
182 186
			NotificationManager.addError(e.getMessage(), e);
187
		} catch (CreateEnvelopeException e) {
188
			NotificationManager.addError(e.getMessage(), e);
183 189
		}
184 190
	}
185 191

  

Also available in: Unified diff