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 @ 40435
History | View | Annotate | Download (3.49 KB)
1 | 40435 | jjdelcerro | /* 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 | |||
48 | import org.gvsig.fmap.geom.Geometry; |
||
49 | import org.gvsig.fmap.geom.primitive.Curve; |
||
50 | import org.gvsig.fmap.geom.primitive.FShape; |
||
51 | import org.gvsig.fmap.geom.primitive.GeneralPathX; |
||
52 | import org.gvsig.fmap.geom.primitive.Point; |
||
53 | import org.gvsig.fmap.geom.type.GeometryType; |
||
54 | import org.gvsig.fmap.geom.util.UtilFunctions; |
||
55 | |||
56 | /**
|
||
57 | * DOCUMENT ME!
|
||
58 | *
|
||
59 | * @author Fernando Gonz?lez Cort?s
|
||
60 | */
|
||
61 | public class Curve2D extends DefaultCurve implements Curve { |
||
62 | private static final long serialVersionUID = 8161943328767877860L; |
||
63 | |||
64 | /**
|
||
65 | * The constructor with the GeometryType like and argument
|
||
66 | * is used by the {@link GeometryType}{@link #create()}
|
||
67 | * to create the geometry
|
||
68 | * @param type
|
||
69 | * The geometry type
|
||
70 | */
|
||
71 | public Curve2D(GeometryType geomType) {
|
||
72 | super(geomType);
|
||
73 | } |
||
74 | |||
75 | /**
|
||
76 | * Constructor used in the {@link Geometry#cloneGeometry()} method.
|
||
77 | * @param geomType
|
||
78 | * @param id
|
||
79 | * @param projection
|
||
80 | * @param gpx
|
||
81 | */
|
||
82 | public Curve2D(GeometryType geomType, String id, IProjection projection, GeneralPathX gpx) { |
||
83 | super(geomType, id, projection, gpx);
|
||
84 | gp=gpx; |
||
85 | } |
||
86 | |||
87 | /*
|
||
88 | * (non-Javadoc)
|
||
89 | * @see org.gvsig.fmap.geom.Geometry#getShapeType()
|
||
90 | */
|
||
91 | public int getShapeType() { |
||
92 | return TYPES.CURVE;
|
||
93 | } |
||
94 | |||
95 | /*
|
||
96 | * (non-Javadoc)
|
||
97 | * @see org.gvsig.fmap.geom.primitive.FShape#cloneFShape()
|
||
98 | */
|
||
99 | public FShape cloneFShape() {
|
||
100 | return new Curve2D(getGeometryType(), id, projection, (GeneralPathX) gp.clone()); |
||
101 | } |
||
102 | |||
103 | /* (non-Javadoc)
|
||
104 | * @see org.gvsig.fmap.geom.primitive.Curve#setPoints(org.gvsig.fmap.geom.primitive.Point, org.gvsig.fmap.geom.primitive.Point)
|
||
105 | */
|
||
106 | public void setPoints(Point startPoint, Point endPoint) { |
||
107 | Point2D _startPoint = new java.awt.geom.Point2D.Double(startPoint.getCoordinateAt(0), startPoint.getCoordinateAt(1)); |
||
108 | Point2D _endPoint = new java.awt.geom.Point2D.Double(endPoint.getCoordinateAt(0), endPoint.getCoordinateAt(1)); |
||
109 | setPoints(_startPoint, _endPoint); |
||
110 | } |
||
111 | |||
112 | /* (non-Javadoc)
|
||
113 | * @see org.gvsig.fmap.geom.primitive.Curve#setPoints(java.awt.geom.Point2D, java.awt.geom.Point2D)
|
||
114 | */
|
||
115 | private void setPoints(Point2D startPoint, Point2D endPoint) { |
||
116 | Line2D line = UtilFunctions.createLine(startPoint, endPoint);
|
||
117 | setGeneralPath(new GeneralPathX(line.getPathIterator(null))); |
||
118 | } |
||
119 | } |