svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / primitive / impl / EllipticArc2D.java @ 27049
History | View | Annotate | Download (16.8 KB)
1 |
/*
|
---|---|
2 |
* Created on 09-feb-2005
|
3 |
*
|
4 |
* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
|
5 |
*
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
21 |
USA.
|
22 |
*
|
23 |
* For more information, contact:
|
24 |
*
|
25 |
* Generalitat Valenciana
|
26 |
* Conselleria d'Infraestructures i Transport
|
27 |
* Av. Blasco Ib��ez, 50
|
28 |
* 46010 VALENCIA
|
29 |
* SPAIN
|
30 |
*
|
31 |
* +34 963862235
|
32 |
* gvsig@gva.es
|
33 |
* www.gvsig.gva.es
|
34 |
*
|
35 |
* or
|
36 |
*
|
37 |
* IVER T.I. S.A
|
38 |
* Salamanca 50
|
39 |
* 46005 Valencia
|
40 |
* Spain
|
41 |
*
|
42 |
* +34 963163400
|
43 |
* dac@iver.es
|
44 |
*/
|
45 |
package org.gvsig.fmap.geom.primitive.impl; |
46 |
|
47 |
import java.awt.geom.AffineTransform; |
48 |
import java.awt.geom.Arc2D; |
49 |
import java.awt.geom.Point2D; |
50 |
import java.awt.geom.Rectangle2D; |
51 |
import java.util.ArrayList; |
52 |
|
53 |
import org.cresques.cts.IProjection; |
54 |
import org.gvsig.fmap.geom.GeometryLocator; |
55 |
import org.gvsig.fmap.geom.handler.AbstractHandler; |
56 |
import org.gvsig.fmap.geom.handler.CuadrantHandler; |
57 |
import org.gvsig.fmap.geom.handler.Handler; |
58 |
import org.gvsig.fmap.geom.primitive.EllipticArc; |
59 |
import org.gvsig.fmap.geom.primitive.FShape; |
60 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
61 |
import org.gvsig.fmap.geom.primitive.Point; |
62 |
import org.gvsig.fmap.geom.type.GeometryType; |
63 |
import org.gvsig.fmap.geom.util.UtilFunctions; |
64 |
|
65 |
|
66 |
|
67 |
/**
|
68 |
* DOCUMENT ME!
|
69 |
*
|
70 |
* @author Vicente Caballero Navarro
|
71 |
*/
|
72 |
public class EllipticArc2D extends Curve2D implements EllipticArc { |
73 |
private static final long serialVersionUID = 2988037614443119814L; |
74 |
|
75 |
private static GeometryType geomType = GeometryLocator.getGeometryManager() |
76 |
.registerGeometryType(EllipticArc2D.class, null, TYPES.ELLIPTICARC, SUBTYPES.GEOM2D);
|
77 |
|
78 |
private Point2D axis1Start; |
79 |
private Point2D axis1End; |
80 |
private double semiAxis2Length; |
81 |
private double angSt; |
82 |
private double angExt; |
83 |
|
84 |
/**
|
85 |
* Constructor without arguments. It is necessary to create
|
86 |
* geometries using the {@link GeometryType}{@link #create()}
|
87 |
* method
|
88 |
*/
|
89 |
public EllipticArc2D() {
|
90 |
super();
|
91 |
} |
92 |
|
93 |
/**
|
94 |
* DOCUMENT ME!
|
95 |
*
|
96 |
* @param gpx
|
97 |
*/
|
98 |
public EllipticArc2D(String id, IProjection projection, GeneralPathX gpx, Point2D axis1Start,Point2D axis1End, double semiAxis2Length, double angSt, double angExt) { |
99 |
super(id, projection, gpx);
|
100 |
this.axis1Start = axis1Start;
|
101 |
this.axis1End = axis1End;
|
102 |
this.semiAxis2Length = semiAxis2Length;
|
103 |
this.angSt = angSt;
|
104 |
this.angExt = angExt;
|
105 |
} |
106 |
|
107 |
/*
|
108 |
* (non-Javadoc)
|
109 |
* @see org.gvsig.fmap.geom.primitive.EllipticArc#getAxis1Start()
|
110 |
*/
|
111 |
public Point getAxis1Start(){ |
112 |
return new org.gvsig.fmap.geom.primitive.impl.Point2D(axis1Start); |
113 |
} |
114 |
|
115 |
/*
|
116 |
* (non-Javadoc)
|
117 |
* @see org.gvsig.fmap.geom.primitive.EllipticArc#getAxis1End()
|
118 |
*/
|
119 |
public Point getAxis1End(){ |
120 |
return new org.gvsig.fmap.geom.primitive.impl.Point2D(axis1End); |
121 |
} |
122 |
|
123 |
/*
|
124 |
* (non-Javadoc)
|
125 |
* @see org.gvsig.fmap.geom.primitive.EllipticArc#getAxis2Dist()
|
126 |
*/
|
127 |
public double getAxis2Dist(){ |
128 |
return this.semiAxis2Length; |
129 |
} |
130 |
|
131 |
/*
|
132 |
* (non-Javadoc)
|
133 |
* @see org.gvsig.fmap.geom.primitive.EllipticArc#getAngSt()
|
134 |
*/
|
135 |
public double getAngSt(){ |
136 |
return this.angSt; |
137 |
} |
138 |
|
139 |
/*
|
140 |
* (non-Javadoc)
|
141 |
* @see org.gvsig.fmap.geom.primitive.EllipticArc#getAngExt()
|
142 |
*/
|
143 |
public double getAngExt(){ |
144 |
return this.angExt; |
145 |
} |
146 |
|
147 |
/*
|
148 |
* (non-Javadoc)
|
149 |
* @see org.gvsig.fmap.geom.primitive.impl.OrientablePrimitive2D#transform(java.awt.geom.AffineTransform)
|
150 |
*/
|
151 |
public void transform(AffineTransform at) { |
152 |
Point2D center = new Point2D.Double((axis1Start.getX() + axis1End.getX()) / 2, |
153 |
(axis1Start.getY() + axis1End.getY()) / 2);
|
154 |
Point2D pdist = UtilFunctions.getPerpendicularPoint(axis1Start, axis1End, center,
|
155 |
semiAxis2Length); |
156 |
Point2D aux1 = new Point2D.Double(); |
157 |
at.transform(axis1Start, aux1); |
158 |
axis1Start = aux1; |
159 |
Point2D aux2 = new Point2D.Double(); |
160 |
at.transform(axis1End, aux2); |
161 |
axis1End = aux2; |
162 |
|
163 |
center = new Point2D.Double((axis1Start.getX() + axis1End.getX()) / 2, (axis1Start |
164 |
.getY() + axis1End.getY()) / 2);
|
165 |
|
166 |
Point2D aux3 = new Point2D.Double(); |
167 |
at.transform(pdist, aux3); |
168 |
semiAxis2Length = center.distance(aux3); |
169 |
gp.transform(at); |
170 |
} |
171 |
|
172 |
/*
|
173 |
* (non-Javadoc)
|
174 |
* @see org.gvsig.fmap.geom.primitive.impl.Curve2D#getShapeType()
|
175 |
*/
|
176 |
public int getShapeType() { |
177 |
return FShape.ARC;
|
178 |
} |
179 |
|
180 |
/*
|
181 |
* (non-Javadoc)
|
182 |
* @see org.gvsig.fmap.geom.primitive.impl.OrientablePrimitive2D#getStretchingHandlers()
|
183 |
*/
|
184 |
public Handler[] getStretchingHandlers() { |
185 |
ArrayList handlers = new ArrayList(); |
186 |
Rectangle2D rect = this.getBounds2D(); |
187 |
handlers.add(new CenterHandler(0, rect.getCenterX(), rect.getCenterY())); |
188 |
return (Handler[]) handlers.toArray(new Handler[0]); |
189 |
} |
190 |
|
191 |
/*
|
192 |
* (non-Javadoc)
|
193 |
* @see org.gvsig.fmap.geom.primitive.impl.OrientablePrimitive2D#getSelectHandlers()
|
194 |
*/
|
195 |
public Handler[] getSelectHandlers() { |
196 |
//TODO: Faltaria tener en cuenta handlers para los angulos angSt y angExt
|
197 |
ArrayList handlers = new ArrayList(); |
198 |
Rectangle2D rect = this.getBounds2D(); |
199 |
handlers.add(new CenterSelHandler(0, rect.getCenterX(), rect.getCenterY())); |
200 |
handlers.add(new Axis1StSelHandler(1, axis1Start.getX(), axis1Start.getY())); |
201 |
handlers.add(new Axis1EndSelHandler(2, axis1End.getX(), axis1End.getY())); |
202 |
Point2D mediop = new Point2D.Double((axis1End.getX() + axis1Start.getX()) / 2, |
203 |
(axis1End.getY() + axis1Start.getY()) / 2);
|
204 |
Point2D[] p = UtilFunctions.getPerpendicular(axis1Start, axis1End, mediop); |
205 |
Point2D u = UtilFunctions.getPoint(mediop, p[1], semiAxis2Length); |
206 |
Point2D d = UtilFunctions.getPoint(mediop, p[1], -semiAxis2Length); |
207 |
|
208 |
handlers.add(new RadioSelYHandler(3, u.getX(), u.getY())); |
209 |
handlers.add(new RadioSelYHandler(4, d.getX(), d.getY())); |
210 |
|
211 |
return (Handler[]) handlers.toArray(new Handler[0]); |
212 |
} |
213 |
|
214 |
/**
|
215 |
* DOCUMENT ME!
|
216 |
*
|
217 |
* @author Vicente Caballero Navarro
|
218 |
*/
|
219 |
class CenterHandler extends AbstractHandler implements Handler { |
220 |
/**
|
221 |
* Crea un nuevo PointHandler.
|
222 |
*
|
223 |
* @param i
|
224 |
* DOCUMENT ME!
|
225 |
* @param x
|
226 |
* DOCUMENT ME!
|
227 |
* @param y
|
228 |
* DOCUMENT ME!
|
229 |
*/
|
230 |
public CenterHandler(int i, double x, double y) { |
231 |
point = new Point2D.Double(x, y); |
232 |
index = i; |
233 |
} |
234 |
|
235 |
/**
|
236 |
* DOCUMENT ME!
|
237 |
*
|
238 |
* @param x
|
239 |
* DOCUMENT ME!
|
240 |
* @param y
|
241 |
* DOCUMENT ME!
|
242 |
*
|
243 |
* @return DOCUMENT ME!
|
244 |
*/
|
245 |
public void move(double x, double y) { |
246 |
for (int i = 0; i < gp.getNumCoords() / 2; i++) { |
247 |
gp.getPointCoords()[i * 2] += x;
|
248 |
gp.getPointCoords()[i * 2 + 1] += y; |
249 |
} |
250 |
axis1Start = new Point2D.Double(axis1Start.getX() + x, axis1Start.getY() + y); |
251 |
axis1End = new Point2D.Double(axis1End.getX() + x, axis1End.getY() + y); |
252 |
} |
253 |
|
254 |
/**
|
255 |
* @see org.gvsig.fmap.geom.handler.Handler#set(double, double)
|
256 |
*/
|
257 |
public void set(double x, double y) { |
258 |
} |
259 |
} |
260 |
|
261 |
/**
|
262 |
* DOCUMENT ME!
|
263 |
*
|
264 |
* @author Vicente Caballero Navarro
|
265 |
*/
|
266 |
class CenterSelHandler extends AbstractHandler implements Handler { |
267 |
/**
|
268 |
* Crea un nuevo PointHandler.
|
269 |
*
|
270 |
* @param i
|
271 |
* DOCUMENT ME!
|
272 |
* @param x
|
273 |
* DOCUMENT ME!
|
274 |
* @param y
|
275 |
* DOCUMENT ME!
|
276 |
*/
|
277 |
public CenterSelHandler(int i, double x, double y) { |
278 |
point = new Point2D.Double(x, y); |
279 |
index = i; |
280 |
} |
281 |
|
282 |
/**
|
283 |
* DOCUMENT ME!
|
284 |
*
|
285 |
* @param x
|
286 |
* DOCUMENT ME!
|
287 |
* @param y
|
288 |
* DOCUMENT ME!
|
289 |
*
|
290 |
* @return DOCUMENT ME!
|
291 |
*/
|
292 |
public void move(double x, double y) { |
293 |
for (int i = 0; i < gp.getNumCoords() / 2; i++) { |
294 |
gp.getPointCoords()[i * 2] += x;
|
295 |
gp.getPointCoords()[i * 2 + 1] += y; |
296 |
} |
297 |
} |
298 |
|
299 |
/**
|
300 |
* @see org.gvsig.fmap.geom.handler.Handler#set(double, double)
|
301 |
*/
|
302 |
public void set(double x, double y) { |
303 |
Point2D center = new Point2D.Double((axis1Start.getX() + axis1End.getX()) / 2, |
304 |
(axis1Start.getY() + axis1End.getY()) / 2);
|
305 |
double dx = x - center.getX();
|
306 |
double dy = y - center.getY();
|
307 |
for (int i = 0; i < gp.getNumCoords() / 2; i++) { |
308 |
gp.getPointCoords()[i * 2] += dx;
|
309 |
gp.getPointCoords()[i * 2 + 1] += dy; |
310 |
} |
311 |
axis1Start = new Point2D.Double(axis1Start.getX() + dx, axis1Start.getY() + dy); |
312 |
axis1End = new Point2D.Double(axis1End.getX() + dx, axis1End.getY() + dy); |
313 |
} |
314 |
} |
315 |
|
316 |
/**
|
317 |
* DOCUMENT ME!
|
318 |
*
|
319 |
* @author Vicente Caballero Navarro
|
320 |
*/
|
321 |
class Axis1StSelHandler extends AbstractHandler implements CuadrantHandler { |
322 |
/**
|
323 |
* Crea un nuevo PointHandler.
|
324 |
*
|
325 |
* @param i
|
326 |
* DOCUMENT ME!
|
327 |
* @param x
|
328 |
* DOCUMENT ME!
|
329 |
* @param y
|
330 |
* DOCUMENT ME!
|
331 |
*/
|
332 |
public Axis1StSelHandler(int i, double x, double y) { |
333 |
point = new Point2D.Double(x, y); |
334 |
index = i; |
335 |
} |
336 |
|
337 |
/**
|
338 |
* DOCUMENT ME!
|
339 |
*
|
340 |
* @param x
|
341 |
* DOCUMENT ME!
|
342 |
* @param y
|
343 |
* DOCUMENT ME!
|
344 |
*
|
345 |
* @return DOCUMENT ME!
|
346 |
*/
|
347 |
public void move(double x, double y) { |
348 |
|
349 |
} |
350 |
|
351 |
/**
|
352 |
* @see org.gvsig.fmap.geom.handler.Handler#set(double, double)
|
353 |
*/
|
354 |
public void set(double x, double y) { |
355 |
// TODO comentado para quitar warning: double dx=x-init.getX();
|
356 |
// TODO comentado para quitar warning: double dy=y-init.getY();
|
357 |
Point2D center = new Point2D.Double((axis1Start.getX() + axis1End.getX()) / 2, |
358 |
(axis1Start.getY() + axis1End.getY()) / 2);
|
359 |
// Point2D[]
|
360 |
// p1=TrigonometricalFunctions.getPerpendicular(init,end,center);
|
361 |
// Point2D[]
|
362 |
// p2=TrigonometricalFunctions.getPerpendicular(p1[0],p1[1],new
|
363 |
// Point2D.Double(x,y));
|
364 |
|
365 |
// Point2D
|
366 |
// pl=TrigonometricalFunctions.getIntersection(p2[0],p2[1],p1[0],p1[1]);
|
367 |
// double xdist=2*pl.distance(x,y);
|
368 |
double xdist = 2 * center.distance(x, y); |
369 |
// init=new Point2D.Double(init.getX()+dx,init.getY()+dy);
|
370 |
axis1Start = UtilFunctions.getPoint(center, axis1Start, center.distance(x, y)); |
371 |
axis1End = UtilFunctions.getPoint(axis1Start, center, xdist); |
372 |
Arc2D.Double arc = new Arc2D.Double(axis1Start.getX(), axis1Start.getY() |
373 |
- semiAxis2Length, xdist, 2 * semiAxis2Length, Math.toDegrees(angSt), Math.toDegrees(angExt), Arc2D.OPEN); |
374 |
// TODO comentado para quitar warning: Point2D rotationPoint = new
|
375 |
// Point2D.Double(init.getX() + xdist /2, init.getY());
|
376 |
|
377 |
double angle = UtilFunctions.getAngle(axis1Start, axis1End);
|
378 |
AffineTransform mT = AffineTransform.getRotateInstance(angle, axis1Start |
379 |
.getX(), axis1Start.getY()); |
380 |
gp = new GeneralPathX(arc);
|
381 |
gp.transform(mT); |
382 |
|
383 |
} |
384 |
} |
385 |
|
386 |
/**
|
387 |
* DOCUMENT ME!
|
388 |
*
|
389 |
* @author Vicente Caballero Navarro
|
390 |
*/
|
391 |
class Axis1EndSelHandler extends AbstractHandler implements CuadrantHandler { |
392 |
/**
|
393 |
* Crea un nuevo PointHandler.
|
394 |
*
|
395 |
* @param i
|
396 |
* DOCUMENT ME!
|
397 |
* @param x
|
398 |
* DOCUMENT ME!
|
399 |
* @param y
|
400 |
* DOCUMENT ME!
|
401 |
*/
|
402 |
public Axis1EndSelHandler(int i, double x, double y) { |
403 |
point = new Point2D.Double(x, y); |
404 |
index = i; |
405 |
} |
406 |
|
407 |
/**
|
408 |
* DOCUMENT ME!
|
409 |
*
|
410 |
* @param x
|
411 |
* DOCUMENT ME!
|
412 |
* @param y
|
413 |
* DOCUMENT ME!
|
414 |
*
|
415 |
* @return DOCUMENT ME!
|
416 |
*/
|
417 |
public void move(double x, double y) { |
418 |
|
419 |
} |
420 |
|
421 |
/**
|
422 |
* @see org.gvsig.fmap.geom.handler.Handler#set(double, double)
|
423 |
*/
|
424 |
public void set(double x, double y) { |
425 |
// double dx=x-getPoint().getX();
|
426 |
// double dy=y-getPoint().getY();
|
427 |
Point2D center = new Point2D.Double((axis1Start.getX() + axis1End.getX()) / 2, |
428 |
(axis1Start.getY() + axis1End.getY()) / 2);
|
429 |
// Point2D[]
|
430 |
// p1=TrigonometricalFunctions.getPerpendicular(init,end,center);
|
431 |
// Point2D[]
|
432 |
// p2=TrigonometricalFunctions.getPerpendicular(p1[0],p1[1],new
|
433 |
// Point2D.Double(x,y));
|
434 |
|
435 |
// Point2D
|
436 |
// pl=TrigonometricalFunctions.getIntersection(p2[0],p2[1],p1[0],p1[1]);
|
437 |
// double xdist=2*pl.distance(x,y);
|
438 |
double xdist = 2 * center.distance(x, y); |
439 |
axis1End = UtilFunctions.getPoint(center, axis1End, center.distance(x, y)); |
440 |
// end=new Point2D.Double(end.getX()+dx,end.getY()+dy);
|
441 |
axis1Start = UtilFunctions.getPoint(axis1End, center, xdist); |
442 |
Arc2D.Double arc = new Arc2D.Double(axis1Start.getX(), axis1Start.getY() |
443 |
- semiAxis2Length, xdist, 2 * semiAxis2Length, Math.toDegrees(angSt), Math.toDegrees(angExt), Arc2D.OPEN); |
444 |
// Point2D rotationPoint = new Point2D.Double(init.getX() + xdist
|
445 |
// /2, init.getY());
|
446 |
|
447 |
double angle = UtilFunctions.getAngle(axis1Start, axis1End);
|
448 |
AffineTransform mT = AffineTransform.getRotateInstance(angle, axis1Start |
449 |
.getX(), axis1Start.getY()); |
450 |
gp = new GeneralPathX(arc);
|
451 |
gp.transform(mT); |
452 |
|
453 |
} |
454 |
} |
455 |
|
456 |
/**
|
457 |
* DOCUMENT ME!
|
458 |
*
|
459 |
* @author Vicente Caballero Navarro
|
460 |
*/
|
461 |
class RadioSelYHandler extends AbstractHandler implements CuadrantHandler { |
462 |
/**
|
463 |
* Crea un nuevo PointHandler.
|
464 |
*
|
465 |
* @param i
|
466 |
* DOCUMENT ME!
|
467 |
* @param x
|
468 |
* DOCUMENT ME!
|
469 |
* @param y
|
470 |
* DOCUMENT ME!
|
471 |
*/
|
472 |
public RadioSelYHandler(int i, double x, double y) { |
473 |
point = new Point2D.Double(x, y); |
474 |
index = i; |
475 |
} |
476 |
|
477 |
/**
|
478 |
* DOCUMENT ME!
|
479 |
*
|
480 |
* @param x
|
481 |
* DOCUMENT ME!
|
482 |
* @param y
|
483 |
* DOCUMENT ME!
|
484 |
*
|
485 |
* @return DOCUMENT ME!
|
486 |
*/
|
487 |
public void move(double x, double y) { |
488 |
|
489 |
} |
490 |
|
491 |
/**
|
492 |
* @see org.gvsig.fmap.geom.handler.Handler#set(double, double)
|
493 |
*/
|
494 |
public void set(double x, double y) { |
495 |
semiAxis2Length = new Point2D.Double((axis1Start.getX() + axis1End.getX()) / 2, (axis1Start |
496 |
.getY() + axis1End.getY()) / 2).distance(x, y);
|
497 |
// ydist=getSelectHandlers()[1].getPoint().distance(x,y);
|
498 |
// Point2D center=new Point2D.Double((init.getX() + end.getX()) / 2,
|
499 |
// (init.getY() + end.getY()) / 2);
|
500 |
// Point2D[]
|
501 |
// p=TrigonometricalFunctions.getPerpendicular(init,end,new
|
502 |
// Point2D.Double(x,y));
|
503 |
// Point2D
|
504 |
// pl=TrigonometricalFunctions.getIntersection(p[0],p[1],init,end);
|
505 |
// double xdist=2*pl.distance(x,y);
|
506 |
double xdist = axis1Start.distance(axis1End);
|
507 |
Arc2D.Double arc = new Arc2D.Double(axis1Start.getX(), axis1Start.getY() |
508 |
- semiAxis2Length, xdist, 2 * semiAxis2Length, Math.toDegrees(angSt), Math.toDegrees(angExt), Arc2D.OPEN); |
509 |
// Point2D rotationPoint = new Point2D.Double(init.getX() + xdist
|
510 |
// /2, init.getY());
|
511 |
|
512 |
double angle = UtilFunctions.getAngle(axis1Start, axis1End);
|
513 |
AffineTransform mT = AffineTransform.getRotateInstance(angle, axis1Start |
514 |
.getX(), axis1Start.getY()); |
515 |
gp = new GeneralPathX(arc);
|
516 |
gp.transform(mT); |
517 |
} |
518 |
} |
519 |
|
520 |
//TODO: Faltan Handlers para los angulos inicial y de extension (o final)
|
521 |
|
522 |
|
523 |
|
524 |
/* (non-Javadoc)
|
525 |
* @see com.iver.cit.gvsig.fmap.core.FPolyline2D#intersects(java.awt.geom.Rectangle2D)
|
526 |
*/
|
527 |
public boolean intersects(Rectangle2D r) { |
528 |
return gp.intersects(r);
|
529 |
} |
530 |
|
531 |
public GeometryType getGeometryType() {
|
532 |
return geomType;
|
533 |
} |
534 |
|
535 |
/* (non-Javadoc)
|
536 |
* @see org.gvsig.fmap.geom.primitive.EllipticArc#setPoints(org.gvsig.fmap.geom.primitive.Point, java.awt.geom.Point2D, double, double, double)
|
537 |
*/
|
538 |
public void setPoints(Point axis1Start, Point axis1End, |
539 |
double semiAxis2Length, double angSt, double angExt) { |
540 |
Point2D _axis1Start = new java.awt.geom.Point2D.Double(axis1Start.getCoordinateAt(0), axis1Start.getCoordinateAt(1)); |
541 |
Point2D _axis1End = new java.awt.geom.Point2D.Double(axis1End.getCoordinateAt(0), axis1End.getCoordinateAt(1)); |
542 |
setPoints(_axis1Start, _axis1End, semiAxis2Length, angSt, angExt); |
543 |
} |
544 |
|
545 |
/* (non-Javadoc)
|
546 |
* @see org.gvsig.fmap.geom.primitive.EllipticArc#setPoints(java.awt.geom.Point2D, java.awt.geom.Point2D, double, double, double)
|
547 |
*/
|
548 |
private void setPoints(Point2D axis1Start, Point2D axis1End, |
549 |
double semiAxis2Length, double angSt, double angExt) { |
550 |
double axis1Lenght = axis1Start.distance(axis1End);
|
551 |
Point2D center = new Point2D.Double((axis1Start.getX()+axis1End.getX())/2, (axis1Start.getY()+axis1End.getY())/2); |
552 |
double x = center.getX()-axis1Lenght/2; |
553 |
double y = center.getY()-semiAxis2Length;
|
554 |
|
555 |
double angle = UtilFunctions.getAngle(center, axis1Start);
|
556 |
|
557 |
Arc2D.Double arc = new Arc2D.Double( |
558 |
x, |
559 |
y, |
560 |
axis1Lenght, |
561 |
2 * semiAxis2Length,
|
562 |
Math.toDegrees(angSt),
|
563 |
Math.toDegrees(angExt),
|
564 |
Arc2D.OPEN);
|
565 |
AffineTransform mT = AffineTransform.getRotateInstance(angle, |
566 |
center.getX(), center.getY()); |
567 |
GeneralPathX gp = new GeneralPathX(arc);
|
568 |
gp.transform(mT); |
569 |
|
570 |
this.gp = gp;
|
571 |
this.axis1Start = axis1Start;
|
572 |
this.axis1End = axis1End;
|
573 |
this.semiAxis2Length = semiAxis2Length;
|
574 |
this.angSt = angSt;
|
575 |
this.angExt = angExt;
|
576 |
} |
577 |
|
578 |
/*
|
579 |
* (non-Javadoc)
|
580 |
* @see org.gvsig.fmap.geom.primitive.Curve2D#setGeneralPath(org.gvsig.fmap.geom.primitive.GeneralPathX)
|
581 |
*/
|
582 |
public void setGeneralPath(GeneralPathX generalPathX) { |
583 |
throw new UnsupportedOperationException("Use setPoints(Point center, Point radious)"); |
584 |
} |
585 |
|
586 |
} |