Revision 21047
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/GeometryManager.java | ||
---|---|---|
53 | 53 |
|
54 | 54 |
/** |
55 | 55 |
* This singleton provides a centralized access to gvSIG's Geometry Model. |
56 |
* Its responsibilities are: |
|
56 |
* Its responsibilities are:<br>
|
|
57 | 57 |
* |
58 |
* Offering a set of convenient methods for registering geometry types. |
|
59 |
* Offering a set of convenient methods for registering geometry operations associated |
|
58 |
* <ul> |
|
59 |
* <li>Offering a set of convenient methods for registering and retrieving geometry types. |
|
60 |
* <li>Offering a set of convenient methods for registering and retrieving geometry operations associated |
|
60 | 61 |
* to one or more geometry types. |
61 |
* TODO Offering a set of convenient methods for registering custom geometry factories. |
|
62 |
* <li><code>TODO:</code> Offering a set of convenient methods for registering and retrieving custom |
|
63 |
* geometry factories. |
|
64 |
* <ul> |
|
62 | 65 |
* |
63 |
* |
|
64 | 66 |
* @author jiyarza |
65 | 67 |
* |
66 | 68 |
*/ |
... | ... | |
76 | 78 |
private List commonOperations = new ArrayList(); |
77 | 79 |
|
78 | 80 |
/** Common operations are assigned an index greater or equal than this constant, so that it is easy and efficient for the manager |
79 |
* to decide where to lookup, in the common register or in type specific register. */
|
|
81 |
* to decide whether to lookup in the common register or in the type specific register. */
|
|
80 | 82 |
private static final int COMMON_OPS_OFFSET = 1000; |
81 | 83 |
|
82 | 84 |
/** This map holds the instances of all registered GeometryType. The key is the name of the specific Geometry subclass. |
... | ... | |
124 | 126 |
return index; |
125 | 127 |
} |
126 | 128 |
|
129 |
|
|
127 | 130 |
/** |
131 |
* Sets a common operation into the common operations map. |
|
132 |
* @param index index in which to set the operation |
|
133 |
* @param geomOp operation to be set |
|
134 |
*/ |
|
135 |
private void setCommonOperation(int index, GeometryOperation geomOp) { |
|
136 |
|
|
137 |
while (index > commonOperations.size()) { |
|
138 |
commonOperations.add(null); |
|
139 |
} |
|
140 |
|
|
141 |
if (index == commonOperations.size()) { |
|
142 |
commonOperations.add(geomOp); |
|
143 |
} else { |
|
144 |
commonOperations.set(index, geomOp); |
|
145 |
} |
|
146 |
} |
|
147 |
|
|
148 |
/** |
|
128 | 149 |
* Registers a GeometryOperation associated to a GeometryType. |
129 | 150 |
* Returns an unique index that is used later to identify and invoke the operation. |
151 |
* |
|
152 |
* This method is only used if you already got a reference to the GeometryType. If not, |
|
153 |
* it is more convenient to use the method that receives the geometry class as parameter. |
|
130 | 154 |
* |
131 | 155 |
* By convention, the return value should be stored in a public constant within the class implementing |
132 | 156 |
* the operation:<BR> |
... | ... | |
134 | 158 |
* public class MyOperation extends GeometryOperation { |
135 | 159 |
* public static final int OPERATION_INDEX = |
136 | 160 |
* GeometryManager.getInstance() |
137 |
* .registerGeometryOperation("MyOperation", new MyOperation(), ); |
|
161 |
* .registerGeometryOperation("MyOperation", new MyOperation(), geomType);
|
|
138 | 162 |
* } |
139 | 163 |
* </pre> |
140 | 164 |
* @param geomOpName Operation's unique name |
... | ... | |
174 | 198 |
* @param geomOpName Operation's unique name |
175 | 199 |
* @param geomOp Specific GeometryOperation's instance implementing this operation |
176 | 200 |
* @return Index assigned to this operation. This index is used later to access the operation. |
177 |
|
|
178 | 201 |
*/ |
179 | 202 |
public int registerGeometryOperation(String geomOpName, |
180 | 203 |
GeometryOperation geomOp) { |
... | ... | |
193 | 216 |
} |
194 | 217 |
|
195 | 218 |
/** |
196 |
* Sets a common operation into the common operations map. |
|
197 |
* @param index index in which to set the operation |
|
198 |
* @param geomOp operation to be set |
|
199 |
*/ |
|
200 |
private void setCommonOperation(int index, GeometryOperation geomOp) { |
|
201 |
|
|
202 |
while (index > commonOperations.size()) { |
|
203 |
commonOperations.add(null); |
|
204 |
} |
|
205 |
|
|
206 |
if (index == commonOperations.size()) { |
|
207 |
commonOperations.add(geomOp); |
|
208 |
} else { |
|
209 |
commonOperations.set(index, geomOp); |
|
210 |
} |
|
211 |
} |
|
212 |
|
|
219 |
* Registers a GeometryOperation associated to a GeometryType. |
|
220 |
* Returns an unique index that is used later to identify and invoke the operation.<br> |
|
221 |
* |
|
222 |
* By convention, the return value should be stored in a public constant within the class implementing |
|
223 |
* the operation:<BR> |
|
224 |
* <pre> |
|
225 |
* public class MyOperation extends GeometryOperation { |
|
226 |
* public static final int OPERATION_INDEX = |
|
227 |
* GeometryManager.getInstance() |
|
228 |
* .registerGeometryOperation("MyOperation", new MyOperation(), MyGeometry.class); |
|
229 |
* } |
|
230 |
* </pre> |
|
231 |
* |
|
232 |
* This method is only used if you have not a reference to the GeometryType associated to the |
|
233 |
* geometry class. If you have such reference then it is slightly faster to use the method that receives |
|
234 |
* the GeometryType.<br> |
|
235 |
* |
|
236 |
* @param geomOpName Operation's unique name |
|
237 |
* @param geomOp Specific GeometryOperation's instance implementing this operation |
|
238 |
* @param geomClass Geometry implementation class |
|
239 |
* @return Index assigned to this operation. This index is used later to access the operation. |
|
240 |
*/ |
|
213 | 241 |
public int registerGeometryOperation(String geomOpName, |
214 | 242 |
GeometryOperation geomOp, Class geomClass) { |
215 | 243 |
|
... | ... | |
219 | 247 |
|
220 | 248 |
|
221 | 249 |
/** |
222 |
* |
|
223 |
* @param geomOpName |
|
224 |
* @param geomOpClass |
|
225 |
* @param geomType |
|
226 |
* @return |
|
227 |
* @throws GeometryOperationNotSupportedException |
|
250 |
* Registers a GeometryOperation associated to a GeometryType. |
|
251 |
* Returns an unique index that is used later to identify and invoke the operation.<br> |
|
252 |
* |
|
253 |
* By convention, the return value should be stored in a public constant within the class implementing |
|
254 |
* the operation:<BR> |
|
255 |
* <pre> |
|
256 |
* public class MyOperation extends GeometryOperation { |
|
257 |
* public static final int OPERATION_INDEX = |
|
258 |
* GeometryManager.getInstance() |
|
259 |
* .registerGeometryOperation("MyOperation", MyOperation.class, myGeomType); |
|
260 |
* } |
|
261 |
* </pre> |
|
262 |
* |
|
263 |
* @param geomOpName Operation's unique name |
|
264 |
* @param geomOpClass GeometryOperation class |
|
265 |
* @param geomType GeometryType instance to which this operation should be associated |
|
266 |
* @return Index assigned to this operation. This index is used later to access the operation. |
|
267 |
* @throws IllegalAccessException, {@link InstantiationException} Either exception maybe thrown when |
|
268 |
* trying to instance the geometry operation class. |
|
228 | 269 |
*/ |
229 | 270 |
public int registerGeometryOperation(String geomOpName, Class geomOpClass, |
230 | 271 |
GeometryType geomType) |
... | ... | |
235 | 276 |
} |
236 | 277 |
|
237 | 278 |
/** |
238 |
* Registra una clase de geometr?a y devuelve la instancia GeometryType
|
|
239 |
* asociada. Si la clase ya est? registrada s?lo se devuelve la instancia
|
|
240 |
* GeometryType asociada.
|
|
279 |
* Registers a Geometry implementation class as a new geometry type and returns the
|
|
280 |
* associated GeometryType instance. If the class is already registered
|
|
281 |
* then this method does nothing but returning the associated GeometryType.<br>
|
|
241 | 282 |
* |
242 |
* geomClass no debe ser nulo y debe implementar la interfaz Geometry, en |
|
243 |
* caso contrario se lanza una excepci?n. |
|
244 |
* |
|
245 | 283 |
* @param geomClass |
246 |
* Clase de Geometry |
|
284 |
* Geometry subclass. It must not be null and must implement Geometry, otherwise an exception |
|
285 |
* is raised. |
|
247 | 286 |
* @param name |
248 |
* Nombre simb?lico del tipo de geometr?a. Si se pasa un null entonces
|
|
249 |
* se toma como nombre simb?lico el nombre simple de la clase.
|
|
250 |
* @return Instancia de GeometryType asociada a la clase de geometr?a
|
|
287 |
* Symbolic name for the geometry type, it can be null. If it is null then the symbolic name
|
|
288 |
* will be the simple class name.
|
|
289 |
* @return Instance of GeometryType associated to the Geometry implementation class
|
|
251 | 290 |
* geomClass |
252 | 291 |
* @throws IllegalArgumentException |
253 |
* si geomClass es nulo o no implementa Geometry
|
|
292 |
* If geomClass is null or does not implement Geometry
|
|
254 | 293 |
*/ |
255 | 294 |
public GeometryType registerGeometryType(Class geomClass, String name) { |
256 | 295 |
|
... | ... | |
277 | 316 |
} |
278 | 317 |
|
279 | 318 |
/** |
280 |
* Registra una clase de geometr?a y devuelve la instancia GeometryType |
|
281 |
* asociada. Si la clase ya est? registrada s?lo se devuelve la instancia |
|
282 |
* GeometryType asociada. Como nombre simb?lico se fija el nombre simple |
|
283 |
* de la clase. |
|
319 |
* Registers a Geometry implementation as a new geometry type and returns the |
|
320 |
* associated GeometryType instance. If the class is already registered |
|
321 |
* then this method does nothing but returning the associated GeometryType.<br> |
|
284 | 322 |
* |
285 |
* geomClass no debe ser nulo y debe implementar la interfaz Geometry, en |
|
286 |
* caso contrario se lanza una excepci?n. |
|
287 |
* |
|
288 | 323 |
* @param geomClass |
289 |
* Clase de Geometry |
|
324 |
* Geometry implementation class. It must not be null and must implement Geometry, |
|
325 |
* otherwise an exception is thrown. |
|
326 |
* @param name |
|
327 |
* Symbolic name for the geometry type, it can be null. If it is null then the symbolic name |
|
328 |
* will be the simple class name. |
|
290 | 329 |
* @return Instancia de GeometryType asociada a la clase de geometr?a |
291 | 330 |
* geomClass |
292 | 331 |
* @throws IllegalArgumentException |
293 |
* si geomClass es nulo o no implementa Geometry
|
|
332 |
* If geomClass is null or does not implement Geometry
|
|
294 | 333 |
*/ |
295 | 334 |
public GeometryType registerGeometryType(Class geomClass) { |
296 | 335 |
return registerGeometryType(geomClass, null); |
297 | 336 |
} |
298 | 337 |
/** |
299 |
* Devuelve un GeometryType dada la clase que lo implementa |
|
338 |
* Returns an instance of GeometryType given the associated Geometry implementation |
|
339 |
* class. |
|
300 | 340 |
* |
301 | 341 |
* @param geomClass |
302 |
* @return |
|
342 |
* @return Instance of GeometryType associated to geomClass
|
|
303 | 343 |
*/ |
304 | 344 |
public GeometryType getGeometryType(Class geomClass) { |
305 | 345 |
return (GeometryType) geometryTypes.get(geomClass.getName()); |
306 | 346 |
} |
307 | 347 |
|
308 | 348 |
/** |
309 |
* Devuelve un GeometryType dado el nombre cualificado de la clase de
|
|
310 |
* geometr?a
|
|
349 |
* Returns the associated GeometryType given the fully qualified name of
|
|
350 |
* the Geometry implementation class.
|
|
311 | 351 |
* |
312 | 352 |
* @param className |
313 |
* Nombre cualificado de la clase de geometr?a
|
|
314 |
* @return GeometryType asociado
|
|
353 |
* Fully qualified name of the Geometry implementation class
|
|
354 |
* @return GeometryType associated to the class
|
|
315 | 355 |
*/ |
316 | 356 |
public GeometryType getGeometryType(String className) { |
317 | 357 |
return (GeometryType) geometryTypes.get(className); |
318 | 358 |
} |
319 | 359 |
|
320 | 360 |
/** |
321 |
* Devuelve una operaci?n dada la clase de geometr?a y el ?ndice de la
|
|
322 |
* operaci?n. Este ?ndice se obtiene al registrar la operaci?n.
|
|
361 |
* Returns an operation given the Geometry implementation class and the operation
|
|
362 |
* index.
|
|
323 | 363 |
* |
324 | 364 |
* @param geomClass |
325 | 365 |
* @param index |
... | ... | |
334 | 374 |
} |
335 | 375 |
|
336 | 376 |
/** |
337 |
* Invoca una operaci?n dado su ?ndice, la geometr?a y el contexto con los par?metros. |
|
338 |
* @param index |
|
339 |
* @param geom |
|
340 |
* @param ctx |
|
341 |
* @return |
|
377 |
* Invokes an operation given its code, the geometry and the operation context holding the |
|
378 |
* parameters required for the operation. |
|
379 |
* |
|
380 |
* @param opCode Operation code. |
|
381 |
* @param geom Geometry to which apply the operation |
|
382 |
* @param ctx Context holding the operation parameters |
|
383 |
* @return The object returned by an operation, depends on each operation. |
|
342 | 384 |
*/ |
343 |
public Object invokeOperation(int index, Geometry geom, GeometryOperationContext ctx) throws GeometryOperationNotSupportedException, GeometryOperationException {
|
|
385 |
public Object invokeOperation(int opCode, Geometry geom, GeometryOperationContext ctx) throws GeometryOperationNotSupportedException, GeometryOperationException {
|
|
344 | 386 |
|
345 | 387 |
GeometryOperation geomOp = null; |
346 | 388 |
|
347 |
if (index < COMMON_OPS_OFFSET) {
|
|
348 |
geomOp = geom.getGeometryType().getGeometryOperation(index);
|
|
389 |
if (opCode < COMMON_OPS_OFFSET) {
|
|
390 |
geomOp = geom.getGeometryType().getGeometryOperation(opCode);
|
|
349 | 391 |
} else { |
350 |
geomOp = ((GeometryOperation)commonOperations.get(index - COMMON_OPS_OFFSET));
|
|
392 |
geomOp = ((GeometryOperation)commonOperations.get(opCode - COMMON_OPS_OFFSET));
|
|
351 | 393 |
} |
352 | 394 |
|
353 | 395 |
if (geomOp != null) { |
354 | 396 |
return geomOp.invoke(geom, ctx); |
355 | 397 |
} |
356 | 398 |
|
357 |
throw new GeometryOperationNotSupportedException(index, geom.getGeometryType()); |
|
358 |
|
|
399 |
throw new GeometryOperationNotSupportedException(opCode, geom.getGeometryType()); |
|
359 | 400 |
} |
360 | 401 |
} |
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/Circle.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.geom.primitive; |
2 | 2 |
|
3 |
import org.gvsig.fmap.geom.Geometry; |
|
4 |
|
|
3 | 5 |
public interface Circle extends Arc { |
4 |
|
|
6 |
|
|
7 |
/** This predefined geometry's type */ |
|
8 |
public static final int GEOM_TYPE = Geometry.TYPES.CIRCLE; |
|
5 | 9 |
} |
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/Arc.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.geom.primitive; |
2 | 2 |
|
3 |
import org.gvsig.fmap.geom.Geometry; |
|
3 | 4 |
|
5 |
|
|
4 | 6 |
public interface Arc extends Curve { |
7 |
|
|
8 |
/** This predefined geometry's type */ |
|
9 |
public static final int GEOM_TYPE = Geometry.TYPES.ARC; |
|
5 | 10 |
} |
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/Curve.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.geom.primitive; |
2 |
|
|
3 |
import org.gvsig.fmap.geom.Geometry; |
|
4 |
|
|
2 | 5 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
3 | 6 |
* |
4 | 7 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
... | ... | |
52 | 55 |
* @author Jorge Piera Llodr� (jorge.piera@iver.es) |
53 | 56 |
*/ |
54 | 57 |
public interface Curve extends OrientableCurve{ |
55 |
public static final int GEOM_TYPE = 2; |
|
58 |
|
|
59 |
/** This predefined geometry's type */ |
|
60 |
public static final int GEOM_TYPE = Geometry.TYPES.CURVE; |
|
56 | 61 |
} |
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/Geometry.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
|
|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
|
2 | 2 |
* |
3 | 3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
4 | 4 |
* |
... | ... | |
20 | 20 |
* |
21 | 21 |
* Generalitat Valenciana |
22 | 22 |
* Conselleria d'Infraestructures i Transport |
23 |
* Av. Blasco Ib��ez, 50
|
|
23 |
* Av. Blasco Ib??ez, 50
|
|
24 | 24 |
* 46010 VALENCIA |
25 | 25 |
* SPAIN |
26 | 26 |
* |
... | ... | |
55 | 55 |
import org.gvsig.fmap.geom.type.GeometryType; |
56 | 56 |
|
57 | 57 |
/** |
58 |
* Interfaz de Geometr?a. |
|
59 |
* |
|
60 |
* @author $author$ |
|
58 |
* Root interface in the geometry model. |
|
61 | 59 |
*/ |
62 | 60 |
public interface Geometry extends Shape, Serializable { |
63 | 61 |
|
62 |
/** |
|
63 |
* Predefined geometry types in the model |
|
64 |
*/ |
|
64 | 65 |
public interface TYPES { |
65 | 66 |
/** |
66 | 67 |
* Unknown or not defined type. |
... | ... | |
129 | 130 |
public final static int Z=8192; |
130 | 131 |
} |
131 | 132 |
|
132 |
|
|
133 |
// /** Tipo de geometr?a de esta interfaz*/ |
|
134 |
// public final static int GEOM_TYPE = TYPES.NULL; |
|
135 |
|
|
136 | 133 |
public static int BEST = 0; |
137 | 134 |
public static int N = 1; |
138 | 135 |
public static int NE = 2; |
... | ... | |
147 | 144 |
public static int STRETCHINGHANDLER=1; |
148 | 145 |
|
149 | 146 |
/** |
150 |
* Obtiene el tipo de la geometr?a
|
|
147 |
* Returns the FShape type of the geometry.
|
|
151 | 148 |
* |
152 |
* @return una de las constantes de FShape: POINT, LINE, POLIGON
|
|
153 |
* @deprecated |
|
149 |
* @return One FShape constant: {@link FShape}
|
|
150 |
* @deprecated Use {@link getType} instead
|
|
154 | 151 |
*/ |
155 | 152 |
public int getShapeType(); |
156 | 153 |
|
157 | 154 |
/** |
158 |
* Devuelve el valor de la cte del tipo de geometr?a. |
|
155 |
* If this geometry is a predefined interface then this method returns one of {@link Geometry.TYPES} contants.<br> |
|
156 |
* If this geometry is an extended type then this method returns a runtime constant that identifies its type. |
|
157 |
* By convention this value is stored in a constant called GEOM_TYPE within the geometry class, for instance: Point2D.GEOM_TYPE. |
|
159 | 158 |
* |
160 |
* @return |
|
159 |
* @return If this geometry is a predefined interface then one of {@link Geometry.TYPES} or a runtime constant if |
|
160 |
* it is an extended type. |
|
161 | 161 |
*/ |
162 | 162 |
public int getType(); |
163 | 163 |
|
164 | 164 |
/** |
165 |
* Clona la Geometr�a.
|
|
165 |
* Creates a clone of this geometry
|
|
166 | 166 |
* |
167 |
* @return Geometr�a clonada.
|
|
167 |
* @return A clone of this geometry.
|
|
168 | 168 |
*/ |
169 | 169 |
public Geometry cloneGeometry(); |
170 | 170 |
|
171 | 171 |
/** |
172 |
* Devuelve true si la geometr�a intersecta con el rect�ngulo que se pasa |
|
173 |
* como par�metro. |
|
172 |
* Returns true if this geometry intersects the rectangle passed as parameter |
|
174 | 173 |
* |
175 |
* @param r Rect�ngulo.
|
|
174 |
* @param r Rectangle.
|
|
176 | 175 |
* |
177 |
* @return True, si intersecta.
|
|
176 |
* @return True, if <code>this</code> intersects <code>r</code>.
|
|
178 | 177 |
*/ |
179 | 178 |
public boolean intersects(Rectangle2D r); |
180 |
/** |
|
181 |
* Devuelve true si la geometr�a contiene al rect�ngulo que se pasa |
|
182 |
* como par�metro. |
|
183 |
* |
|
184 |
* @param r Rect�ngulo. |
|
185 |
* |
|
186 |
* @return True, si intersecta. |
|
187 |
*/ |
|
188 |
//boolean contains(IGeometry g); |
|
189 | 179 |
|
190 | 180 |
/** |
191 |
* Se usa en las strategies de dibujo para comprobar de manera r�pida |
|
192 |
* si intersecta con el rect�ngulo visible |
|
181 |
* Used by the drawing strategies to quickly test whether this geometry |
|
182 |
* intersects with the visible rectangle. |
|
183 |
* |
|
193 | 184 |
* @param x |
194 |
* @param y |
|
195 |
* @param w |
|
196 |
* @param h |
|
197 |
* @return |
|
185 |
* @param y
|
|
186 |
* @param w Width
|
|
187 |
* @param h Height
|
|
188 |
* @return true if <code>this</code> intersects the rectangle defined by the parameters
|
|
198 | 189 |
*/ |
199 | 190 |
public boolean fastIntersects(double x, double y, double w, double h); |
200 | 191 |
|
201 | 192 |
/** |
202 |
* Devuelve el Rect�ngulo que ocupa la geometr�a.
|
|
193 |
* Returns this geometry's boundary rectangle.
|
|
203 | 194 |
* |
204 |
* @return Rect�ngulo.
|
|
195 |
* @return Boundary rectangle.
|
|
205 | 196 |
*/ |
206 | 197 |
public Rectangle2D getBounds2D(); |
207 | 198 |
|
208 | 199 |
/** |
209 |
* Reproyecta la geometr�a a partir del transformador de coordenadas.
|
|
200 |
* Reprojects this geometry by the coordinate transformer passed as parameter.
|
|
210 | 201 |
* |
211 | 202 |
* @param ct Coordinate Transformer. |
212 | 203 |
*/ |
213 | 204 |
public void reProject(ICoordTrans ct); |
214 | 205 |
|
215 | 206 |
/** |
216 |
* Devuelve el GeneralPathXIterator con la informaci�n relativa a la geometr�a.
|
|
217 |
* @param at TODO
|
|
207 |
* Returns the GeneralPathXIterator with this geometry's information
|
|
208 |
* @param at AffineTransform
|
|
218 | 209 |
* |
219 | 210 |
* @return PathIterator. |
220 | 211 |
*/ |
221 | 212 |
public PathIterator getPathIterator(AffineTransform at); |
222 | 213 |
|
223 | 214 |
/** |
224 |
* It returns the handlers of the geomety, |
|
225 |
* these they can be of two types is straightening and of seleccion.
|
|
215 |
* It returns the handlers of the geometry,
|
|
216 |
* these they can be of two types is straightening and of selection.
|
|
226 | 217 |
* |
227 | 218 |
* @param type Type of handlers |
228 | 219 |
* |
... | ... | |
246 | 237 |
public boolean isSimple(); |
247 | 238 |
|
248 | 239 |
/** |
249 |
* @param index |
|
250 |
* @return |
|
240 |
* Invokes a geometry operation given its index and context |
|
241 |
* @param index unique index of the operation. Operation code. |
|
242 |
* @return object returned by the operation. |
|
251 | 243 |
*/ |
252 | 244 |
public Object invokeOperation(int index, GeometryOperationContext ctx) throws GeometryOperationNotSupportedException, GeometryOperationException; |
253 | 245 |
|
246 |
/** |
|
247 |
* Instance of the GeometryType associated to this geometry |
|
248 |
* @return |
|
249 |
*/ |
|
254 | 250 |
public GeometryType getGeometryType(); |
255 | 251 |
|
256 | 252 |
} |
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/util/Converter.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 08-jun-2004 |
|
3 |
* |
|
4 |
* TODO To change the template for this generated file go to |
|
5 |
* Window - Preferences - Java - Code Generation - Code and Comments |
|
6 |
*/ |
|
7 | 1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
8 | 2 |
* |
9 | 3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/GeometryOperationContext.java | ||
---|---|---|
4 | 4 |
import java.util.Map; |
5 | 5 |
|
6 | 6 |
/** |
7 |
* Clase base que sirve de contenedor de parámetros |
|
8 |
* para las operaciones sobre geometrías. |
|
7 |
* This class is a default parameter container for geometry operation.<br> |
|
9 | 8 |
* |
10 |
* Normalmente cada GeometryOperation deberá extender esta clase |
|
11 |
* e identificar los parámetros mediante getters/setters. |
|
9 |
* Normally every GeometryOperation will extend this class and identify |
|
10 |
* its parameters publicly with getters/setters |
|
11 |
* |
|
12 |
* For those operations that need high performance, parameters should be declared as class |
|
13 |
* members instead of using the setAttribute/getAttribute mechanism. This way you avoid a hash |
|
14 |
* and a cast operation. |
|
12 | 15 |
* |
13 |
* Para aquellas operaciones que requieran eficiencia, se deberá |
|
14 |
* declarar los parámetros de la operación como miembros de la clase |
|
15 |
* en vez de usar el mecanismo por defecto (getAttribute/setAttribute), |
|
16 |
* de este modo se evita el acceso <i>hash</i> y el <i>cast</i> posterior. |
|
17 |
* |
|
18 | 16 |
* @author jyarza |
19 | 17 |
* |
20 | 18 |
*/ |
... | ... | |
22 | 20 |
|
23 | 21 |
private Map ctx = new HashMap(); |
24 | 22 |
|
23 |
/** |
|
24 |
* Returns an attribute given its name. |
|
25 |
* If it does not exist returns <code>null</code> |
|
26 |
* @param name |
|
27 |
* @return attribute |
|
28 |
*/ |
|
25 | 29 |
public Object getAttribute(String name) { |
26 | 30 |
return ctx.get(name); |
27 | 31 |
} |
28 | 32 |
|
33 |
/** |
|
34 |
* Sets an attribute |
|
35 |
* @param name |
|
36 |
* @param value |
|
37 |
*/ |
|
29 | 38 |
public void setAttribute(String name, Object value) { |
30 | 39 |
ctx.put(name, value); |
31 | 40 |
} |
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/GeometryOperation.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import org.gvsig.fmap.geom.Geometry; |
4 | 4 |
|
5 |
/** |
|
6 |
* Every geometry operation that is registered dynamically must extend this class.<br> |
|
7 |
* |
|
8 |
* The following example shows how to implement and register a custom operation: |
|
9 |
* |
|
10 |
* <pre> |
|
11 |
* public class MyOperation extends GeometryOperation { |
|
12 |
* |
|
13 |
* // Check GeometryManager for alternative methods to register an operation |
|
14 |
* public static final int OPERATION_INDEX = |
|
15 |
* GeometryManager.getInstance() |
|
16 |
* .registerGeometryOperation("MyOperation", new MyOperation(), geomType); |
|
17 |
* |
|
18 |
* public Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException { |
|
19 |
* // Operation logic goes here |
|
20 |
* } |
|
21 |
* |
|
22 |
* public int getOperationIndex() { |
|
23 |
* return OPERATION_INDEX; |
|
24 |
* } |
|
25 |
* |
|
26 |
* } |
|
27 |
* </pre> |
|
28 |
* |
|
29 |
* @author jiyarza |
|
30 |
* |
|
31 |
*/ |
|
5 | 32 |
public abstract class GeometryOperation { |
6 | 33 |
|
34 |
/** |
|
35 |
* Invokes this operation given the geometry and context |
|
36 |
* @param geom Geometry to which apply this operation |
|
37 |
* @param ctx Parameter container |
|
38 |
* @return Place-holder object that may contain any specific return value. |
|
39 |
* @throws GeometryOperationException The implementation is responsible to throw this exception when needed. |
|
40 |
*/ |
|
7 | 41 |
public abstract Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException; |
8 | 42 |
|
43 |
/** |
|
44 |
* Returns the constant value that identifies this operation and that was obtained upon registering it. |
|
45 |
* @return operation unique index |
|
46 |
*/ |
|
9 | 47 |
public abstract int getOperationIndex(); |
10 | 48 |
} |
Also available in: Unified diff