Revision 21731
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/GeometryManager.java | ||
---|---|---|
56 | 56 |
/** |
57 | 57 |
* This singleton provides a centralized access to gvSIG's Geometry Model. |
58 | 58 |
* Its responsibilities are:<br> |
59 |
*
|
|
59 |
* |
|
60 | 60 |
* <ul> |
61 | 61 |
* <li>Offering a set of convenient methods for registering and retrieving geometry types. |
62 |
* <li>Offering a set of convenient methods for registering and retrieving geometry operations associated
|
|
62 |
* <li>Offering a set of convenient methods for registering and retrieving geometry operations associated |
|
63 | 63 |
* to one or more geometry types. |
64 |
* <li><code>TODO:</code> Offering a set of convenient methods for registering and retrieving custom
|
|
64 |
* <li><code>TODO:</code> Offering a set of convenient methods for registering and retrieving custom |
|
65 | 65 |
* geometry factories. |
66 | 66 |
* <ul> |
67 |
*
|
|
67 |
* |
|
68 | 68 |
* @author jiyarza |
69 | 69 |
* |
70 | 70 |
*/ |
71 | 71 |
public class GeometryManager { |
72 | 72 |
|
73 | 73 |
private static Logger logger = Logger.getLogger(GeometryManager.class); |
74 |
|
|
74 |
|
|
75 | 75 |
private static GeometryManager instance; |
76 | 76 |
|
77 |
/** This list holds the unique name of all registered geometry operations.
|
|
77 |
/** This list holds the unique name of all registered geometry operations. |
|
78 | 78 |
* The index in which they are stored is also the operation code used to invoke each one of them */ |
79 | 79 |
private List geometryOperations = new ArrayList(); |
80 |
|
|
81 |
/** Common operations are registered here. Type specific operations are registered in the corresponding GeometryType instance */
|
|
80 |
|
|
81 |
/** Common operations are registered here. Type specific operations are registered in the corresponding GeometryType instance */ |
|
82 | 82 |
private List commonOperations = new ArrayList(); |
83 |
|
|
84 |
/** Common operations are assigned an index greater or equal than this constant, so that it is easy and efficient for the manager
|
|
83 |
|
|
84 |
/** Common operations are assigned an index greater or equal than this constant, so that it is easy and efficient for the manager |
|
85 | 85 |
* to decide whether to lookup in the common register or in the type specific register. */ |
86 | 86 |
private static final int COMMON_OPS_OFFSET = 1000; |
87 |
|
|
88 |
/** This map holds the instances of all registered GeometryType. The key is the name of the specific Geometry subclass.
|
|
89 |
* In other words, the string "org.gvsig.fmap.geom.primitive.Point2D" is the hash key to obtain an instance of GeometryType holding the
|
|
87 |
|
|
88 |
/** This map holds the instances of all registered GeometryType. The key is the name of the specific Geometry subclass. |
|
89 |
* In other words, the string "org.gvsig.fmap.geom.primitive.Point2D" is the hash key to obtain an instance of GeometryType holding the |
|
90 | 90 |
* operations associated to the class org.gvsig.fmap.geom.primitive.Point2D. |
91 | 91 |
*/ |
92 | 92 |
private Map geometryTypes = new HashMap(); |
93 |
|
|
94 |
/** GeometryType index counter. Each time a new geometry type is registered it is assigned this counter's value as index and after that
|
|
93 |
|
|
94 |
/** GeometryType index counter. Each time a new geometry type is registered it is assigned this counter's value as index and after that |
|
95 | 95 |
* it is incremented by 1 */ |
96 |
private int geomTypeIndex = 10000;
|
|
96 |
private int geomTypeIndex = 65536;//2^16
|
|
97 | 97 |
|
98 | 98 |
/** |
99 | 99 |
* Geometry Factory |
100 | 100 |
*/ |
101 | 101 |
private GeometryFactory factory = new GeometryFactory(); |
102 |
|
|
102 |
|
|
103 | 103 |
/** |
104 | 104 |
* Singleton's private constructor |
105 | 105 |
*/ |
... | ... | |
125 | 125 |
public void registerGeometryFactory(GeometryFactory factory) { |
126 | 126 |
this.factory = factory; |
127 | 127 |
} |
128 |
|
|
128 |
|
|
129 | 129 |
/** |
130 | 130 |
* Returns the current geometry factory |
131 | 131 |
* @return |
... | ... | |
133 | 133 |
public GeometryFactory getGeometryFactory() { |
134 | 134 |
return factory; |
135 | 135 |
} |
136 |
|
|
136 |
|
|
137 | 137 |
/** |
138 |
* Registers the unique name of one operation. If it already exists then this method does nothing but returning
|
|
139 |
* the name's corresponding index.
|
|
138 |
* Registers the unique name of one operation. If it already exists then this method does nothing but returning |
|
139 |
* the name's corresponding index. |
|
140 | 140 |
* @param geomOpName Name used to register the geometry operation |
141 | 141 |
* @return index assigned to the operation name passed as parameter |
142 | 142 |
*/ |
... | ... | |
151 | 151 |
} |
152 | 152 |
return index; |
153 | 153 |
} |
154 |
|
|
155 |
|
|
154 |
|
|
155 |
|
|
156 | 156 |
/** |
157 |
* Sets a common operation into the common operations map.
|
|
157 |
* Sets a common operation into the common operations map. |
|
158 | 158 |
* @param index index in which to set the operation |
159 | 159 |
* @param geomOp operation to be set |
160 | 160 |
*/ |
161 | 161 |
private void setCommonOperation(int index, GeometryOperation geomOp) { |
162 |
|
|
162 |
|
|
163 | 163 |
while (index > commonOperations.size()) { |
164 | 164 |
commonOperations.add(null); |
165 | 165 |
} |
166 |
|
|
166 |
|
|
167 | 167 |
if (index == commonOperations.size()) { |
168 | 168 |
commonOperations.add(geomOp); |
169 |
} else {
|
|
169 |
} else { |
|
170 | 170 |
commonOperations.set(index, geomOp); |
171 | 171 |
} |
172 |
}
|
|
173 |
|
|
172 |
} |
|
173 |
|
|
174 | 174 |
/** |
175 |
* Registers a GeometryOperation associated to a GeometryType.
|
|
175 |
* Registers a GeometryOperation associated to a GeometryType. |
|
176 | 176 |
* Returns an unique index that is used later to identify and invoke the operation. |
177 |
*
|
|
177 |
* |
|
178 | 178 |
* This method is only used if you already got a reference to the GeometryType. If not, |
179 |
* it is more convenient to use the method that receives the geometry class as parameter.
|
|
180 |
*
|
|
181 |
* By convention, the return value should be stored in a public constant within the class implementing
|
|
182 |
* the operation:<BR>
|
|
179 |
* it is more convenient to use the method that receives the geometry class as parameter. |
|
180 |
* |
|
181 |
* By convention, the return value should be stored in a public constant within the class implementing |
|
182 |
* the operation:<BR> |
|
183 | 183 |
* <pre> |
184 | 184 |
* public class MyOperation extends GeometryOperation { |
185 |
* public static final int CODE =
|
|
185 |
* public static final int CODE = |
|
186 | 186 |
* GeometryManager.getInstance() |
187 | 187 |
* .registerGeometryOperation("MyOperation", new MyOperation(), geomType); |
188 | 188 |
* } |
... | ... | |
191 | 191 |
* @param geomOp Specific GeometryOperation's instance implementing this operation |
192 | 192 |
* @param geomType GeometryType instance to which this operation should be associated |
193 | 193 |
* @return Index assigned to this operation. This index is used later to access the operation. |
194 |
*
|
|
194 |
* |
|
195 | 195 |
*/ |
196 | 196 |
public int registerGeometryOperation(String geomOpName, |
197 | 197 |
GeometryOperation geomOp, GeometryType geomType) { |
... | ... | |
201 | 201 |
throw new IllegalArgumentException("geomType cannot be null."); |
202 | 202 |
|
203 | 203 |
int index = registerGeometryOperationName(geomOpName); |
204 |
|
|
204 |
|
|
205 | 205 |
geomType.setGeometryOperation(index, geomOp); |
206 | 206 |
|
207 | 207 |
return index; |
208 | 208 |
} |
209 | 209 |
|
210 | 210 |
/** |
211 |
* Registers a GeometryOperation that is common for all GeometryType (registered yet or not)
|
|
211 |
* Registers a GeometryOperation that is common for all GeometryType (registered yet or not) |
|
212 | 212 |
* Returns an unique index that is used later to identify and invoke the operation. |
213 |
*
|
|
214 |
* By convention, the return value should be stored in a public constant within the class implementing
|
|
215 |
* the operation:<BR>
|
|
213 |
* |
|
214 |
* By convention, the return value should be stored in a public constant within the class implementing |
|
215 |
* the operation:<BR> |
|
216 | 216 |
* <pre> |
217 | 217 |
* public class MyOperation extends GeometryOperation { |
218 |
* public static final int CODE =
|
|
218 |
* public static final int CODE = |
|
219 | 219 |
* GeometryManager.getInstance() |
220 | 220 |
* .registerGeometryOperation("MyOperation", new MyOperation()); |
221 | 221 |
* } |
222 | 222 |
* </pre> |
223 |
*
|
|
223 |
* |
|
224 | 224 |
* @param geomOpName Operation's unique name |
225 | 225 |
* @param geomOp Specific GeometryOperation's instance implementing this operation |
226 |
* @return Index assigned to this operation. This index is used later to access the operation.
|
|
226 |
* @return Index assigned to this operation. This index is used later to access the operation. |
|
227 | 227 |
*/ |
228 | 228 |
public int registerGeometryOperation(String geomOpName, |
229 | 229 |
GeometryOperation geomOp) { |
... | ... | |
235 | 235 |
int index = registerGeometryOperationName(geomOpName); |
236 | 236 |
|
237 | 237 |
setCommonOperation(index, geomOp); |
238 |
|
|
239 |
|
|
238 |
|
|
239 |
|
|
240 | 240 |
return index + COMMON_OPS_OFFSET; |
241 |
|
|
241 |
|
|
242 | 242 |
} |
243 |
|
|
243 |
|
|
244 | 244 |
/** |
245 |
* Registers a GeometryOperation associated to a GeometryType.
|
|
245 |
* Registers a GeometryOperation associated to a GeometryType. |
|
246 | 246 |
* Returns an unique index that is used later to identify and invoke the operation.<br> |
247 |
*
|
|
248 |
* By convention, the return value should be stored in a public constant within the class implementing
|
|
249 |
* the operation:<BR>
|
|
247 |
* |
|
248 |
* By convention, the return value should be stored in a public constant within the class implementing |
|
249 |
* the operation:<BR> |
|
250 | 250 |
* <pre> |
251 | 251 |
* public class MyOperation extends GeometryOperation { |
252 |
* public static final int CODE =
|
|
252 |
* public static final int CODE = |
|
253 | 253 |
* GeometryManager.getInstance() |
254 | 254 |
* .registerGeometryOperation("MyOperation", new MyOperation(), MyGeometry.class); |
255 | 255 |
* } |
256 | 256 |
* </pre> |
257 |
*
|
|
257 |
* |
|
258 | 258 |
* This method is only used if you have not a reference to the GeometryType associated to the |
259 | 259 |
* geometry class. If you have such reference then it is slightly faster to use the method that receives |
260 | 260 |
* the GeometryType.<br> |
261 |
*
|
|
261 |
* |
|
262 | 262 |
* @param geomOpName Operation's unique name |
263 | 263 |
* @param geomOp Specific GeometryOperation's instance implementing this operation |
264 | 264 |
* @param geomClass Geometry implementation class |
265 | 265 |
* @return Index assigned to this operation. This index is used later to access the operation. |
266 |
*/
|
|
266 |
*/ |
|
267 | 267 |
public int registerGeometryOperation(String geomOpName, |
268 | 268 |
GeometryOperation geomOp, Class geomClass) { |
269 |
|
|
269 |
|
|
270 | 270 |
GeometryType geomType = getGeometryType(geomClass); |
271 | 271 |
return registerGeometryOperation(geomOpName, geomOp, geomType); |
272 | 272 |
} |
273 |
|
|
274 | 273 |
|
274 |
|
|
275 | 275 |
/** |
276 |
* Registers a GeometryOperation associated to a GeometryType.
|
|
276 |
* Registers a GeometryOperation associated to a GeometryType. |
|
277 | 277 |
* Returns an unique index that is used later to identify and invoke the operation.<br> |
278 |
*
|
|
279 |
* By convention, the return value should be stored in a public constant within the class implementing
|
|
280 |
* the operation:<BR>
|
|
278 |
* |
|
279 |
* By convention, the return value should be stored in a public constant within the class implementing |
|
280 |
* the operation:<BR> |
|
281 | 281 |
* <pre> |
282 | 282 |
* public class MyOperation extends GeometryOperation { |
283 |
* public static final int CODE =
|
|
283 |
* public static final int CODE = |
|
284 | 284 |
* GeometryManager.getInstance() |
285 | 285 |
* .registerGeometryOperation("MyOperation", MyOperation.class, myGeomType); |
286 | 286 |
* } |
... | ... | |
296 | 296 |
public int registerGeometryOperation(String geomOpName, Class geomOpClass, |
297 | 297 |
GeometryType geomType) |
298 | 298 |
throws IllegalAccessException, InstantiationException { |
299 |
|
|
300 |
GeometryOperation geomOp = (GeometryOperation) geomOpClass.newInstance();
|
|
301 |
return registerGeometryOperation(geomOpName, geomOp, geomType);
|
|
299 |
|
|
300 |
GeometryOperation geomOp = (GeometryOperation) geomOpClass.newInstance(); |
|
301 |
return registerGeometryOperation(geomOpName, geomOp, geomType); |
|
302 | 302 |
} |
303 | 303 |
|
304 | 304 |
/** |
305 |
* Registers a Geometry implementation class as a new geometry type and returns the
|
|
305 |
* Registers a Geometry implementation class as a new geometry type and returns the |
|
306 | 306 |
* associated GeometryType instance. If the class is already registered |
307 | 307 |
* then this method does nothing but returning the associated GeometryType.<br> |
308 |
*
|
|
308 |
* |
|
309 | 309 |
* How to register a new geometry type: |
310 | 310 |
* <pre> |
311 |
*
|
|
311 |
* |
|
312 | 312 |
* public class MyGeom3D implements Solid { |
313 | 313 |
* private static final GeometryType geomType = GeometryManager.getInstance() |
314 | 314 |
* .registerGeometryType(MyGeom3D.class, "MyGeom3D"); |
315 |
*
|
|
315 |
* |
|
316 | 316 |
* public static final int .CODE = geomType.getType(); |
317 | 317 |
* ... |
318 | 318 |
* public int getType() { |
... | ... | |
320 | 320 |
* } |
321 | 321 |
* } |
322 | 322 |
* </pre> |
323 |
*
|
|
323 |
* |
|
324 | 324 |
* @param geomClass |
325 |
* Geometry subclass. It must not be null and must implement Geometry, otherwise an exception
|
|
325 |
* Geometry subclass. It must not be null and must implement Geometry, otherwise an exception |
|
326 | 326 |
* is raised. |
327 | 327 |
* @param name |
328 |
* Symbolic name for the geometry type, it can be null. If it is null then the symbolic name
|
|
328 |
* Symbolic name for the geometry type, it can be null. If it is null then the symbolic name |
|
329 | 329 |
* will be the simple class name. |
330 | 330 |
* @return Instance of GeometryType associated to the Geometry implementation class |
331 | 331 |
* geomClass |
... | ... | |
356 | 356 |
throw new IllegalArgumentException("Attempt to register a geometry type that is already registered: " + geomClass.getName()); |
357 | 357 |
} |
358 | 358 |
logger.debug("Class " + geomType.getGeometryClass().getName() + " registered with name " + geomType.getName()); |
359 |
|
|
359 |
|
|
360 | 360 |
return geomType; |
361 | 361 |
} |
362 | 362 |
|
363 | 363 |
/** |
364 |
* Registers a Geometry implementation as a new geometry type and returns the
|
|
364 |
* Registers a Geometry implementation as a new geometry type and returns the |
|
365 | 365 |
* associated GeometryType instance. If the class is already registered |
366 | 366 |
* then this method does nothing but returning the associated GeometryType.<br> |
367 |
*
|
|
367 |
* |
|
368 | 368 |
* In this case the symbolic name will be the geometry's simple class name |
369 |
*
|
|
369 |
* |
|
370 | 370 |
* How to register a new geometry type: |
371 | 371 |
* <pre> |
372 |
*
|
|
372 |
* |
|
373 | 373 |
* public class MyGeom3D implements Solid { |
374 | 374 |
* private static final GeometryType geomType = GeometryManager.getInstance() |
375 | 375 |
* .registerGeometryType(MyGeom3D.class); |
376 |
*
|
|
376 |
* |
|
377 | 377 |
* public static final int .CODE = geomType.getType(); |
378 | 378 |
* ... |
379 | 379 |
* public int getType() { |
... | ... | |
381 | 381 |
* } |
382 | 382 |
* } |
383 | 383 |
* </pre> |
384 |
*
|
|
384 |
* |
|
385 | 385 |
* @param geomClass |
386 |
* Geometry implementation class. It must not be null and must implement Geometry,
|
|
386 |
* Geometry implementation class. It must not be null and must implement Geometry, |
|
387 | 387 |
* otherwise an exception is thrown. |
388 | 388 |
* @return Instance of GeometryType associated to the Geometry implementation class |
389 | 389 |
* @throws IllegalArgumentException |
... | ... | |
393 | 393 |
return registerGeometryType(geomClass, null); |
394 | 394 |
} |
395 | 395 |
/** |
396 |
* Returns an instance of GeometryType given the associated Geometry implementation
|
|
396 |
* Returns an instance of GeometryType given the associated Geometry implementation |
|
397 | 397 |
* class. |
398 |
*
|
|
398 |
* |
|
399 | 399 |
* @param geomClass |
400 | 400 |
* @return Instance of GeometryType associated to the Geometry implementation class |
401 | 401 |
*/ |
... | ... | |
407 | 407 |
/** |
408 | 408 |
* Returns the associated GeometryType given the fully qualified name of |
409 | 409 |
* the Geometry implementation class. |
410 |
*
|
|
410 |
* |
|
411 | 411 |
* @param className |
412 | 412 |
* Fully qualified name of the Geometry implementation class |
413 | 413 |
* @return GeometryType associated to the class |
... | ... | |
417 | 417 |
} |
418 | 418 |
|
419 | 419 |
/** |
420 |
* Returns an operation given the Geometry implementation class and the operation
|
|
420 |
* Returns an operation given the Geometry implementation class and the operation |
|
421 | 421 |
* code. If opCode corresponds to a common operation (a common operation is an operation |
422 | 422 |
* registered for all geometries), then this method returns the common operation. |
423 | 423 |
* <br> |
424 |
* For better performance, if you need to call an operation multiple times,
|
|
425 |
* use this method only once and keep the returned object in a local variable
|
|
424 |
* For better performance, if you need to call an operation multiple times, |
|
425 |
* use this method only once and keep the returned object in a local variable |
|
426 | 426 |
* over which you can iterate. For instance: |
427 |
*
|
|
427 |
* |
|
428 | 428 |
* <pre> |
429 | 429 |
* ... |
430 | 430 |
* // Get the operation you need |
... | ... | |
437 | 437 |
* } catch (GeometryOperationNotSupportedException gonse) { |
438 | 438 |
* // treat exception |
439 | 439 |
* } |
440 |
*
|
|
440 |
* |
|
441 | 441 |
* // Fill the operation context with required params |
442 | 442 |
* GeometryOperationContext ctx = new GeometryOperationContext(); |
443 |
*
|
|
444 |
* // Here is the main loop where you call the operation
|
|
443 |
* |
|
444 |
* // Here is the main loop where you call the operation |
|
445 | 445 |
* for (int i=0; i<MyGeometries.length; i++) { |
446 | 446 |
* Object result = geomOp.invoke(myGeometries[i], ctx); |
447 | 447 |
* } |
448 |
*
|
|
448 |
* |
|
449 | 449 |
* </pre> |
450 |
*
|
|
450 |
* |
|
451 | 451 |
* @param geomClass |
452 | 452 |
* @param opCode |
453 | 453 |
* @return Geometry operation |
454 | 454 |
*/ |
455 | 455 |
public GeometryOperation getGeometryOperation(Class geomClass, int opCode) throws GeometryTypeNotSupportedException, GeometryOperationNotSupportedException { |
456 |
|
|
457 |
GeometryOperation geomOp = null;
|
|
458 |
|
|
456 |
|
|
457 |
GeometryOperation geomOp = null; |
|
458 |
|
|
459 | 459 |
// Check if it is a common operation, and if so, get it from the common registry |
460 | 460 |
if (opCode >= COMMON_OPS_OFFSET) { |
461 | 461 |
geomOp = ((GeometryOperation)commonOperations.get(opCode - COMMON_OPS_OFFSET)); |
462 |
|
|
462 |
|
|
463 | 463 |
if (geomOp == null) { |
464 | 464 |
throw new GeometryOperationNotSupportedException(opCode); |
465 | 465 |
} |
466 | 466 |
} else { |
467 |
// If it is type specific, get it from its type registry
|
|
467 |
// If it is type specific, get it from its type registry |
|
468 | 468 |
if (geomClass != null) { |
469 | 469 |
GeometryType geomType = getGeometryType(geomClass); |
470 |
|
|
470 |
|
|
471 | 471 |
// If the geometry type is not registered, throw an exception |
472 | 472 |
if (geomType == null) { |
473 | 473 |
throw new GeometryTypeNotSupportedException(geomClass); |
474 | 474 |
} |
475 |
|
|
475 |
|
|
476 | 476 |
// Get the operation |
477 | 477 |
geomOp = geomType.getGeometryOperation(opCode); |
478 |
|
|
478 |
|
|
479 | 479 |
// If the operation is not registered throw an exception |
480 | 480 |
if (geomOp == null) { |
481 | 481 |
throw new GeometryOperationNotSupportedException(opCode, geomType); |
482 |
}
|
|
482 |
} |
|
483 | 483 |
} |
484 |
}
|
|
484 |
} |
|
485 | 485 |
return geomOp; |
486 | 486 |
} |
487 |
|
|
487 |
|
|
488 | 488 |
/** |
489 |
* Invokes an operation given its code, the geometry and the operation context holding the
|
|
489 |
* Invokes an operation given its code, the geometry and the operation context holding the |
|
490 | 490 |
* parameters required for the operation. |
491 |
*
|
|
491 |
* |
|
492 | 492 |
* @param opCode Operation code. |
493 | 493 |
* @param geom Geometry to which apply the operation |
494 | 494 |
* @param ctx Context holding the operation parameters |
495 |
* @return The object returned by an operation, depends on each operation.
|
|
495 |
* @return The object returned by an operation, depends on each operation. |
|
496 | 496 |
*/ |
497 | 497 |
public Object invokeOperation(int opCode, Geometry geom, GeometryOperationContext ctx) throws GeometryOperationNotSupportedException, GeometryOperationException { |
498 |
|
|
498 |
|
|
499 | 499 |
GeometryOperation geomOp = null; |
500 |
|
|
500 |
|
|
501 | 501 |
if (opCode < COMMON_OPS_OFFSET) { |
502 | 502 |
geomOp = geom.getGeometryType().getGeometryOperation(opCode); |
503 | 503 |
} else { |
504 | 504 |
geomOp = ((GeometryOperation)commonOperations.get(opCode - COMMON_OPS_OFFSET)); |
505 | 505 |
} |
506 |
|
|
506 |
|
|
507 | 507 |
if (geomOp != null) { |
508 | 508 |
return geomOp.invoke(geom, ctx); |
509 | 509 |
} |
510 |
|
|
510 |
|
|
511 | 511 |
throw new GeometryOperationNotSupportedException(opCode, geom.getGeometryType()); |
512 | 512 |
} |
513 | 513 |
} |
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/Surface.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.geom.primitive; |
2 | 2 |
|
3 |
import org.gvsig.fmap.geom.Geometry; |
|
4 | 3 |
|
5 | 4 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
6 | 5 |
* |
... | ... | |
56 | 55 |
*/ |
57 | 56 |
public interface Surface extends OrientableSurface { |
58 | 57 |
/** This predefined geometry's type */ |
59 |
public static final int CODE = Geometry.TYPES.SURFACE;
|
|
58 |
public static final int CODE = TYPES.SURFACE; |
|
60 | 59 |
} |
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/Surface2DZ.java | ||
---|---|---|
46 | 46 |
|
47 | 47 |
/** |
48 | 48 |
* Polilinea 3D. |
49 |
*
|
|
49 |
* |
|
50 | 50 |
* @author Vicente Caballero Navarro |
51 | 51 |
*/ |
52 | 52 |
public class Surface2DZ extends Surface2D implements Surface { |
... | ... | |
55 | 55 |
|
56 | 56 |
private static GeometryType geomType = GeometryManager.getInstance() |
57 | 57 |
.registerGeometryType(Surface2DZ.class); |
58 |
public static int CODE = geomType.getType(); |
|
58 |
public static int CODE = TYPES.SURFACE | TYPES.Z;//geomType.getType();
|
|
59 | 59 |
|
60 | 60 |
double[] pZ = null; |
61 | 61 |
|
62 | 62 |
/** |
63 | 63 |
* Crea un nuevo Polyline3D. |
64 |
*
|
|
64 |
* |
|
65 | 65 |
* @param gpx |
66 | 66 |
* GeneralPathX. |
67 | 67 |
* @param pZ |
... | ... | |
79 | 79 |
|
80 | 80 |
/** |
81 | 81 |
* Clona FPolygon3D. |
82 |
*
|
|
82 |
* |
|
83 | 83 |
* @return FShape clonado. |
84 | 84 |
*/ |
85 | 85 |
public FShape cloneFShape() { |
... | ... | |
89 | 89 |
|
90 | 90 |
/** |
91 | 91 |
* Devuelve un array con los valores de todas las Z. |
92 |
*
|
|
92 |
* |
|
93 | 93 |
* @return Array de Zs. |
94 | 94 |
*/ |
95 | 95 |
public double[] getZs() { |
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/Curve2D.java | ||
---|---|---|
58 | 58 |
private static GeometryType geomType = GeometryManager.getInstance() |
59 | 59 |
.registerGeometryType(Curve2D.class); |
60 | 60 |
|
61 |
public static int CODE = geomType.getType(); |
|
61 |
public static int CODE = TYPES.CURVE;//geomType.getType();
|
|
62 | 62 |
|
63 | 63 |
public Curve2D(String id, IProjection projection, GeneralPathX gpx) { |
64 | 64 |
super(id, projection, gpx); |
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/Ellipse2D.java | ||
---|---|---|
56 | 56 |
|
57 | 57 |
/** |
58 | 58 |
* DOCUMENT ME! |
59 |
*
|
|
59 |
* |
|
60 | 60 |
* @author Vicente Caballero Navarro |
61 | 61 |
*/ |
62 | 62 |
public class Ellipse2D extends Surface2D implements Surface { |
... | ... | |
65 | 65 |
|
66 | 66 |
private static GeometryType geomType = GeometryManager.getInstance() |
67 | 67 |
.registerGeometryType(Ellipse2D.class); |
68 |
public static int CODE = geomType.getType(); |
|
68 |
public static int CODE = TYPES.ELLIPSE;//geomType.getType();
|
|
69 | 69 |
|
70 | 70 |
private Point2D init; |
71 | 71 |
private Point2D end; |
... | ... | |
73 | 73 |
|
74 | 74 |
/** |
75 | 75 |
* DOCUMENT ME! |
76 |
*
|
|
76 |
* |
|
77 | 77 |
* @param gpx |
78 | 78 |
*/ |
79 | 79 |
public Ellipse2D(String id, IProjection projection, GeneralPathX gpx, |
... | ... | |
98 | 98 |
|
99 | 99 |
/* |
100 | 100 |
* (non-Javadoc) |
101 |
*
|
|
101 |
* |
|
102 | 102 |
* @see com.iver.cit.gvsig.fmap.core.FShape#cloneFShape() |
103 | 103 |
*/ |
104 | 104 |
public FShape cloneFShape() { |
... | ... | |
115 | 115 |
|
116 | 116 |
/** |
117 | 117 |
* DOCUMENT ME! |
118 |
*
|
|
118 |
* |
|
119 | 119 |
* @param at |
120 | 120 |
* DOCUMENT ME! |
121 | 121 |
*/ |
... | ... | |
142 | 142 |
|
143 | 143 |
/** |
144 | 144 |
* DOCUMENT ME! |
145 |
*
|
|
145 |
* |
|
146 | 146 |
* @return DOCUMENT ME! |
147 | 147 |
*/ |
148 | 148 |
public Handler[] getStretchingHandlers() { |
... | ... | |
174 | 174 |
|
175 | 175 |
/** |
176 | 176 |
* DOCUMENT ME! |
177 |
*
|
|
177 |
* |
|
178 | 178 |
* @author Vicente Caballero Navarro |
179 | 179 |
*/ |
180 | 180 |
class CenterHandler extends AbstractHandler implements Handler { |
181 | 181 |
/** |
182 | 182 |
* Crea un nuevo PointHandler. |
183 |
*
|
|
183 |
* |
|
184 | 184 |
* @param i |
185 | 185 |
* DOCUMENT ME! |
186 | 186 |
* @param x |
... | ... | |
195 | 195 |
|
196 | 196 |
/** |
197 | 197 |
* DOCUMENT ME! |
198 |
*
|
|
198 |
* |
|
199 | 199 |
* @param x |
200 | 200 |
* DOCUMENT ME! |
201 | 201 |
* @param y |
202 | 202 |
* DOCUMENT ME! |
203 |
*
|
|
203 |
* |
|
204 | 204 |
* @return DOCUMENT ME! |
205 | 205 |
*/ |
206 | 206 |
public void move(double x, double y) { |
... | ... | |
221 | 221 |
|
222 | 222 |
/** |
223 | 223 |
* DOCUMENT ME! |
224 |
*
|
|
224 |
* |
|
225 | 225 |
* @author Vicente Caballero Navarro |
226 | 226 |
*/ |
227 | 227 |
class CenterSelHandler extends AbstractHandler implements Handler { |
228 | 228 |
/** |
229 | 229 |
* Crea un nuevo PointHandler. |
230 |
*
|
|
230 |
* |
|
231 | 231 |
* @param i |
232 | 232 |
* DOCUMENT ME! |
233 | 233 |
* @param x |
... | ... | |
242 | 242 |
|
243 | 243 |
/** |
244 | 244 |
* DOCUMENT ME! |
245 |
*
|
|
245 |
* |
|
246 | 246 |
* @param x |
247 | 247 |
* DOCUMENT ME! |
248 | 248 |
* @param y |
249 | 249 |
* DOCUMENT ME! |
250 |
*
|
|
250 |
* |
|
251 | 251 |
* @return DOCUMENT ME! |
252 | 252 |
*/ |
253 | 253 |
public void move(double x, double y) { |
... | ... | |
276 | 276 |
|
277 | 277 |
/** |
278 | 278 |
* DOCUMENT ME! |
279 |
*
|
|
279 |
* |
|
280 | 280 |
* @author Vicente Caballero Navarro |
281 | 281 |
*/ |
282 | 282 |
class InitSelHandler extends AbstractHandler implements CuadrantHandler { |
283 | 283 |
/** |
284 | 284 |
* Crea un nuevo PointHandler. |
285 |
*
|
|
285 |
* |
|
286 | 286 |
* @param i |
287 | 287 |
* DOCUMENT ME! |
288 | 288 |
* @param x |
... | ... | |
297 | 297 |
|
298 | 298 |
/** |
299 | 299 |
* DOCUMENT ME! |
300 |
*
|
|
300 |
* |
|
301 | 301 |
* @param x |
302 | 302 |
* DOCUMENT ME! |
303 | 303 |
* @param y |
304 | 304 |
* DOCUMENT ME! |
305 |
*
|
|
305 |
* |
|
306 | 306 |
* @return DOCUMENT ME! |
307 | 307 |
*/ |
308 | 308 |
public void move(double x, double y) { |
... | ... | |
346 | 346 |
|
347 | 347 |
/** |
348 | 348 |
* DOCUMENT ME! |
349 |
*
|
|
349 |
* |
|
350 | 350 |
* @author Vicente Caballero Navarro |
351 | 351 |
*/ |
352 | 352 |
class EndSelHandler extends AbstractHandler implements CuadrantHandler { |
353 | 353 |
/** |
354 | 354 |
* Crea un nuevo PointHandler. |
355 |
*
|
|
355 |
* |
|
356 | 356 |
* @param i |
357 | 357 |
* DOCUMENT ME! |
358 | 358 |
* @param x |
... | ... | |
367 | 367 |
|
368 | 368 |
/** |
369 | 369 |
* DOCUMENT ME! |
370 |
*
|
|
370 |
* |
|
371 | 371 |
* @param x |
372 | 372 |
* DOCUMENT ME! |
373 | 373 |
* @param y |
374 | 374 |
* DOCUMENT ME! |
375 |
*
|
|
375 |
* |
|
376 | 376 |
* @return DOCUMENT ME! |
377 | 377 |
*/ |
378 | 378 |
public void move(double x, double y) { |
... | ... | |
416 | 416 |
|
417 | 417 |
/** |
418 | 418 |
* DOCUMENT ME! |
419 |
*
|
|
419 |
* |
|
420 | 420 |
* @author Vicente Caballero Navarro |
421 | 421 |
*/ |
422 | 422 |
class RadioSelYHandler extends AbstractHandler implements CuadrantHandler { |
423 | 423 |
/** |
424 | 424 |
* Crea un nuevo PointHandler. |
425 |
*
|
|
425 |
* |
|
426 | 426 |
* @param i |
427 | 427 |
* DOCUMENT ME! |
428 | 428 |
* @param x |
... | ... | |
437 | 437 |
|
438 | 438 |
/** |
439 | 439 |
* DOCUMENT ME! |
440 |
*
|
|
440 |
* |
|
441 | 441 |
* @param x |
442 | 442 |
* DOCUMENT ME! |
443 | 443 |
* @param y |
444 | 444 |
* DOCUMENT ME! |
445 |
*
|
|
445 |
* |
|
446 | 446 |
* @return DOCUMENT ME! |
447 | 447 |
*/ |
448 | 448 |
public void move(double x, double y) { |
... | ... | |
480 | 480 |
|
481 | 481 |
/* |
482 | 482 |
* (non-Javadoc) |
483 |
*
|
|
483 |
* |
|
484 | 484 |
* @see com.iver.cit.gvsig.fmap.core.FPolyline2D#intersects(java.awt.geom.Rectangle2D) |
485 | 485 |
*/ |
486 | 486 |
public boolean intersects(Rectangle2D r) { |
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 | 2 |
|
3 |
import org.gvsig.fmap.geom.Geometry; |
|
4 | 3 |
|
5 | 4 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
6 | 5 |
* |
... | ... | |
55 | 54 |
* @author Jorge Piera Llodr? (jorge.piera@iver.es) |
56 | 55 |
*/ |
57 | 56 |
public interface Curve extends OrientableCurve{ |
58 |
|
|
57 |
|
|
59 | 58 |
/** This predefined geometry's type */ |
60 |
public static final int CODE = Geometry.TYPES.CURVE;
|
|
59 |
public static final int CODE = TYPES.CURVE; |
|
61 | 60 |
} |
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/NullGeometry.java | ||
---|---|---|
64 | 64 |
private static GeometryType geomType = GeometryManager.getInstance() |
65 | 65 |
.registerGeometryType(NullGeometry.class); |
66 | 66 |
|
67 |
public static int CODE = geomType.getType(); |
|
67 |
public static int CODE = TYPES.NULL;//geomType.getType();
|
|
68 | 68 |
|
69 | 69 |
|
70 | 70 |
public NullGeometry() { |
... | ... | |
227 | 227 |
// TODO Auto-generated method stub |
228 | 228 |
return null; |
229 | 229 |
} |
230 |
|
|
230 |
|
|
231 | 231 |
} |
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/Circle2D.java | ||
---|---|---|
66 | 66 |
private static GeometryType geomType = GeometryManager.getInstance() |
67 | 67 |
.registerGeometryType(Circle2D.class); |
68 | 68 |
|
69 |
public static int CODE = geomType.getType(); |
|
69 |
public static int CODE = TYPES.CIRCLE;//geomType.getType();
|
|
70 | 70 |
|
71 | 71 |
private Point2D center; |
72 | 72 |
private double radio; |
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/Arc2D.java | ||
---|---|---|
72 | 72 |
private static GeometryType geomType = GeometryManager.getInstance() |
73 | 73 |
.registerGeometryType(Arc2D.class); |
74 | 74 |
|
75 |
public static int CODE = geomType.getType(); |
|
75 |
public static int CODE = TYPES.ARC;//geomType.getType();
|
|
76 | 76 |
|
77 | 77 |
private Point2D init; |
78 | 78 |
private Point2D center; |
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 | 4 |
public interface Circle extends Arc { |
6 |
|
|
5 |
|
|
7 | 6 |
/** This predefined geometry's type */ |
8 |
public static final int CODE = Geometry.TYPES.CIRCLE;
|
|
7 |
public static final int CODE = TYPES.CIRCLE; |
|
9 | 8 |
} |
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/Curve2DZ.java | ||
---|---|---|
46 | 46 |
|
47 | 47 |
/** |
48 | 48 |
* Polilinea 3D. |
49 |
*
|
|
49 |
* |
|
50 | 50 |
* @author Vicente Caballero Navarro |
51 | 51 |
*/ |
52 | 52 |
public class Curve2DZ extends Curve2D implements Curve { |
... | ... | |
55 | 55 |
|
56 | 56 |
private static GeometryType geomType = GeometryManager.getInstance() |
57 | 57 |
.registerGeometryType(Curve2DZ.class); |
58 |
public static int CODE = geomType.getType(); |
|
58 |
public static int CODE = TYPES.CURVE | TYPES.Z;//geomType.getType();
|
|
59 | 59 |
|
60 | 60 |
double[] pZ = null; |
61 | 61 |
|
62 | 62 |
/** |
63 | 63 |
* Crea un nuevo Polyline3D. |
64 |
*
|
|
64 |
* |
|
65 | 65 |
* @param gpx |
66 | 66 |
* GeneralPathX |
67 | 67 |
* @param pZ |
... | ... | |
86 | 86 |
|
87 | 87 |
/** |
88 | 88 |
* Devuelve un Array con todos los valores de Z. |
89 |
*
|
|
89 |
* |
|
90 | 90 |
* @return Array de Zs. |
91 | 91 |
*/ |
92 | 92 |
public double[] getZs() { |
... | ... | |
95 | 95 |
|
96 | 96 |
/* |
97 | 97 |
* (non-Javadoc) |
98 |
*
|
|
98 |
* |
|
99 | 99 |
* @see com.iver.cit.gvsig.fmap.core.FShape#cloneFShape() |
100 | 100 |
*/ |
101 | 101 |
public FShape cloneFShape() { |
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; |
|
4 | 3 |
|
5 | 4 |
|
6 | 5 |
public interface Arc extends Curve { |
7 |
|
|
6 |
|
|
8 | 7 |
/** This predefined geometry's type */ |
9 |
public static final int CODE = Geometry.TYPES.ARC;
|
|
8 |
public static final int CODE = TYPES.ARC;
|
|
10 | 9 |
} |
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/Point2DZ.java | ||
---|---|---|
52 | 52 |
public class Point2DZ extends Point2D implements Point{ |
53 | 53 |
|
54 | 54 |
private static final long serialVersionUID = 1L; |
55 |
|
|
55 |
|
|
56 | 56 |
private static GeometryType geomType = GeometryManager.getInstance() |
57 | 57 |
.registerGeometryType(Point2DZ.class); |
58 | 58 |
|
59 |
public static int CODE = geomType.getType();
|
|
60 |
|
|
59 |
public static int CODE = TYPES.POINT | TYPES.Z;//geomType.getType();
|
|
60 |
|
|
61 | 61 |
double z; |
62 | 62 |
|
63 | 63 |
/** |
... | ... | |
71 | 71 |
super(id, projection, x, y); |
72 | 72 |
this.z = z; |
73 | 73 |
} |
74 |
|
|
74 |
|
|
75 | 75 |
public Point2DZ(double x, double y, double z) { |
76 | 76 |
this(null, null, x, y, z); |
77 | 77 |
} |
... | ... | |
106 | 106 |
public int getCoordinateDimension() { |
107 | 107 |
return 3; |
108 | 108 |
} |
109 |
|
|
109 |
|
|
110 | 110 |
public GeometryType getGeometryType() { |
111 | 111 |
return geomType; |
112 | 112 |
} |
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/Surface2D.java | ||
---|---|---|
48 | 48 |
|
49 | 49 |
/** |
50 | 50 |
* Pol�gono 2D. |
51 |
*
|
|
51 |
* |
|
52 | 52 |
* @author Vicente Caballero Navarro |
53 | 53 |
*/ |
54 | 54 |
public class Surface2D extends OrientableSurface2D implements Surface { |
55 | 55 |
|
56 | 56 |
private static final long serialVersionUID = 1L; |
57 |
|
|
57 |
|
|
58 | 58 |
private GeneralPathX generalpathx; |
59 |
|
|
59 |
|
|
60 | 60 |
private static GeometryType geomType = GeometryManager.getInstance() |
61 | 61 |
.registerGeometryType(Surface2D.class); |
62 |
|
|
63 |
public static int CODE = geomType.getType(); |
|
64 | 62 |
|
63 |
public static int CODE = TYPES.SURFACE;//geomType.getType(); |
|
64 |
|
|
65 | 65 |
/** |
66 | 66 |
* Crea un nuevo Polygon2D. |
67 |
*
|
|
67 |
* |
|
68 | 68 |
* @param gpx |
69 | 69 |
* GeneralPathX. |
70 | 70 |
*/ |
... | ... | |
87 | 87 |
|
88 | 88 |
/** |
89 | 89 |
* Clona FPolygon2D. |
90 |
*
|
|
90 |
* |
|
91 | 91 |
* @return FShape clonado. |
92 | 92 |
*/ |
93 | 93 |
public FShape cloneFShape() { |
... | ... | |
96 | 96 |
|
97 | 97 |
/* |
98 | 98 |
* (non-Javadoc) |
99 |
*
|
|
99 |
* |
|
100 | 100 |
* @see java.awt.Shape#intersects(java.awt.geom.Rectangle2D) |
101 | 101 |
*/ |
102 | 102 |
public boolean intersects(Rectangle2D r) { |
103 | 103 |
return gp.intersects(r); |
104 | 104 |
} |
105 |
|
|
105 |
|
|
106 | 106 |
public GeometryType getGeometryType() { |
107 | 107 |
return geomType; |
108 | 108 |
} |
109 |
|
|
109 |
|
|
110 | 110 |
public int getType() { |
111 | 111 |
return CODE; |
112 | 112 |
} |
... | ... | |
114 | 114 |
public GeneralPathX getGeneralPath() { |
115 | 115 |
// TODO Auto-generated method stub |
116 | 116 |
return generalpathx; |
117 |
}
|
|
117 |
} |
|
118 | 118 |
} |
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/Point2D.java | ||
---|---|---|
48 | 48 |
|
49 | 49 |
import org.cresques.cts.ICoordTrans; |
50 | 50 |
import org.cresques.cts.IProjection; |
51 |
import org.gvsig.fmap.geom.Geometry; |
|
51 | 52 |
import org.gvsig.fmap.geom.GeometryManager; |
52 | 53 |
import org.gvsig.fmap.geom.handler.AbstractHandler; |
53 | 54 |
import org.gvsig.fmap.geom.handler.FinalHandler; |
... | ... | |
68 | 69 |
private static final GeometryType geomType = GeometryManager.getInstance() |
69 | 70 |
.registerGeometryType(Point2D.class); |
70 | 71 |
|
71 |
public static final int CODE = geomType.getType(); |
|
72 |
public static final int CODE = TYPES.POINT;//geomType.getType();
|
|
72 | 73 |
|
73 | 74 |
|
74 | 75 |
/** |
Also available in: Unified diff