svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / GeometryManager.java @ 29018
History | View | Annotate | Download (18.3 KB)
1 | 21008 | jiyarza | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | 20861 | jiyarza | *
|
3 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | *
|
||
19 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | 21008 | jiyarza | * Av. Blasco Ib??ez, 50
|
24 | 20861 | jiyarza | * 46010 VALENCIA
|
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | 20761 | jmvivo | package org.gvsig.fmap.geom; |
42 | |||
43 | 27397 | jpiera | import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
44 | import org.gvsig.fmap.geom.exception.CreateGeometryException; |
||
45 | 26788 | jpiera | import org.gvsig.fmap.geom.operation.GeometryOperation; |
46 | import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
||
47 | import org.gvsig.fmap.geom.operation.GeometryOperationException; |
||
48 | import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
||
49 | 27397 | jpiera | import org.gvsig.fmap.geom.primitive.Curve; |
50 | 27019 | jpiera | import org.gvsig.fmap.geom.primitive.Envelope; |
51 | 27397 | jpiera | import org.gvsig.fmap.geom.primitive.GeneralPathX; |
52 | import org.gvsig.fmap.geom.primitive.NullGeometry; |
||
53 | import org.gvsig.fmap.geom.primitive.Point; |
||
54 | import org.gvsig.fmap.geom.primitive.Surface; |
||
55 | 20761 | jmvivo | import org.gvsig.fmap.geom.type.GeometryType; |
56 | 21308 | jiyarza | import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException; |
57 | 28085 | jpiera | import org.gvsig.fmap.geom.type.GeometryTypeNotValidException; |
58 | 20761 | jmvivo | |
59 | 21008 | jiyarza | /**
|
60 | * This singleton provides a centralized access to gvSIG's Geometry Model.
|
||
61 | 21047 | jiyarza | * Its responsibilities are:<br>
|
62 | 21731 | vcaballero | *
|
63 | 21047 | jiyarza | * <ul>
|
64 | * <li>Offering a set of convenient methods for registering and retrieving geometry types.
|
||
65 | 21731 | vcaballero | * <li>Offering a set of convenient methods for registering and retrieving geometry operations associated
|
66 | 21008 | jiyarza | * to one or more geometry types.
|
67 | 21731 | vcaballero | * <li><code>TODO:</code> Offering a set of convenient methods for registering and retrieving custom
|
68 | 21047 | jiyarza | * geometry factories.
|
69 | * <ul>
|
||
70 | 21731 | vcaballero | *
|
71 | 21008 | jiyarza | * @author jiyarza
|
72 | *
|
||
73 | */
|
||
74 | 26788 | jpiera | public interface GeometryManager { |
75 | /**
|
||
76 | 21731 | vcaballero | * Registers a GeometryOperation associated to a GeometryType.
|
77 | 21008 | jiyarza | * Returns an unique index that is used later to identify and invoke the operation.
|
78 | 21731 | vcaballero | *
|
79 | 21047 | jiyarza | * This method is only used if you already got a reference to the GeometryType. If not,
|
80 | 21731 | vcaballero | * it is more convenient to use the method that receives the geometry class as parameter.
|
81 | *
|
||
82 | * By convention, the return value should be stored in a public constant within the class implementing
|
||
83 | * the operation:<BR>
|
||
84 | 21007 | jiyarza | * <pre>
|
85 | * public class MyOperation extends GeometryOperation {
|
||
86 | 21731 | vcaballero | * public static final int CODE =
|
87 | 21007 | jiyarza | * GeometryManager.getInstance()
|
88 | 21047 | jiyarza | * .registerGeometryOperation("MyOperation", new MyOperation(), geomType);
|
89 | 21007 | jiyarza | * }
|
90 | * </pre>
|
||
91 | 21008 | jiyarza | * @param geomOpName Operation's unique name
|
92 | * @param geomOp Specific GeometryOperation's instance implementing this operation
|
||
93 | * @param geomType GeometryType instance to which this operation should be associated
|
||
94 | * @return Index assigned to this operation. This index is used later to access the operation.
|
||
95 | 21731 | vcaballero | *
|
96 | 20761 | jmvivo | */
|
97 | public int registerGeometryOperation(String geomOpName, |
||
98 | 26788 | jpiera | GeometryOperation geomOp, GeometryType geomType); |
99 | |||
100 | 20953 | jiyarza | /**
|
101 | 21731 | vcaballero | * Registers a GeometryOperation that is common for all GeometryType (registered yet or not)
|
102 | 21008 | jiyarza | * Returns an unique index that is used later to identify and invoke the operation.
|
103 | 21731 | vcaballero | *
|
104 | * By convention, the return value should be stored in a public constant within the class implementing
|
||
105 | * the operation:<BR>
|
||
106 | 21007 | jiyarza | * <pre>
|
107 | * public class MyOperation extends GeometryOperation {
|
||
108 | 21731 | vcaballero | * public static final int CODE =
|
109 | 21007 | jiyarza | * GeometryManager.getInstance()
|
110 | * .registerGeometryOperation("MyOperation", new MyOperation());
|
||
111 | * }
|
||
112 | * </pre>
|
||
113 | 21731 | vcaballero | *
|
114 | 21008 | jiyarza | * @param geomOpName Operation's unique name
|
115 | * @param geomOp Specific GeometryOperation's instance implementing this operation
|
||
116 | 21731 | vcaballero | * @return Index assigned to this operation. This index is used later to access the operation.
|
117 | 20953 | jiyarza | */
|
118 | 20918 | jiyarza | public int registerGeometryOperation(String geomOpName, |
119 | 26788 | jpiera | GeometryOperation geomOp); |
120 | 27229 | jpiera | |
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 | *
|
||
125 | * By convention, the return value should be stored in a public constant within the class implementing
|
||
126 | * the operation:<BR>
|
||
127 | * <pre>
|
||
128 | * public class MyOperation extends GeometryOperation {
|
||
129 | * public static final int CODE =
|
||
130 | * GeometryManager.getInstance()
|
||
131 | * .registerGeometryOperation("MyOperation", new MyOperation(), TYPES.POINT, SUBTYPES.GEOM2D);
|
||
132 | * }
|
||
133 | * </pre>
|
||
134 | *
|
||
135 | * This method is only used if you have not a reference to the GeometryType associated to the
|
||
136 | * geometry class. If you have such reference then it is slightly faster to use the method that receives
|
||
137 | * the GeometryType.<br>
|
||
138 | *
|
||
139 | * @param geomOpName Operation's unique name
|
||
140 | * @param geomOp Specific GeometryOperation's instance implementing this operation
|
||
141 | * @param type
|
||
142 | * Type of geometry. Must be a value defined in {@link Geometry.TYPES}
|
||
143 | * @param subType
|
||
144 | * SubType of geometry. Must be a value defined in {@link Geometry.SUBTYPES}
|
||
145 | * @return Index assigned to this operation. This index is used later to access the operation.
|
||
146 | 28085 | jpiera | * @throws GeometryTypeNotSupportedException
|
147 | * @throws GeometryTypeNotValidException
|
||
148 | 27229 | jpiera | */
|
149 | public int registerGeometryOperation(String geomOpName, |
||
150 | 28085 | jpiera | GeometryOperation geomOp, int type, int subType) throws GeometryTypeNotSupportedException, GeometryTypeNotValidException; |
151 | 26788 | jpiera | |
152 | 21008 | jiyarza | /**
|
153 | 21731 | vcaballero | * Registers a GeometryOperation associated to a GeometryType.
|
154 | 21047 | jiyarza | * Returns an unique index that is used later to identify and invoke the operation.<br>
|
155 | 21731 | vcaballero | *
|
156 | * By convention, the return value should be stored in a public constant within the class implementing
|
||
157 | * the operation:<BR>
|
||
158 | 21047 | jiyarza | * <pre>
|
159 | * public class MyOperation extends GeometryOperation {
|
||
160 | 21731 | vcaballero | * public static final int CODE =
|
161 | 21047 | jiyarza | * GeometryManager.getInstance()
|
162 | 27229 | jpiera | * .registerGeometryOperation("MyOperation", new MyOperation(), TYPES.POINT, SUBTYPES.GEOM2D);
|
163 | 21047 | jiyarza | * }
|
164 | * </pre>
|
||
165 | 21731 | vcaballero | *
|
166 | 21047 | jiyarza | * 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 | 21731 | vcaballero | *
|
170 | 21047 | jiyarza | * @param geomOpName Operation's unique name
|
171 | * @param geomOp Specific GeometryOperation's instance implementing this operation
|
||
172 | 27229 | jpiera | * @param type
|
173 | * Type of geometry. Must be a value defined in {@link Geometry.TYPES}
|
||
174 | 21047 | jiyarza | * @return Index assigned to this operation. This index is used later to access the operation.
|
175 | 21731 | vcaballero | */
|
176 | 20918 | jiyarza | public int registerGeometryOperation(String geomOpName, |
177 | 27229 | jpiera | GeometryOperation geomOp, int type);
|
178 | |||
179 | 26788 | jpiera | |
180 | 20761 | jmvivo | /**
|
181 | 21731 | vcaballero | * Registers a GeometryOperation associated to a GeometryType.
|
182 | 21047 | jiyarza | * Returns an unique index that is used later to identify and invoke the operation.<br>
|
183 | 21731 | vcaballero | *
|
184 | * By convention, the return value should be stored in a public constant within the class implementing
|
||
185 | * the operation:<BR>
|
||
186 | 21047 | jiyarza | * <pre>
|
187 | * public class MyOperation extends GeometryOperation {
|
||
188 | 21731 | vcaballero | * public static final int CODE =
|
189 | 21047 | jiyarza | * GeometryManager.getInstance()
|
190 | 27229 | jpiera | * .registerGeometryOperation("MyOperation", new MyOperation(), TYPES.POINT, SUBTYPES.GEOM2D);
|
191 | 21047 | jiyarza | * }
|
192 | * </pre>
|
||
193 | *
|
||
194 | 27229 | jpiera | * 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 | *
|
||
198 | 21047 | jiyarza | * @param geomOpName Operation's unique name
|
199 | 27229 | jpiera | * @param geomOp Specific GeometryOperation's instance implementing this operation
|
200 | * @param subType
|
||
201 | * SubType of geometry. Must be a value defined in {@link Geometry.SUBTYPES}
|
||
202 | 21047 | jiyarza | * @return Index assigned to this operation. This index is used later to access the operation.
|
203 | 20761 | jmvivo | */
|
204 | 27229 | jpiera | public int registerGeometryOperationBySubtype(String geomOpName, |
205 | GeometryOperation geomOp, int subType);
|
||
206 | 26788 | jpiera | |
207 | 20761 | jmvivo | /**
|
208 | 26788 | jpiera | * Registers a Geometry implementation class with a predefined geometry type and returns the
|
209 | * associated GeometryType instance. Available predefined types are defined in {@link Geometry.TYPES}
|
||
210 | * If the class is already registered then this method throws an IllegalArgumentException.<br>
|
||
211 | 21731 | vcaballero | *
|
212 | 26788 | jpiera | * How to register a geometry class with a predefined type:
|
213 | 21049 | jiyarza | * <pre>
|
214 | 21731 | vcaballero | *
|
215 | 26788 | jpiera | * public class Point2D implements Point {
|
216 | 21049 | jiyarza | * private static final GeometryType geomType = GeometryManager.getInstance()
|
217 | 26788 | jpiera | * .registerBasicGeometryType(Point2D.class, "Point2D", Geometry.TYPES.POINT);
|
218 | 21731 | vcaballero | *
|
219 | 21750 | jiyarza | * public static final int CODE = geomType.getType();
|
220 | 21049 | jiyarza | * ...
|
221 | * public int getType() {
|
||
222 | 21750 | jiyarza | * return CODE;
|
223 | 21049 | jiyarza | * }
|
224 | * }
|
||
225 | * </pre>
|
||
226 | 21731 | vcaballero | *
|
227 | 20761 | jmvivo | * @param geomClass
|
228 | 21731 | vcaballero | * Geometry subclass. It must not be null and must implement Geometry, otherwise an exception
|
229 | 21047 | jiyarza | * is raised.
|
230 | 21007 | jiyarza | * @param name
|
231 | 21731 | vcaballero | * Symbolic name for the geometry type, it can be null. If it is null then the symbolic name
|
232 | 21047 | jiyarza | * will be the simple class name.
|
233 | 26788 | jpiera | * @param type
|
234 | 26866 | jpiera | * Type of geometry. Must be a value defined in {@link Geometry.TYPES}
|
235 | * @param subType
|
||
236 | * SubType of geometry. Must be a value defined in {@link Geometry.SUBTYPES}
|
||
237 | 21047 | jiyarza | * @return Instance of GeometryType associated to the Geometry implementation class
|
238 | 20761 | jmvivo | * geomClass
|
239 | * @throws IllegalArgumentException
|
||
240 | 21047 | jiyarza | * If geomClass is null or does not implement Geometry
|
241 | 20761 | jmvivo | */
|
242 | 26866 | jpiera | public GeometryType registerGeometryType(Class geomClass, String name, int type, int subType); |
243 | 26809 | jpiera | |
244 | 21732 | vcaballero | /**
|
245 | 21731 | vcaballero | * Registers a Geometry implementation as a new geometry type and returns the
|
246 | 21047 | jiyarza | * associated GeometryType instance. If the class is already registered
|
247 | 21750 | jiyarza | * then this method throws an IllegalArgumentException.<br>
|
248 | 21731 | vcaballero | *
|
249 | 21049 | jiyarza | * In this case the symbolic name will be the geometry's simple class name
|
250 | 21731 | vcaballero | *
|
251 | 21049 | jiyarza | * How to register a new geometry type:
|
252 | * <pre>
|
||
253 | 21731 | vcaballero | *
|
254 | 21049 | jiyarza | * public class MyGeom3D implements Solid {
|
255 | * private static final GeometryType geomType = GeometryManager.getInstance()
|
||
256 | * .registerGeometryType(MyGeom3D.class);
|
||
257 | 21731 | vcaballero | *
|
258 | 21081 | jiyarza | * public static final int .CODE = geomType.getType();
|
259 | 21049 | jiyarza | * ...
|
260 | * public int getType() {
|
||
261 | 21081 | jiyarza | * return .CODE;
|
262 | 21049 | jiyarza | * }
|
263 | * }
|
||
264 | * </pre>
|
||
265 | 21731 | vcaballero | *
|
266 | 26788 | jpiera | * @param geomClass Geometry implementation class. It must not be null and must implement Geometry,
|
267 | * otherwise an exception is thrown.
|
||
268 | * @param type
|
||
269 | 26866 | jpiera | * Type of geometry. Must be a value defined in {@link Geometry.TYPES}
|
270 | * @param subType
|
||
271 | * SubType of geometry. Must be a value defined in {@link Geometry.SUBTYPES}
|
||
272 | 21049 | jiyarza | * @return Instance of GeometryType associated to the Geometry implementation class
|
273 | 21007 | jiyarza | * @throws IllegalArgumentException
|
274 | 21047 | jiyarza | * If geomClass is null or does not implement Geometry
|
275 | 21007 | jiyarza | */
|
276 | 26866 | jpiera | public GeometryType registerGeometryType(Class geomClass, int type, int subType); |
277 | 27229 | jpiera | |
278 | 20761 | jmvivo | /**
|
279 | 21731 | vcaballero | * Returns an instance of GeometryType given the associated Geometry implementation
|
280 | 21047 | jiyarza | * class.
|
281 | 21731 | vcaballero | *
|
282 | 27229 | jpiera | * * @param type
|
283 | * Type of geometry. Must be a value defined in {@link Geometry.TYPES}
|
||
284 | * @param subType
|
||
285 | * SubType of geometry. Must be a value defined in {@link Geometry.SUBTYPES}
|
||
286 | * @return Instance of GeometryType associated to the type and the subtype
|
||
287 | 28085 | jpiera | * @throws GeometryTypeNotValidException
|
288 | 20761 | jmvivo | */
|
289 | 28085 | jpiera | public GeometryType getGeometryType(int type, int subType) throws GeometryTypeNotSupportedException, GeometryTypeNotValidException; |
290 | 26788 | jpiera | |
291 | 20761 | jmvivo | /**
|
292 | 21047 | jiyarza | * Returns the associated GeometryType given the fully qualified name of
|
293 | * the Geometry implementation class.
|
||
294 | 21731 | vcaballero | *
|
295 | 20761 | jmvivo | * @param className
|
296 | 21047 | jiyarza | * Fully qualified name of the Geometry implementation class
|
297 | * @return GeometryType associated to the class
|
||
298 | 20761 | jmvivo | */
|
299 | 28085 | jpiera | public GeometryType getGeometryType(String className) throws GeometryTypeNotSupportedException; |
300 | 26788 | jpiera | |
301 | /**
|
||
302 | 26809 | jpiera | * This method creates a {@link Geometry} with the type specified
|
303 | * by this GeometryType. The geometry is empty, and all the internal
|
||
304 | * attributes must be assigned to a value when the geometry has
|
||
305 | * been created.
|
||
306 | 26788 | jpiera | *
|
307 | 26809 | jpiera | * This example creates a point2D and sets the coordinates to 1,1:
|
308 | *
|
||
309 | * <pre>
|
||
310 | * Point point = (Point)GeometryLocator
|
||
311 | * .getGeometryManager().create(Point2D.CODE);
|
||
312 | * point.setX(1);
|
||
313 | * point.setY(1);
|
||
314 | * </pre>
|
||
315 | *
|
||
316 | 26788 | jpiera | * @param geomType
|
317 | 26809 | jpiera | * The geometry type
|
318 | 26788 | jpiera | * @return
|
319 | 26809 | jpiera | * A instance of a geometry.
|
320 | 27397 | jpiera | * @throws CreateGeometryException
|
321 | * This exception is thrown when the manager can not create
|
||
322 | * the geometry.
|
||
323 | 26788 | jpiera | */
|
324 | 27397 | jpiera | public Geometry create(GeometryType geomType) throws CreateGeometryException; |
325 | 20761 | jmvivo | |
326 | 27397 | jpiera | public Envelope createEnvelope(int subType) throws CreateEnvelopeException; |
327 | 27019 | jpiera | |
328 | 27397 | jpiera | public Envelope createEnvelope(double minX, double minY, double maxX, double maxY, int subType) throws CreateEnvelopeException; |
329 | |||
330 | 20761 | jmvivo | /**
|
331 | 26809 | jpiera | * This method creates a {@link Geometry} with the type specified
|
332 | * by this name. If a geometry with this name doesn't exist, a
|
||
333 | * {@link IllegalArgumentException} is thrown. The geometry is empty,
|
||
334 | * and all the internal attributes must be assigned to a value when
|
||
335 | * the geometry has been created.
|
||
336 | 26788 | jpiera | *
|
337 | 26809 | jpiera | * This example creates a point2D and sets the coordinates to 1,1:
|
338 | * It supposes that there is a Point2D class with name "Point2D".
|
||
339 | *
|
||
340 | * <pre>
|
||
341 | * Point point = (Point)GeometryLocator
|
||
342 | * .getGeometryManager().create("Point2D");
|
||
343 | * point.setX(1);
|
||
344 | * point.setY(1);
|
||
345 | * </pre>
|
||
346 | *
|
||
347 | 26788 | jpiera | * @param name
|
348 | 26809 | jpiera | * The name of the geometry type
|
349 | 26788 | jpiera | * @return
|
350 | 26809 | jpiera | * A instance of a geometry.
|
351 | 27397 | jpiera | * @throws CreateGeometryException
|
352 | * This exception is thrown when the manager can not create
|
||
353 | * the geometry.
|
||
354 | 26788 | jpiera | */
|
355 | 27397 | jpiera | public Geometry create(String name) throws CreateGeometryException; |
356 | 26788 | jpiera | |
357 | /**
|
||
358 | 26809 | jpiera | * This method creates a {@link Geometry} with the type specified
|
359 | * by this id. If a geometry with this id doesn't exist, a
|
||
360 | * {@link IllegalArgumentException} is thrown. The geometry is empty,
|
||
361 | * and all the internal attributes must be assigned to a value when
|
||
362 | * the geometry has been created.
|
||
363 | 26788 | jpiera | *
|
364 | 26809 | jpiera | * This example creates a point2D and sets the coordinates to 1,1.
|
365 | * It supposes that there is a Point2D class with the id 1.
|
||
366 | *
|
||
367 | * <pre>
|
||
368 | * Point point = (Point)GeometryLocator
|
||
369 | * .getGeometryManager().create(1);
|
||
370 | * point.setX(1);
|
||
371 | * point.setY(1);
|
||
372 | * </pre>
|
||
373 | *
|
||
374 | 26866 | jpiera | * @param type
|
375 | * Type of geometry. Must be a value defined in {@link Geometry.TYPES}
|
||
376 | * @param subType
|
||
377 | * SubType of geometry. Must be a value defined in {@link Geometry.SUBTYPES}
|
||
378 | 26788 | jpiera | * @return
|
379 | 26809 | jpiera | * A instance of a geometry.
|
380 | 27397 | jpiera | * @throws CreateGeometryException
|
381 | * This exception is thrown when the manager can not create
|
||
382 | * the geometry.
|
||
383 | 26788 | jpiera | */
|
384 | 27397 | jpiera | public Geometry create(int type, int subType) throws CreateGeometryException; |
385 | 26788 | jpiera | |
386 | 27397 | jpiera | public NullGeometry createNullGeometry(int subType) throws CreateGeometryException; |
387 | |||
388 | /**
|
||
389 | * Create point. If there is an
|
||
390 | * error return <code>null</code> and add the error
|
||
391 | * to the log
|
||
392 | * @param x
|
||
393 | * The X coordinate
|
||
394 | * @param y
|
||
395 | * The y coordinate
|
||
396 | * @return
|
||
397 | * The Point
|
||
398 | */
|
||
399 | public Point createPoint(double x, double y, int subType) throws CreateGeometryException; |
||
400 | |||
401 | public Curve createCurve(GeneralPathX generalPathX, int subType) throws CreateGeometryException; |
||
402 | |||
403 | public Surface createSurface(GeneralPathX generalPathX, int subType) throws CreateGeometryException; |
||
404 | |||
405 | 26788 | jpiera | /**
|
406 | 27229 | jpiera | * Returns an operation given the Geometry type, the Geometry subtype and and the operation
|
407 | 21308 | jiyarza | * code. If opCode corresponds to a common operation (a common operation is an operation
|
408 | * registered for all geometries), then this method returns the common operation.
|
||
409 | * <br>
|
||
410 | 21731 | vcaballero | * For better performance, if you need to call an operation multiple times,
|
411 | * use this method only once and keep the returned object in a local variable
|
||
412 | 21308 | jiyarza | * over which you can iterate. For instance:
|
413 | 21731 | vcaballero | *
|
414 | 21308 | jiyarza | * <pre>
|
415 | * ...
|
||
416 | * // Get the operation you need
|
||
417 | * GeometryManager gm = GeometryManager.getInstance();
|
||
418 | * GeometryOperation geomOp = null;
|
||
419 | * try {
|
||
420 | 27229 | jpiera | * geomOp = gm.getGeometryOperation(Draw2D.CODE);
|
421 | 21308 | jiyarza | * } catch (GeometryTypeNotSupportedException gtnse) {
|
422 | * // treat exception
|
||
423 | * } catch (GeometryOperationNotSupportedException gonse) {
|
||
424 | * // treat exception
|
||
425 | * }
|
||
426 | 21731 | vcaballero | *
|
427 | 21308 | jiyarza | * // Fill the operation context with required params
|
428 | * GeometryOperationContext ctx = new GeometryOperationContext();
|
||
429 | 21731 | vcaballero | *
|
430 | * // Here is the main loop where you call the operation
|
||
431 | 21308 | jiyarza | * for (int i=0; i<MyGeometries.length; i++) {
|
432 | * Object result = geomOp.invoke(myGeometries[i], ctx);
|
||
433 | * }
|
||
434 | 21731 | vcaballero | *
|
435 | 21308 | jiyarza | * </pre>
|
436 | 21731 | vcaballero | *
|
437 | 21308 | jiyarza | * @param opCode
|
438 | 27229 | jpiera | * @param type
|
439 | * Type of geometry. Must be a value defined in {@link Geometry.TYPES}
|
||
440 | * @param subType
|
||
441 | * SubType of geometry. Must be a value defined in {@link Geometry.SUBTYPES}
|
||
442 | 21049 | jiyarza | * @return Geometry operation
|
443 | 28085 | jpiera | * @throws GeometryTypeNotValidException
|
444 | 20761 | jmvivo | */
|
445 | 28085 | jpiera | public GeometryOperation getGeometryOperation(int opCode, int type, int subType) throws GeometryTypeNotSupportedException, GeometryOperationNotSupportedException, GeometryTypeNotValidException; |
446 | 26788 | jpiera | |
447 | 20953 | jiyarza | /**
|
448 | 21731 | vcaballero | * Invokes an operation given its code, the geometry and the operation context holding the
|
449 | 21047 | jiyarza | * parameters required for the operation.
|
450 | 21731 | vcaballero | *
|
451 | 21047 | jiyarza | * @param opCode Operation code.
|
452 | * @param geom Geometry to which apply the operation
|
||
453 | * @param ctx Context holding the operation parameters
|
||
454 | 21731 | vcaballero | * @return The object returned by an operation, depends on each operation.
|
455 | 20953 | jiyarza | */
|
456 | 26788 | jpiera | public Object invokeOperation(int opCode, Geometry geom, GeometryOperationContext ctx) throws GeometryOperationNotSupportedException, GeometryOperationException; |
457 | 21750 | jiyarza | |
458 | /**
|
||
459 | 27011 | jpiera | * Invokes an operation given its code, the geometry and the operation context holding the
|
460 | * parameters required for the operation.
|
||
461 | *
|
||
462 | * @param geomOpName Operation name.
|
||
463 | * @param geom Geometry to which apply the operation
|
||
464 | * @param ctx Context holding the operation parameters
|
||
465 | * @return The object returned by an operation, depends on each operation.
|
||
466 | */
|
||
467 | public Object invokeOperation(String geomOpName, Geometry geom, GeometryOperationContext ctx) throws GeometryOperationNotSupportedException, GeometryOperationException; |
||
468 | |||
469 | /**
|
||
470 | 21750 | jiyarza | * Unregisters a geometry class.
|
471 | * @param geomTypeName
|
||
472 | * @return
|
||
473 | */
|
||
474 | 26788 | jpiera | public GeometryType unregisterGeometryType(Class geomClass); |
475 | |||
476 | 20761 | jmvivo | } |