Statistics
| Revision:

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

History | View | Annotate | Download (24.8 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 geometry types.
69
 * <li>Offering a set of convenient methods for registering and retrieving geometry operations associated
70
 * to one or more geometry types.
71
 * <li>Offering a set of convenient methods for registering and retrieving new geometries.
72
 * </ul>
73
 *
74
 * @author jiyarza
75
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
76
 */
77
public interface GeometryManager {
78
        public interface OPERATIONS {
79
                public final static String FROMWKT = "FromWKT";
80
                public final static String FROMWKB = "FromWKB";
81
        }
82

    
83
        /**
84
         * <p>
85
         * Registers a GeometryOperation associated to a GeometryType.
86
         * Returns an unique index that is used later to identify and invoke the operation.
87
         * </p>
88
         * <p>
89
         * By convention this index should be in a final and static variable in the 
90
         * class that implements the operation. The value of this variable must be set 
91
         * using the method {@link GeometryManager#getGeometryOperationCode(String)}:<BR>        
92
         * <pre>
93
         * public class MyOperation extends GeometryOperation {
94
         *   public static final int CODE =
95
         *     GeometryLocator.getGeometryManager()
96
         *        .getGeometryOperationCode("MyOperation");
97
         * }
98
         * </pre>
99
         * </p>
100
         * @param geomOpName Operation's unique name
101
         * @param geomOp Specific GeometryOperation's instance implementing this operation
102
         * @param geomType GeometryType instance to which this operation should be associated
103
         * @return Index assigned to this operation. This index is used later to access the operation.
104
         *
105
         */
106
        public int registerGeometryOperation(String geomOpName,
107
                        GeometryOperation geomOp, GeometryType geomType);
108

    
109
        /**
110
         * <p>
111
         * Registers a GeometryOperation that is common for all GeometryType (registered yet or not).
112
         * Returns an unique index that is used later to identify and invoke the operation.
113
         * </p>
114
         * <p>
115
         * By convention this index should be in a final and static variable in the 
116
         * class that implements the operation. The value of this variable must be set 
117
         * using the method {@link GeometryManager#getGeometryOperationCode(String)}:<BR>        
118
         * <pre>
119
         * public class MyOperation extends GeometryOperation {
120
         *   public static final int CODE =
121
         *     GeometryLocator.getGeometryManager()
122
         *        .getGeometryOperationCode("MyOperation");
123
         * }
124
         * </pre>
125
         * </p>
126
         * @param geomOpName Operation's unique name
127
         * @param geomOp Specific GeometryOperation's instance implementing this operation
128
         * @return Index assigned to this operation. This index is used later to access the operation.
129
         */
130
        public int registerGeometryOperation(String geomOpName,
131
                        GeometryOperation geomOp);
132

    
133
        /**
134
         * <p>
135
         * Registers a GeometryOperation associated to a GeometryType, that has been specified
136
         * using the type code and the subtype code.
137
         * Returns an unique index that is used later to identify and invoke the operation.
138
         * </p>
139
         * <p>
140
         * By convention this index should be in a final and static variable in the 
141
         * class that implements the operation. The value of this variable must be set 
142
         * using the method {@link GeometryManager#getGeometryOperationCode(String)}:<BR>        
143
         * <pre>
144
         * public class MyOperation extends GeometryOperation {
145
         *   public static final int CODE =
146
         *     GeometryLocator.getGeometryManager()
147
         *        .getGeometryOperationCode("MyOperation");
148
         * }
149
         * </pre>
150
         * </p>
151
         * <p>
152
         * This method is only used if you have not a reference to the GeometryType associated to the
153
         * geometry class. If you have such reference then it is slightly faster to use the method that receives
154
         * the GeometryType.<br>
155
         * </p>
156
         * @param geomOpName Operation's unique name
157
         * @param geomOp Specific GeometryOperation's instance implementing this operation
158
         * @param type
159
         * Type of geometry. Must be a value defined in {@link Geometry.TYPES}
160
         * @param subType
161
         * SubType of geometry. Must be a value defined in {@link Geometry.SUBTYPES}
162
         * @return Index assigned to this operation. This index is used later to access the operation.
163
         * @throws GeometryTypeNotSupportedException
164
         * Returns this exception if there is not a registered geometry with
165
         * these type and subtype
166
         * @throws GeometryTypeNotValidException
167
         * Returns if the type and subtype are not valid
168
         */
169
        public int registerGeometryOperation(String geomOpName,
170
                        GeometryOperation geomOp, int type, int subType) throws GeometryTypeNotSupportedException, GeometryTypeNotValidException;
171

    
172
        /**
173
         * <p>
174
         * Registers a GeometryOperation associated to all the geometries with a concrete type.
175
         * Returns an unique index that is used later to identify and invoke the operation.<br>
176
         * </p>
177
         * <p>
178
         * By convention this index should be in a final and static variable in the 
179
         * class that implements the operation. The value of this variable must be set 
180
         * using the method {@link GeometryManager#getGeometryOperationCode(String)}:<BR>        
181
         * <pre>
182
         * public class MyOperation extends GeometryOperation {
183
         *   public static final int CODE =
184
         *     GeometryLocator.getGeometryManager()
185
         *        .getGeometryOperationCode("MyOperation");
186
         * }
187
         * </pre>
188
         * </p>
189
         * @param geomOpName Operation's unique name
190
         * @param geomOp Specific GeometryOperation's instance implementing this operation
191
         * @param type
192
         * Type of geometry. Must be a value defined in {@link Geometry.TYPES}
193
         * @return Index assigned to this operation. This index is used later to access the operation.
194
         */
195
        public int registerGeometryOperation(String geomOpName,
196
                        GeometryOperation geomOp, int type);
197

    
198

    
199
        /**
200
         * <p>
201
         * Registers a GeometryOperation associated to all the geometries with a concrete subtype.
202
         * Returns an unique index that is used later to identify and invoke the operation.<br>
203
         * </p>
204
         * <p>
205
         * By convention this index should be in a final and static variable in the 
206
         * class that implements the operation. The value of this variable must be set 
207
         * using the method {@link GeometryManager#getGeometryOperationCode(String)}:<BR>        
208
         * <pre>
209
         * public class MyOperation extends GeometryOperation {
210
         *   public static final int CODE =
211
         *     GeometryLocator.getGeometryManager()
212
         *        .getGeometryOperationCode("MyOperation");
213
         * }
214
         * </pre>
215
         * </p>
216
         * @param geomOpName Operation's unique name
217
         * @param geomOp Specific GeometryOperation's instance implementing this operation
218
         * @param subType
219
         * SubType of geometry. Must be a value defined in {@link Geometry.SUBTYPES}
220
         * @return Index assigned to this operation. This index is used later to access the operation.
221
         */
222
        public int registerGeometryOperationBySubtype(String geomOpName,
223
                        GeometryOperation geomOp, int subType);
224

    
225
        /**
226
         * <p>
227
         * Registers a Geometry implementation class with a predefined geometry type and returns the
228
         * associated GeometryType instance. Available predefined types are defined in {@link Geometry.TYPES}
229
         * and the subtypes are defined in {@link Geometry.SUBTYPES}.
230
         * </p>
231
         * <p>
232
         * How to register a geometry class with a predefined type:
233
         * <pre>
234
         *   GeometryType geomType = GeometryLocator.getGeometryManager().
235
         *      registerBasicGeometryType(Point2D.class, "Point2D", Geometry.TYPES.POINT, Geometry.SYBTYPES.GEOM2D);
236
         * </pre>
237
         * </p>
238
         * @param geomClass
239
         *            Geometry subclass. It must not be null and must implement Geometry, otherwise an exception
240
         *            is raised.
241
         * @param name
242
         *                           Symbolic name for the geometry type, it can be null. If it is null then the symbolic name
243
         *                       will be the simple class name.
244
         * @param type
245
         * Type of geometry. Must be a value defined in {@link Geometry.TYPES}
246
         * @param subType
247
         * SubType of geometry. Must be a value defined in {@link Geometry.SUBTYPES}
248
         * @return Instance of GeometryType associated to the Geometry implementation class
249
         *         geomClass
250
         * @throws IllegalArgumentException
251
         *             If geomClass is null or does not implement Geometry
252
         */
253
        public GeometryType registerGeometryType(Class geomClass, String name, int type, int subType);
254

    
255
        /**
256
         * <p>
257
         * Registers a Geometry implementation class with a predefined geometry type and returns the
258
         * associated GeometryType instance. Available predefined types are defined in {@link Geometry.TYPES}
259
         * and the subtypes are defined in {@link Geometry.SUBTYPES}.
260
         * </p>
261
         * <p>
262
         * In this case the symbolic name will be the geometry's simple class name
263
         * </p>
264
         * How to register a new geometry type:
265
         * <pre>
266
         * GeometryType geomType = GeometryLocator.getGeometryManager().
267
         *      registerBasicGeometryType(Point2D.class, Geometry.TYPES.POINT, Geometry.SYBTYPES.GEOM2D);
268
         * </pre>
269
         *
270
         * @param geomClass Geometry implementation class. It must not be null and must implement Geometry,
271
         * otherwise an exception is thrown.
272
         * @param type
273
         * Type of geometry. Must be a value defined in {@link Geometry.TYPES}
274
         * @param subType
275
         * SubType of geometry. Must be a value defined in {@link Geometry.SUBTYPES}
276
         * @return Instance of GeometryType associated to the Geometry implementation class
277
         * @throws IllegalArgumentException
278
         *             If geomClass is null or does not implement Geometry
279
         */
280
        public GeometryType registerGeometryType(Class geomClass, int type, int subType);
281

    
282
        /**
283
         * <p>
284
         * Returns an instance of GeometryType given the Geometry type
285
         * and the subtype.
286
         * </p>
287
         * @param type
288
         * Type of geometry. Must be a value defined in {@link Geometry.TYPES}
289
         * @param subType
290
         * SubType of geometry. Must be a value defined in {@link Geometry.SUBTYPES}
291
         * @return Instance of GeometryType associated to the type and the subtype
292
         * @throws GeometryTypeNotSupportedException
293
         * Returns this exception if there is not a registered geometry with
294
         * these type and subtype
295
         * @throws GeometryTypeNotValidException
296
         * Returns if the type and subtype are not valid
297
         */
298
        public GeometryType getGeometryType(int type, int subType) throws GeometryTypeNotSupportedException, GeometryTypeNotValidException;
299

    
300
        /**
301
         * <p>
302
         * This method creates a {@link Geometry} with the type specified
303
         * by this GeometryType. The geometry is empty, and all the internal
304
         * attributes must be assigned to a value when the geometry has
305
         * been created.
306
         * </p>
307
         * <p>
308
         * This example creates a point2D and sets the coordinates to 1,1:
309
         *
310
         * <pre>
311
         * Point point = (Point)GeometryLocator
312
         *                 .getGeometryManager().create(GEOMETRY.TYPES.POINT, GEOMETRY.SUBTYPES.GEOM2D);
313
         *         point.setX(1);
314
         *         point.setY(1);
315
         * </pre>
316
         * </p>
317
         * @param geomType
318
         * The geometry type
319
         * @return
320
         * A instance of a geometry.
321
         * @throws CreateGeometryException
322
         * This exception is thrown when the manager can not create
323
         * the geometry.
324
         */
325
        public Geometry create(GeometryType geomType) throws CreateGeometryException;
326

    
327
        /**
328
         * <p>
329
         * Creates a Envelope with a concrete subtype. The envelope is empty
330
         * and it have to be filled with the corners once has been created.
331
         * </p>
332
         * @param subType
333
         * SubType of envelope. Must be a value defined in {@link Geometry.SUBTYPES}
334
         * @return
335
         * A Envelope
336
         * @throws CreateEnvelopeException
337
         * If it is not possible to create the envelope.
338
         */
339
        public Envelope createEnvelope(int subType) throws CreateEnvelopeException;
340

    
341
        /**
342
         * <p>
343
         * Creates a Envelope with a concrete subtype. It sets the values
344
         * for the lower corner and the upper corner (in 2D) using the
345
         * method parameters.
346
         * </p>
347
         * @param minX
348
         * The minimum value for the X coordinate.
349
         * @param minY
350
         * The minimum value for the Y coordinate.
351
         * @param maxX
352
         * The maximum value for the X coordinate.
353
         * @param maxY
354
         * The maximum value for the Y coordinate.
355
         * @param subType
356
         * SubType of envelope. Must be a value defined in {@link Geometry.SUBTYPES}
357
         * @return
358
         * @throws CreateEnvelopeException
359
         */
360
        public Envelope createEnvelope(double minX, double minY, double maxX, double maxY, int subType) throws CreateEnvelopeException;
361

    
362
        /**
363
         * <p>
364
         * This method creates a {@link Geometry} with the type specified
365
         * by this name. If a geometry with this name doesn't exist, a
366
         * {@link IllegalArgumentException} is thrown. The geometry is empty,
367
         * and all the internal attributes must be assigned to a value when
368
         * the geometry has  been created.
369
         * </p>
370
         * <p>
371
         * This example creates a point2D and sets the coordinates to 1,1:
372
         * It supposes that there is a Point2D class with name "Point2D".
373
         * </p>
374
         * <pre>
375
         * Point point = (Point)GeometryLocator
376
         *                 .getGeometryManager().create("Point2D");
377
         * point.setX(1);
378
         * point.setY(1);
379
         * </pre>
380
         *
381
         * @param name
382
         * The name of the geometry type
383
         * @return
384
         * A instance of a geometry.
385
         * @throws CreateGeometryException
386
         * This exception is thrown when the manager can not create
387
         * the geometry.
388
         */
389
        public Geometry create(String name) throws CreateGeometryException;
390

    
391
        /**
392
         * Create a geometry from a WKT definition.
393
         * 
394
         * This is a utility method to wrap the invocation to the operation
395
         * {@link OPERATIONS#FROMWKT}.
396
         * 
397
         * @param wkt geometry in Well-known text format 
398
         * 
399
         * @return the geometry as a Geometry
400
         * 
401
         * @throws CreateGeometryException
402
         * @throws GeometryException 
403
         */
404
        public Geometry createFrom(String wkt, String srs) throws CreateGeometryException, GeometryException;
405

    
406
        /**
407
         * Create a geometry from a WKB definition.
408
         * 
409
         * This is a utility method to wrap the invocation to the operation
410
         * {@link OPERATIONS#FROMWKB}.
411
         * 
412
         * @param wkb geometry in well-known binary format 
413
         * 
414
         * @return the geometry as a Geometry
415
         * 
416
         * @throws CreateGeometryException
417
         * @throws GeometryException 
418
         */
419
        public Geometry createFrom(byte[] wkb) throws CreateGeometryException, GeometryException;
420
        
421
        /**
422
         * <p>
423
         * This method creates a {@link Geometry} with a concrete type and subtype.
424
         * The geometry is empty, and all the internal attributes must be assigned
425
         * to a value when the geometry has  been created.
426
         * </p>
427
         * <p>
428
         * This example creates a point2D and sets the coordinates to 1,1.
429
         * It supposes that there is a Point2D class with the id 1.
430
         * </p>
431
         * <pre>
432
         * Point point = (Point)GeometryLocator
433
         *                 .getGeometryManager().create(Geometry.TYPES.POINT, Geometry.SYBTYPES.GEOM2D);
434
         *         point.setX(1);
435
         *         point.setY(1);
436
         * </pre>
437
         * @param type
438
         * Type of geometry. Must be a value defined in {@link Geometry.TYPES}
439
         * @param subType
440
         * SubType of geometry. Must be a value defined in {@link Geometry.SUBTYPES}
441
         * @return
442
         * A instance of a geometry.
443
         * @throws CreateGeometryException
444
         * This exception is thrown when the manager can not create
445
         * the geometry.
446
         */
447
        public Geometry create(int type, int subType) throws CreateGeometryException;
448

    
449
        /**
450
         * <p>
451
         * It creates a null geometry with a concrete subtype.
452
         * <p>
453
         * @param subType
454
         * SubType of geometry. Must be a value defined in {@link Geometry.SUBTYPES}
455
         * @return
456
         * A NullGeometry
457
         * @throws CreateGeometryException
458
         * This exception is thrown when the manager can not create
459
         * the geometry.
460
         */
461
        public NullGeometry createNullGeometry(int subType) throws CreateGeometryException;
462

    
463
        /**
464
         * <p>
465
         * Create a new point with a concrete type and sets the value
466
         * for the X and the Y.
467
         * </p>
468
         * @param x
469
         * The X coordinate
470
         * @param y
471
         * The y coordinate
472
         * @param subType
473
         * SubType of geometry. Must be a value defined in {@link Geometry.SUBTYPES}
474
         * @throws CreateGeometryException
475
         * This exception is thrown when the manager can not create
476
         * the geometry.
477
         * @return
478
         * The Point
479
         */
480
        public Point createPoint(double x, double y, int subType) throws CreateGeometryException;
481

    
482
        /**
483
         * <p>
484
         * Create a new curve with a concrete type and sets the value
485
         * for the coordinates using a GeneralPathX.
486
         * </p>
487
         * @param generalPathX
488
         * It is used to set the values for the X and Y coordinates.
489
         * @param subType
490
         * SubType of geometry. Must be a value defined in {@link Geometry.SUBTYPES}
491
         * @return
492
         * A curve
493
         * @throws CreateGeometryException
494
         * This exception is thrown when the manager can not create
495
         * the geometry.
496
         */
497
        public Curve createCurve(GeneralPathX generalPathX, int subType) throws CreateGeometryException;
498

    
499

    
500
        /**
501
         * <p>
502
         * Create a new multicurve with a concrete type and sets the value for the
503
         * coordinates using a GeneralPathX.
504
         * </p>
505
         *
506
         * @param generalPathX
507
         *            It is used to set the values for the X and Y coordinates.
508
         * @param subType
509
         *            SubType of geometry. Must be a value defined in
510
         *            {@link Geometry.SUBTYPES}
511
         * @return A multicurve
512
         * @throws CreateGeometryException
513
         *             This exception is thrown when the manager can not create the
514
         *             geometry.
515
         */
516
        public MultiCurve createMultiCurve(GeneralPathX generalPathX, int subType) throws CreateGeometryException;
517

    
518

    
519
        /**
520
         * <p>
521
         * Create a new surface with a concrete type and sets the value
522
         * for the coordinates using a GeneralPathX.
523
         * </p>
524
         * @param generalPathX
525
         * It is used to set the values for the X and Y coordinates.
526
         * @param subType
527
         * SubType of geometry. Must be a value defined in {@link Geometry.SUBTYPES}
528
         * @return
529
         * A surface
530
         * @throws CreateGeometryException
531
         * This exception is thrown when the manager can not create
532
         * the geometry.
533
         */
534
        public Surface createSurface(GeneralPathX generalPathX, int subType) throws CreateGeometryException;
535

    
536
        /**
537
         * <p>
538
         * Create a new multisurface with a concrete type and sets the value for the
539
         * coordinates using a GeneralPathX.
540
         * </p>
541
         * 
542
         * @param generalPathX
543
         *            It is used to set the values for the X and Y coordinates.
544
         * @param subType
545
         *            SubType of geometry. Must be a value defined in
546
         *            {@link Geometry.SUBTYPES}
547
         * @return A multisurface
548
         * @throws CreateGeometryException
549
         *             This exception is thrown when the manager can not create the
550
         *             geometry.
551
         */
552
        public MultiSurface createMultiSurface(GeneralPathX generalPathX, int subType) throws CreateGeometryException;
553

    
554
        /**
555
         * <p>
556
         * Returns an operation given the Geometry type, the Geometry subtype and and the operation
557
         * code. If opCode corresponds to a common operation (a common operation is an operation
558
         * registered for all geometries), then this method returns the common operation.
559
         * </p>
560
         * <p>
561
         * For better performance, if you need to call an operation multiple times,
562
         * use this method only once and keep the returned object in a local variable
563
         * over which you can iterate. For instance:
564
         *
565
         * <pre>
566
         * // Get the operation you need
567
         * GeometryManager gm = GeometryLocator.getGeometryManager()
568
         * GeometryOperation geomOp = null;
569
         * try {
570
         *    geomOp = gm.getGeometryOperation(Draw2D.CODE);
571
         * } catch (GeometryTypeNotSupportedException gtnse) {
572
         *    // treat exception
573
         * } catch (GeometryOperationNotSupportedException gonse) {
574
         *    // treat exception
575
         * }
576
         *
577
         *  // Fill the operation context with required params
578
         * GeometryOperationContext ctx = new GeometryOperationContext();
579
         *
580
         *  // Here is the main loop where you call the operation
581
         * for (int i=0; i<MyGeometries.length; i++) {
582
         *    Object result = geomOp.invoke(myGeometries[i], ctx);
583
         * }
584
         * </pre>
585
         * </p>
586
         * @param opCode
587
         * The operation code
588
         * @param type
589
         * Type of geometry. Must be a value defined in {@link Geometry.TYPES}
590
         * @param subType
591
         * SubType of geometry. Must be a value defined in {@link Geometry.SUBTYPES}
592
         * @return Geometry operation
593
         * @throws GeometryTypeNotSupportedException
594
         * Returns this exception if there is not a registered geometry with
595
         * these type and subtype
596
         * @throws GeometryTypeNotValidException
597
         * Returns this exception if the type and subtype are not valid
598
         * @throws GeometryOperationNotSupportedException
599
         * Returns this exception if there is not a registered operation with
600
         * this operation code
601
         */
602
        public GeometryOperation getGeometryOperation(int opCode, int type, int subType) throws GeometryTypeNotSupportedException, GeometryOperationNotSupportedException, GeometryTypeNotValidException;
603

    
604
        /**
605
         * <p>
606
         * Invokes an operation given its code, the geometry and the operation context holding the
607
         * parameters required for the operation.
608
         * </p>
609
         * @param opCode
610
         * Operation code.
611
         * @param geom
612
         * Geometry to which apply the operation
613
         * @param ctx
614
         * Context holding the operation parameters
615
         * @return
616
         * The object returned by an operation, depends on each operation.
617
         */
618
        public Object invokeOperation(int opCode, Geometry geom, GeometryOperationContext ctx) throws GeometryOperationNotSupportedException, GeometryOperationException;
619

    
620
        /**
621
         * <p>
622
         * Invokes an operation given its code, the geometry and the operation context holding the
623
         * parameters required for the operation.
624
         * </p>
625
         * @param geomOpName
626
         * Operation name.
627
         * @param geom
628
         * Geometry to which apply the operation
629
         * @param ctx
630
         * Context holding the operation parameters
631
         * @return
632
         * The object returned by an operation, depends on each operation.
633
         */
634
        public Object invokeOperation(String geomOpName, Geometry geom, GeometryOperationContext ctx) throws GeometryOperationNotSupportedException, GeometryOperationException;
635
        
636
        /**
637
         * <p>
638
         * Invokes an operation given its code, the geometry and the operation context holding the
639
         * parameters required for the operation.
640
         * </p>
641
         * @param geomOpName
642
         * Operation name.
643
         * @param ctx
644
         * Context holding the operation parameters
645
         * @return
646
         * The object returned by an operation, depends on each operation.
647
         */
648
        public Object invokeOperation(String geomOpName, GeometryOperationContext ctx) throws GeometryOperationNotSupportedException, GeometryOperationException;
649
        
650
        /**
651
         * <p>
652
         * Registers the unique name of one operation. If it already exists 
653
         * then this method does nothing but returning the name's corresponding 
654
         * index.
655
         * </p>
656
         * <p>
657
         * By convention this method is used to set the value of the final and static 
658
         * variable that is located in the classes that implements the operation:<BR>        
659
         * <pre>
660
         * public class MyOperation extends GeometryOperation {
661
         *   public static final int CODE =
662
         *     GeometryLocator.getGeometryManager()
663
         *        .getGeometryOperationCode("MyOperation");
664
         * }
665
         * </pre>
666
         * </p>
667
         * @param geomOpName
668
         * Name used to register the geometry operation
669
         * @return
670
         * Index assigned to the operation name passed as parameter
671
         */
672
        public int getGeometryOperationCode(String geomOpName);
673
        
674
        /**
675
         * Returns a list with the name of the operations that have been
676
         * registered.
677
         * @return
678
         * A list of the registered operations.
679
         */
680
        public List getGeometryOperationNames();
681
        
682
        /**
683
         * Returns the flatness used to convert a curve is a set
684
         * of points.
685
         * @return
686
         * The flatness.
687
         */
688
        public double getFlatness();
689
        
690
        /**
691
         * Sets the application flatness.
692
         * @param flatness
693
         * The flatness to set
694
         */
695
        public void setFlatness(double flatness);        
696
}