root / trunk / libraries / libDwg / src / com / iver / cit / jdwglib / util / FMapUtil.java @ 10632
History | View | Annotate | Download (1.99 KB)
1 | 9825 | azabala | /*
|
---|---|---|---|
2 | * Created on 18-ene-2007 by azabala
|
||
3 | *
|
||
4 | */
|
||
5 | package com.iver.cit.jdwglib.util; |
||
6 | |||
7 | 10632 | azabala | import java.util.List; |
8 | 9825 | azabala | |
9 | import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
||
10 | import com.iver.cit.gvsig.fmap.core.FPolyline3D; |
||
11 | import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
||
12 | |||
13 | /**
|
||
14 | * @author alzabord
|
||
15 | *
|
||
16 | */
|
||
17 | public class FMapUtil { |
||
18 | /**
|
||
19 | * Method that changes a Point3D array to a FPolyline3D. Is useful to
|
||
20 | * convert a polyline given by it points to a FPolyline3D, a polyline 3D in
|
||
21 | * the FMap model object
|
||
22 | *
|
||
23 | * @param pts
|
||
24 | * Array of Point3D that defines the polyline 3D that will be
|
||
25 | * converted in a FPolyline3D
|
||
26 | * @return FPolyline3D This FPolyline3D is build using the array of Point3D
|
||
27 | * that is the argument of the method
|
||
28 | */
|
||
29 | 10632 | azabala | public static FPolyline3D points3DToFPolyline3D(List pts) { |
30 | 9825 | azabala | GeneralPathX genPathX = new GeneralPathX();
|
31 | 10632 | azabala | genPathX.moveTo(((double[])pts.get(0))[0], |
32 | ((double[])pts.get(0))[1]); |
||
33 | for (int i = 1; i < pts.size(); i++) { |
||
34 | genPathX.lineTo(((double[])pts.get(i))[0], |
||
35 | ((double[])pts.get(i))[1]); |
||
36 | 9825 | azabala | } |
37 | 10632 | azabala | double[] elevations = new double[pts.size()]; |
38 | for (int i = 0; i < pts.size(); i++) { |
||
39 | elevations[i] = ((double[])pts.get(i))[2]; |
||
40 | 9825 | azabala | } |
41 | return new FPolyline3D(genPathX, elevations); |
||
42 | } |
||
43 | /**
|
||
44 | * Method that changes a Point2D array to a FPolyline2D. Is useful to
|
||
45 | * convert a polyline given by it points to a FPolyline2D, a polyline in the
|
||
46 | * FMap model object
|
||
47 | *
|
||
48 | * @param pts
|
||
49 | * Array of Point2D that defines the polyline that will be
|
||
50 | * converted in a FPolyline2D
|
||
51 | * @return FPolyline2D This FPolyline2D is build using the array of Point2D
|
||
52 | * that is the argument of the method
|
||
53 | */
|
||
54 | 10632 | azabala | public static FPolyline2D points2DToFPolyline2D(List pts) { |
55 | 9825 | azabala | GeneralPathX genPathX = new GeneralPathX();
|
56 | 10632 | azabala | genPathX.moveTo(((double[])pts.get(0))[0], ((double[])pts.get(0))[1]); |
57 | for (int i = 1; i < pts.size(); i++) { |
||
58 | genPathX.lineTo(((double[])pts.get(i))[0], |
||
59 | ((double[])pts.get(i))[1]); |
||
60 | 9825 | azabala | } |
61 | return new FPolyline2D(genPathX); |
||
62 | } |
||
63 | } |