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 | 159 | llmarques | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 88 | fdiaz | *
|
4 | 159 | llmarques | * 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 | 88 | fdiaz | */
|
24 | 159 | llmarques | |
25 | 88 | fdiaz | package org.gvsig.vectorediting.lib.prov.circlecr; |
26 | |||
27 | import org.gvsig.fmap.geom.Geometry; |
||
28 | 99 | fdiaz | import org.gvsig.fmap.geom.GeometryLocator; |
29 | 575 | fdiaz | import org.gvsig.fmap.geom.GeometryManager; |
30 | 88 | fdiaz | import org.gvsig.fmap.geom.aggregate.MultiCurve; |
31 | 2102 | fdiaz | import org.gvsig.fmap.geom.primitive.Circle; |
32 | 575 | fdiaz | import org.gvsig.fmap.geom.primitive.Circumference; |
33 | 88 | fdiaz | 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 | 2109 | fdiaz | public class CircumferenceTanTanRadiusEditingProvider extends CircleTanTanRadiusEditingProvider |
42 | 227 | llmarques | implements EditingProvider {
|
43 | 88 | fdiaz | |
44 | 2109 | fdiaz | public CircumferenceTanTanRadiusEditingProvider(ProviderServices providerServices,
|
45 | 138 | llmarques | DynObject parameters) { |
46 | super(providerServices, parameters);
|
||
47 | } |
||
48 | 88 | fdiaz | |
49 | 2102 | fdiaz | public Geometry finish() throws FinishServiceException { |
50 | 575 | fdiaz | |
51 | 2102 | fdiaz | final GeometryManager geomManager = GeometryLocator.getGeometryManager();
|
52 | |||
53 | Point firstPointValue = (Point) values.get(firstPoint); |
||
54 | Point secondPointValue = (Point) values.get(secondPoint); |
||
55 | 2109 | fdiaz | Double radiusValue = (Double) values.get(radius); |
56 | 2102 | fdiaz | |
57 | 138 | llmarques | EditingProviderServices editingProviderServices = |
58 | (EditingProviderServices) getProviderServices(); |
||
59 | 2102 | fdiaz | |
60 | 138 | llmarques | try {
|
61 | 178 | llmarques | int subtype = editingProviderServices.getSubType(featureStore);
|
62 | 138 | llmarques | GeometryType storeGeomType = |
63 | editingProviderServices.getGeomType(featureStore); |
||
64 | 2102 | fdiaz | Circle circle = |
65 | 2109 | fdiaz | editingProviderServices.createCircle(firstGeometry, secondGeometry, radiusValue, firstPointValue, secondPointValue, subtype); |
66 | 575 | fdiaz | Circumference circumference = (Circumference) geomManager.create(CIRCUMFERENCE, subtype); |
67 | 2102 | fdiaz | circumference.setPoints(circle.getCenter(), circle.getRadious()); |
68 | 88 | fdiaz | |
69 | 138 | llmarques | if (storeGeomType.isTypeOf(MULTICURVE)) {
|
70 | MultiCurve multicurve; |
||
71 | multicurve = |
||
72 | 2102 | fdiaz | geomManager.createMultiCurve( |
73 | 138 | llmarques | storeGeomType.getSubType()); |
74 | 575 | fdiaz | multicurve.addCurve((Circumference) circumference); |
75 | 138 | llmarques | return multicurve;
|
76 | } |
||
77 | 174 | llmarques | |
78 | 575 | fdiaz | return circumference;
|
79 | 138 | llmarques | } catch (Exception e) { |
80 | throw new FinishServiceException(e); |
||
81 | } |
||
82 | } |
||
83 | 88 | fdiaz | |
84 | 227 | llmarques | @Override
|
85 | 138 | llmarques | public String getName() { |
86 | 2109 | fdiaz | return CircumferenceTanTanRadiusEditingProviderFactory.PROVIDER_NAME;
|
87 | 88 | fdiaz | } |
88 | |||
89 | } |