svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / primitive / Surface2D.java @ 26866
History | View | Annotate | Download (3.65 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; |
42 |
|
43 |
import java.awt.geom.Rectangle2D; |
44 |
|
45 |
import org.cresques.cts.IProjection; |
46 |
import org.gvsig.fmap.geom.GeometryLocator; |
47 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
48 |
import org.gvsig.fmap.geom.type.GeometryType; |
49 |
|
50 |
/**
|
51 |
* Pol?gono 2D.
|
52 |
*
|
53 |
* @author Vicente Caballero Navarro
|
54 |
*/
|
55 |
public class Surface2D extends OrientableSurface2D implements Surface { |
56 |
|
57 |
private static final long serialVersionUID = 1L; |
58 |
|
59 |
private GeneralPathX generalpathx;
|
60 |
|
61 |
private static GeometryType geomType = GeometryLocator.getGeometryManager() |
62 |
.registerGeometryType(Surface2D.class, null, TYPES.SURFACE, SUBTYPES.GEOM2D);
|
63 |
|
64 |
public static int CODE = geomType.getId(); |
65 |
|
66 |
/**
|
67 |
* Constructor without arguments. It is necessary to create
|
68 |
* geometries using the {@link GeometryType}{@link #create()}
|
69 |
* method
|
70 |
*/
|
71 |
public Surface2D() {
|
72 |
super();
|
73 |
} |
74 |
|
75 |
/**
|
76 |
* Crea un nuevo Polygon2D.
|
77 |
*
|
78 |
* @param gpx
|
79 |
* GeneralPathX.
|
80 |
*/
|
81 |
public Surface2D(String id, IProjection projection, GeneralPathX gpx) { |
82 |
super(id, projection, gpx);
|
83 |
generalpathx=gpx; |
84 |
} |
85 |
|
86 |
public Surface2D(GeneralPathX gpx) {
|
87 |
this(null, null, gpx); |
88 |
generalpathx=gpx; |
89 |
} |
90 |
|
91 |
/**
|
92 |
* @see org.gvsig.fmap.geom.primitive.FShape#getShapeType()
|
93 |
*/
|
94 |
public int getShapeType() { |
95 |
return FShape.POLYGON;
|
96 |
} |
97 |
|
98 |
/**
|
99 |
* Clona FPolygon2D.
|
100 |
*
|
101 |
* @return FShape clonado.
|
102 |
*/
|
103 |
public FShape cloneFShape() {
|
104 |
return new Surface2D(id, projection, (GeneralPathX) gp.clone()); |
105 |
} |
106 |
|
107 |
/*
|
108 |
* (non-Javadoc)
|
109 |
*
|
110 |
* @see java.awt.Shape#intersects(java.awt.geom.Rectangle2D)
|
111 |
*/
|
112 |
public boolean intersects(Rectangle2D r) { |
113 |
return gp.intersects(r);
|
114 |
} |
115 |
|
116 |
public GeometryType getGeometryType() {
|
117 |
return geomType;
|
118 |
} |
119 |
|
120 |
public int getType() { |
121 |
return geomType.getType();
|
122 |
} |
123 |
|
124 |
public GeneralPathX getGeneralPath() {
|
125 |
// TODO Auto-generated method stub
|
126 |
return generalpathx;
|
127 |
} |
128 |
|
129 |
/* (non-Javadoc)
|
130 |
* @see org.gvsig.fmap.geom.primitive.Surface#setGeneralPath(org.gvsig.fmap.geom.primitive.GeneralPathX)
|
131 |
*/
|
132 |
public void setGeneralPath(GeneralPathX generalPathX) { |
133 |
gp = generalPathX; |
134 |
} |
135 |
|
136 |
/* (non-Javadoc)
|
137 |
* @see org.gvsig.fmap.geom.primitive.Surface#setCoordinateAt(int, int, double)
|
138 |
*/
|
139 |
public void setCoordinateAt(int index, int dimension, double value) { |
140 |
throw new UnsupportedOperationException("Use setGeneralPathX"); |
141 |
} |
142 |
|
143 |
/* (non-Javadoc)
|
144 |
* @see org.gvsig.fmap.geom.primitive.Surface#addVertex(org.gvsig.fmap.geom.primitive.Point)
|
145 |
*/
|
146 |
public void addVertex(Point point) { |
147 |
gp.lineTo(point.getX(), point.getY()); |
148 |
} |
149 |
} |