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 @ 40559
History | View | Annotate | Download (2.86 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 |
package org.gvsig.fmap.geom.operation; |
25 |
|
26 |
import org.gvsig.fmap.geom.Geometry; |
27 |
import org.gvsig.fmap.geom.GeometryLocator; |
28 |
|
29 |
/**
|
30 |
* Every geometry operation that is registered dynamically must extend this class.<br>
|
31 |
*
|
32 |
* The following example shows how to implement and register a custom operation:
|
33 |
*
|
34 |
* <pre>
|
35 |
* public class MyOperation extends GeometryOperation {
|
36 |
*
|
37 |
* // Check GeometryManager for alternative methods to register an operation
|
38 |
* public static final int CODE =
|
39 |
* GeometryManager.getInstance()
|
40 |
* .registerGeometryOperation("MyOperation", new MyOperation(), geomType);
|
41 |
*
|
42 |
* public Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException {
|
43 |
* // Operation logic goes here
|
44 |
* }
|
45 |
*
|
46 |
* public int getOperationIndex() {
|
47 |
* return CODE;
|
48 |
* }
|
49 |
*
|
50 |
* }
|
51 |
* </pre>
|
52 |
*
|
53 |
* @author jiyarza
|
54 |
*
|
55 |
*/
|
56 |
public abstract class GeometryOperation { |
57 |
|
58 |
|
59 |
// Constants for well-known operations to avoid dependency between geometry model and
|
60 |
// operations.
|
61 |
public static final String OPERATION_INTERSECTS_NAME = "intersects"; |
62 |
public static final String OPERATION_CONTAINS_NAME = "contains"; |
63 |
|
64 |
public static int OPERATION_INTERSECTS_CODE = Integer.MIN_VALUE; |
65 |
public static int OPERATION_CONTAINS_CODE = Integer.MIN_VALUE; |
66 |
|
67 |
|
68 |
|
69 |
|
70 |
/**
|
71 |
* Invokes this operation given the geometry and context
|
72 |
* @param geom Geometry to which apply this operation
|
73 |
* @param ctx Parameter container
|
74 |
* @return Place-holder object that may contain any specific return value.
|
75 |
* @throws GeometryOperationException The implementation is responsible to throw this exception when needed.
|
76 |
*/
|
77 |
public abstract Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException; |
78 |
|
79 |
/**
|
80 |
* Returns the constant value that identifies this operation and that was obtained upon registering it.
|
81 |
* @return operation unique index
|
82 |
*/
|
83 |
public abstract int getOperationIndex(); |
84 |
} |