Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / Geometry.java @ 21425

History | View | Annotate | Download (7.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;
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
 * 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
                 * Unknown or not defined type.
71
                 */
72
                public final static int NULL = 0;
73
                /**
74
                 * A geometric element that has zero dimensions and a location determinable by an ordered set
75
                 *  of coordinates
76
                 */
77
                public final static int POINT = 1;
78
                /**
79
                 * A straight or curved geometric element that is generated by a moving point and that has extension
80
                 *  only along the path of the point.
81
                 */
82
                public final static int CURVE = 2;
83
                /**
84
                 * A closed plane figure bounded by straight lines.
85
                 */
86
                public final static int SURFACE = 4;
87
                /**
88
                 * Solids in 3D
89
                 */
90
                public final static int SOLID = 8;
91
                /**
92
                 * Words, symbols and form of a written or printed work.
93
                 */
94
                public final static int TEXT = 16;
95
                /**
96
                 * A set that can contain points, lines and polygons. This is usual in <i>CAD</i> layers <i>(dxf, dgn, dwg)</i>.
97
                 */
98
                public final static int AGGREGATE = 32;
99
                /**
100
                 * A set of points.
101
                 */
102
                public final static int MULTIPOINT = 64;
103
                /**
104
                 * A set of lines.
105
                 */
106
                public final static int MULTICURVE = 128;
107
                /**
108
                 * A set of polygons.
109
                 */
110
                public final static int MULTISURFACE = 256;
111
                /**
112
                 * A set of solids.
113
                 */
114
                public final static int MULTISOLID = 512;
115
                /**
116
                 * A closed plane curve every point of which is equidistant from a fixed point within the curve.
117
                 */
118
                public final static int CIRCLE = 1024;
119
                /**
120
                 * A continuous portion (as of a circle or ellipse) of a curved line.
121
                 */
122
                public final static int ARC = 2048;
123
                /**
124
                 *  A closed plane curve generated by a point moving in such a way that the sums of its distances
125
                 *   from two fixed points is a constant : a plane section of a right circular cone that is a closed
126
                 *   curve.
127
                 *
128
                 */
129
                public final static int ELLIPSE=4096;
130
                /**
131
                 * Indicates third coordinate. And can be combined with other geometries via the bits enabled.
132
                 */
133
                public final static int Z=8192;
134
        }
135

    
136
        public static int BEST = 0;
137
        public static int N = 1;
138
        public static int NE = 2;
139
        public static int E = 3;
140
        public static int SE = 4;
141
        public static int S = 5;
142
        public static int SW = 6;
143
        public static int W = 7;
144
        public static int NW = 8;
145

    
146
        public static int SELECTHANDLER=0;
147
        public static int STRETCHINGHANDLER=1;
148

    
149
        /**
150
         * Returns the FShape type of the geometry.
151
         *
152
         * @return One FShape constant: {@link FShape}
153
         * @deprecated Use {@link getType} instead
154
         */
155
        public int getShapeType();
156

    
157
        /**
158
         * If this geometry is a predefined interface then this method returns one of {@link Geometry.TYPES} contants.<br>
159
         * If this geometry is an extended type then this method returns a runtime constant that identifies its type.
160
         * By convention this value is stored in a constant called .CODE within the geometry class, for instance: Point2D.CODE.
161
         *
162
         * @return If this geometry is a predefined interface then one of {@link Geometry.TYPES} or a runtime constant if
163
         * it is an extended type.
164
         */
165
        public int getType();
166

    
167
        /**
168
         * Creates a clone of this geometry
169
         *
170
         * @return A clone of this geometry.
171
         */
172
        public Geometry cloneGeometry();
173

    
174
        /**
175
         * Returns true if this geometry intersects the rectangle passed as parameter
176
         *
177
         * @param r Rectangle.
178
         *
179
         * @return True, if <code>this</code> intersects <code>r</code>.
180
         */
181
        public boolean intersects(Rectangle2D r);
182

    
183
        /**
184
         * Used by the drawing strategies to quickly test whether this geometry
185
         * intersects with the visible rectangle.
186
         *
187
         * @param x
188
         * @param y
189
         * @param w Width
190
         * @param h Height
191
         * @return true if <code>this</code> intersects the rectangle defined by the parameters
192
         */
193
        public boolean fastIntersects(double x, double y, double w, double h);
194

    
195
        /**
196
         * Returns this geometry's boundary rectangle.
197
         * @deprecated use getEnvelope.
198
         * @return Boundary rectangle.
199
         */
200
        public Rectangle2D getBounds2D();
201
        public Envelope getEnvelope();
202

    
203
        /**
204
         * Reprojects this geometry by the coordinate transformer passed as parameter.
205
         *
206
         * @param ct Coordinate Transformer.
207
         */
208
        public void reProject(ICoordTrans ct);
209

    
210
        /**
211
         * Returns the GeneralPathXIterator with this geometry's information
212
         * @param at AffineTransform
213
         *
214
         * @return PathIterator.
215
         */
216
        public PathIterator getPathIterator(AffineTransform at);
217

    
218
    /**
219
         * It returns the handlers of the geometry,
220
         * these they can be of two types is straightening and of selection.
221
         *
222
         * @param type Type of handlers
223
         *
224
         * @return Handlers.
225
         */
226
        public Handler[] getHandlers(int type);
227

    
228
        public void transform(AffineTransform at);
229

    
230
        PathIterator getPathIterator(AffineTransform at, double flatness);
231

    
232
        /**
233
         * Useful to have the real shape behind the scenes.
234
         * May be uses to edit it knowing it it is a Circle, Ellipse, etc
235
         * @return
236
         */
237
        public Shape getInternalShape();
238

    
239
        public int getCoordinateDimension();
240

    
241
        public boolean isSimple();
242

    
243
        /**
244
         * Invokes a geometry operation given its index and context
245
         * @param index unique index of the operation. Operation code.
246
         * @return object returned by the operation.
247
         */
248
        public Object invokeOperation(int index, GeometryOperationContext ctx) throws GeometryOperationNotSupportedException, GeometryOperationException;
249

    
250
        /**
251
         * Instance of the GeometryType associated to this geometry
252
         * @return
253
         */
254
        public GeometryType getGeometryType();
255

    
256
        /**
257
         * Get GeneralPathIterator, to do registered operations to it:
258
         */
259
        public GeneralPathX getGeneralPath();
260
}