Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / libraries / libDwg / src / com / iver / cit / jdwglib / util / FMapUtil.java @ 10539

History | View | Annotate | Download (1.99 KB)

1
/*
2
 * Created on 18-ene-2007 by azabala
3
 *
4
 */
5
package com.iver.cit.jdwglib.util;
6

    
7
import java.awt.geom.Point2D;
8

    
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
 * TODO To change the template for this generated type comment go to
17
 * Window - Preferences - Java - Code Style - Code Templates
18
 */
19
public class FMapUtil {
20
        /**
21
         * Method that changes a Point3D array to a FPolyline3D. Is useful to
22
         * convert a polyline given by it points to a FPolyline3D, a polyline 3D in
23
         * the FMap model object
24
         * 
25
         * @param pts
26
         *            Array of Point3D that defines the polyline 3D that will be
27
         *            converted in a FPolyline3D
28
         * @return FPolyline3D This FPolyline3D is build using the array of Point3D
29
         *         that is the argument of the method
30
         */
31
        public static FPolyline3D points3DToFPolyline3D(double[][] pts) {
32
                GeneralPathX genPathX = new GeneralPathX();
33
                genPathX.moveTo(pts[0][0], pts[0][1]);
34
                for (int i = 1; i < pts.length; i++) {
35
                        genPathX.lineTo(pts[i][0], pts[i][1]);
36
                }
37
                double[] elevations = new double[pts.length];
38
                for (int i = 0; i < pts.length; i++) {
39
                        elevations[i] = pts[i][2];
40
                }
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
        public static FPolyline2D points2DToFPolyline2D(Point2D[] pts) {
55
                GeneralPathX genPathX = new GeneralPathX();
56
                genPathX.moveTo(pts[0].getX(), pts[0].getY());
57
                for (int i = 1; i < pts.length; i++) {
58
                        genPathX.lineTo(pts[i].getX(), pts[i].getY());
59
                }
60
                return new FPolyline2D(genPathX);
61
        }
62
}