svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.geometry / org.gvsig.fmap.geometry.api / src / main / java / org / gvsig / fmap / geom / Geometry.java @ 41439
History | View | Annotate | Download (23.8 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
|
25 |
package org.gvsig.fmap.geom; |
26 |
|
27 |
import java.awt.Shape; |
28 |
import java.awt.geom.AffineTransform; |
29 |
import java.awt.geom.PathIterator; |
30 |
import java.awt.geom.Rectangle2D; |
31 |
import java.io.Serializable; |
32 |
|
33 |
import org.cresques.cts.ICoordTrans; |
34 |
|
35 |
import org.gvsig.fmap.geom.handler.Handler; |
36 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
37 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
38 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
39 |
import org.gvsig.fmap.geom.primitive.Envelope; |
40 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
41 |
import org.gvsig.fmap.geom.primitive.Point; |
42 |
import org.gvsig.fmap.geom.type.GeometryType; |
43 |
|
44 |
/**
|
45 |
* <p>
|
46 |
* This interface is equivalent to the GM_Object specified in <a href="http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=26012"
|
47 |
* >ISO 19107</a>. It is the root class of the geometric object taxonomy and
|
48 |
* supports interfaces common to all geographically referenced geometric
|
49 |
* objects.
|
50 |
* </p>
|
51 |
* <p>
|
52 |
* Geometry instances are sets of direct positions in a particular coordinate
|
53 |
* reference system. A Geometry can be regarded as an infinite set of points
|
54 |
* that satisfies the set operation interfaces for a set of direct positions.
|
55 |
* </p>
|
56 |
* <p>
|
57 |
* A geometric object shall be a combination of a coordinate geometry and a
|
58 |
* coordinate reference system. In all of the operations, all geometric
|
59 |
* calculations shall be done in the coordinate reference system of the first
|
60 |
* geometric object accessed, which is normally the object whose operation is
|
61 |
* being invoked. Returned objects shall be in the coordinate reference system
|
62 |
* in which the calculations are done unless explicitly stated otherwise.
|
63 |
* </p>
|
64 |
* <p>
|
65 |
* This class extends of the {@link Shape} class by historical reasons but this
|
66 |
* inheritance will disappear in future versions.
|
67 |
* </p>
|
68 |
* @see <a href="http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=26012"
|
69 |
* >ISO 19107< /a>
|
70 |
*/
|
71 |
public interface Geometry extends Shape, Serializable, Comparable { |
72 |
|
73 |
/**
|
74 |
* Predefined geometry types in the model.
|
75 |
*/
|
76 |
public interface TYPES { |
77 |
|
78 |
/**
|
79 |
* Any geometry.
|
80 |
*/
|
81 |
|
82 |
public final static int GEOMETRY = 0; |
83 |
|
84 |
/**
|
85 |
* A geometric element that has zero dimensions and a location
|
86 |
* determinable by an ordered set of coordinates.
|
87 |
*/
|
88 |
public final static int POINT = 1; |
89 |
|
90 |
/**
|
91 |
* A straight or curved geometric element that is generated by a moving
|
92 |
* point and that has extension only along the path of the point.
|
93 |
*/
|
94 |
public final static int CURVE = 2; |
95 |
|
96 |
/**
|
97 |
* A closed plane figure bounded by straight lines.
|
98 |
*/
|
99 |
public final static int SURFACE = 3; |
100 |
|
101 |
/**
|
102 |
* Solids in 3D.
|
103 |
*/
|
104 |
public final static int SOLID = 4; |
105 |
|
106 |
/**
|
107 |
* A set that can contain points, lines and polygons. This is usual in
|
108 |
* <i>CAD</i> layers <i>(dxf, dgn, dwg)</i>.
|
109 |
*/
|
110 |
public final static int AGGREGATE = 6; |
111 |
/**
|
112 |
* A set of points.
|
113 |
*/
|
114 |
public final static int MULTIPOINT = 7; |
115 |
|
116 |
/**
|
117 |
* A set of lines.
|
118 |
*/
|
119 |
public final static int MULTICURVE = 8; |
120 |
|
121 |
/**
|
122 |
* A set of polygons.
|
123 |
*/
|
124 |
public final static int MULTISURFACE = 9; |
125 |
|
126 |
/**
|
127 |
* A set of solids.
|
128 |
*/
|
129 |
public final static int MULTISOLID = 10; |
130 |
|
131 |
/**
|
132 |
* A closed plane curve every point of which is equidistant from a fixed
|
133 |
* point within the curve.
|
134 |
*/
|
135 |
public final static int CIRCLE = 11; |
136 |
|
137 |
/**
|
138 |
* A continuous portion (as of a circle or ellipse) of a curved line.
|
139 |
*/
|
140 |
public final static int ARC = 12; |
141 |
|
142 |
/**
|
143 |
* A closed plane curve generated by a point moving in such a way that
|
144 |
* the sums of its distances from two fixed points is a constant : a
|
145 |
* plane section of a right circular cone that is a closed curve.
|
146 |
*/
|
147 |
public final static int ELLIPSE = 13; |
148 |
|
149 |
public final static int SPLINE = 14; |
150 |
|
151 |
public final static int ELLIPTICARC = 15; |
152 |
|
153 |
/**
|
154 |
* NO DATA geometry.
|
155 |
*/
|
156 |
public final static int NULL = 16; |
157 |
|
158 |
public final static int COMPLEX = 17; |
159 |
} |
160 |
|
161 |
public interface DIMENSIONS { |
162 |
public final static int X = 0; |
163 |
public final static int Y = 1; |
164 |
public final static int Z = 2; |
165 |
} |
166 |
|
167 |
/**
|
168 |
* The subtype of a geometry is related with the dimension of the geometry,
|
169 |
* that is a combination between the spatial dimension (2D, 2ZD, 3D) and the
|
170 |
* M coordinate or "measure".
|
171 |
*
|
172 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
173 |
*/
|
174 |
public interface SUBTYPES { |
175 |
|
176 |
/**
|
177 |
* Geometries with two dimensions.
|
178 |
*/
|
179 |
public final static int GEOM2D = 0; |
180 |
|
181 |
/**
|
182 |
* Geometries with three dimensions.
|
183 |
*/
|
184 |
public final static int GEOM3D = 1; |
185 |
|
186 |
/**
|
187 |
* Geometries with two dimensions and with the M coordinate.
|
188 |
*/
|
189 |
public final static int GEOM2DM = 2; |
190 |
|
191 |
/**
|
192 |
* Geometries with three dimensions and with the M coordinate.
|
193 |
*/
|
194 |
public final static int GEOM3DM = 3; |
195 |
|
196 |
/**
|
197 |
* The subtype us unknown.
|
198 |
*/
|
199 |
public final static int UNKNOWN = 4; |
200 |
} |
201 |
|
202 |
/**
|
203 |
* Initial value for new geometry types (it must not overlap with the basic
|
204 |
* ones defined in TYPES).
|
205 |
*/
|
206 |
public static final int EXTENDED_GEOMTYPE_OFFSET = 17; |
207 |
|
208 |
/**
|
209 |
* Initial value for new geometry subtypes (it must not overlap with the
|
210 |
* basic ones defined in SUBTYPES).
|
211 |
*/
|
212 |
public static final int EXTENDED_GEOMSUBTYPE_OFFSET = 6; |
213 |
|
214 |
public interface OPERATIONS { |
215 |
public final static String CONVERTTOWKT = "toWKT"; |
216 |
public final static String CONVERTTOWKB = "toWKB"; |
217 |
public final static String BUFFER = "buffer"; |
218 |
public final static String DISTANCE = "Distance"; |
219 |
public final static String CONTAINS = "Contains"; |
220 |
public final static String OVERLAPS = "OVERLAPS"; |
221 |
public final static String CONVEXHULL = "ConvexHull"; |
222 |
public final static String COVERS = "Covers"; |
223 |
public final static String CROSSES = "Crosses"; |
224 |
public final static String DIFFERENCE = "Difference"; |
225 |
public final static String DISJOIN = "Disjoin"; |
226 |
public final static String INTERSECTION = "Intersaction"; |
227 |
public final static String INTERSECTS = "Intersects"; |
228 |
public final static String TOUCHES = "Touches"; |
229 |
public final static String UNION = "Union"; |
230 |
public final static String WITHIN = "Within"; |
231 |
public final static String COVEREDBY = "CoveredBy"; |
232 |
} |
233 |
|
234 |
public interface ValidationStatus { |
235 |
|
236 |
public static final int VALID = 0; |
237 |
public static final int CURRUPTED = 1; |
238 |
public static final int UNKNOW = 2; |
239 |
public static final int DISCONNECTED_INTERIOR = 10; |
240 |
public static final int DUPLICATE_RINGS = 11; |
241 |
public static final int HOLE_OUTSIDE_SHELL = 12; |
242 |
public static final int INVALID_COORDINATE = 13; |
243 |
public static final int NESTED_HOLES = 14; |
244 |
public static final int NESTED_SHELLS = 15; |
245 |
public static final int RING_NOT_CLOSED = 17; |
246 |
public static final int RING_SELF_INTERSECTION = 18; |
247 |
public static final int SELF_INTERSECTION = 19; |
248 |
public static final int TOO_FEW_POINTS = 20; |
249 |
|
250 |
/**
|
251 |
* True if the geoemtry are valid.
|
252 |
*
|
253 |
* @return true form valid geometries
|
254 |
*/
|
255 |
public boolean isValid(); |
256 |
|
257 |
/**
|
258 |
* Return the status code results of validate the geometry.
|
259 |
*
|
260 |
* @return validation code
|
261 |
*/
|
262 |
public int getStatusCode(); |
263 |
|
264 |
/**
|
265 |
* Return the nearest point to the problem when validate the geometry.
|
266 |
*
|
267 |
* If the geometry is valid, this return null.
|
268 |
*
|
269 |
* @return the nearest point to the problem or null.
|
270 |
*/
|
271 |
public Point getProblemLocation(); |
272 |
|
273 |
/**
|
274 |
* Return a human readable message explaining the cause of the problem.
|
275 |
*
|
276 |
* If the geometry is valid this is null.
|
277 |
*
|
278 |
* @return the message cause of the problem.
|
279 |
*/
|
280 |
public String getMessage(); |
281 |
} |
282 |
|
283 |
public static int BEST = 0; |
284 |
/**
|
285 |
* North.
|
286 |
*/
|
287 |
public static int N = 1; |
288 |
|
289 |
/**
|
290 |
* North - East.
|
291 |
*/
|
292 |
public static int NE = 2; |
293 |
|
294 |
/**
|
295 |
* East.
|
296 |
*/
|
297 |
public static int E = 3; |
298 |
|
299 |
/**
|
300 |
* South - East.
|
301 |
*/
|
302 |
public static int SE = 4; |
303 |
|
304 |
/**
|
305 |
* South.
|
306 |
*/
|
307 |
public static int S = 5; |
308 |
|
309 |
/**
|
310 |
* South - West.
|
311 |
*/
|
312 |
public static int SW = 6; |
313 |
|
314 |
/**
|
315 |
* West.
|
316 |
*/
|
317 |
public static int W = 7; |
318 |
|
319 |
/**
|
320 |
* North - West.
|
321 |
*/
|
322 |
public static int NW = 8; |
323 |
|
324 |
public static int SELECTHANDLER = 0; |
325 |
public static int STRETCHINGHANDLER = 1; |
326 |
|
327 |
/**
|
328 |
* If this geometry is a predefined interface then this method returns one
|
329 |
* of {@link Geometry.TYPES} contants.<br>
|
330 |
* If this geometry is an extended type then this method returns a runtime
|
331 |
* constant that identifies its type. By convention this value is stored in
|
332 |
* a constant called .CODE within the geometry class, for instance:
|
333 |
* Point2D.CODE.
|
334 |
*
|
335 |
* @return If this geometry is a predefined interface then one of
|
336 |
* {@link Geometry.TYPES} or a runtime constant if it is an extended
|
337 |
* type.
|
338 |
*/
|
339 |
public int getType(); |
340 |
|
341 |
/**
|
342 |
* Creates a clone of this geometry.
|
343 |
*
|
344 |
* @return A clone of this geometry.
|
345 |
*/
|
346 |
public Geometry cloneGeometry();
|
347 |
|
348 |
/**
|
349 |
* Returns true if this geometry intersects the rectangle passed as
|
350 |
* parameter.
|
351 |
*
|
352 |
* @param r
|
353 |
* Rectangle.
|
354 |
*
|
355 |
* @return True, if <code>this</code> intersects <code>r</code>.
|
356 |
*/
|
357 |
public boolean intersects(Rectangle2D r); |
358 |
|
359 |
/**
|
360 |
* Used by the drawing strategies to quickly test whether this geometry
|
361 |
* intersects with the visible rectangle.
|
362 |
*
|
363 |
* @param x
|
364 |
* The minimum X coordinate.
|
365 |
* @param y
|
366 |
* The minimum Y coordinate.
|
367 |
* @param w
|
368 |
* The width of the envelope.
|
369 |
* @param h
|
370 |
* The height of the envelope.
|
371 |
* @return true if <code>this</code> intersects the rectangle defined by the
|
372 |
* parameters.
|
373 |
*/
|
374 |
public boolean fastIntersects(double x, double y, double w, double h); |
375 |
|
376 |
/**
|
377 |
* <p>
|
378 |
* Returns the minimum bounding box for this Geometry. This shall be the
|
379 |
* coordinate region spanning the minimum and maximum value for each
|
380 |
* ordinate taken on by DirectPositions in this Geometry. The simplest
|
381 |
* representation for an envelope consists of two DirectPositions, the first
|
382 |
* one containing all the minimums for each ordinate, and second one
|
383 |
* containing all the maximums.
|
384 |
* </p>
|
385 |
*
|
386 |
* @return The minimum bounding box for this Geometry.
|
387 |
*/
|
388 |
public Envelope getEnvelope();
|
389 |
|
390 |
/**
|
391 |
* Reprojects this geometry by the coordinate transformer passed as
|
392 |
* parameter.
|
393 |
*
|
394 |
* @param ct
|
395 |
* Coordinate Transformer.
|
396 |
*/
|
397 |
public void reProject(ICoordTrans ct); |
398 |
|
399 |
/**
|
400 |
* It applies an affine transformation to the geometry.
|
401 |
* If parameter value is null, it will be considered an
|
402 |
* empty transformation, therefore equivalent to the identity
|
403 |
* transformation.
|
404 |
*
|
405 |
* @param at
|
406 |
* The transformation to apply.
|
407 |
*/
|
408 |
public void transform(AffineTransform at); |
409 |
/**
|
410 |
* Returns the largest number n such that each direct position in a
|
411 |
* geometric set can be associated with a subset that has the direct
|
412 |
* position in its interior and is similar (isomorphic) to Rn, Euclidean
|
413 |
* n-space.
|
414 |
*
|
415 |
* @return The dimension.
|
416 |
*/
|
417 |
public int getDimension(); |
418 |
|
419 |
/**
|
420 |
* Returns <code>true</code> if this Geometry has no interior point of
|
421 |
* self-intersection or self-tangency. In mathematical formalisms, this
|
422 |
* means that every point in the interior of the object must have a metric
|
423 |
* neighborhood whose intersection with the object is isomorphic to an
|
424 |
* n-sphere, where n is the dimension of this Geometry.
|
425 |
*
|
426 |
* @return If the geometry is simple.
|
427 |
*/
|
428 |
public boolean isSimple(); |
429 |
|
430 |
/**
|
431 |
* Invokes a geometry operation given its index and context.
|
432 |
*
|
433 |
* @param index
|
434 |
* Unique index of the operation. Operation code.
|
435 |
* @param ctx
|
436 |
* The context of the geometry operation.
|
437 |
* @return Object returned by the operation.
|
438 |
* @throws GeometryOperationNotSupportedException
|
439 |
* It is thrown when the operation has been not registered for
|
440 |
* this geometry.
|
441 |
* @throws GeometryOperationException
|
442 |
* It is thrown when there is an error executing the operation.
|
443 |
*/
|
444 |
public Object invokeOperation(int index, GeometryOperationContext ctx) |
445 |
throws GeometryOperationNotSupportedException,
|
446 |
GeometryOperationException; |
447 |
|
448 |
/**
|
449 |
* Invokes a geometry operation given its name and context.
|
450 |
*
|
451 |
* @param opName
|
452 |
* Operation name.
|
453 |
* @param ctx
|
454 |
* The context of the geometry operation.
|
455 |
* @return Object returned by the operation.
|
456 |
* @throws GeometryOperationNotSupportedException
|
457 |
* It is thrown when the operation has been not registered for
|
458 |
* this geometry.
|
459 |
* @throws GeometryOperationException
|
460 |
* It is thrown when there is an error executing the operation.
|
461 |
*/
|
462 |
public Object invokeOperation(String opName, GeometryOperationContext ctx) |
463 |
throws GeometryOperationNotSupportedException,
|
464 |
GeometryOperationException; |
465 |
|
466 |
/**
|
467 |
* Instance of the GeometryType associated to this geometry.
|
468 |
*
|
469 |
* @return The geometry type.
|
470 |
*/
|
471 |
public GeometryType getGeometryType();
|
472 |
|
473 |
/**
|
474 |
* Return a byte array with the equivalent in WKB format of the Geometry.
|
475 |
*
|
476 |
* Utility method to wrap the invocation to the operation
|
477 |
* {@link OPERATIONS#CONVERTTOWKB}.
|
478 |
*
|
479 |
* @return the WKB version of the geometry
|
480 |
*/
|
481 |
public byte[] convertToWKB() throws GeometryOperationNotSupportedException, |
482 |
GeometryOperationException; |
483 |
|
484 |
public byte[] convertToWKB(int srs) |
485 |
throws GeometryOperationNotSupportedException, GeometryOperationException;
|
486 |
|
487 |
public byte[] convertToWKBForcingType(int srs, int type) |
488 |
throws GeometryOperationNotSupportedException, GeometryOperationException;
|
489 |
|
490 |
/**
|
491 |
* Return a string with the equivalent in WKT format of the Geometry.
|
492 |
*
|
493 |
* This is a utility method to wrap the invocation to the operation
|
494 |
* {@link OPERATIONS#CONVERTTOWKT}.
|
495 |
*
|
496 |
* @return the WKT version of the geometry.
|
497 |
*
|
498 |
* @throws GeometryOperationNotSupportedException
|
499 |
* @throws GeometryOperationException
|
500 |
*/
|
501 |
public String convertToWKT() throws GeometryOperationNotSupportedException, |
502 |
GeometryOperationException; |
503 |
|
504 |
/**
|
505 |
* Computes a buffer area around this geometry having the given width
|
506 |
*
|
507 |
* This is a utility method to wrap the invocation to the operation
|
508 |
* {@link OPERATIONS#BUFFER}.
|
509 |
*
|
510 |
* @param distance
|
511 |
* the width of the buffer
|
512 |
*
|
513 |
* @return a new Geometry with the computed buffer.
|
514 |
*
|
515 |
* @throws GeometryOperationNotSupportedException
|
516 |
* @throws GeometryOperationException
|
517 |
*/
|
518 |
public Geometry buffer(double distance) |
519 |
throws GeometryOperationNotSupportedException,
|
520 |
GeometryOperationException; |
521 |
|
522 |
/**
|
523 |
* Tests whether this geometry contains the specified geometry.
|
524 |
*
|
525 |
* This is a utility method to wrap the invocation to the operation
|
526 |
* {@link OPERATIONS#CONTAINS}.
|
527 |
*
|
528 |
* @param geometry
|
529 |
* the Geometry with which to compare this Geometry
|
530 |
*
|
531 |
* @return if this Geometry contains the specified geometry
|
532 |
*
|
533 |
* @throws GeometryOperationNotSupportedException
|
534 |
* @throws GeometryOperationException
|
535 |
*/
|
536 |
public boolean contains(Geometry geometry) |
537 |
throws GeometryOperationNotSupportedException,
|
538 |
GeometryOperationException; |
539 |
|
540 |
/**
|
541 |
* Returns the minimum distance between this Geometry and the specified
|
542 |
* geometry.
|
543 |
*
|
544 |
* This is a utility method to wrap the invocation to the operation
|
545 |
* {@link OPERATIONS#DISTANCE}.
|
546 |
*
|
547 |
* @param geometry
|
548 |
* the Geometry from which to compute the distance
|
549 |
*
|
550 |
* @return the distance between the geometries
|
551 |
*
|
552 |
* @throws GeometryOperationNotSupportedException
|
553 |
* @throws GeometryOperationException
|
554 |
*/
|
555 |
public double distance(Geometry other) |
556 |
throws GeometryOperationNotSupportedException,
|
557 |
GeometryOperationException; |
558 |
|
559 |
public Geometry[] closestPoints(Geometry other) |
560 |
throws GeometryOperationNotSupportedException,
|
561 |
GeometryOperationException; |
562 |
|
563 |
boolean isWithinDistance(Geometry other, double distance) |
564 |
throws GeometryOperationNotSupportedException,
|
565 |
GeometryOperationException; |
566 |
|
567 |
/**
|
568 |
* Tests whether this geometry overlaps the specified geometry.
|
569 |
*
|
570 |
* This is a utility method to wrap the invocation to the operation
|
571 |
* {@link OPERATIONS#OVERLAPS}.
|
572 |
*
|
573 |
* @param geometry
|
574 |
* the Geometry with which to compare this Geometry
|
575 |
*
|
576 |
* @return true if the two geometries overlap.
|
577 |
*
|
578 |
* @throws GeometryOperationNotSupportedException
|
579 |
* @throws GeometryOperationException
|
580 |
*/
|
581 |
public boolean overlaps(Geometry geometry) |
582 |
throws GeometryOperationNotSupportedException,
|
583 |
GeometryOperationException; |
584 |
|
585 |
public Geometry convexHull() throws GeometryOperationNotSupportedException, |
586 |
GeometryOperationException; |
587 |
|
588 |
public boolean coveredBy(Geometry geometry) |
589 |
throws GeometryOperationNotSupportedException,
|
590 |
GeometryOperationException; |
591 |
|
592 |
public boolean covers(Geometry geometry) |
593 |
throws GeometryOperationNotSupportedException,
|
594 |
GeometryOperationException; |
595 |
|
596 |
public boolean crosses(Geometry geometry) |
597 |
throws GeometryOperationNotSupportedException,
|
598 |
GeometryOperationException; |
599 |
|
600 |
public Geometry difference(Geometry other)
|
601 |
throws GeometryOperationNotSupportedException,
|
602 |
GeometryOperationException; |
603 |
|
604 |
public boolean disjoint(Geometry geometry) |
605 |
throws GeometryOperationNotSupportedException,
|
606 |
GeometryOperationException; |
607 |
|
608 |
public Geometry intersection(Geometry other)
|
609 |
throws GeometryOperationNotSupportedException,
|
610 |
GeometryOperationException; |
611 |
|
612 |
public boolean intersects(Geometry geometry) |
613 |
throws GeometryOperationNotSupportedException,
|
614 |
GeometryOperationException; |
615 |
|
616 |
public Geometry snapTo(Geometry other, double snapTolerance) |
617 |
throws GeometryOperationNotSupportedException,
|
618 |
GeometryOperationException; |
619 |
|
620 |
public boolean touches(Geometry geometry) |
621 |
throws GeometryOperationNotSupportedException,
|
622 |
GeometryOperationException; |
623 |
|
624 |
public Geometry union(Geometry other)
|
625 |
throws GeometryOperationNotSupportedException,
|
626 |
GeometryOperationException; |
627 |
|
628 |
public boolean within(Geometry geometry) |
629 |
throws GeometryOperationNotSupportedException,
|
630 |
GeometryOperationException; |
631 |
|
632 |
public Point centroid() throws GeometryOperationNotSupportedException, GeometryOperationException; |
633 |
|
634 |
/**
|
635 |
* This method returns a point which is inside the geometry.
|
636 |
* This is useful for mathematical purposes but it is very unlikely
|
637 |
* to be a suitable place for a label, for example.
|
638 |
*
|
639 |
*
|
640 |
* @return an interior point
|
641 |
* @throws GeometryOperationNotSupportedException
|
642 |
* @throws GeometryOperationException
|
643 |
*/
|
644 |
public Point getInteriorPoint() throws GeometryOperationNotSupportedException, GeometryOperationException; |
645 |
|
646 |
public double area() throws GeometryOperationNotSupportedException, GeometryOperationException; |
647 |
|
648 |
public double perimeter() throws GeometryOperationNotSupportedException, GeometryOperationException; |
649 |
|
650 |
|
651 |
|
652 |
|
653 |
/**
|
654 |
* Rotates the geometry by radAngle radians using the given
|
655 |
* coordinates as center of rotation. Rotating with a positive
|
656 |
* angle rotates points on the positive x axis toward the
|
657 |
* positive y axis. In most cases, we assume x increases
|
658 |
* rightwards and y increases upwards, so in most cases,
|
659 |
* a positive angle will mean counter-clockwise rotation.
|
660 |
*
|
661 |
* @param radAngle the amount of rotation, in radians
|
662 |
* @param basex x coordinate of center of rotation
|
663 |
* @param basey y coordinate of center of rotation
|
664 |
*/
|
665 |
public void rotate(double radAngle, double basex, double basey); |
666 |
|
667 |
/**
|
668 |
* Shifts geometry by given amount in x and y axes
|
669 |
*
|
670 |
* @param dx
|
671 |
* @param dy
|
672 |
*/
|
673 |
public void move(double dx, double dy); |
674 |
|
675 |
|
676 |
/**
|
677 |
* Scales geometry in x and y axes by given scale factors
|
678 |
* using the given point as center of projection.
|
679 |
*
|
680 |
* @param basePoint
|
681 |
* @param sx scale factor in x axis
|
682 |
* @param sy scale factor in y axis
|
683 |
*/
|
684 |
public void scale(Point basePoint, double sx, double sy); |
685 |
|
686 |
/**
|
687 |
* Check if the geometry is valid.
|
688 |
*
|
689 |
* @return true if the geometry is valid.
|
690 |
*/
|
691 |
public boolean isValid(); |
692 |
|
693 |
/**
|
694 |
* Check if the geometry is valid and returns the validation status.
|
695 |
*
|
696 |
* @return the ValidationStatus
|
697 |
*/
|
698 |
public ValidationStatus getValidationStatus();
|
699 |
|
700 |
//
|
701 |
// ===============================================
|
702 |
//
|
703 |
|
704 |
|
705 |
/**
|
706 |
* @return the awt shape used to display the geometry. It
|
707 |
* applies a tranformation before to return the coordinates
|
708 |
* of the shape
|
709 |
* @deprecated this class inherits of {@link Shape} by historical
|
710 |
* reasons. This method has been added just to control the usage of
|
711 |
* the {@link Shape} class but it will removed in a future.
|
712 |
*/
|
713 |
public Shape getShape(AffineTransform affineTransform); |
714 |
|
715 |
/**
|
716 |
* @return the awt shape used to display the geometry.
|
717 |
* @deprecated this class inherits of {@link Shape} by historical
|
718 |
* reasons. This method has been added just to control the usage of
|
719 |
* the {@link Shape} class but it will removed in a future.
|
720 |
*/
|
721 |
public Shape getShape(); |
722 |
|
723 |
/**
|
724 |
* Returns this geometry's boundary rectangle.
|
725 |
*
|
726 |
* @deprecated use getEnvelope.
|
727 |
* @return Boundary rectangle.
|
728 |
*/
|
729 |
public Rectangle2D getBounds2D(); |
730 |
|
731 |
/**
|
732 |
* If applies an affine transformation and returns the GeneralPathXIterator
|
733 |
* with this geometry's information.
|
734 |
*
|
735 |
* @param at
|
736 |
* The transformation to apply.
|
737 |
* @return The GeneralPathXIterator with this geometry's information.
|
738 |
* @deprecated don't use PathIterator over geometries, use instead specific API for each operation. If not has API for that operation let the project team.
|
739 |
*
|
740 |
*/
|
741 |
public PathIterator getPathIterator(AffineTransform at); |
742 |
|
743 |
/**
|
744 |
* It returns the handlers of the geometry, these they can be of two types
|
745 |
* is straightening and of selection.
|
746 |
*
|
747 |
* @param type
|
748 |
* Type of handlers.
|
749 |
*
|
750 |
* @deprecated don't use Handlers over geometries, use instead specific API for each operation. If not has API for that operation let the project team.
|
751 |
* @return The handlers.
|
752 |
*/
|
753 |
public Handler[] getHandlers(int type); |
754 |
|
755 |
|
756 |
/**
|
757 |
* If applies an affine transformation and returns the GeneralPathXIterator
|
758 |
* with this geometry's information.
|
759 |
*
|
760 |
* @param at
|
761 |
* The affine transformation.
|
762 |
* @param flatness
|
763 |
*
|
764 |
* @return The GeneralPathXIterator with this geometry's information.
|
765 |
* @deprecated don't use PathIterator over geometries, use instead specific API for each operation. If not has API for that operation let the project team.
|
766 |
*/
|
767 |
PathIterator getPathIterator(AffineTransform at, double flatness); |
768 |
|
769 |
/**
|
770 |
* Useful to have the real shape behind the scenes. May be uses to edit it
|
771 |
* knowing it it is a Circle, Ellipse, etc.
|
772 |
*
|
773 |
* @return The awt shape
|
774 |
* @deprecated
|
775 |
*/
|
776 |
public Shape getInternalShape(); |
777 |
|
778 |
|
779 |
/**
|
780 |
* Get GeneralPathIterator, to do registered operations to it.
|
781 |
*
|
782 |
* @return The GeneralPathX.
|
783 |
* @deprecated don't use GeneralPathX over geometries, use instead specific API for each operation. If not has API for that operation let the project team.
|
784 |
*/
|
785 |
public GeneralPathX getGeneralPath();
|
786 |
|
787 |
} |