root / branches / v2_0_0_prep / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / GeometryManager.java @ 34708
History | View | Annotate | Download (29.2 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 |
import java.util.List; |
44 |
|
45 |
import org.gvsig.fmap.geom.aggregate.MultiCurve; |
46 |
import org.gvsig.fmap.geom.aggregate.MultiSurface; |
47 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
48 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
49 |
import org.gvsig.fmap.geom.operation.GeometryOperation; |
50 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
51 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
52 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
53 |
import org.gvsig.fmap.geom.primitive.Curve; |
54 |
import org.gvsig.fmap.geom.primitive.Envelope; |
55 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
56 |
import org.gvsig.fmap.geom.primitive.NullGeometry; |
57 |
import org.gvsig.fmap.geom.primitive.Point; |
58 |
import org.gvsig.fmap.geom.primitive.Surface; |
59 |
import org.gvsig.fmap.geom.type.GeometryType; |
60 |
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException; |
61 |
import org.gvsig.fmap.geom.type.GeometryTypeNotValidException; |
62 |
|
63 |
/**
|
64 |
* This singleton provides a centralized access to gvSIG's Geometry Model.
|
65 |
* Its responsibilities are:<br>
|
66 |
*
|
67 |
* <ul>
|
68 |
* <li>Offering a set of convenient methods for registering and retrieving
|
69 |
* geometry types.
|
70 |
* <li>Offering a set of convenient methods for registering and retrieving
|
71 |
* geometry operations associated to one or more geometry types.
|
72 |
* <li>Offering a set of convenient methods for registering and retrieving new
|
73 |
* geometries.
|
74 |
* </ul>
|
75 |
*
|
76 |
* @author jiyarza
|
77 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
78 |
*/
|
79 |
public interface GeometryManager { |
80 |
|
81 |
public interface OPERATIONS { |
82 |
|
83 |
public final static String FROMWKT = "FromWKT"; |
84 |
public final static String FROMWKB = "FromWKB"; |
85 |
} |
86 |
|
87 |
/**
|
88 |
* <p>
|
89 |
* Registers a GeometryOperation associated to a GeometryType. Returns an
|
90 |
* unique index that is used later to identify and invoke the operation.
|
91 |
* </p>
|
92 |
* <p>
|
93 |
* By convention this index should be in a final and static variable in the
|
94 |
* class that implements the operation. The value of this variable must be
|
95 |
* set using the method
|
96 |
* {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
|
97 |
*
|
98 |
* <pre>
|
99 |
*
|
100 |
* public class MyOperation extends GeometryOperation {
|
101 |
*
|
102 |
* public static final int CODE = GeometryLocator.getGeometryManager()
|
103 |
* .getGeometryOperationCode("MyOperation");
|
104 |
* }
|
105 |
* </pre>
|
106 |
*
|
107 |
* </p>
|
108 |
*
|
109 |
* @param geomOpName
|
110 |
* Operation's unique name
|
111 |
* @param geomOp
|
112 |
* Specific GeometryOperation's instance implementing this
|
113 |
* operation
|
114 |
* @param geomType
|
115 |
* GeometryType instance to which this operation should be
|
116 |
* associated
|
117 |
* @return Index assigned to this operation. This index is used later to
|
118 |
* access the operation.
|
119 |
*
|
120 |
*/
|
121 |
public int registerGeometryOperation(String geomOpName, |
122 |
GeometryOperation geomOp, GeometryType geomType); |
123 |
|
124 |
/**
|
125 |
* <p>
|
126 |
* Registers a GeometryOperation that is common for all GeometryType
|
127 |
* (registered yet or not). Returns an unique index that is used later to
|
128 |
* identify and invoke the operation.
|
129 |
* </p>
|
130 |
* <p>
|
131 |
* By convention this index should be in a final and static variable in the
|
132 |
* class that implements the operation. The value of this variable must be
|
133 |
* set using the method
|
134 |
* {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
|
135 |
*
|
136 |
* <pre>
|
137 |
*
|
138 |
* public class MyOperation extends GeometryOperation {
|
139 |
*
|
140 |
* public static final int CODE = GeometryLocator.getGeometryManager()
|
141 |
* .getGeometryOperationCode("MyOperation");
|
142 |
* }
|
143 |
* </pre>
|
144 |
*
|
145 |
* </p>
|
146 |
*
|
147 |
* @param geomOpName
|
148 |
* Operation's unique name
|
149 |
* @param geomOp
|
150 |
* Specific GeometryOperation's instance implementing this
|
151 |
* operation
|
152 |
* @return Index assigned to this operation. This index is used later to
|
153 |
* access the operation.
|
154 |
*/
|
155 |
public int registerGeometryOperation(String geomOpName, |
156 |
GeometryOperation geomOp); |
157 |
|
158 |
/**
|
159 |
* <p>
|
160 |
* Registers a GeometryOperation associated to a GeometryType, that has been
|
161 |
* specified using the type code and the subtype code. Returns an unique
|
162 |
* index that is used later to identify and invoke the operation.
|
163 |
* </p>
|
164 |
* <p>
|
165 |
* By convention this index should be in a final and static variable in the
|
166 |
* class that implements the operation. The value of this variable must be
|
167 |
* set using the method
|
168 |
* {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
|
169 |
*
|
170 |
* <pre>
|
171 |
*
|
172 |
* public class MyOperation extends GeometryOperation {
|
173 |
*
|
174 |
* public static final int CODE = GeometryLocator.getGeometryManager()
|
175 |
* .getGeometryOperationCode("MyOperation");
|
176 |
* }
|
177 |
* </pre>
|
178 |
*
|
179 |
* </p>
|
180 |
* <p>
|
181 |
* This method is only used if you have not a reference to the GeometryType
|
182 |
* associated to the geometry class. If you have such reference then it is
|
183 |
* slightly faster to use the method that receives the GeometryType.<br>
|
184 |
* </p>
|
185 |
*
|
186 |
* @param geomOpName
|
187 |
* Operation's unique name
|
188 |
* @param geomOp
|
189 |
* Specific GeometryOperation's instance implementing this
|
190 |
* operation
|
191 |
* @param type
|
192 |
* Type of geometry. Must be a value defined in
|
193 |
* {@link Geometry.TYPES}
|
194 |
* @param subType
|
195 |
* SubType of geometry. Must be a value defined in
|
196 |
* {@link Geometry.SUBTYPES}
|
197 |
* @return Index assigned to this operation. This index is used later to
|
198 |
* access the operation.
|
199 |
* @throws GeometryTypeNotSupportedException
|
200 |
* Returns this exception if there is not a registered geometry
|
201 |
* with
|
202 |
* these type and subtype
|
203 |
* @throws GeometryTypeNotValidException
|
204 |
* Returns if the type and subtype are not valid
|
205 |
*/
|
206 |
public int registerGeometryOperation(String geomOpName, |
207 |
GeometryOperation geomOp, int type, int subType) |
208 |
throws GeometryTypeNotSupportedException, GeometryTypeNotValidException;
|
209 |
|
210 |
/**
|
211 |
* <p>
|
212 |
* Registers a GeometryOperation associated to all the geometries with a
|
213 |
* concrete type. Returns an unique index that is used later to identify and
|
214 |
* invoke the operation.<br>
|
215 |
* </p>
|
216 |
* <p>
|
217 |
* By convention this index should be in a final and static variable in the
|
218 |
* class that implements the operation. The value of this variable must be
|
219 |
* set using the method
|
220 |
* {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
|
221 |
*
|
222 |
* <pre>
|
223 |
*
|
224 |
* public class MyOperation extends GeometryOperation {
|
225 |
*
|
226 |
* public static final int CODE = GeometryLocator.getGeometryManager()
|
227 |
* .getGeometryOperationCode("MyOperation");
|
228 |
* }
|
229 |
* </pre>
|
230 |
*
|
231 |
* </p>
|
232 |
*
|
233 |
* @param geomOpName
|
234 |
* Operation's unique name
|
235 |
* @param geomOp
|
236 |
* Specific GeometryOperation's instance implementing this
|
237 |
* operation
|
238 |
* @param type
|
239 |
* Type of geometry. Must be a value defined in
|
240 |
* {@link Geometry.TYPES}
|
241 |
* @return Index assigned to this operation. This index is used later to
|
242 |
* access the operation.
|
243 |
*/
|
244 |
public int registerGeometryOperation(String geomOpName, |
245 |
GeometryOperation geomOp, int type);
|
246 |
|
247 |
/**
|
248 |
* <p>
|
249 |
* Registers a GeometryOperation associated to all the geometries with a
|
250 |
* concrete subtype. Returns an unique index that is used later to identify
|
251 |
* and invoke the operation.<br>
|
252 |
* </p>
|
253 |
* <p>
|
254 |
* By convention this index should be in a final and static variable in the
|
255 |
* class that implements the operation. The value of this variable must be
|
256 |
* set using the method
|
257 |
* {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
|
258 |
*
|
259 |
* <pre>
|
260 |
*
|
261 |
* public class MyOperation extends GeometryOperation {
|
262 |
*
|
263 |
* public static final int CODE = GeometryLocator.getGeometryManager()
|
264 |
* .getGeometryOperationCode("MyOperation");
|
265 |
* }
|
266 |
* </pre>
|
267 |
*
|
268 |
* </p>
|
269 |
*
|
270 |
* @param geomOpName
|
271 |
* Operation's unique name
|
272 |
* @param geomOp
|
273 |
* Specific GeometryOperation's instance implementing this
|
274 |
* operation
|
275 |
* @param subType
|
276 |
* SubType of geometry. Must be a value defined in
|
277 |
* {@link Geometry.SUBTYPES}
|
278 |
* @return Index assigned to this operation. This index is used later to
|
279 |
* access the operation.
|
280 |
*/
|
281 |
public int registerGeometryOperationBySubtype(String geomOpName, |
282 |
GeometryOperation geomOp, int subType);
|
283 |
|
284 |
/**
|
285 |
* <p>
|
286 |
* Registers a Geometry implementation class with a predefined geometry type
|
287 |
* and returns the associated GeometryType instance. Available predefined
|
288 |
* types are defined in {@link Geometry.TYPES} and the subtypes are defined
|
289 |
* in {@link Geometry.SUBTYPES}.
|
290 |
* </p>
|
291 |
* <p>
|
292 |
* How to register a geometry class with a predefined type:
|
293 |
*
|
294 |
* <pre>
|
295 |
*
|
296 |
* GeometryType geomType = GeometryLocator.getGeometryManager()
|
297 |
* .registerBasicGeometryType(Point2D.class, "Point2D", Geometry.TYPES.POINT,
|
298 |
* Geometry.SYBTYPES.GEOM2D);
|
299 |
* </pre>
|
300 |
*
|
301 |
* </p>
|
302 |
*
|
303 |
* @param geomClass
|
304 |
* Geometry subclass. It must not be null and must implement
|
305 |
* Geometry, otherwise an exception
|
306 |
* is raised.
|
307 |
* @param name
|
308 |
* Symbolic name for the geometry type, it can be null. If it is
|
309 |
* null then the symbolic name
|
310 |
* will be the simple class name.
|
311 |
* @param type
|
312 |
* Type of geometry. Must be a value defined in
|
313 |
* {@link Geometry.TYPES}
|
314 |
* @param subType
|
315 |
* SubType of geometry. Must be a value defined in
|
316 |
* {@link Geometry.SUBTYPES}
|
317 |
* @return Instance of GeometryType associated to the Geometry
|
318 |
* implementation class
|
319 |
* geomClass
|
320 |
* @throws IllegalArgumentException
|
321 |
* If geomClass is null or does not implement Geometry
|
322 |
*/
|
323 |
public GeometryType registerGeometryType(Class geomClass, String name, |
324 |
int type, int subType); |
325 |
|
326 |
/**
|
327 |
* <p>
|
328 |
* Registers a Geometry implementation class with a predefined geometry type
|
329 |
* and returns the associated GeometryType instance. Available predefined
|
330 |
* types are defined in {@link Geometry.TYPES} and the subtypes are defined
|
331 |
* in {@link Geometry.SUBTYPES}.
|
332 |
* </p>
|
333 |
* <p>
|
334 |
* In this case the symbolic name will be the geometry's simple class name
|
335 |
* </p>
|
336 |
* How to register a new geometry type:
|
337 |
*
|
338 |
* <pre>
|
339 |
*
|
340 |
* GeometryType geomType = GeometryLocator.getGeometryManager()
|
341 |
* .registerBasicGeometryType(Point2D.class, Geometry.TYPES.POINT,
|
342 |
* Geometry.SYBTYPES.GEOM2D);
|
343 |
* </pre>
|
344 |
*
|
345 |
* @param geomClass
|
346 |
* Geometry implementation class. It must not be null and must
|
347 |
* implement Geometry,
|
348 |
* otherwise an exception is thrown.
|
349 |
* @param type
|
350 |
* Type of geometry. Must be a value defined in
|
351 |
* {@link Geometry.TYPES}
|
352 |
* @param subType
|
353 |
* SubType of geometry. Must be a value defined in
|
354 |
* {@link Geometry.SUBTYPES}
|
355 |
* @return Instance of GeometryType associated to the Geometry
|
356 |
* implementation class
|
357 |
* @throws IllegalArgumentException
|
358 |
* If geomClass is null or does not implement Geometry
|
359 |
*/
|
360 |
public GeometryType registerGeometryType(Class geomClass, int type, |
361 |
int subType);
|
362 |
|
363 |
/**
|
364 |
* <p>
|
365 |
* Returns an instance of GeometryType given the Geometry type and the
|
366 |
* subtype.
|
367 |
* </p>
|
368 |
*
|
369 |
* @param type
|
370 |
* Type of geometry. Must be a value defined in
|
371 |
* {@link Geometry.TYPES}
|
372 |
* @param subType
|
373 |
* SubType of geometry. Must be a value defined in
|
374 |
* {@link Geometry.SUBTYPES}
|
375 |
* @return Instance of GeometryType associated to the type and the subtype
|
376 |
* @throws GeometryTypeNotSupportedException
|
377 |
* Returns this exception if there is not a registered geometry
|
378 |
* with
|
379 |
* these type and subtype
|
380 |
* @throws GeometryTypeNotValidException
|
381 |
* Returns if the type and subtype are not valid
|
382 |
*/
|
383 |
public GeometryType getGeometryType(int type, int subType) |
384 |
throws GeometryTypeNotSupportedException, GeometryTypeNotValidException;
|
385 |
|
386 |
/**
|
387 |
* <p>
|
388 |
* This method creates a {@link Geometry} with the type specified by this
|
389 |
* GeometryType. The geometry is empty, and all the internal attributes must
|
390 |
* be assigned to a value when the geometry has been created.
|
391 |
* </p>
|
392 |
* <p>
|
393 |
* This example creates a point2D and sets the coordinates to 1,1:
|
394 |
*
|
395 |
* <pre>
|
396 |
* Point point =
|
397 |
* (Point) GeometryLocator.getGeometryManager().create(GEOMETRY.TYPES.POINT,
|
398 |
* GEOMETRY.SUBTYPES.GEOM2D);
|
399 |
* point.setX(1);
|
400 |
* point.setY(1);
|
401 |
* </pre>
|
402 |
*
|
403 |
* </p>
|
404 |
*
|
405 |
* @param geomType
|
406 |
* The geometry type
|
407 |
* @return
|
408 |
* A instance of a geometry.
|
409 |
* @throws CreateGeometryException
|
410 |
* This exception is thrown when the manager can not create
|
411 |
* the geometry.
|
412 |
*/
|
413 |
public Geometry create(GeometryType geomType)
|
414 |
throws CreateGeometryException;
|
415 |
|
416 |
/**
|
417 |
* <p>
|
418 |
* Creates a Envelope with a concrete subtype. The envelope is empty and it
|
419 |
* have to be filled with the corners once has been created.
|
420 |
* </p>
|
421 |
*
|
422 |
* @param subType
|
423 |
* SubType of envelope. Must be a value defined in
|
424 |
* {@link Geometry.SUBTYPES}
|
425 |
* @return
|
426 |
* A Envelope
|
427 |
* @throws CreateEnvelopeException
|
428 |
* If it is not possible to create the envelope.
|
429 |
*/
|
430 |
public Envelope createEnvelope(int subType) throws CreateEnvelopeException; |
431 |
|
432 |
/**
|
433 |
* <p>
|
434 |
* Creates a Envelope with a concrete subtype. It sets the values for the
|
435 |
* lower corner and the upper corner (in 2D) using the method parameters.
|
436 |
* </p>
|
437 |
*
|
438 |
* @param minX
|
439 |
* The minimum value for the X coordinate.
|
440 |
* @param minY
|
441 |
* The minimum value for the Y coordinate.
|
442 |
* @param maxX
|
443 |
* The maximum value for the X coordinate.
|
444 |
* @param maxY
|
445 |
* The maximum value for the Y coordinate.
|
446 |
* @param subType
|
447 |
* SubType of envelope. Must be a value defined in
|
448 |
* {@link Geometry.SUBTYPES}
|
449 |
* @return
|
450 |
* @throws CreateEnvelopeException
|
451 |
*/
|
452 |
public Envelope createEnvelope(double minX, double minY, double maxX, |
453 |
double maxY, int subType) throws CreateEnvelopeException; |
454 |
|
455 |
/**
|
456 |
* <p>
|
457 |
* This method creates a {@link Geometry} with the type specified by this
|
458 |
* name. If a geometry with this name doesn't exist, a
|
459 |
* {@link IllegalArgumentException} is thrown. The geometry is empty, and
|
460 |
* all the internal attributes must be assigned to a value when the geometry
|
461 |
* has been created.
|
462 |
* </p>
|
463 |
* <p>
|
464 |
* This example creates a point2D and sets the coordinates to 1,1: It
|
465 |
* supposes that there is a Point2D class with name "Point2D".
|
466 |
* </p>
|
467 |
*
|
468 |
* <pre>
|
469 |
* Point point = (Point) GeometryLocator.getGeometryManager().create("Point2D");
|
470 |
* point.setX(1);
|
471 |
* point.setY(1);
|
472 |
* </pre>
|
473 |
*
|
474 |
* @param name
|
475 |
* The name of the geometry type
|
476 |
* @return
|
477 |
* A instance of a geometry.
|
478 |
* @throws CreateGeometryException
|
479 |
* This exception is thrown when the manager can not create
|
480 |
* the geometry.
|
481 |
*/
|
482 |
public Geometry create(String name) throws CreateGeometryException; |
483 |
|
484 |
/**
|
485 |
* Create a geometry from a WKT definition.
|
486 |
*
|
487 |
* This is a utility method to wrap the invocation to the operation
|
488 |
* {@link OPERATIONS#FROMWKT}.
|
489 |
*
|
490 |
* @param wkt
|
491 |
* geometry in Well-known text format
|
492 |
*
|
493 |
* @return the geometry as a Geometry
|
494 |
*
|
495 |
* @throws CreateGeometryException
|
496 |
* @throws GeometryException
|
497 |
*/
|
498 |
public Geometry createFrom(String wkt, String srs) |
499 |
throws CreateGeometryException, GeometryException;
|
500 |
|
501 |
public Geometry createFrom(String wkt) throws CreateGeometryException, |
502 |
GeometryException; |
503 |
|
504 |
/**
|
505 |
* Create a geometry from a WKB definition.
|
506 |
*
|
507 |
* This is a utility method to wrap the invocation to the operation
|
508 |
* {@link OPERATIONS#FROMWKB}.
|
509 |
*
|
510 |
* @param wkb
|
511 |
* geometry in well-known binary format
|
512 |
*
|
513 |
* @return the geometry as a Geometry
|
514 |
*
|
515 |
* @throws CreateGeometryException
|
516 |
* @throws GeometryException
|
517 |
*/
|
518 |
public Geometry createFrom(byte[] wkb) throws CreateGeometryException, |
519 |
GeometryException; |
520 |
|
521 |
/**
|
522 |
* <p>
|
523 |
* This method creates a {@link Geometry} with a concrete type and subtype.
|
524 |
* The geometry is empty, and all the internal attributes must be assigned
|
525 |
* to a value when the geometry has been created.
|
526 |
* </p>
|
527 |
* <p>
|
528 |
* This example creates a point2D and sets the coordinates to 1,1. It
|
529 |
* supposes that there is a Point2D class with the id 1.
|
530 |
* </p>
|
531 |
*
|
532 |
* <pre>
|
533 |
* Point point =
|
534 |
* (Point) GeometryLocator.getGeometryManager().create(Geometry.TYPES.POINT,
|
535 |
* Geometry.SYBTYPES.GEOM2D);
|
536 |
* point.setX(1);
|
537 |
* point.setY(1);
|
538 |
* </pre>
|
539 |
*
|
540 |
* @param type
|
541 |
* Type of geometry. Must be a value defined in
|
542 |
* {@link Geometry.TYPES}
|
543 |
* @param subType
|
544 |
* SubType of geometry. Must be a value defined in
|
545 |
* {@link Geometry.SUBTYPES}
|
546 |
* @return
|
547 |
* A instance of a geometry.
|
548 |
* @throws CreateGeometryException
|
549 |
* This exception is thrown when the manager can not create
|
550 |
* the geometry.
|
551 |
*/
|
552 |
public Geometry create(int type, int subType) |
553 |
throws CreateGeometryException;
|
554 |
|
555 |
/**
|
556 |
* <p>
|
557 |
* It creates a null geometry with a concrete subtype.
|
558 |
* <p>
|
559 |
*
|
560 |
* @param subType
|
561 |
* SubType of geometry. Must be a value defined in
|
562 |
* {@link Geometry.SUBTYPES}
|
563 |
* @return
|
564 |
* A NullGeometry
|
565 |
* @throws CreateGeometryException
|
566 |
* This exception is thrown when the manager can not create
|
567 |
* the geometry.
|
568 |
*/
|
569 |
public NullGeometry createNullGeometry(int subType) |
570 |
throws CreateGeometryException;
|
571 |
|
572 |
/**
|
573 |
* <p>
|
574 |
* Create a new point with a concrete type and sets the value for the X and
|
575 |
* the Y.
|
576 |
* </p>
|
577 |
*
|
578 |
* @param x
|
579 |
* The X coordinate
|
580 |
* @param y
|
581 |
* The y coordinate
|
582 |
* @param subType
|
583 |
* SubType of geometry. Must be a value defined in
|
584 |
* {@link Geometry.SUBTYPES}
|
585 |
* @throws CreateGeometryException
|
586 |
* This exception is thrown when the manager can not create
|
587 |
* the geometry.
|
588 |
* @return
|
589 |
* The Point
|
590 |
*/
|
591 |
public Point createPoint(double x, double y, int subType) |
592 |
throws CreateGeometryException;
|
593 |
|
594 |
/**
|
595 |
* <p>
|
596 |
* Create a new curve with a concrete type and sets the value for the
|
597 |
* coordinates using a GeneralPathX.
|
598 |
* </p>
|
599 |
*
|
600 |
* @param generalPathX
|
601 |
* It is used to set the values for the X and Y coordinates.
|
602 |
* @param subType
|
603 |
* SubType of geometry. Must be a value defined in
|
604 |
* {@link Geometry.SUBTYPES}
|
605 |
* @return
|
606 |
* A curve
|
607 |
* @throws CreateGeometryException
|
608 |
* This exception is thrown when the manager can not create
|
609 |
* the geometry.
|
610 |
*/
|
611 |
public Curve createCurve(GeneralPathX generalPathX, int subType) |
612 |
throws CreateGeometryException;
|
613 |
|
614 |
/**
|
615 |
* <p>
|
616 |
* Create a new multicurve with a concrete type and sets the value for the
|
617 |
* coordinates using a GeneralPathX.
|
618 |
* </p>
|
619 |
*
|
620 |
* @param generalPathX
|
621 |
* It is used to set the values for the X and Y coordinates.
|
622 |
* @param subType
|
623 |
* SubType of geometry. Must be a value defined in
|
624 |
* {@link Geometry.SUBTYPES}
|
625 |
* @return A multicurve
|
626 |
* @throws CreateGeometryException
|
627 |
* This exception is thrown when the manager can not create the
|
628 |
* geometry.
|
629 |
*/
|
630 |
public MultiCurve createMultiCurve(GeneralPathX generalPathX, int subType) |
631 |
throws CreateGeometryException;
|
632 |
|
633 |
/**
|
634 |
* <p>
|
635 |
* Create a new surface with a concrete type and sets the value for the
|
636 |
* coordinates using a GeneralPathX.
|
637 |
* </p>
|
638 |
*
|
639 |
* @param generalPathX
|
640 |
* It is used to set the values for the X and Y coordinates.
|
641 |
* @param subType
|
642 |
* SubType of geometry. Must be a value defined in
|
643 |
* {@link Geometry.SUBTYPES}
|
644 |
* @return
|
645 |
* A surface
|
646 |
* @throws CreateGeometryException
|
647 |
* This exception is thrown when the manager can not create
|
648 |
* the geometry.
|
649 |
*/
|
650 |
public Surface createSurface(GeneralPathX generalPathX, int subType) |
651 |
throws CreateGeometryException;
|
652 |
|
653 |
/**
|
654 |
* <p>
|
655 |
* Create a new multisurface with a concrete type and sets the value for the
|
656 |
* coordinates using a GeneralPathX.
|
657 |
* </p>
|
658 |
*
|
659 |
* @param generalPathX
|
660 |
* It is used to set the values for the X and Y coordinates.
|
661 |
* @param subType
|
662 |
* SubType of geometry. Must be a value defined in
|
663 |
* {@link Geometry.SUBTYPES}
|
664 |
* @return A multisurface
|
665 |
* @throws CreateGeometryException
|
666 |
* This exception is thrown when the manager can not create the
|
667 |
* geometry.
|
668 |
*/
|
669 |
public MultiSurface createMultiSurface(GeneralPathX generalPathX,
|
670 |
int subType) throws CreateGeometryException; |
671 |
|
672 |
/**
|
673 |
* <p>
|
674 |
* Returns an operation given the Geometry type, the Geometry subtype and
|
675 |
* and the operation code. If opCode corresponds to a common operation (a
|
676 |
* common operation is an operation registered for all geometries), then
|
677 |
* this method returns the common operation.
|
678 |
* </p>
|
679 |
* <p>
|
680 |
* For better performance, if you need to call an operation multiple times,
|
681 |
* use this method only once and keep the returned object in a local
|
682 |
* variable over which you can iterate. For instance:
|
683 |
*
|
684 |
* <pre>
|
685 |
* // Get the operation you need
|
686 |
* GeometryManager gm = GeometryLocator.getGeometryManager()
|
687 |
* GeometryOperation geomOp = null;
|
688 |
* try {
|
689 |
* geomOp = gm.getGeometryOperation(Draw2D.CODE);
|
690 |
* } catch (GeometryTypeNotSupportedException gtnse) {
|
691 |
* // treat exception
|
692 |
* } catch (GeometryOperationNotSupportedException gonse) {
|
693 |
* // treat exception
|
694 |
* }
|
695 |
*
|
696 |
* // Fill the operation context with required params
|
697 |
* GeometryOperationContext ctx = new GeometryOperationContext();
|
698 |
*
|
699 |
* // Here is the main loop where you call the operation
|
700 |
* for (int i=0; i<MyGeometries.length; i++) {
|
701 |
* Object result = geomOp.invoke(myGeometries[i], ctx);
|
702 |
* }
|
703 |
* </pre>
|
704 |
*
|
705 |
* </p>
|
706 |
*
|
707 |
* @param opCode
|
708 |
* The operation code
|
709 |
* @param type
|
710 |
* Type of geometry. Must be a value defined in
|
711 |
* {@link Geometry.TYPES}
|
712 |
* @param subType
|
713 |
* SubType of geometry. Must be a value defined in
|
714 |
* {@link Geometry.SUBTYPES}
|
715 |
* @return Geometry operation
|
716 |
* @throws GeometryTypeNotSupportedException
|
717 |
* Returns this exception if there is not a registered geometry
|
718 |
* with
|
719 |
* these type and subtype
|
720 |
* @throws GeometryTypeNotValidException
|
721 |
* Returns this exception if the type and subtype are not valid
|
722 |
* @throws GeometryOperationNotSupportedException
|
723 |
* Returns this exception if there is not a registered operation
|
724 |
* with
|
725 |
* this operation code
|
726 |
*/
|
727 |
public GeometryOperation getGeometryOperation(int opCode, int type, |
728 |
int subType) throws GeometryTypeNotSupportedException, |
729 |
GeometryOperationNotSupportedException, GeometryTypeNotValidException; |
730 |
|
731 |
/**
|
732 |
* <p>
|
733 |
* Invokes an operation given its code, the geometry and the operation
|
734 |
* context holding the parameters required for the operation.
|
735 |
* </p>
|
736 |
*
|
737 |
* @param opCode
|
738 |
* Operation code.
|
739 |
* @param geom
|
740 |
* Geometry to which apply the operation
|
741 |
* @param ctx
|
742 |
* Context holding the operation parameters
|
743 |
* @return
|
744 |
* The object returned by an operation, depends on each operation.
|
745 |
*/
|
746 |
public Object invokeOperation(int opCode, Geometry geom, |
747 |
GeometryOperationContext ctx) |
748 |
throws GeometryOperationNotSupportedException,
|
749 |
GeometryOperationException; |
750 |
|
751 |
/**
|
752 |
* <p>
|
753 |
* Invokes an operation given its code, the geometry and the operation
|
754 |
* context holding the parameters required for the operation.
|
755 |
* </p>
|
756 |
*
|
757 |
* @param geomOpName
|
758 |
* Operation name.
|
759 |
* @param geom
|
760 |
* Geometry to which apply the operation
|
761 |
* @param ctx
|
762 |
* Context holding the operation parameters
|
763 |
* @return
|
764 |
* The object returned by an operation, depends on each operation.
|
765 |
*/
|
766 |
public Object invokeOperation(String geomOpName, Geometry geom, |
767 |
GeometryOperationContext ctx) |
768 |
throws GeometryOperationNotSupportedException,
|
769 |
GeometryOperationException; |
770 |
|
771 |
/**
|
772 |
* <p>
|
773 |
* Invokes an operation given its code, the geometry and the operation
|
774 |
* context holding the parameters required for the operation.
|
775 |
* </p>
|
776 |
*
|
777 |
* @param geomOpName
|
778 |
* Operation name.
|
779 |
* @param ctx
|
780 |
* Context holding the operation parameters
|
781 |
* @return
|
782 |
* The object returned by an operation, depends on each operation.
|
783 |
*/
|
784 |
public Object invokeOperation(String geomOpName, |
785 |
GeometryOperationContext ctx) |
786 |
throws GeometryOperationNotSupportedException,
|
787 |
GeometryOperationException; |
788 |
|
789 |
/**
|
790 |
* <p>
|
791 |
* Registers the unique name of one operation. If it already exists then
|
792 |
* this method does nothing but returning the name's corresponding index.
|
793 |
* </p>
|
794 |
* <p>
|
795 |
* By convention this method is used to set the value of the final and
|
796 |
* static variable that is located in the classes that implements the
|
797 |
* operation:<BR>
|
798 |
*
|
799 |
* <pre>
|
800 |
*
|
801 |
* public class MyOperation extends GeometryOperation {
|
802 |
*
|
803 |
* public static final int CODE = GeometryLocator.getGeometryManager()
|
804 |
* .getGeometryOperationCode("MyOperation");
|
805 |
* }
|
806 |
* </pre>
|
807 |
*
|
808 |
* </p>
|
809 |
*
|
810 |
* @param geomOpName
|
811 |
* Name used to register the geometry operation
|
812 |
* @return
|
813 |
* Index assigned to the operation name passed as parameter
|
814 |
*/
|
815 |
public int getGeometryOperationCode(String geomOpName); |
816 |
|
817 |
/**
|
818 |
* Returns a list with the name of the operations that have been
|
819 |
* registered.
|
820 |
*
|
821 |
* @return
|
822 |
* A list of the registered operations.
|
823 |
*/
|
824 |
public List getGeometryOperationNames(); |
825 |
|
826 |
/**
|
827 |
* Returns the flatness used to convert a curve is a set
|
828 |
* of points.
|
829 |
*
|
830 |
* @return
|
831 |
* The flatness.
|
832 |
*/
|
833 |
public double getFlatness(); |
834 |
|
835 |
/**
|
836 |
* Sets the application flatness.
|
837 |
*
|
838 |
* @param flatness
|
839 |
* The flatness to set
|
840 |
*/
|
841 |
public void setFlatness(double flatness); |
842 |
} |