Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.geometry / org.gvsig.fmap.geometry.impl / src / main / java / org / gvsig / fmap / geom / primitive / impl / Curve2D.java @ 40559

History | View | Annotate | Download (3.24 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.primitive.impl;
25

    
26
import java.awt.geom.Line2D;
27
import java.awt.geom.Point2D;
28

    
29
import org.cresques.cts.IProjection;
30

    
31
import org.gvsig.fmap.geom.Geometry;
32
import org.gvsig.fmap.geom.primitive.Curve;
33
import org.gvsig.fmap.geom.primitive.FShape;
34
import org.gvsig.fmap.geom.primitive.GeneralPathX;
35
import org.gvsig.fmap.geom.primitive.Point;
36
import org.gvsig.fmap.geom.type.GeometryType;
37
import org.gvsig.fmap.geom.util.UtilFunctions;
38

    
39
/**
40
 * DOCUMENT ME!
41
 *
42
 * @author Fernando Gonz�lez Cort�s
43
 */
44
public class Curve2D extends DefaultCurve implements Curve {
45
        private static final long serialVersionUID = 8161943328767877860L;
46

    
47
        /**
48
         * The constructor with the GeometryType like and argument 
49
         * is used by the {@link GeometryType}{@link #create()}
50
         * to create the geometry
51
         * @param type
52
         * The geometry type
53
         */
54
        public Curve2D(GeometryType geomType) {
55
                super(geomType);
56
        }
57

    
58
        /**
59
         * Constructor used in the {@link Geometry#cloneGeometry()} method.
60
         * @param geomType
61
         * @param id
62
         * @param projection
63
         * @param gpx
64
         */
65
        public Curve2D(GeometryType geomType, String id, IProjection projection, GeneralPathX gpx) {
66
                super(geomType, id, projection, gpx);
67
                gp=gpx;
68
        }
69

    
70
        /*
71
         * (non-Javadoc)
72
         * @see org.gvsig.fmap.geom.Geometry#getShapeType()
73
         */
74
        public int getShapeType() {
75
                return TYPES.CURVE;
76
        }
77

    
78
        /*
79
         * (non-Javadoc)
80
         * @see org.gvsig.fmap.geom.primitive.FShape#cloneFShape()
81
         */
82
        public FShape cloneFShape() {
83
                return new Curve2D(getGeometryType(), id, projection, (GeneralPathX) gp.clone());
84
        }
85

    
86
        /* (non-Javadoc)
87
         * @see org.gvsig.fmap.geom.primitive.Curve#setPoints(org.gvsig.fmap.geom.primitive.Point, org.gvsig.fmap.geom.primitive.Point)
88
         */
89
        public void setPoints(Point startPoint, Point endPoint) {
90
                Point2D _startPoint = new java.awt.geom.Point2D.Double(startPoint.getCoordinateAt(0), startPoint.getCoordinateAt(1));
91
                Point2D _endPoint = new java.awt.geom.Point2D.Double(endPoint.getCoordinateAt(0), endPoint.getCoordinateAt(1));
92
                setPoints(_startPoint, _endPoint);
93
        }
94

    
95
        /* (non-Javadoc)
96
         * @see org.gvsig.fmap.geom.primitive.Curve#setPoints(java.awt.geom.Point2D, java.awt.geom.Point2D)
97
         */
98
        private void setPoints(Point2D startPoint, Point2D endPoint) {
99
                Line2D line = UtilFunctions.createLine(startPoint, endPoint);
100
                setGeneralPath(new GeneralPathX(line.getPathIterator(null)));
101
        }
102
}