Revision 265
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/pom.xml | ||
---|---|---|
25 | 25 |
<module>org.gvsig.vectorediting.lib.prov.rotate</module> |
26 | 26 |
<module>org.gvsig.vectorediting.lib.prov.duplicate</module> |
27 | 27 |
<module>org.gvsig.vectorediting.lib.prov.splitline</module> |
28 |
<module>org.gvsig.vectorediting.lib.prov.scale</module> |
|
28 | 29 |
</modules> |
29 | 30 |
<dependencies> |
30 | 31 |
<dependency> |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.scale/src/main/java/org/gvsig/vectorediting/lib/prov/scale/ScaleEditingLibrary.java | ||
---|---|---|
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 |
package org.gvsig.vectorediting.lib.prov.scale; |
|
25 |
|
|
26 |
|
|
27 |
import org.gvsig.tools.ToolsLocator; |
|
28 |
import org.gvsig.tools.i18n.I18nManager; |
|
29 |
import org.gvsig.tools.library.AbstractLibrary; |
|
30 |
import org.gvsig.tools.library.LibraryException; |
|
31 |
import org.gvsig.vectorediting.lib.api.EditingLibrary; |
|
32 |
import org.gvsig.vectorediting.lib.spi.EditingProviderLocator; |
|
33 |
import org.gvsig.vectorediting.lib.spi.EditingProviderManager; |
|
34 |
|
|
35 |
/** |
|
36 |
* Library for default implementation initialization and configuration. |
|
37 |
* |
|
38 |
* @author gvSIG team |
|
39 |
* @version $Id$ |
|
40 |
*/ |
|
41 |
public class ScaleEditingLibrary extends AbstractLibrary { |
|
42 |
|
|
43 |
@Override |
|
44 |
public void doRegistration() { |
|
45 |
registerAsServiceOf(EditingLibrary.class); |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
protected void doInitialize() throws LibraryException { |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
protected void doPostInitialize() throws LibraryException { |
|
54 |
EditingProviderManager manager = |
|
55 |
EditingProviderLocator.getProviderManager(); |
|
56 |
|
|
57 |
manager.addProviderFactory(new ScaleEditingProviderFactory()); |
|
58 |
|
|
59 |
manager.registerIcon("vectorediting-tools", "modify-scale", this |
|
60 |
.getClass().getClassLoader(), this.getClass().getName()); |
|
61 |
|
|
62 |
registerTranslations(); |
|
63 |
} |
|
64 |
|
|
65 |
private void registerTranslations() { |
|
66 |
I18nManager manager = ToolsLocator.getI18nManager(); |
|
67 |
manager.addResourceFamily("i18n.text", |
|
68 |
this.getClass().getClassLoader(), "scale-editing"); |
|
69 |
} |
|
70 |
|
|
71 |
} |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.scale/src/main/java/org/gvsig/vectorediting/lib/prov/scale/ScaleEditingProvider.java | ||
---|---|---|
1 |
package org.gvsig.vectorediting.lib.prov.scale; |
|
2 |
/** |
|
3 |
* gvSIG. Desktop Geographic Information System. |
|
4 |
* |
|
5 |
* Copyright ? 2007-2014 gvSIG Association |
|
6 |
* |
|
7 |
* This program is free software; you can redistribute it and/or |
|
8 |
* modify it under the terms of the GNU General Public License |
|
9 |
* as published by the Free Software Foundation; either version 2 |
|
10 |
* of the License, or (at your option) any later version. |
|
11 |
* |
|
12 |
* This program is distributed in the hope that it will be useful, |
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
* GNU General Public License for more details. |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License |
|
18 |
* along with this program; if not, write to the Free Software |
|
19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
* MA 02110-1301, USA. |
|
21 |
* |
|
22 |
* For any additional information, do not hesitate to contact us |
|
23 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
24 |
*/ |
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
import java.awt.geom.AffineTransform; |
|
29 |
import java.util.ArrayList; |
|
30 |
import java.util.HashMap; |
|
31 |
import java.util.List; |
|
32 |
import java.util.Map; |
|
33 |
|
|
34 |
import org.gvsig.fmap.dal.exception.DataException; |
|
35 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
36 |
import org.gvsig.fmap.dal.feature.Feature; |
|
37 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
38 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
39 |
import org.gvsig.fmap.geom.Geometry; |
|
40 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
41 |
import org.gvsig.fmap.geom.GeometryManager; |
|
42 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
43 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
44 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
45 |
import org.gvsig.fmap.geom.primitive.Arc; |
|
46 |
import org.gvsig.fmap.geom.primitive.Line; |
|
47 |
import org.gvsig.fmap.geom.primitive.Point; |
|
48 |
import org.gvsig.tools.ToolsLocator; |
|
49 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
50 |
import org.gvsig.tools.dynobject.DynObject; |
|
51 |
import org.gvsig.tools.exception.BaseException; |
|
52 |
import org.gvsig.tools.i18n.I18nManager; |
|
53 |
import org.gvsig.tools.service.spi.ProviderServices; |
|
54 |
import org.gvsig.tools.visitor.VisitCanceledException; |
|
55 |
import org.gvsig.tools.visitor.Visitor; |
|
56 |
import org.gvsig.vectorediting.lib.api.DrawingStatus; |
|
57 |
import org.gvsig.vectorediting.lib.api.EditingServiceParameter; |
|
58 |
import org.gvsig.vectorediting.lib.api.EditingServiceParameter.TYPE; |
|
59 |
import org.gvsig.vectorediting.lib.api.exceptions.DrawServiceException; |
|
60 |
import org.gvsig.vectorediting.lib.api.exceptions.FinishServiceException; |
|
61 |
import org.gvsig.vectorediting.lib.api.exceptions.InvalidEntryException; |
|
62 |
import org.gvsig.vectorediting.lib.api.exceptions.StartServiceException; |
|
63 |
import org.gvsig.vectorediting.lib.spi.AbstractEditingProvider; |
|
64 |
import org.gvsig.vectorediting.lib.spi.DefaultDrawingStatus; |
|
65 |
import org.gvsig.vectorediting.lib.spi.DefaultEditingServiceParameter; |
|
66 |
import org.gvsig.vectorediting.lib.spi.EditingProvider; |
|
67 |
import org.gvsig.vectorediting.lib.spi.EditingProviderFactory; |
|
68 |
import org.gvsig.vectorediting.lib.spi.EditingProviderServices; |
|
69 |
|
|
70 |
public class ScaleEditingProvider extends AbstractEditingProvider implements |
|
71 |
EditingProvider { |
|
72 |
|
|
73 |
private I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
74 |
|
|
75 |
private EditingServiceParameter selectionParameter; |
|
76 |
|
|
77 |
private EditingServiceParameter originPointParameter; |
|
78 |
|
|
79 |
private EditingServiceParameter scaleFactorOrReferencePointParameter; |
|
80 |
|
|
81 |
private EditingServiceParameter secondScalePointParameter; |
|
82 |
|
|
83 |
private Map<EditingServiceParameter, Object> values; |
|
84 |
|
|
85 |
private FeatureStore featureStore; |
|
86 |
|
|
87 |
public ScaleEditingProvider(ProviderServices providerServices, |
|
88 |
DynObject parameters) { |
|
89 |
super(providerServices); |
|
90 |
this.featureStore = |
|
91 |
(FeatureStore) parameters |
|
92 |
.getDynValue(EditingProviderFactory.FEATURE_STORE_FIELD); |
|
93 |
|
|
94 |
this.selectionParameter = |
|
95 |
new DefaultEditingServiceParameter("selection", |
|
96 |
i18nManager.getTranslation("selection"), TYPE.SELECTION); |
|
97 |
|
|
98 |
this.originPointParameter = |
|
99 |
new DefaultEditingServiceParameter("origin_point", |
|
100 |
i18nManager.getTranslation("origin_point"), TYPE.VALUE, TYPE.POSITION); |
|
101 |
|
|
102 |
this.scaleFactorOrReferencePointParameter = |
|
103 |
new DefaultEditingServiceParameter("scale_factor_or_reference_point", |
|
104 |
i18nManager.getTranslation("scale_factor_or_reference_point"), TYPE.VALUE, TYPE.POSITION); |
|
105 |
|
|
106 |
this.secondScalePointParameter = |
|
107 |
new DefaultEditingServiceParameter("second_scale_point", |
|
108 |
i18nManager.getTranslation("second_scale_point"), TYPE.POSITION); |
|
109 |
} |
|
110 |
|
|
111 |
public List<EditingServiceParameter> getParameters() { |
|
112 |
List<EditingServiceParameter> list = |
|
113 |
new ArrayList<EditingServiceParameter>(); |
|
114 |
list.add(selectionParameter); |
|
115 |
list.add(originPointParameter); |
|
116 |
list.add(secondScalePointParameter); |
|
117 |
return list; |
|
118 |
} |
|
119 |
|
|
120 |
private void validateAndInsertValue(EditingServiceParameter param, |
|
121 |
Object value) throws InvalidEntryException { |
|
122 |
if (param == selectionParameter) { |
|
123 |
if (value instanceof FeatureSelection) { |
|
124 |
values.put(param, value); |
|
125 |
return; |
|
126 |
} |
|
127 |
} else if (param == originPointParameter) { |
|
128 |
if (value instanceof Point) { |
|
129 |
values.put(param, value); |
|
130 |
return; |
|
131 |
} |
|
132 |
} else if (param == scaleFactorOrReferencePointParameter) { |
|
133 |
if (value instanceof Point) { |
|
134 |
values.put(param, value); |
|
135 |
return; |
|
136 |
} else if (value instanceof Double) { |
|
137 |
if ((Double)value == 0.0){ |
|
138 |
throw new InvalidEntryException(null); |
|
139 |
} |
|
140 |
values.put(param, value); |
|
141 |
return; |
|
142 |
} |
|
143 |
} else if (param == secondScalePointParameter) { |
|
144 |
if (value instanceof Point) { |
|
145 |
values.put(param, value); |
|
146 |
return; |
|
147 |
} |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
151 |
public EditingServiceParameter next() { |
|
152 |
if (values.get(selectionParameter) == null) { |
|
153 |
return this.selectionParameter; |
|
154 |
} else if (values.get(originPointParameter) == null) { |
|
155 |
return this.originPointParameter; |
|
156 |
} else if (values.get(scaleFactorOrReferencePointParameter) == null) { |
|
157 |
return this.scaleFactorOrReferencePointParameter; |
|
158 |
} else { |
|
159 |
if (values.get(scaleFactorOrReferencePointParameter) instanceof Point ) { |
|
160 |
if (values.get(secondScalePointParameter) == null) { |
|
161 |
return this.secondScalePointParameter; |
|
162 |
} |
|
163 |
} |
|
164 |
} |
|
165 |
return null; |
|
166 |
} |
|
167 |
|
|
168 |
|
|
169 |
public DrawingStatus getDrawingStatus(Point mousePosition) |
|
170 |
throws DrawServiceException { |
|
171 |
DefaultDrawingStatus geometries = new DefaultDrawingStatus(); |
|
172 |
EditingProviderServices editingProviderServices = |
|
173 |
(EditingProviderServices) getProviderServices(); |
|
174 |
|
|
175 |
FeatureSelection selected = |
|
176 |
(FeatureSelection) values.get(this.selectionParameter); |
|
177 |
try { |
|
178 |
int subType = |
|
179 |
editingProviderServices |
|
180 |
.getSubType(featureStore); |
|
181 |
if ((selected != null) && !selected.isEmpty()) { |
|
182 |
Point origin = (Point) values.get(this.originPointParameter); |
|
183 |
if (origin != null) { |
|
184 |
Object scaleFactorOrReferencePointValue = |
|
185 |
values.get(this.scaleFactorOrReferencePointParameter); |
|
186 |
Double scale = 1.0; |
|
187 |
|
|
188 |
if (scaleFactorOrReferencePointValue != null) { |
|
189 |
if (scaleFactorOrReferencePointValue instanceof Double) { |
|
190 |
scale = (Double) scaleFactorOrReferencePointValue; |
|
191 |
} else if (scaleFactorOrReferencePointValue instanceof Point) { |
|
192 |
double unity = ((Point) scaleFactorOrReferencePointValue).getX()-origin.getX(); |
|
193 |
// Unidad de referencia |
|
194 |
Line line = |
|
195 |
createHorizontalLineFromAPointWithLenght(origin, unity, subType); |
|
196 |
geometries.addGeometry(line); |
|
197 |
createRule(geometries, origin, unity, unity, unity/10, subType); |
|
198 |
|
|
199 |
Object secondScalePointParameter = |
|
200 |
values.get(this.secondScalePointParameter); |
|
201 |
if (secondScalePointParameter != null |
|
202 |
&& secondScalePointParameter instanceof Point) { |
|
203 |
double rawScale = ((Point) secondScalePointParameter).getX()-origin.getX(); |
|
204 |
scale = rawScale / unity; |
|
205 |
|
|
206 |
Line line2 = |
|
207 |
createHorizontalLineFromAPointWithLenght(origin, rawScale, subType); |
|
208 |
geometries.addGeometry(line2); |
|
209 |
createRule(geometries, origin, unity, rawScale, unity/10, subType); |
|
210 |
} else { |
|
211 |
double rawScale = mousePosition.getX()-origin.getX(); |
|
212 |
scale = rawScale / unity; |
|
213 |
Line line2 = |
|
214 |
createHorizontalLineFromAPointWithLenght(origin, rawScale, subType); |
|
215 |
geometries.addGeometry(line2); |
|
216 |
createRule(geometries, origin, unity, rawScale, unity/10, subType); |
|
217 |
|
|
218 |
AffineTransform at; |
|
219 |
try { |
|
220 |
at = getScaleAffineTransform(origin, scale); |
|
221 |
} catch (Exception e) { |
|
222 |
throw new DrawServiceException(e); |
|
223 |
} |
|
224 |
applyTransformToDrawingStatus(geometries, selected, at); |
|
225 |
} |
|
226 |
} |
|
227 |
} else { |
|
228 |
double unity = mousePosition.getX()-origin.getX(); |
|
229 |
Line line = |
|
230 |
createHorizontalLineFromAPointWithLenght(origin, unity, subType); |
|
231 |
geometries.addGeometry(line); |
|
232 |
} |
|
233 |
|
|
234 |
} |
|
235 |
return geometries; |
|
236 |
} |
|
237 |
} catch (Exception e) { |
|
238 |
throw new DrawServiceException(e); |
|
239 |
} |
|
240 |
return null; |
|
241 |
} |
|
242 |
|
|
243 |
private Line createHorizontalLineFromAPointWithLenght(Point origin, |
|
244 |
double rawScale, int subType) throws CreateGeometryException { |
|
245 |
GeometryManager geometryManager = GeometryLocator.getGeometryManager(); |
|
246 |
|
|
247 |
Line line = geometryManager.createLine(subType); |
|
248 |
line.addVertex(origin); |
|
249 |
Point p3 = |
|
250 |
geometryManager.createPoint(origin.getX() + rawScale, |
|
251 |
origin.getY(), subType); |
|
252 |
line.addVertex(p3); |
|
253 |
return line; |
|
254 |
} |
|
255 |
|
|
256 |
private Line createMark(Point point,double distance, double height, int subType) throws CreateGeometryException { |
|
257 |
GeometryManager geometryManager = GeometryLocator.getGeometryManager(); |
|
258 |
|
|
259 |
Line line = geometryManager.createLine(subType); |
|
260 |
line.addVertex(point.getX()+distance, point.getY()-height/2); |
|
261 |
line.addVertex(point.getX()+distance, point.getY()+height/2); |
|
262 |
return line; |
|
263 |
} |
|
264 |
|
|
265 |
private void createRule(DefaultDrawingStatus geometries, Point point, double unity, double length, double height, int subType) throws CreateGeometryException { |
|
266 |
double pos = 0; |
|
267 |
int i = 0; |
|
268 |
while (Math.abs(pos)<Math.abs(length)) { |
|
269 |
Line mark = null; |
|
270 |
if (i%10==0){ |
|
271 |
mark = createMark(point, pos, height, subType); |
|
272 |
} else { |
|
273 |
mark = createMark(point, pos, height/2, subType); |
|
274 |
} |
|
275 |
geometries.addGeometry(mark); |
|
276 |
pos += Math.signum(length)*Math.signum(unity)*unity/10; |
|
277 |
i++; |
|
278 |
} |
|
279 |
Line finalMark = createMark(point, length, height, subType); |
|
280 |
geometries.addGeometry(finalMark); |
|
281 |
} |
|
282 |
|
|
283 |
|
|
284 |
|
|
285 |
private void applyTransformToDrawingStatus( |
|
286 |
final DefaultDrawingStatus geometries, FeatureSelection selected, |
|
287 |
final AffineTransform at) throws BaseException { |
|
288 |
selected.accept(new Visitor() { |
|
289 |
|
|
290 |
public void visit(Object obj) throws VisitCanceledException, |
|
291 |
BaseException { |
|
292 |
Feature feature = (Feature) obj; |
|
293 |
Geometry geom = feature.getDefaultGeometry().cloneGeometry(); |
|
294 |
geom.transform(at); |
|
295 |
geometries.addGeometry(geom); |
|
296 |
|
|
297 |
} |
|
298 |
}); |
|
299 |
} |
|
300 |
|
|
301 |
private AffineTransform getScaleAffineTransform(Point axisP1, Double scale) |
|
302 |
throws GeometryOperationNotSupportedException, |
|
303 |
GeometryOperationException { |
|
304 |
|
|
305 |
AffineTransform translate = |
|
306 |
AffineTransform |
|
307 |
.getTranslateInstance(-axisP1.getX(), -axisP1.getY()); |
|
308 |
|
|
309 |
AffineTransform rotate = AffineTransform.getScaleInstance(scale,scale); |
|
310 |
|
|
311 |
AffineTransform inverseTranslate = |
|
312 |
AffineTransform.getTranslateInstance(axisP1.getX(), axisP1.getY()); |
|
313 |
AffineTransform at = new AffineTransform(translate); |
|
314 |
|
|
315 |
at.preConcatenate(rotate); |
|
316 |
at.preConcatenate(inverseTranslate); |
|
317 |
return at; |
|
318 |
} |
|
319 |
|
|
320 |
|
|
321 |
public void stop() { |
|
322 |
values.clear(); |
|
323 |
} |
|
324 |
|
|
325 |
|
|
326 |
|
|
327 |
public void setValue(Object value) throws InvalidEntryException { |
|
328 |
EditingServiceParameter param = next(); |
|
329 |
validateAndInsertValue(param, value); |
|
330 |
} |
|
331 |
|
|
332 |
public void finishAndStore() throws FinishServiceException { |
|
333 |
|
|
334 |
FeatureSelection selected = |
|
335 |
(FeatureSelection) values.get(selectionParameter); |
|
336 |
try { |
|
337 |
if (!selected.isEmpty()) { |
|
338 |
Point origin = (Point) values.get(this.originPointParameter); |
|
339 |
Double scale = null; |
|
340 |
if (origin != null) { |
|
341 |
Object scaleFactorOrReferencePointValue = |
|
342 |
values.get(this.scaleFactorOrReferencePointParameter); |
|
343 |
|
|
344 |
if (scaleFactorOrReferencePointValue != null) { |
|
345 |
if (scaleFactorOrReferencePointValue instanceof Double) { |
|
346 |
scale = (Double) scaleFactorOrReferencePointValue; |
|
347 |
} else if (scaleFactorOrReferencePointValue instanceof Point) { |
|
348 |
Object secondScalePointParameter = |
|
349 |
values.get(this.secondScalePointParameter); |
|
350 |
if (secondScalePointParameter != null |
|
351 |
&& secondScalePointParameter instanceof Point) { |
|
352 |
double unity = ((Point) scaleFactorOrReferencePointValue).getX()-origin.getX(); |
|
353 |
double rawScale = ((Point) secondScalePointParameter).getX()-origin.getX(); |
|
354 |
scale = rawScale / unity; |
|
355 |
} |
|
356 |
} |
|
357 |
} |
|
358 |
} |
|
359 |
|
|
360 |
if ((origin != null) && (scale != null)) { |
|
361 |
|
|
362 |
final AffineTransform at; |
|
363 |
try { |
|
364 |
at = getScaleAffineTransform(origin, scale); |
|
365 |
} catch (GeometryOperationNotSupportedException e) { |
|
366 |
throw new FinishServiceException(e); |
|
367 |
} catch (GeometryOperationException e) { |
|
368 |
throw new FinishServiceException(e); |
|
369 |
} |
|
370 |
|
|
371 |
try { |
|
372 |
selected.accept(new Visitor() { |
|
373 |
|
|
374 |
public void visit(Object obj) |
|
375 |
throws VisitCanceledException, BaseException { |
|
376 |
Feature feature = (Feature) obj; |
|
377 |
Geometry geom = |
|
378 |
feature.getDefaultGeometry() |
|
379 |
.cloneGeometry(); |
|
380 |
geom.transform(at); |
|
381 |
// Se sustituye la geometr?a original por la |
|
382 |
// calculada |
|
383 |
EditableFeature editableFeature = |
|
384 |
feature.getEditable(); |
|
385 |
editableFeature.setDefaultGeometry(geom); |
|
386 |
((EditingProviderServices) getProviderServices()) |
|
387 |
.updateFeatureInFeatureStore( |
|
388 |
editableFeature, featureStore); |
|
389 |
} |
|
390 |
}); |
|
391 |
} catch (BaseException e) { |
|
392 |
throw new FinishServiceException(e); |
|
393 |
} |
|
394 |
featureStore.getFeatureSelection().deselectAll(); |
|
395 |
} |
|
396 |
} |
|
397 |
} catch (DataException e) { |
|
398 |
throw new FinishServiceException(e); |
|
399 |
} |
|
400 |
} |
|
401 |
|
|
402 |
public Geometry finish() throws FinishServiceException { |
|
403 |
return null; |
|
404 |
} |
|
405 |
|
|
406 |
public void start() throws StartServiceException { |
|
407 |
this.values = new HashMap<EditingServiceParameter, Object>(); |
|
408 |
FeatureSelection selected = null; |
|
409 |
if (featureStore != null) { |
|
410 |
try { |
|
411 |
selected = |
|
412 |
(FeatureSelection) featureStore.getFeatureSelection() |
|
413 |
.clone(); |
|
414 |
} catch (DataException e) { |
|
415 |
throw new StartServiceException(e); |
|
416 |
} catch (CloneNotSupportedException e) { |
|
417 |
// Do nothing |
|
418 |
} |
|
419 |
if ((selected != null) && (selected.getSelectedCount() > 0)) { |
|
420 |
values.put(selectionParameter, selected); |
|
421 |
} |
|
422 |
} |
|
423 |
} |
|
424 |
|
|
425 |
public String getName() { |
|
426 |
return ScaleEditingProviderFactory.PROVIDER_NAME; |
|
427 |
} |
|
428 |
|
|
429 |
} |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.scale/src/main/java/org/gvsig/vectorediting/lib/prov/scale/ScaleEditingProviderFactory.java | ||
---|---|---|
1 |
package org.gvsig.vectorediting.lib.prov.scale; |
|
2 |
/** |
|
3 |
* gvSIG. Desktop Geographic Information System. |
|
4 |
* |
|
5 |
* Copyright ? 2007-2014 gvSIG Association |
|
6 |
* |
|
7 |
* This program is free software; you can redistribute it and/or |
|
8 |
* modify it under the terms of the GNU General Public License |
|
9 |
* as published by the Free Software Foundation; either version 2 |
|
10 |
* of the License, or (at your option) any later version. |
|
11 |
* |
|
12 |
* This program is distributed in the hope that it will be useful, |
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
* GNU General Public License for more details. |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License |
|
18 |
* along with this program; if not, write to the Free Software |
|
19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
* MA 02110-1301, USA. |
|
21 |
* |
|
22 |
* For any additional information, do not hesitate to contact us |
|
23 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
24 |
*/ |
|
25 |
|
|
26 |
|
|
27 |
import org.gvsig.fmap.geom.Geometry; |
|
28 |
import org.gvsig.tools.ToolsLocator; |
|
29 |
import org.gvsig.tools.dynobject.DynClass; |
|
30 |
import org.gvsig.tools.dynobject.DynObject; |
|
31 |
import org.gvsig.tools.service.spi.AbstractProviderFactory; |
|
32 |
import org.gvsig.tools.service.spi.Provider; |
|
33 |
import org.gvsig.tools.service.spi.ProviderServices; |
|
34 |
import org.gvsig.vectorediting.lib.api.EditingServiceInfo; |
|
35 |
import org.gvsig.vectorediting.lib.spi.DefaultEditingServiceinfo; |
|
36 |
import org.gvsig.vectorediting.lib.spi.EditingProviderFactory; |
|
37 |
|
|
38 |
public class ScaleEditingProviderFactory extends AbstractProviderFactory |
|
39 |
implements EditingProviderFactory { |
|
40 |
|
|
41 |
public static final String PROVIDER_NAME = "modify-scale"; |
|
42 |
|
|
43 |
private final static String PROVIDER_DESCRIPTION = |
|
44 |
"Scale selected geometries"; |
|
45 |
|
|
46 |
public void initialize() { |
|
47 |
|
|
48 |
} |
|
49 |
|
|
50 |
public EditingServiceInfo getServiceInfo() { |
|
51 |
EditingServiceInfo serviceInfo = |
|
52 |
new DefaultEditingServiceinfo(PROVIDER_NAME, "", false, null, |
|
53 |
new int[] { Geometry.TYPES.POINT, Geometry.TYPES.MULTIPOINT, |
|
54 |
Geometry.TYPES.SURFACE, Geometry.TYPES.MULTISURFACE, |
|
55 |
Geometry.TYPES.CURVE, Geometry.TYPES.MULTICURVE }); |
|
56 |
|
|
57 |
return serviceInfo; |
|
58 |
} |
|
59 |
|
|
60 |
@Override |
|
61 |
protected Provider doCreate(DynObject parameters, ProviderServices services) { |
|
62 |
return new ScaleEditingProvider(services, parameters); |
|
63 |
} |
|
64 |
|
|
65 |
@Override |
|
66 |
public DynObject createParameters() { |
|
67 |
DynObject dynobject = super.createParameters(); |
|
68 |
dynobject.setDynValue(PROVIDER_NAME_FIELD, PROVIDER_NAME); |
|
69 |
return dynobject; |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
protected DynClass createParametersDynClass() { |
|
74 |
DynClass dynclass = |
|
75 |
ToolsLocator.getDynObjectManager().createDynClass(PROVIDER_NAME, |
|
76 |
PROVIDER_DESCRIPTION); |
|
77 |
|
|
78 |
dynclass.addDynFieldString(PROVIDER_NAME_FIELD); |
|
79 |
dynclass.addDynFieldObject(FEATURE_STORE_FIELD); |
|
80 |
|
|
81 |
return dynclass; |
|
82 |
} |
|
83 |
|
|
84 |
} |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.scale/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.vectorediting.lib.prov.scale.ScaleEditingLibrary |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.scale/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.vectorediting.lib.prov</artifactId> |
|
6 |
<version>1.0.0-SNAPSHOT</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.vectorediting.lib.prov.scale</artifactId> |
|
9 |
<name>org.gvsig.vectorediting.lib.prov.scale</name> |
|
10 |
</project> |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
74 | 74 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.move</include> |
75 | 75 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.rotate</include> |
76 | 76 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.duplicate</include> |
77 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.scale</include> |
|
77 | 78 |
<include>org.gvsig:org.gvsig.vectorediting.lib.prov.splitline</include> |
78 | 79 |
</includes> |
79 | 80 |
</dependencySet> |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/src/main/resources-plugin/config.xml | ||
---|---|---|
1 | 1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
2 |
<!-- gvSIG. Desktop Geographic Information System. Copyright (C) 2007-2013
|
|
3 |
gvSIG Association. This program is free software; you can redistribute it
|
|
4 |
and/or modify it under the terms of the GNU General Public License as published
|
|
5 |
by the Free Software Foundation; either version 3 of the License, or (at
|
|
6 |
your option) any later version. This program is distributed in the hope that
|
|
7 |
it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
8 |
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
9 |
Public License for more details. You should have received a copy of the GNU
|
|
10 |
General Public License along with this program; if not, write to the Free
|
|
11 |
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
|
12 |
USA. For any additional information, do not hesitate to contact us at info
|
|
2 |
<!-- gvSIG. Desktop Geographic Information System. Copyright (C) 2007-2013 |
|
3 |
gvSIG Association. This program is free software; you can redistribute it |
|
4 |
and/or modify it under the terms of the GNU General Public License as published |
|
5 |
by the Free Software Foundation; either version 3 of the License, or (at |
|
6 |
your option) any later version. This program is distributed in the hope that |
|
7 |
it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
|
8 |
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
|
9 |
Public License for more details. You should have received a copy of the GNU |
|
10 |
General Public License along with this program; if not, write to the Free |
|
11 |
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
|
12 |
USA. For any additional information, do not hesitate to contact us at info |
|
13 | 13 |
AT gvsig.com, or visit our website www.gvsig.com. --> |
14 | 14 |
<plugin-config> |
15 | 15 |
<depends plugin-name="org.gvsig.app.mainplugin" /> |
... | ... | |
122 | 122 |
<action name="modify-move" label="modify_move" tooltip="modify_move" |
123 | 123 |
position="601002700" action-command="modify-move" icon="modify-move" |
124 | 124 |
accelerator="" /> |
125 |
|
|
125 |
|
|
126 | 126 |
<action name="modify-rotate" label="modify_rotate" |
127 | 127 |
tooltip="modify_rotate" position="601002800" |
128 | 128 |
action-command="modify-rotate" icon="modify-rotate" |
129 | 129 |
accelerator="" /> |
130 |
|
|
130 |
|
|
131 | 131 |
<action name="modify-duplicate" label="modify_duplicate" tooltip="modify_duplicate" |
132 | 132 |
position="601002900" action-command="modify-duplicate" icon="modify-duplicate" |
133 | 133 |
accelerator="" /> |
134 |
|
|
134 |
|
|
135 | 135 |
<action name="modify-split-line" label="modify_split_line" tooltip="modify_split_line" |
136 | 136 |
position="601003000" action-command="modify-split-line" icon="modify-split-line" |
137 | 137 |
accelerator="" /> |
138 | 138 |
|
139 |
<action name="modify-scale" label="modify_scale" tooltip="modify_scale" |
|
140 |
position="601003100" action-command="modify-scale" icon="modify-scale" |
|
141 |
accelerator="" /> |
|
142 |
|
|
139 | 143 |
<menu text="Layer/Insert/insert_point" name="insert-point" /> |
140 | 144 |
<menu text="Layer/Insert/insert_line" name="insert-line" /> |
141 | 145 |
<menu text="Layer/Insert/insert_arc" name="insert-arc" /> |
... | ... | |
157 | 161 |
<menu text="Layer/Modify/modify_move" name="modify-move" /> |
158 | 162 |
<menu text="Layer/Modify/modify_rotate" name="modify-rotate" /> |
159 | 163 |
<menu text="Layer/Modify/modify_duplicate" name="modify-duplicate" /> |
160 |
<menu text="Layer/Modify/modify_split_line" name="modify-split-line" />
|
|
161 |
|
|
164 |
<menu text="Layer/Modify/modify_scale" name="modify-scale" />
|
|
165 |
|
|
162 | 166 |
<tool-bar name="vector_editing" position="600800000"> |
163 | 167 |
<selectable-tool name="insert-point" /> |
164 | 168 |
<selectable-tool name="insert-line" /> |
... | ... | |
181 | 185 |
<selectable-tool name="modify-move" /> |
182 | 186 |
<selectable-tool name="modify-rotate" /> |
183 | 187 |
<selectable-tool name="modify-duplicate" /> |
184 |
<selectable-tool name="modify-split-line" />
|
|
188 |
<selectable-tool name="modify-scale" />
|
|
185 | 189 |
</tool-bar> |
186 | 190 |
|
187 | 191 |
</extension> |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/src/main/resources-plugin/i18n/text.properties | ||
---|---|---|
22 | 22 |
modify_rotate = Rotar geometr\u00eda |
23 | 23 |
modify_duplicate = Duplicar geometr\u00eda |
24 | 24 |
modify_split_line = Partir linea por un punto |
25 |
modify_scale = Escalar geometr\u00eda |
|
25 | 26 |
selection=Selecci\u00f3n |
26 | 27 |
invalid_option=Opci\u00f3n no v\u00e1lida |
27 | 28 |
center=Centro |
... | ... | |
71 | 72 |
close_spline = Cerrar curva spline |
72 | 73 |
new_point = Nuevo punto |
73 | 74 |
new_value = Nuevo valor |
74 |
finished = finalizadacenter_of_rotation = Centro de rotaci\u00f3n |
|
75 |
angle_of_rotation = \u00c1ngulo de rotaci\u00f3n |
|
75 |
finished = finalizada |
|
76 |
center_of_rotation = Centro de rotaci\u00f3n |
|
77 |
angle_of_rotation = \u00c1ngulo de rotaci\u00f3n |
|
78 |
origin_point = Origen |
|
79 |
scale_factor_or_reference_point = Factor de escala o punto de referencia |
|
80 |
second_scale_point = Segundo punto para la escala |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties | ||
---|---|---|
22 | 22 |
modify_rotate = Rotate geometry |
23 | 23 |
modify_duplicate = Duplicate geometry |
24 | 24 |
modify_split_line = Split line open by a point |
25 |
modify_scale = Scale geometry |
|
25 | 26 |
selection=Selection |
26 | 27 |
invalid_option=Invalid option |
27 | 28 |
center=Center |
... | ... | |
73 | 74 |
new_value = New value |
74 | 75 |
finished = finished |
75 | 76 |
center_of_rotation=Center of rotation |
76 |
angle_of_rotation=Angle of rotation |
|
77 |
angle_of_rotation=Angle of rotation |
|
78 |
origin_point = Origin |
|
79 |
scale_factor_or_reference_point = Scale factor or reference point |
|
80 |
second_scale_point = Second scale point |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/pom.xml | ||
---|---|---|
148 | 148 |
<dependency> |
149 | 149 |
<groupId>org.gvsig</groupId> |
150 | 150 |
<artifactId> |
151 |
org.gvsig.vectorediting.lib.prov.scale |
|
152 |
</artifactId> |
|
153 |
</dependency> |
|
154 |
<dependency> |
|
155 |
<groupId>org.gvsig</groupId> |
|
156 |
<artifactId> |
|
151 | 157 |
org.gvsig.vectorediting.lib.prov.splitline |
152 | 158 |
</artifactId> |
153 | 159 |
</dependency> |
160 |
|
|
154 | 161 |
</dependencies> |
155 | 162 |
</project> |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/pom.xml | ||
---|---|---|
222 | 222 |
</artifactId> |
223 | 223 |
<version>1.0.0-SNAPSHOT</version> |
224 | 224 |
</dependency> |
225 |
<dependency> |
|
226 |
<groupId>org.gvsig</groupId> |
|
227 |
<artifactId> |
|
228 |
org.gvsig.vectorediting.lib.prov.scale |
|
229 |
</artifactId> |
|
230 |
<version>1.0.0-SNAPSHOT</version> |
|
231 |
</dependency> |
|
225 | 232 |
</dependencies> |
226 | 233 |
</dependencyManagement> |
227 | 234 |
</project> |
Also available in: Unified diff