Revision 377 org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.regularpolygon/src/main/java/org/gvsig/vectorediting/lib/prov/regularpolygon/RegularPolygonEditingProvider.java
RegularPolygonEditingProvider.java | ||
---|---|---|
71 | 71 |
implements EditingProvider { |
72 | 72 |
|
73 | 73 |
protected final Integer DEFAULT_VALUE_SIDES = 5; |
74 |
|
|
75 | 74 |
protected final String DEFAULT_VALUE_MODE = "key_inscribed"; |
75 |
protected final String SIDES_KEY= "sides"; |
|
76 |
protected final String MODE_KEY = "mode"; |
|
76 | 77 |
|
77 | 78 |
protected EditingServiceParameter polygonSides; |
78 | 79 |
|
... | ... | |
84 | 85 |
|
85 | 86 |
protected Map<EditingServiceParameter, Object> values; |
86 | 87 |
|
88 |
protected Map<String, String> defaultValues = null; |
|
89 |
|
|
87 | 90 |
protected Map<String, String> options; |
88 | 91 |
|
89 | 92 |
protected FeatureStore featureStore; |
... | ... | |
95 | 98 |
(FeatureStore) parameters |
96 | 99 |
.getDynValue(EditingProviderFactory.FEATURE_STORE_FIELD); |
97 | 100 |
|
101 |
Integer sideDefaultValue = Integer.valueOf((String)getDefaultValues().get(SIDES_KEY)); |
|
102 |
if (sideDefaultValue == null){ |
|
103 |
sideDefaultValue = DEFAULT_VALUE_SIDES; |
|
104 |
} |
|
105 |
|
|
98 | 106 |
polygonSides = |
99 |
new DefaultEditingServiceParameter("sides", DEFAULT_VALUE_SIDES,
|
|
107 |
new DefaultEditingServiceParameter(SIDES_KEY, sideDefaultValue,
|
|
100 | 108 |
"sides_of_regular_polygon", EditingServiceParameter.TYPE.VALUE); |
101 | 109 |
|
102 | 110 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
... | ... | |
111 | 119 |
String consoleMsg = |
112 | 120 |
editingProviderServices.makeConsoleMessage(null, options); |
113 | 121 |
|
122 |
String modeDefaultValue = (String)getDefaultValues().get(MODE_KEY); |
|
123 |
if (modeDefaultValue == null){ |
|
124 |
modeDefaultValue = DEFAULT_VALUE_MODE; |
|
125 |
} |
|
126 |
|
|
114 | 127 |
mode = |
115 |
new DefaultEditingServiceParameter("mode", consoleMsg, options,
|
|
116 |
i18nManager.getTranslation(DEFAULT_VALUE_MODE),
|
|
128 |
new DefaultEditingServiceParameter(MODE_KEY, consoleMsg, options,
|
|
129 |
modeDefaultValue,
|
|
117 | 130 |
EditingServiceParameter.TYPE.OPTION); |
118 | 131 |
|
119 | 132 |
center = |
... | ... | |
126 | 139 |
"point_of_circle", EditingServiceParameter.TYPE.POSITION); |
127 | 140 |
} |
128 | 141 |
|
142 |
private Map<String, String> getDefaultValues() { |
|
143 |
if (this.defaultValues == null){ |
|
144 |
EditingProviderManager editingProviderManager = |
|
145 |
EditingProviderLocator.getProviderManager(); |
|
146 |
this.defaultValues = editingProviderManager.getDefaultValues("regularpolygon"); |
|
147 |
} |
|
148 |
return this.defaultValues; |
|
149 |
} |
|
150 |
|
|
129 | 151 |
public EditingServiceParameter next() { |
130 | 152 |
if (values.get(polygonSides) == null) { |
131 | 153 |
return polygonSides; |
... | ... | |
164 | 186 |
editingProviderServices.getSubType(featureStore); |
165 | 187 |
|
166 | 188 |
if (modeValue == null) { |
167 |
modeValue = DEFAULT_VALUE_MODE;
|
|
189 |
modeValue = (String)getDefaultValues().get(MODE_KEY);
|
|
168 | 190 |
} |
169 | 191 |
|
170 | 192 |
Curve polygon = |
... | ... | |
376 | 398 |
|
377 | 399 |
if (sides > 2) { |
378 | 400 |
values.put(param, sides); |
401 |
getDefaultValues().put(SIDES_KEY, sides.toString()); |
|
402 |
polygonSides.setDefaultValue(sides.toString()); |
|
379 | 403 |
return; |
380 | 404 |
} else { |
381 | 405 |
throw new InvalidEntryException(null); |
382 | 406 |
} |
383 | 407 |
} else if (value instanceof Point) { |
384 | 408 |
|
385 |
values.put(param, DEFAULT_VALUE_SIDES);
|
|
409 |
values.put(param, Integer.valueOf((String)getDefaultValues().get(SIDES_KEY)));
|
|
386 | 410 |
values.put(center, (Point) value); |
387 | 411 |
return; |
388 | 412 |
} |
... | ... | |
397 | 421 |
.getTranslation("key_inscribed"))) { |
398 | 422 |
|
399 | 423 |
values.put(param, "key_inscribed"); |
424 |
getDefaultValues().put(MODE_KEY, "key_inscribed"); |
|
425 |
mode.setDefaultValue("key_inscribed"); |
|
400 | 426 |
return; |
401 | 427 |
|
402 | 428 |
} else if (option.equalsIgnoreCase(i18nManager |
403 | 429 |
.getTranslation("key_circumscribed"))) { |
404 | 430 |
|
405 | 431 |
values.put(param, "key_circumscribed"); |
432 |
getDefaultValues().put(MODE_KEY, "key_circumscribed"); |
|
433 |
mode.setDefaultValue("key_circumscribed"); |
|
406 | 434 |
return; |
407 | 435 |
|
408 | 436 |
} else { |
... | ... | |
410 | 438 |
} |
411 | 439 |
} else if (value instanceof Point) { |
412 | 440 |
|
413 |
values.put(param, DEFAULT_VALUE_MODE);
|
|
441 |
values.put(param, getDefaultValues().get(MODE_KEY));
|
|
414 | 442 |
if(values.get(center) != null){ |
415 | 443 |
values.put(pointOfCircle, (Point) value); |
416 | 444 |
} else { |
Also available in: Unified diff