Revision 30788 branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/gui/cad/DefaultCADTool.java

View differences:

DefaultCADTool.java
46 46
import java.util.ArrayList;
47 47

  
48 48
import org.apache.log4j.Logger;
49
import org.cresques.cts.ICoordTrans;
49 50
import org.gvsig.andami.PluginServices;
50 51
import org.gvsig.andami.messages.NotificationManager;
51 52
import org.gvsig.andami.ui.mdiManager.IWindow;
......
80 81
import org.gvsig.fmap.geom.primitive.Primitive;
81 82
import org.gvsig.fmap.geom.primitive.Spline;
82 83
import org.gvsig.fmap.geom.primitive.Surface;
84
import org.gvsig.fmap.geom.util.UtilFunctions;
83 85
import org.gvsig.fmap.mapcontext.MapContextLocator;
84 86
import org.gvsig.fmap.mapcontext.MapContextManager;
87
import org.gvsig.fmap.mapcontext.ViewPort;
85 88
import org.gvsig.fmap.mapcontext.layers.SpatialCache;
86 89
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
87 90
import org.gvsig.fmap.mapcontrol.MapControlDrawer;
......
183 186
			draw(geometry, mapControlManager.getGeometrySelectionSymbol());			
184 187
		}
185 188
	}
189
	
190
	/**
191
	 * It draw the selected geometries from the initial point until a new
192
	 * point.
193
	 * @param mapControlDrawer
194
	 * The drawer.
195
	 * @param firstPoint
196
	 * The initial point.
197
	 * @param x
198
	 * The X coordinate of the mouse.
199
	 * @param y
200
	 * The Y coordinate of the mouse.
201
	 */
202
	protected void drawSelectedGeometries(MapControlDrawer mapControlDrawer,
203
			Point2D firstPoint, double x, double y){
204
		FeatureStore featureStore = null;
205
		DisposableIterator iterator = null;
206
		ICoordTrans ct = getVLE().getLayer().getCoordTrans();
186 207

  
208
		try {
209
			featureStore = getVLE().getFeatureStore();
210
			FeatureSet selection = (FeatureSet) featureStore.getSelection();
211

  
212
			iterator = selection.iterator();
213
			while (iterator.hasNext()) {
214
				Feature feature = (Feature) iterator.next();
215
				Geometry geometry = (feature.getDefaultGeometry())
216
				.cloneGeometry();
217
									
218
				if (geometry == null) {
219
					continue;
220
				}				
221
				
222
				Point2D currentPoint = new Point2D.Double(x, y);
223
				if (ct != null) {
224
					currentPoint = ct.getInverted().convert(currentPoint,
225
							null);
226
				}				
227
				
228
				UtilFunctions.moveGeom(geometry, currentPoint.getX()
229
						- firstPoint.getX(), currentPoint.getY()
230
						- firstPoint.getY());
231
						
232
				mapControlDrawer.draw(geometry, mapControlManager.getGeometrySelectionSymbol());					
233
			}				
234
		} catch (Exception e) {
235
			logger.error("Retrieving the selection", e);
236
		} finally {
237
			if (iterator != null) {
238
				iterator.dispose();
239
			}
240
		}           
241
	}
242
	
187 243
	/**
244
	 * It draw the selected geometries from the initial point until a new
245
	 * point.
246
	 * @param mapControlDrawer
247
	 * The drawer.
248
	 * @param firstPoint
249
	 * The initial point.
250
	 * @param x
251
	 * The X coordinate of the mouse.
252
	 * @param y
253
	 * The Y coordinate of the mouse.
254
	 * @param affineTransform
255
	 * The transformation to apply
256
	 */
257
	protected void drawAndRotateSelectedGeometries(MapControlDrawer mapControlDrawer,
258
			Point2D firstPoint, double x, double y){
259
		FeatureStore featureStore = null;
260
		DisposableIterator iterator = null;
261
		ICoordTrans ct = getVLE().getLayer().getCoordTrans();
262

  
263
		try {
264
			Point2D lastPoint = new Point2D.Double(x, y);
265

  
266
			double w = lastPoint.getX() - firstPoint.getX();
267
			double h = lastPoint.getY() - firstPoint.getY();
268
				
269
			featureStore = getVLE().getFeatureStore();
270
			FeatureSet selection = (FeatureSet) featureStore.getSelection();
271

  
272
			iterator = selection.iterator();
273
			while (iterator.hasNext()) {
274
				Feature feature = (Feature) iterator.next();
275
				Geometry geometry = (feature.getDefaultGeometry())
276
				.cloneGeometry();
277
									
278
				if (geometry == null) {
279
					continue;
280
				}				
281
				
282
				UtilFunctions.rotateGeom(geometry, -Math.atan2(w, h)
283
						+ (Math.PI / 2), firstPoint.getX(), firstPoint
284
						.getY());					
285
						
286
				mapControlDrawer.draw(geometry, mapControlManager.getGeometrySelectionSymbol());					
287
			}				
288
		} catch (Exception e) {
289
			logger.error("Retrieving the selection", e);
290
		} finally {
291
			if (iterator != null) {
292
				iterator.dispose();
293
			}
294
		}           
295
	}
296

  
297
	/**
188 298
	 *
189 299
	 * @param cta
190 300
	 *            DOCUMENT ME!

Also available in: Unified diff