Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / primitive / impl / Curve2D.java @ 29097

History | View | Annotate | Download (4.26 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.fmap.geom.primitive.impl;
42

    
43
import java.awt.geom.Line2D;
44
import java.awt.geom.Point2D;
45

    
46
import org.cresques.cts.IProjection;
47
import org.gvsig.fmap.geom.Geometry;
48
import org.gvsig.fmap.geom.primitive.Curve;
49
import org.gvsig.fmap.geom.primitive.FShape;
50
import org.gvsig.fmap.geom.primitive.GeneralPathX;
51
import org.gvsig.fmap.geom.primitive.Point;
52
import org.gvsig.fmap.geom.type.GeometryType;
53
import org.gvsig.fmap.geom.util.UtilFunctions;
54

    
55
/**
56
 * DOCUMENT ME!
57
 *
58
 * @author Fernando Gonz?lez Cort?s
59
 */
60
public class Curve2D extends DefaultCurve implements Curve {
61
        private static final long serialVersionUID = 8161943328767877860L;
62

    
63
        /**
64
         * The constructor with the GeometryType like and argument 
65
         * is used by the {@link GeometryType}{@link #create()}
66
         * to create the geometry
67
         * @param type
68
         * The geometry type
69
         */
70
        public Curve2D(GeometryType geomType) {
71
                super(geomType);
72
        }
73

    
74
        /**
75
         * Constructor used in the {@link Geometry#cloneGeometry()} method.
76
         * @param geomType
77
         * @param id
78
         * @param projection
79
         * @param gpx
80
         */
81
        public Curve2D(GeometryType geomType, String id, IProjection projection, GeneralPathX gpx) {
82
                super(geomType, id, projection, gpx);
83
                gp=gpx;
84
        }
85

    
86
        /*
87
         * (non-Javadoc)
88
         * @see org.gvsig.fmap.geom.Geometry#getShapeType()
89
         */
90
        public int getShapeType() {
91
                return TYPES.CURVE;
92
        }
93

    
94
        /*
95
         * (non-Javadoc)
96
         * @see org.gvsig.fmap.geom.primitive.FShape#cloneFShape()
97
         */
98
        public FShape cloneFShape() {
99
                return new Curve2D(getGeometryType(), id, projection, (GeneralPathX) gp.clone());
100
        }
101

    
102
        /*
103
         * (non-Javadoc)
104
         * @see org.gvsig.fmap.geom.Geometry#getGeneralPath()
105
         */
106
        public GeneralPathX getGeneralPath() {
107
                return gp;
108
        }
109

    
110
        /*
111
         * (non-Javadoc)
112
         * @see org.gvsig.fmap.geom.primitive.impl.DefaultCurve#setGeneralPath(org.gvsig.fmap.geom.primitive.GeneralPathX)
113
         */
114
        public void setGeneralPath(GeneralPathX generalPathX) {
115
                gp = generalPathX;
116
        }
117

    
118
        /* (non-Javadoc)
119
         * @see org.gvsig.fmap.geom.primitive.Curve#setCoordinateAt(int, int, double)
120
         */
121
        public void setCoordinateAt(int index, int dimension, double value) {
122
                throw new UnsupportedOperationException("Use setGeneralPathX");
123
        }
124

    
125
        /* (non-Javadoc)
126
         * @see org.gvsig.fmap.geom.primitive.Curve#setPoints(org.gvsig.fmap.geom.primitive.Point, org.gvsig.fmap.geom.primitive.Point)
127
         */
128
        public void setPoints(Point startPoint, Point endPoint) {
129
                Point2D _startPoint = new java.awt.geom.Point2D.Double(startPoint.getCoordinateAt(0), startPoint.getCoordinateAt(1));
130
                Point2D _endPoint = new java.awt.geom.Point2D.Double(endPoint.getCoordinateAt(0), endPoint.getCoordinateAt(1));
131
                setPoints(_startPoint, _endPoint);
132
        }
133

    
134
        /* (non-Javadoc)
135
         * @see org.gvsig.fmap.geom.primitive.Curve#setPoints(java.awt.geom.Point2D, java.awt.geom.Point2D)
136
         */
137
        private void setPoints(Point2D startPoint, Point2D endPoint) {
138
                Line2D line = UtilFunctions.createLine(startPoint, endPoint);
139
                setGeneralPath(new GeneralPathX(line));
140
        }
141

    
142
        /* (non-Javadoc)
143
         * @see org.gvsig.fmap.geom.primitive.Curve#addPoint(org.gvsig.fmap.geom.primitive.Point)
144
         */
145
        public void addVertex(Point point) {
146
                gp.lineTo(point.getX(), point.getY());
147
        }
148
}