Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / Geometry.java @ 21081

History | View | Annotate | Download (7 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.FShape;
56
import org.gvsig.fmap.geom.type.GeometryType;
57

    
58
/**
59
 * Root interface in the geometry model.
60
 */
61
public interface Geometry extends Shape, Serializable {
62

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

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

    
144
        public static int SELECTHANDLER=0;
145
        public static int STRETCHINGHANDLER=1;
146

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

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

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

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

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

    
193
        /**
194
         * Returns this geometry's boundary rectangle.
195
         *
196
         * @return Boundary rectangle.
197
         */
198
        public Rectangle2D getBounds2D();
199

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

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

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

    
225
        public void transform(AffineTransform at);
226

    
227
        PathIterator getPathIterator(AffineTransform at, double flatness);
228

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

    
236
        public int getCoordinateDimension();
237

    
238
        public boolean isSimple();
239

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

    
247
        /**
248
         * Instance of the GeometryType associated to this geometry
249
         * @return
250
         */
251
        public GeometryType getGeometryType();
252
        
253
}