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 / operation / GeometryOperation.java @ 40435
History | View | Annotate | Download (1.93 KB)
1 | 40435 | jjdelcerro | 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 = Integer.MIN_VALUE; |
||
42 | public static int OPERATION_CONTAINS_CODE = Integer.MIN_VALUE; |
||
43 | |||
44 | |||
45 | |||
46 | |||
47 | /**
|
||
48 | * Invokes this operation given the geometry and context
|
||
49 | * @param geom Geometry to which apply this operation
|
||
50 | * @param ctx Parameter container
|
||
51 | * @return Place-holder object that may contain any specific return value.
|
||
52 | * @throws GeometryOperationException The implementation is responsible to throw this exception when needed.
|
||
53 | */
|
||
54 | public abstract Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException; |
||
55 | |||
56 | /**
|
||
57 | * Returns the constant value that identifies this operation and that was obtained upon registering it.
|
||
58 | * @return operation unique index
|
||
59 | */
|
||
60 | public abstract int getOperationIndex(); |
||
61 | } |