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