Revision 4522 trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/PolygonCADTool.java
PolygonCADTool.java | ||
---|---|---|
45 | 45 |
import java.awt.event.InputEvent; |
46 | 46 |
import java.awt.geom.Point2D; |
47 | 47 |
|
48 |
import com.iver.cit.gvsig.fmap.core.FGeometryCollection;
|
|
48 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D;
|
|
49 | 49 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
50 | 50 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
51 | 51 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
... | ... | |
222 | 222 |
* @return GeometryCollection con las geometr?as del pol?gono. |
223 | 223 |
*/ |
224 | 224 |
private IGeometry getCPolygon(Point2D point, double radio) { |
225 |
Point2D p1 = UtilFunctions.getPoint(center, point, radio); |
|
226 |
|
|
227 |
double initangle = UtilFunctions.getAngle(center, point); |
|
228 |
Point2D antPoint = p1; |
|
229 |
Point2D antInter = null; |
|
230 |
double an = (Math.PI * 2) / numLines; |
|
231 |
GeneralPathX elShape = new GeneralPathX(); |
|
232 |
boolean firstTime=true; |
|
233 |
for (int i = 1; i < (numLines+1); i++) { |
|
234 |
Point2D p2 = UtilFunctions.getPoint(center, (an * i) + initangle, |
|
235 |
radio); |
|
236 |
Point2D[] ps1 = UtilFunctions.getPerpendicular(antPoint, center, |
|
237 |
antPoint); |
|
238 |
Point2D[] ps2 = UtilFunctions.getPerpendicular(p2, center, p2); |
|
239 |
Point2D inter = UtilFunctions.getIntersection(ps1[0], ps1[1], |
|
240 |
ps2[0], ps2[1]); |
|
241 |
|
|
242 |
if (antInter != null) { |
|
243 |
|
|
244 |
if (firstTime){ |
|
245 |
elShape.moveTo(antInter.getX(), antInter.getY()); |
|
246 |
firstTime=false; |
|
247 |
} |
|
248 |
elShape.lineTo(inter.getX(), inter.getY()); |
|
249 |
|
|
250 |
} |
|
251 |
|
|
252 |
antInter = inter; |
|
253 |
antPoint = p2; |
|
254 |
} |
|
255 |
|
|
256 |
return ShapeFactory.createGeometry(new FPolygon2D(elShape)); |
|
257 |
} |
|
258 |
|
|
259 |
/** |
|
260 |
* Devuelve la geometr?a con el poligono regular inscrito en la |
|
261 |
* circunferencia. |
|
262 |
* |
|
263 |
* @param point Puntero del rat?n. |
|
264 |
* @param radio Radio |
|
265 |
* |
|
266 |
* @return GeometryCollection con las geometr?as del pol?gono. |
|
267 |
*/ |
|
268 |
private IGeometry getIPolygon(Point2D point, double radio) { |
|
269 |
Point2D p1 = UtilFunctions.getPoint(center, point, radio); |
|
270 |
double initangle = UtilFunctions.getAngle(center, point); |
|
271 |
Point2D antPoint = p1; |
|
272 |
double an = (Math.PI * 2) / numLines; |
|
273 |
GeneralPathX elShape = new GeneralPathX(); |
|
274 |
boolean firstTime=true; |
|
275 |
for (int i = 1; i < (numLines); i++) { |
|
276 |
Point2D p2 = UtilFunctions.getPoint(center, (an * i) + initangle, |
|
277 |
radio); |
|
278 |
|
|
279 |
if (firstTime){ |
|
280 |
elShape.moveTo(antPoint.getX(), antPoint.getY()); |
|
281 |
firstTime=false; |
|
282 |
} |
|
283 |
|
|
284 |
elShape.lineTo(p2.getX(), p2.getY()); |
|
285 |
|
|
286 |
antPoint = p2; |
|
287 |
} |
|
288 |
|
|
289 |
return ShapeFactory.createGeometry(new FPolygon2D(elShape)); |
|
290 |
} |
|
291 |
/** |
|
292 |
* Devuelve la geometr?a con el poligono regular circunscrito a la |
|
293 |
* circunferencia formada por el punto central y el radio que se froma |
|
294 |
* entre este y el puntero del rat?n.. |
|
295 |
* |
|
296 |
* @param point Puntero del rat?n. |
|
297 |
* @param radio Radio |
|
298 |
* |
|
299 |
* @return GeometryCollection con las geometr?as del pol?gono. |
|
300 |
*/ |
|
301 |
/* private IGeometry getCPolygonOld(Point2D point, double radio) { |
|
225 | 302 |
IGeometry[] geoms = new IGeometry[numLines]; |
226 | 303 |
Point2D p1 = UtilFunctions.getPoint(center, point, radio); |
227 | 304 |
|
... | ... | |
254 | 331 |
|
255 | 332 |
return new FGeometryCollection(geoms); |
256 | 333 |
} |
257 |
|
|
334 |
*/ |
|
258 | 335 |
/** |
259 | 336 |
* Devuelve la geometr?a con el poligono regular inscrito en la |
260 | 337 |
* circunferencia. |
... | ... | |
264 | 341 |
* |
265 | 342 |
* @return GeometryCollection con las geometr?as del pol?gono. |
266 | 343 |
*/ |
267 |
private IGeometry getIPolygon(Point2D point, double radio) {
|
|
344 |
/* private IGeometry getIPolygonOld(Point2D point, double radio) {
|
|
268 | 345 |
IGeometry[] geoms = new IGeometry[numLines]; |
269 | 346 |
Point2D p1 = UtilFunctions.getPoint(center, point, radio); |
270 | 347 |
double initangle = UtilFunctions.getAngle(center, point); |
... | ... | |
285 | 362 |
|
286 | 363 |
return new FGeometryCollection(geoms); |
287 | 364 |
} |
288 |
|
|
365 |
*/ |
|
289 | 366 |
public String getName() { |
290 | 367 |
return "POLIGONO"; |
291 | 368 |
} |
Also available in: Unified diff