gvsig-vectorediting / org.gvsig.vectorediting / trunk / org.gvsig.vectorediting / org.gvsig.vectorediting.lib / org.gvsig.vectorediting.lib.prov / org.gvsig.vectorediting.lib.prov.circlecr / src / main / java / org / gvsig / vectorediting / lib / prov / circlecr / CircumferenceTanTanRadiusEditingProvider.java @ 2109
History | View | Annotate | Download (3.49 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright ? 2007-2014 gvSIG Association
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
|
25 |
package org.gvsig.vectorediting.lib.prov.circlecr; |
26 |
|
27 |
import org.gvsig.fmap.geom.Geometry; |
28 |
import org.gvsig.fmap.geom.GeometryLocator; |
29 |
import org.gvsig.fmap.geom.GeometryManager; |
30 |
import org.gvsig.fmap.geom.aggregate.MultiCurve; |
31 |
import org.gvsig.fmap.geom.primitive.Circle; |
32 |
import org.gvsig.fmap.geom.primitive.Circumference; |
33 |
import org.gvsig.fmap.geom.primitive.Point; |
34 |
import org.gvsig.fmap.geom.type.GeometryType; |
35 |
import org.gvsig.tools.dynobject.DynObject; |
36 |
import org.gvsig.tools.service.spi.ProviderServices; |
37 |
import org.gvsig.vectorediting.lib.api.exceptions.FinishServiceException; |
38 |
import org.gvsig.vectorediting.lib.spi.EditingProvider; |
39 |
import org.gvsig.vectorediting.lib.spi.EditingProviderServices; |
40 |
|
41 |
public class CircumferenceTanTanRadiusEditingProvider extends CircleTanTanRadiusEditingProvider |
42 |
implements EditingProvider {
|
43 |
|
44 |
public CircumferenceTanTanRadiusEditingProvider(ProviderServices providerServices,
|
45 |
DynObject parameters) { |
46 |
super(providerServices, parameters);
|
47 |
} |
48 |
|
49 |
public Geometry finish() throws FinishServiceException { |
50 |
|
51 |
final GeometryManager geomManager = GeometryLocator.getGeometryManager();
|
52 |
|
53 |
Point firstPointValue = (Point) values.get(firstPoint); |
54 |
Point secondPointValue = (Point) values.get(secondPoint); |
55 |
Double radiusValue = (Double) values.get(radius); |
56 |
|
57 |
EditingProviderServices editingProviderServices = |
58 |
(EditingProviderServices) getProviderServices(); |
59 |
|
60 |
try {
|
61 |
int subtype = editingProviderServices.getSubType(featureStore);
|
62 |
GeometryType storeGeomType = |
63 |
editingProviderServices.getGeomType(featureStore); |
64 |
Circle circle = |
65 |
editingProviderServices.createCircle(firstGeometry, secondGeometry, radiusValue, firstPointValue, secondPointValue, subtype); |
66 |
Circumference circumference = (Circumference) geomManager.create(CIRCUMFERENCE, subtype); |
67 |
circumference.setPoints(circle.getCenter(), circle.getRadious()); |
68 |
|
69 |
if (storeGeomType.isTypeOf(MULTICURVE)) {
|
70 |
MultiCurve multicurve; |
71 |
multicurve = |
72 |
geomManager.createMultiCurve( |
73 |
storeGeomType.getSubType()); |
74 |
multicurve.addCurve((Circumference) circumference); |
75 |
return multicurve;
|
76 |
} |
77 |
|
78 |
return circumference;
|
79 |
} catch (Exception e) { |
80 |
throw new FinishServiceException(e); |
81 |
} |
82 |
} |
83 |
|
84 |
@Override
|
85 |
public String getName() { |
86 |
return CircumferenceTanTanRadiusEditingProviderFactory.PROVIDER_NAME;
|
87 |
} |
88 |
|
89 |
} |