Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / operation / GeometryOperation.java @ 29972

History | View | Annotate | Download (2.07 KB)

1
package org.gvsig.fmap.geom.operation;
2

    
3
import org.gvsig.fmap.geom.Geometry;
4
import org.gvsig.fmap.geom.GeometryLocator;
5

    
6
/**
7
 * Every geometry operation that is registered dynamically must extend this class.<br>
8
 *
9
 * The following example shows how to implement and register a custom operation:
10
 *  
11
 * <pre>
12
 * public class MyOperation extends GeometryOperation {
13
 * 
14
 *   // Check GeometryManager for alternative methods to register an operation  
15
 *   public static final int CODE = 
16
 *     GeometryManager.getInstance()
17
 *        .registerGeometryOperation("MyOperation", new MyOperation(), geomType);
18
 *   
19
 *   public Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException {
20
 *        // Operation logic goes here
21
 *   }     
22
 *   
23
 *   public int getOperationIndex() {
24
 *      return CODE;
25
 *   }
26
 *   
27
 * }
28
 * </pre>
29
 *
30
 * @author jiyarza
31
 *
32
 */
33
public abstract class GeometryOperation {
34
        
35
        
36
        // Constants for well-known operations to avoid dependency between geometry model and
37
        // operations.
38
        public static final String OPERATION_INTERSECTS_NAME = "intersects";
39
        public static final String OPERATION_CONTAINS_NAME = "contains";
40
        
41
        public static int OPERATION_INTERSECTS_CODE =
42
                GeometryLocator.getGeometryManager().getGeometryOperationCode(OPERATION_INTERSECTS_NAME);;
43
        public static int OPERATION_CONTAINS_CODE =
44
                GeometryLocator.getGeometryManager().getGeometryOperationCode(OPERATION_CONTAINS_NAME);;
45
        
46
        
47
        
48
        
49
        
50
        
51
        /**
52
         * Invokes this operation given the geometry and context 
53
         * @param geom Geometry to which apply this operation
54
         * @param ctx Parameter container
55
         * @return Place-holder object that may contain any specific return value. 
56
         * @throws GeometryOperationException The implementation is responsible to throw this exception when needed.
57
         */
58
        public abstract Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException;
59

    
60
        /**
61
         * Returns the constant value that identifies this operation and that was obtained upon registering it. 
62
         * @return operation unique index 
63
         */
64
        public abstract int getOperationIndex();
65
}