Revision 39135
branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/gui/cad/tools/SymmetryCADTool.java | ||
---|---|---|
39 | 39 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
40 | 40 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
41 | 41 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
42 |
import org.gvsig.fmap.dal.feature.exception.CreateGeometryException; |
|
42 | 43 |
import org.gvsig.fmap.geom.Geometry; |
43 | 44 |
import org.gvsig.fmap.geom.handler.Handler; |
45 |
import org.gvsig.fmap.geom.operation.perpendicular.Perpendicular; |
|
46 |
import org.gvsig.fmap.geom.operation.perpendicular.PerpendicularOperationContext; |
|
44 | 47 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
48 |
import org.gvsig.fmap.geom.primitive.Point; |
|
45 | 49 |
import org.gvsig.fmap.geom.type.GeometryType; |
46 | 50 |
import org.gvsig.fmap.geom.util.UtilFunctions; |
47 | 51 |
import org.gvsig.fmap.mapcontext.ViewPort; |
... | ... | |
286 | 290 |
for (int j = 0; j < handlers.length; j++) { |
287 | 291 |
Handler h = handlers[j]; |
288 | 292 |
Point2D p = h.getPoint(); |
289 |
Point2D[] ps = |
|
290 |
UtilFunctions.getPerpendicular(firstPoint, |
|
291 |
secondPoint, p); |
|
293 |
Point2D[] ps = getPerpendicularLine( |
|
294 |
firstPoint, secondPoint, p); |
|
292 | 295 |
Point2D inter = |
293 | 296 |
UtilFunctions.getIntersection(ps[0], ps[1], |
294 | 297 |
firstPoint, secondPoint); |
... | ... | |
298 | 301 |
h.set(inter.getX() + dif.getX(), |
299 | 302 |
inter.getY() + dif.getY()); |
300 | 303 |
} |
304 |
|
|
305 |
// geom.invokeOperation(index, ctx) |
|
301 | 306 |
|
302 | 307 |
String yes_low_case = |
303 | 308 |
Messages.getText("SymmetryCADTool.yes").toLowerCase(); |
... | ... | |
355 | 360 |
protected int[] getSupportedGeometryTypes() { |
356 | 361 |
return null; |
357 | 362 |
} |
363 |
|
|
364 |
private Point2D[] getPerpendicularLine( |
|
365 |
Point2D p1, Point2D p2, Point2D pp) throws CreateGeometryException { |
|
366 |
|
|
367 |
try { |
|
368 |
Point g_p1 = geomManager.createPoint( |
|
369 |
p1.getX(), p1.getY(), Geometry.SUBTYPES.GEOM2D); |
|
370 |
Point g_p2 = geomManager.createPoint( |
|
371 |
p2.getX(), p2.getY(), Geometry.SUBTYPES.GEOM2D); |
|
372 |
Point g_pp = geomManager.createPoint( |
|
373 |
pp.getX(), pp.getY(), Geometry.SUBTYPES.GEOM2D); |
|
374 |
|
|
375 |
PerpendicularOperationContext poc = new PerpendicularOperationContext( |
|
376 |
g_p2, g_pp); |
|
377 |
|
|
378 |
Point[] res = (Point[]) g_p1.invokeOperation( |
|
379 |
Perpendicular.CODE, poc); |
|
380 |
Point2D[] resp = new Point2D[2]; |
|
381 |
resp[0] = new Point2D.Double(res[0].getX(), res[0].getY()); |
|
382 |
resp[1] = new Point2D.Double(res[1].getX(), res[1].getY()); |
|
383 |
return resp; |
|
384 |
|
|
385 |
} catch (Exception ex) { |
|
386 |
throw new CreateGeometryException( |
|
387 |
Geometry.TYPES.POINT, |
|
388 |
Geometry.SUBTYPES.GEOM2D, |
|
389 |
ex); |
|
390 |
} |
|
391 |
} |
|
358 | 392 |
|
393 |
|
|
359 | 394 |
} |
Also available in: Unified diff