Revision 38785 branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/impl/Arc2D.java
Arc2D.java | ||
---|---|---|
75 | 75 |
private static final long serialVersionUID = 6416027005106924030L; |
76 | 76 |
|
77 | 77 |
private Point2D init; |
78 |
private Point2D center; |
|
78 |
|
|
79 |
/** |
|
80 |
* This is the middle point (belongs to the arc), not the center |
|
81 |
* of the circle/ellipse |
|
82 |
*/ |
|
83 |
private Point2D middle; |
|
79 | 84 |
private Point2D end; |
80 | 85 |
|
81 | 86 |
private static final GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
... | ... | |
103 | 108 |
protected Arc2D(GeometryType geometryType, String id, IProjection projection, GeneralPathX gpx, Point2D i,Point2D c, Point2D e) { |
104 | 109 |
super(geometryType, id, projection, gpx); |
105 | 110 |
init=i; |
106 |
center=c;
|
|
111 |
middle=c;
|
|
107 | 112 |
end=e; |
108 | 113 |
} |
109 | 114 |
|
... | ... | |
111 | 116 |
* @see com.iver.cit.gvsig.fmap.core.FShape#cloneFShape() |
112 | 117 |
*/ |
113 | 118 |
public FShape cloneFShape() { |
114 |
Arc2D arc = new Arc2D(getGeometryType(), id, projection, (GeneralPathX) gp.clone(),init,center,end);
|
|
119 |
Arc2D arc = new Arc2D(getGeometryType(), id, projection, (GeneralPathX) gp.clone(),init,middle,end);
|
|
115 | 120 |
return arc; |
116 | 121 |
} |
117 | 122 |
|
... | ... | |
169 | 174 |
ArrayList handlers = new ArrayList(); |
170 | 175 |
|
171 | 176 |
handlers.add(new InitSelHandler(0, init.getX(), init.getY())); |
172 |
handlers.add(new CenterSelHandler(1, center.getX(), center.getY()));
|
|
177 |
handlers.add(new CenterSelHandler(1, middle.getX(), middle.getY()));
|
|
173 | 178 |
handlers.add(new EndSelHandler(2, end.getX(), end.getY())); |
174 | 179 |
|
175 | 180 |
return (Handler[]) handlers.toArray(new Handler[0]); |
... | ... | |
188 | 193 |
* @param y DOCUMENT ME! |
189 | 194 |
*/ |
190 | 195 |
public CenterSelHandler(int i, double x, double y) { |
191 |
center = new Point2D.Double(x, y);
|
|
196 |
middle = new Point2D.Double(x, y);
|
|
192 | 197 |
index = i; |
193 | 198 |
} |
194 | 199 |
|
... | ... | |
203 | 208 |
public void move(double x, double y) { |
204 | 209 |
} |
205 | 210 |
public void setPoint(Point2D p){ |
206 |
center=p;
|
|
211 |
middle=p;
|
|
207 | 212 |
} |
208 | 213 |
public Point2D getPoint(){ |
209 |
return center;
|
|
214 |
return middle;
|
|
210 | 215 |
} |
211 | 216 |
|
212 | 217 |
/** |
213 | 218 |
* @see org.gvsig.fmap.geom.handler.Handler#set(double, double) |
214 | 219 |
*/ |
215 | 220 |
public void set(double x, double y) { |
216 |
center=new Point2D.Double(x,y);
|
|
217 |
java.awt.geom.Arc2D arco = UtilFunctions.createArc(init, center, end);
|
|
221 |
middle=new Point2D.Double(x,y);
|
|
222 |
java.awt.geom.Arc2D arco = UtilFunctions.createArc(init, middle, end);
|
|
218 | 223 |
gp = new GeneralPathX(arco.getPathIterator(null)); |
219 | 224 |
} |
220 | 225 |
} |
... | ... | |
247 | 252 |
*/ |
248 | 253 |
public void move(double x, double y) { |
249 | 254 |
Point2D mediop=new Point2D.Double((init.getX()+end.getX())/2,(init.getY()+end.getY())/2); |
250 |
double dist=mediop.distance(center);
|
|
255 |
double dist=mediop.distance(middle);
|
|
251 | 256 |
init=new Point2D.Double(init.getX()+x,init.getY()+y); |
252 | 257 |
|
253 | 258 |
mediop=new Point2D.Double((init.getX()+end.getX())/2,(init.getY()+end.getY())/2); |
... | ... | |
255 | 260 |
if (UtilFunctions.getAngle(end,init)<=Math.PI){ |
256 | 261 |
dist=-dist; |
257 | 262 |
} |
258 |
center=UtilFunctions.getPoint(mediop,perp[1],dist);
|
|
263 |
middle=UtilFunctions.getPoint(mediop,perp[1],dist);
|
|
259 | 264 |
|
260 |
java.awt.geom.Arc2D arco = UtilFunctions.createArc(init,center, end);
|
|
265 |
java.awt.geom.Arc2D arco = UtilFunctions.createArc(init,middle, end);
|
|
261 | 266 |
gp=new GeneralPathX(arco.getPathIterator(null)); |
262 | 267 |
} |
263 | 268 |
public void setPoint(Point2D p){ |
... | ... | |
302 | 307 |
*/ |
303 | 308 |
public void move(double x, double y) { |
304 | 309 |
Point2D mediop=new Point2D.Double((init.getX()+end.getX())/2,(init.getY()+end.getY())/2); |
305 |
double dist=mediop.distance(center);
|
|
310 |
double dist=mediop.distance(middle);
|
|
306 | 311 |
end=new Point2D.Double(end.getX()+x,end.getY()+y); |
307 | 312 |
|
308 | 313 |
mediop=new Point2D.Double((init.getX()+end.getX())/2,(init.getY()+end.getY())/2); |
... | ... | |
310 | 315 |
if (UtilFunctions.getAngle(end,init)<=Math.PI){ |
311 | 316 |
dist=-dist; |
312 | 317 |
} |
313 |
center=UtilFunctions.getPoint(mediop,perp[1],dist);
|
|
318 |
middle=UtilFunctions.getPoint(mediop,perp[1],dist);
|
|
314 | 319 |
|
315 |
java.awt.geom.Arc2D arco = UtilFunctions.createArc(init,center, end);
|
|
320 |
java.awt.geom.Arc2D arco = UtilFunctions.createArc(init,middle, end);
|
|
316 | 321 |
gp=new GeneralPathX(arco.getPathIterator(null)); |
317 | 322 |
} |
318 | 323 |
public void setPoint(Point2D p){ |
... | ... | |
358 | 363 |
*/ |
359 | 364 |
public void move(double x, double y) { |
360 | 365 |
Point2D mediop=new Point2D.Double((init.getX()+end.getX())/2,(init.getY()+end.getY())/2); |
361 |
double dist=mediop.distance(center);
|
|
366 |
double dist=mediop.distance(middle);
|
|
362 | 367 |
init=new Point2D.Double(init.getX()+x,init.getY()+y); |
363 | 368 |
|
364 | 369 |
mediop=new Point2D.Double((init.getX()+end.getX())/2,(init.getY()+end.getY())/2); |
... | ... | |
366 | 371 |
if (UtilFunctions.getAngle(end,init)<=Math.PI){ |
367 | 372 |
dist=-dist; |
368 | 373 |
} |
369 |
center=UtilFunctions.getPoint(mediop,perp[1],dist);
|
|
374 |
middle=UtilFunctions.getPoint(mediop,perp[1],dist);
|
|
370 | 375 |
|
371 |
java.awt.geom.Arc2D arco = UtilFunctions.createArc(init,center, end);
|
|
376 |
java.awt.geom.Arc2D arco = UtilFunctions.createArc(init,middle, end);
|
|
372 | 377 |
gp=new GeneralPathX(arco.getPathIterator(null)); |
373 | 378 |
} |
374 | 379 |
public void setPoint(Point2D p){ |
... | ... | |
383 | 388 |
*/ |
384 | 389 |
public void set(double x, double y) { |
385 | 390 |
Point2D mediop=new Point2D.Double((init.getX()+end.getX())/2,(init.getY()+end.getY())/2); |
386 |
double dist=mediop.distance(center);
|
|
391 |
double dist=mediop.distance(middle);
|
|
387 | 392 |
init=new Point2D.Double(x,y); |
388 | 393 |
|
389 | 394 |
mediop=new Point2D.Double((init.getX()+end.getX())/2,(init.getY()+end.getY())/2); |
... | ... | |
392 | 397 |
dist=-dist; |
393 | 398 |
} |
394 | 399 |
///center=TrigonometricalFunctions.getPoint(mediop,perp[1],dist); |
395 |
java.awt.geom.Arc2D arco = UtilFunctions.createArc(init,center, end);
|
|
400 |
java.awt.geom.Arc2D arco = UtilFunctions.createArc(init,middle, end);
|
|
396 | 401 |
gp=new GeneralPathX(arco.getPathIterator(null)); |
397 | 402 |
} |
398 | 403 |
} |
... | ... | |
425 | 430 |
*/ |
426 | 431 |
public void move(double x, double y) { |
427 | 432 |
Point2D mediop=new Point2D.Double((init.getX()+end.getX())/2,(init.getY()+end.getY())/2); |
428 |
double dist=mediop.distance(center);
|
|
433 |
double dist=mediop.distance(middle);
|
|
429 | 434 |
end=new Point2D.Double(end.getX()+x,end.getY()+y); |
430 | 435 |
|
431 | 436 |
mediop=new Point2D.Double((init.getX()+end.getX())/2,(init.getY()+end.getY())/2); |
... | ... | |
433 | 438 |
if (UtilFunctions.getAngle(end,init)<=Math.PI){ |
434 | 439 |
dist=-dist; |
435 | 440 |
} |
436 |
center=UtilFunctions.getPoint(mediop,perp[1],dist);
|
|
441 |
middle=UtilFunctions.getPoint(mediop,perp[1],dist);
|
|
437 | 442 |
|
438 |
java.awt.geom.Arc2D arco = UtilFunctions.createArc(init,center, end);
|
|
443 |
java.awt.geom.Arc2D arco = UtilFunctions.createArc(init,middle, end);
|
|
439 | 444 |
gp=new GeneralPathX(arco.getPathIterator(null)); |
440 | 445 |
} |
441 | 446 |
public void setPoint(Point2D p){ |
... | ... | |
450 | 455 |
*/ |
451 | 456 |
public void set(double x, double y) { |
452 | 457 |
Point2D mediop=new Point2D.Double((init.getX()+end.getX())/2,(init.getY()+end.getY())/2); |
453 |
double dist=mediop.distance(center);
|
|
458 |
double dist=mediop.distance(middle);
|
|
454 | 459 |
end=new Point2D.Double(x,y); |
455 | 460 |
|
456 | 461 |
mediop=new Point2D.Double((init.getX()+end.getX())/2,(init.getY()+end.getY())/2); |
... | ... | |
459 | 464 |
dist=-dist; |
460 | 465 |
} |
461 | 466 |
///center=TrigonometricalFunctions.getPoint(mediop,perp[1],dist); |
462 |
java.awt.geom.Arc2D arco = UtilFunctions.createArc(init,center, end);
|
|
467 |
java.awt.geom.Arc2D arco = UtilFunctions.createArc(init,middle, end);
|
|
463 | 468 |
gp=new GeneralPathX(arco.getPathIterator(null)); |
464 | 469 |
} |
465 | 470 |
} |
... | ... | |
497 | 502 |
throw new IllegalArgumentException(); |
498 | 503 |
} |
499 | 504 |
this.gp = new GeneralPathX(arco.getPathIterator(null)); |
500 |
this.center = p1;
|
|
501 |
this.init = p2;
|
|
505 |
this.init = p1;
|
|
506 |
this.middle = p2;
|
|
502 | 507 |
this.end = p3; |
503 | 508 |
} |
504 | 509 |
|
... | ... | |
529 | 534 |
|
530 | 535 |
setPoints(p1, p2, p3); |
531 | 536 |
} |
537 |
|
|
532 | 538 |
|
539 |
|
|
533 | 540 |
/* (non-Javadoc) |
534 | 541 |
* @see org.gvsig.fmap.geom.primitive.Curve2D#setPoints(org.gvsig.fmap.geom.primitive.Point, org.gvsig.fmap.geom.primitive.Point) |
535 | 542 |
*/ |
... | ... | |
555 | 562 |
* @see org.gvsig.fmap.geom.primitive.Arc#getCenterPoint() |
556 | 563 |
*/ |
557 | 564 |
public Point getCenterPoint() { |
558 |
Point2D p = UtilFunctions.getCenter(init, center,end);
|
|
565 |
Point2D p = UtilFunctions.getCenter(init, middle,end);
|
|
559 | 566 |
try { |
560 | 567 |
return new org.gvsig.fmap.geom.primitive.impl.Point2D(p.getX(), p.getY()); |
561 | 568 |
} catch (Exception e) { |
562 | 569 |
return null; |
563 | 570 |
} |
564 |
} |
|
571 |
} |
|
572 |
|
|
573 |
|
|
565 | 574 |
} |
Also available in: Unified diff