svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / Geometry.java @ 26866
History | View | Annotate | Download (7.8 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; |
42 |
|
43 |
|
44 |
import java.awt.Shape; |
45 |
import java.awt.geom.AffineTransform; |
46 |
import java.awt.geom.PathIterator; |
47 |
import java.awt.geom.Rectangle2D; |
48 |
import java.io.Serializable; |
49 |
|
50 |
import org.cresques.cts.ICoordTrans; |
51 |
import org.gvsig.fmap.geom.handler.Handler; |
52 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
53 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
54 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
55 |
import org.gvsig.fmap.geom.primitive.Envelope; |
56 |
import org.gvsig.fmap.geom.primitive.FShape; |
57 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
58 |
import org.gvsig.fmap.geom.type.GeometryType; |
59 |
|
60 |
|
61 |
/**
|
62 |
* Root interface in the geometry model.
|
63 |
*/
|
64 |
public interface Geometry extends Shape, Serializable, Comparable { |
65 |
|
66 |
/**
|
67 |
* Predefined geometry types in the model
|
68 |
*/
|
69 |
public interface TYPES { |
70 |
/**
|
71 |
* NO DATA geometry.
|
72 |
*/
|
73 |
public final static int NULL = -1; |
74 |
|
75 |
/**
|
76 |
* Any geometry
|
77 |
*/
|
78 |
public final static int GEOMETRY = 0; |
79 |
/**
|
80 |
* A geometric element that has zero dimensions and a location determinable by an ordered set
|
81 |
* of coordinates
|
82 |
*/
|
83 |
public final static int POINT = 1; |
84 |
/**
|
85 |
* A straight or curved geometric element that is generated by a moving point and that has extension
|
86 |
* only along the path of the point.
|
87 |
*/
|
88 |
public final static int CURVE = 2; |
89 |
/**
|
90 |
* A closed plane figure bounded by straight lines.
|
91 |
*/
|
92 |
public final static int SURFACE = 4; |
93 |
/**
|
94 |
* Solids in 3D
|
95 |
*/
|
96 |
public final static int SOLID = 8; |
97 |
/**
|
98 |
* Words, symbols and form of a written or printed work.
|
99 |
*/
|
100 |
public final static int TEXT = 16; |
101 |
/**
|
102 |
* A set that can contain points, lines and polygons. This is usual in <i>CAD</i> layers <i>(dxf, dgn, dwg)</i>.
|
103 |
*/
|
104 |
public final static int AGGREGATE = 32; |
105 |
/**
|
106 |
* A set of points.
|
107 |
*/
|
108 |
public final static int MULTIPOINT = 64; |
109 |
/**
|
110 |
* A set of lines.
|
111 |
*/
|
112 |
public final static int MULTICURVE = 128; |
113 |
/**
|
114 |
* A set of polygons.
|
115 |
*/
|
116 |
public final static int MULTISURFACE = 256; |
117 |
/**
|
118 |
* A set of solids.
|
119 |
*/
|
120 |
public final static int MULTISOLID = 512; |
121 |
/**
|
122 |
* A closed plane curve every point of which is equidistant from a fixed point within the curve.
|
123 |
*/
|
124 |
public final static int CIRCLE = 1024; |
125 |
/**
|
126 |
* A continuous portion (as of a circle or ellipse) of a curved line.
|
127 |
*/
|
128 |
public final static int ARC = 2048; |
129 |
/**
|
130 |
* A closed plane curve generated by a point moving in such a way that the sums of its distances
|
131 |
* from two fixed points is a constant : a plane section of a right circular cone that is a closed
|
132 |
* curve.
|
133 |
*
|
134 |
*/
|
135 |
public final static int ELLIPSE=4096; |
136 |
/**
|
137 |
* Indicates third coordinate. And can be combined with other geometries via the bits enabled.
|
138 |
*/
|
139 |
public final static int Z=8192; |
140 |
|
141 |
public final static int SPLINE = 16384; |
142 |
|
143 |
public final static int ELLIPTICARC = 32768; |
144 |
} |
145 |
|
146 |
public interface SUBTYPES{ |
147 |
public final static int GEOM2D = 0; |
148 |
public final static int GEOM2DZ = 1; |
149 |
public final static int GEOM3D = 2; |
150 |
public final static int GEOM2DM = 3; |
151 |
public final static int GEOM3DM = 4; |
152 |
} |
153 |
|
154 |
/** Initial value for new geometry types (it must not overlap with the basic ones defined in TYPES) */
|
155 |
public static final int EXTENDED_GEOMTYPE_OFFSET = 65536; //2^16; |
156 |
|
157 |
public static int BEST = 0; |
158 |
public static int N = 1; |
159 |
public static int NE = 2; |
160 |
public static int E = 3; |
161 |
public static int SE = 4; |
162 |
public static int S = 5; |
163 |
public static int SW = 6; |
164 |
public static int W = 7; |
165 |
public static int NW = 8; |
166 |
|
167 |
public static int SELECTHANDLER=0; |
168 |
public static int STRETCHINGHANDLER=1; |
169 |
|
170 |
/**
|
171 |
* Returns the FShape type of the geometry.
|
172 |
*
|
173 |
* @return One FShape constant: {@link FShape}
|
174 |
* @deprecated Use {@link getType} instead
|
175 |
*/
|
176 |
public int getShapeType(); |
177 |
|
178 |
/**
|
179 |
* If this geometry is a predefined interface then this method returns one of {@link Geometry.TYPES} contants.<br>
|
180 |
* If this geometry is an extended type then this method returns a runtime constant that identifies its type.
|
181 |
* By convention this value is stored in a constant called .CODE within the geometry class, for instance: Point2D.CODE.
|
182 |
*
|
183 |
* @return If this geometry is a predefined interface then one of {@link Geometry.TYPES} or a runtime constant if
|
184 |
* it is an extended type.
|
185 |
*/
|
186 |
public int getType(); |
187 |
|
188 |
/**
|
189 |
* Creates a clone of this geometry
|
190 |
*
|
191 |
* @return A clone of this geometry.
|
192 |
*/
|
193 |
public Geometry cloneGeometry();
|
194 |
|
195 |
/**
|
196 |
* Returns true if this geometry intersects the rectangle passed as parameter
|
197 |
*
|
198 |
* @param r Rectangle.
|
199 |
*
|
200 |
* @return True, if <code>this</code> intersects <code>r</code>.
|
201 |
*/
|
202 |
public boolean intersects(Rectangle2D r); |
203 |
|
204 |
/**
|
205 |
* Used by the drawing strategies to quickly test whether this geometry
|
206 |
* intersects with the visible rectangle.
|
207 |
*
|
208 |
* @param x
|
209 |
* @param y
|
210 |
* @param w Width
|
211 |
* @param h Height
|
212 |
* @return true if <code>this</code> intersects the rectangle defined by the parameters
|
213 |
*/
|
214 |
public boolean fastIntersects(double x, double y, double w, double h); |
215 |
|
216 |
/**
|
217 |
* Returns this geometry's boundary rectangle.
|
218 |
* @deprecated use getEnvelope.
|
219 |
* @return Boundary rectangle.
|
220 |
*/
|
221 |
public Rectangle2D getBounds2D(); |
222 |
public Envelope getEnvelope();
|
223 |
|
224 |
/**
|
225 |
* Reprojects this geometry by the coordinate transformer passed as parameter.
|
226 |
*
|
227 |
* @param ct Coordinate Transformer.
|
228 |
*/
|
229 |
public void reProject(ICoordTrans ct); |
230 |
|
231 |
/**
|
232 |
* Returns the GeneralPathXIterator with this geometry's information
|
233 |
* @param at AffineTransform
|
234 |
*
|
235 |
* @return PathIterator.
|
236 |
*/
|
237 |
public PathIterator getPathIterator(AffineTransform at); |
238 |
|
239 |
/**
|
240 |
* It returns the handlers of the geometry,
|
241 |
* these they can be of two types is straightening and of selection.
|
242 |
*
|
243 |
* @param type Type of handlers
|
244 |
*
|
245 |
* @return Handlers.
|
246 |
*/
|
247 |
public Handler[] getHandlers(int type); |
248 |
|
249 |
public void transform(AffineTransform at); |
250 |
|
251 |
PathIterator getPathIterator(AffineTransform at, double flatness); |
252 |
|
253 |
/**
|
254 |
* Useful to have the real shape behind the scenes.
|
255 |
* May be uses to edit it knowing it it is a Circle, Ellipse, etc
|
256 |
* @return
|
257 |
*/
|
258 |
public Shape getInternalShape(); |
259 |
|
260 |
public int getDimension(); |
261 |
|
262 |
public boolean isSimple(); |
263 |
|
264 |
/**
|
265 |
* Invokes a geometry operation given its index and context
|
266 |
* @param index unique index of the operation. Operation code.
|
267 |
* @return object returned by the operation.
|
268 |
*/
|
269 |
public Object invokeOperation(int index, GeometryOperationContext ctx) throws GeometryOperationNotSupportedException, GeometryOperationException; |
270 |
|
271 |
/**
|
272 |
* Instance of the GeometryType associated to this geometry
|
273 |
* @return
|
274 |
*/
|
275 |
public GeometryType getGeometryType();
|
276 |
|
277 |
/**
|
278 |
* Get GeneralPathIterator, to do registered operations to it:
|
279 |
*/
|
280 |
public GeneralPathX getGeneralPath();
|
281 |
} |