Revision 29097 branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/GeometryManager.java

View differences:

GeometryManager.java
64 64
 * <li>Offering a set of convenient methods for registering and retrieving geometry types.
65 65
 * <li>Offering a set of convenient methods for registering and retrieving geometry operations associated
66 66
 * to one or more geometry types.
67
 * <li><code>TODO:</code> Offering a set of convenient methods for registering and retrieving custom
68
 * geometry factories.
67
 * <li>Offering a set of convenient methods for registering and retrieving new geometries.
69 68
 * <ul>
70 69
 *
71 70
 * @author jiyarza
72
 *
73 71
 */
74 72
public interface GeometryManager {
75
	 /**
73
	/**
74
	 * <p>
76 75
	 * Registers a GeometryOperation associated to a GeometryType.
77 76
	 * Returns an unique index that is used later to identify and invoke the operation.
78
	 *
79
	 * This method is only used if you already got a reference to the GeometryType. If not,
80
	 * it is more convenient to use the method that receives the geometry class as parameter.
81
	 *
77
	 * </p>
78
	 * <p>
82 79
	 * By convention, the return value should be stored in a public constant within the class implementing
83 80
	 * the operation:<BR>
84 81
	 * <pre>
......
88 85
	 *        .registerGeometryOperation("MyOperation", new MyOperation(), geomType);
89 86
	 * }
90 87
	 * </pre>
88
	 * </p>
91 89
	 * @param geomOpName Operation's unique name
92 90
	 * @param geomOp Specific GeometryOperation's instance implementing this operation
93 91
	 * @param geomType GeometryType instance to which this operation should be associated
......
96 94
	 */
97 95
	public int registerGeometryOperation(String geomOpName,
98 96
			GeometryOperation geomOp, GeometryType geomType);
99
	
97

  
100 98
	/**
101
	 * Registers a GeometryOperation that is common for all GeometryType (registered yet or not)
99
	 * <p>
100
	 * Registers a GeometryOperation that is common for all GeometryType (registered yet or not).
102 101
	 * Returns an unique index that is used later to identify and invoke the operation.
103
	 *
102
	 * </p>
103
	 * <p>
104 104
	 * By convention, the return value should be stored in a public constant within the class implementing
105 105
	 * the operation:<BR>
106 106
	 * <pre>
......
110 110
	 *        .registerGeometryOperation("MyOperation", new MyOperation());
111 111
	 * }
112 112
	 * </pre>
113
	 *
113
	 * </p>
114 114
	 * @param geomOpName Operation's unique name
115 115
	 * @param geomOp Specific GeometryOperation's instance implementing this operation
116 116
	 * @return Index assigned to this operation. This index is used later to access the operation.
117 117
	 */
118 118
	public int registerGeometryOperation(String geomOpName,
119 119
			GeometryOperation geomOp);
120
		
120

  
121 121
	/**
122
	 * Registers a GeometryOperation associated to a GeometryType.
123
	 * Returns an unique index that is used later to identify and invoke the operation.<br>
124
	 *
122
	 * <p>
123
	 * Registers a GeometryOperation associated to a GeometryType, that has been specified 
124
	 * using the type code and the subtype code.
125
	 * Returns an unique index that is used later to identify and invoke the operation.
126
	 * </p>
127
	 * <p>
125 128
	 * By convention, the return value should be stored in a public constant within the class implementing
126 129
	 * the operation:<BR>
127 130
	 * <pre>
......
131 134
	 *        .registerGeometryOperation("MyOperation", new MyOperation(), TYPES.POINT, SUBTYPES.GEOM2D);
132 135
	 * }
133 136
	 * </pre>
134
	 *
137
	 * </p>
138
	 * <p>
135 139
	 * This method is only used if you have not a reference to the GeometryType associated to the
136 140
	 * geometry class. If you have such reference then it is slightly faster to use the method that receives
137 141
	 * the GeometryType.<br>
138
	 *
142
	 * </p>
139 143
	 * @param geomOpName Operation's unique name
140 144
	 * @param geomOp Specific GeometryOperation's instance implementing this operation
141 145
	 * @param type
......
148 152
	 */
149 153
	public int registerGeometryOperation(String geomOpName,
150 154
			GeometryOperation geomOp, int type, int subType) throws GeometryTypeNotSupportedException, GeometryTypeNotValidException;
151
	
155

  
152 156
	/**
153
	 * Registers a GeometryOperation associated to a GeometryType.
157
	 * <p>
158
	 * Registers a GeometryOperation associated to all the geometries with a concrete type.
154 159
	 * Returns an unique index that is used later to identify and invoke the operation.<br>
155
	 *
160
	 * </p>
161
	 * <p>
156 162
	 * By convention, the return value should be stored in a public constant within the class implementing
157 163
	 * the operation:<BR>
158 164
	 * <pre>
159 165
	 * public class MyOperation extends GeometryOperation {
160 166
	 *   public static final int CODE =
161 167
	 *     GeometryManager.getInstance()
162
	 *        .registerGeometryOperation("MyOperation", new MyOperation(), TYPES.POINT, SUBTYPES.GEOM2D);
168
	 *        .registerGeometryOperation("MyOperation", new MyOperation(), TYPES.POINT);
163 169
	 * }
164 170
	 * </pre>
165
	 *
166
	 * This method is only used if you have not a reference to the GeometryType associated to the
167
	 * geometry class. If you have such reference then it is slightly faster to use the method that receives
168
	 * the GeometryType.<br>
169
	 *
171
	 * </p>
170 172
	 * @param geomOpName Operation's unique name
171 173
	 * @param geomOp Specific GeometryOperation's instance implementing this operation
172
	 *  @param type
174
	 * @param type
173 175
	 * Type of geometry. Must be a value defined in {@link Geometry.TYPES}
174 176
	 * @return Index assigned to this operation. This index is used later to access the operation.
175 177
	 */
176 178
	public int registerGeometryOperation(String geomOpName,
177 179
			GeometryOperation geomOp, int type);
178
		
179
	
180

  
181

  
180 182
	/**
181
	 * Registers a GeometryOperation associated to a GeometryType.
183
	 * <p>
184
	 * Registers a GeometryOperation associated to all the geometries with a concrete subtype.
182 185
	 * Returns an unique index that is used later to identify and invoke the operation.<br>
183
	 *
186
	 * </p>
187
	 * <p>
184 188
	 * By convention, the return value should be stored in a public constant within the class implementing
185 189
	 * the operation:<BR>
186 190
	 * <pre>
187 191
	 * public class MyOperation extends GeometryOperation {
188 192
	 *   public static final int CODE =
189 193
	 *     GeometryManager.getInstance()
190
	 *        .registerGeometryOperation("MyOperation", new MyOperation(), TYPES.POINT, SUBTYPES.GEOM2D);
194
	 *        .registerGeometryOperation("MyOperation", new MyOperation(), SUBTYPES.GEOM2D);
191 195
	 * }
192 196
	 * </pre>
193
	 *
194
	 * This method is only used if you have not a reference to the GeometryType associated to the
195
	 * geometry class. If you have such reference then it is slightly faster to use the method that receives
196
	 * the GeometryType.<br>
197
	 *
197
	 * </p>
198 198
	 * @param geomOpName Operation's unique name
199 199
	 * @param geomOp Specific GeometryOperation's instance implementing this operation
200 200
	 * @param subType
......
203 203
	 */
204 204
	public int registerGeometryOperationBySubtype(String geomOpName,
205 205
			GeometryOperation geomOp, int subType);
206
	
206

  
207 207
	/**
208
	 * <p>
208 209
	 * Registers a Geometry implementation class with a predefined geometry type and returns the
209 210
	 * associated GeometryType instance. Available predefined types are defined in {@link Geometry.TYPES}
210 211
	 * If the class is already registered then this method throws an IllegalArgumentException.<br>
......
240 241
	 *             If geomClass is null or does not implement Geometry
241 242
	 */
242 243
	public GeometryType registerGeometryType(Class geomClass, String name, int type, int subType);
243
		
244

  
244 245
	/**
245 246
	 * Registers a Geometry implementation as a new geometry type and returns the
246 247
	 * associated GeometryType instance. If the class is already registered
......
274 275
	 *             If geomClass is null or does not implement Geometry
275 276
	 */
276 277
	public GeometryType registerGeometryType(Class geomClass, int type, int subType);
277
		
278

  
278 279
	/**
279 280
	 * Returns an instance of GeometryType given the associated Geometry implementation
280 281
	 * class.
......
287 288
	 * @throws GeometryTypeNotValidException 
288 289
	 */
289 290
	public GeometryType getGeometryType(int type, int subType) throws GeometryTypeNotSupportedException, GeometryTypeNotValidException;
290
	
291

  
291 292
	/**
292 293
	 * Returns the associated GeometryType given the fully qualified name of
293 294
	 * the Geometry implementation class.
......
297 298
	 * @return GeometryType associated to the class
298 299
	 */
299 300
	public GeometryType getGeometryType(String className) throws GeometryTypeNotSupportedException;
300
	
301

  
301 302
	/**
302 303
	 * This method creates a {@link Geometry} with the type specified 
303 304
	 * by this GeometryType. The geometry is empty, and all the internal 
......
324 325
	public Geometry create(GeometryType geomType) throws CreateGeometryException;
325 326

  
326 327
	public Envelope createEnvelope(int subType) throws CreateEnvelopeException;
327
	
328

  
328 329
	public Envelope createEnvelope(double minX, double minY, double maxX, double maxY, int subType) throws CreateEnvelopeException;
329
	
330

  
330 331
	/**
331 332
	 * This method creates a {@link Geometry} with the type specified 
332 333
	 * by this name. If a geometry with this name doesn't exist, a
......
353 354
	 * the geometry.
354 355
	 */
355 356
	public Geometry create(String name) throws CreateGeometryException;
356
	
357

  
357 358
	/**
358 359
	 * This method creates a {@link Geometry} with the type specified 
359 360
	 * by this id. If a geometry with this id doesn't exist, a
......
384 385
	public Geometry create(int type, int subType) throws CreateGeometryException;
385 386

  
386 387
	public NullGeometry createNullGeometry(int subType) throws CreateGeometryException;
387
	
388
	 /**
388

  
389
	/**
389 390
	 * Create point. If there is an
390 391
	 * error return <code>null</code> and add the error
391 392
	 * to the log
......
397 398
	 * The Point
398 399
	 */
399 400
	public Point createPoint(double x, double y, int subType) throws CreateGeometryException;
400
	
401

  
401 402
	public Curve createCurve(GeneralPathX generalPathX, int subType) throws CreateGeometryException;
402
	
403

  
403 404
	public Surface createSurface(GeneralPathX generalPathX, int subType) throws CreateGeometryException; 
404
	
405

  
405 406
	/**
406 407
	 * Returns an operation given the Geometry type, the Geometry subtype and and the operation
407 408
	 * code. If opCode corresponds to a common operation (a common operation is an operation
......
443 444
	 * @throws GeometryTypeNotValidException 
444 445
	 */
445 446
	public GeometryOperation getGeometryOperation(int opCode, int type, int subType) throws GeometryTypeNotSupportedException, GeometryOperationNotSupportedException, GeometryTypeNotValidException;
446
	
447

  
447 448
	/**
448 449
	 * Invokes an operation given its code, the geometry and the operation context holding the
449 450
	 * parameters required for the operation.
......
454 455
	 * @return The object returned by an operation, depends on each operation.
455 456
	 */
456 457
	public Object invokeOperation(int opCode, Geometry geom, GeometryOperationContext ctx) throws GeometryOperationNotSupportedException, GeometryOperationException;
457
	
458

  
458 459
	/**
459 460
	 * Invokes an operation given its code, the geometry and the operation context holding the
460 461
	 * parameters required for the operation.
......
465 466
	 * @return The object returned by an operation, depends on each operation.
466 467
	 */
467 468
	public Object invokeOperation(String geomOpName, Geometry geom, GeometryOperationContext ctx) throws GeometryOperationNotSupportedException, GeometryOperationException;
468
	
469

  
469 470
	/**
470 471
	 * Unregisters a geometry class.
471 472
	 * @param geomTypeName
472 473
	 * @return
473 474
	 */
474 475
	public GeometryType unregisterGeometryType(Class geomClass);
475
	
476

  
476 477
}

Also available in: Unified diff