Revision 3838 org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.rotate/src/main/java/org/gvsig/vectorediting/lib/prov/rotate/RotateEditingProvider.java
RotateEditingProvider.java | ||
---|---|---|
153 | 153 |
|
154 | 154 |
this.selectionParameter |
155 | 155 |
= new DefaultEditingServiceParameter("selection", |
156 |
i18nManager.getTranslation("selection"), TYPE.SELECTION); |
|
156 |
i18nManager.getTranslation("selection"), TYPE.SELECTION).setAllowNull(false);
|
|
157 | 157 |
|
158 | 158 |
DefaultEditingServiceParameterOptions options = new DefaultEditingServiceParameterOptions() |
159 | 159 |
.add(i18nManager.getTranslation(PIVOT_CENTER_ENVELOPE), PIVOT_CENTER_ENVELOPE, i18nManager.getTranslation(KEY_PIVOT_CENTER_ENVELOPE)) |
... | ... | |
215 | 215 |
"_Angle", |
216 | 216 |
i18nManager.getTranslation("_Angle"), |
217 | 217 |
TYPE.VALUE |
218 |
); |
|
218 |
).setDataType(DataTypes.DOUBLE).setAllowNull(false);
|
|
219 | 219 |
|
220 | 220 |
this.firstPointParameter |
221 | 221 |
= new DefaultEditingServiceParameter( |
222 | 222 |
"Start_of_rotation", |
223 | 223 |
i18nManager.getTranslation("_Start_of_rotation"), |
224 |
TYPE.POSITION); |
|
224 |
TYPE.POSITION).setAllowNull(false);
|
|
225 | 225 |
|
226 | 226 |
this.secondPointParameter |
227 | 227 |
= new DefaultEditingServiceParameter( |
228 | 228 |
"_End_of_rotation", |
229 | 229 |
i18nManager.getTranslation("_End_of_rotation"), |
230 | 230 |
TYPE.POSITION |
231 |
); |
|
231 |
).setAllowNull(false);
|
|
232 | 232 |
|
233 | 233 |
this.values = new HashMap<>(); |
234 | 234 |
|
... | ... | |
494 | 494 |
private void validateAndInsertValue(EditingServiceParameter param, |
495 | 495 |
Object value) throws InvalidEntryException { |
496 | 496 |
if (param == selectionParameter) { |
497 |
if (value instanceof FeatureSelection) { |
|
498 |
values.put(param, value); |
|
499 |
this.selectedFeatures = this.getSelectedFeaturesCopy((FeatureSelection) value); |
|
500 |
} else { |
|
497 |
if (!param.isValidValue(value)) { |
|
501 | 498 |
throw new InvalidEntryException(null); |
502 | 499 |
} |
500 |
values.put(param, value); |
|
501 |
this.selectedFeatures = this.getSelectedFeaturesCopy((FeatureSelection) value); |
|
503 | 502 |
|
504 | 503 |
} else if (param == modeParameter) { |
505 |
if(!(value instanceof String)){
|
|
504 |
if (!param.isValidValue(value)) {
|
|
506 | 505 |
throw new InvalidEntryException(null); |
507 | 506 |
} |
508 | 507 |
String rotateMode = (String) param.getOptions2().getValue(value, param.getDefaultValue()); |
509 | 508 |
modeParameter.setDefaultValue(rotateMode); |
510 | 509 |
values.put(param, rotateMode); |
511 | 510 |
} else if (param == separateElementsParameter) { |
511 |
if (!param.isValidValue(value)) { |
|
512 |
throw new InvalidEntryException(null); |
|
513 |
} |
|
512 | 514 |
savedSeparateElements = (Boolean) param.getOptions2().getValue(value, param.getDefaultValue()); |
513 | 515 |
values.put(param, savedSeparateElements); |
514 | 516 |
} else if (param == pivotPointParameter) { |
517 |
if (!param.isValidValue(value)) { |
|
518 |
center = null; |
|
519 |
throw new InvalidEntryException(null); |
|
520 |
} |
|
515 | 521 |
if (value == null) { |
516 | 522 |
value = param.getDefaultValue(); |
517 | 523 |
} |
518 | 524 |
if (value instanceof Point) { |
519 | 525 |
values.put(param, value); |
520 | 526 |
center = null; |
521 |
} else if (value instanceof String) {
|
|
527 |
} else { //String
|
|
522 | 528 |
String pivotMode = (String) param.getOptions2().getValue(value, param.getDefaultValue()); |
523 |
if (PIVOT_CENTER_ENVELOPE.equalsIgnoreCase(pivotMode) || PIVOT_CENTROID.equalsIgnoreCase(pivotMode)) { |
|
524 |
center = pivotMode; |
|
525 |
FeatureSelection selected |
|
526 |
= (FeatureSelection) values.get(this.selectionParameter); |
|
527 |
values.put(param, calculatePivot(selected, pivotMode)); |
|
528 |
} else { |
|
529 |
center = null; |
|
530 |
values.remove(param); |
|
531 |
} |
|
532 |
} else { |
|
533 |
throw new InvalidEntryException(null); |
|
529 |
center = pivotMode; |
|
530 |
FeatureSelection selected |
|
531 |
= (FeatureSelection) values.get(this.selectionParameter); |
|
532 |
values.put(param, calculatePivot(selected, pivotMode)); |
|
534 | 533 |
} |
535 | 534 |
} else if (param == firstPointParameter) { |
536 |
if (value instanceof Point) { |
|
537 |
if (((Point) value).equals((Point) values.get(pivotPointParameter))) { |
|
538 |
throw new InvalidEntryException(null); |
|
539 |
} |
|
540 |
values.put(param, value); |
|
541 |
} else { |
|
535 |
if (!param.isValidValue(value)) { |
|
542 | 536 |
throw new InvalidEntryException(null); |
543 | 537 |
} |
538 |
if (((Point) value).equals((Point) values.get(pivotPointParameter))) { |
|
539 |
throw new InvalidEntryException(null); |
|
540 |
} |
|
541 |
values.put(param, value); |
|
544 | 542 |
} else if (param == secondPointParameter) { |
545 |
if (value instanceof Point) { |
|
546 |
if (((Point) value).equals((Point) values.get(firstPointParameter)) |
|
547 |
|| ((Point) value).equals((Point) values.get(pivotPointParameter))) { |
|
548 |
throw new InvalidEntryException(null); |
|
549 |
} |
|
550 |
values.put(param, value); |
|
551 |
} else { |
|
543 |
if (!param.isValidValue(value)) { |
|
552 | 544 |
throw new InvalidEntryException(null); |
553 | 545 |
} |
546 |
if (((Point) value).equals((Point) values.get(firstPointParameter)) |
|
547 |
|| ((Point) value).equals((Point) values.get(pivotPointParameter))) { |
|
548 |
throw new InvalidEntryException(null); |
|
549 |
} |
|
550 |
values.put(param, value); |
|
554 | 551 |
} else if (param == angleParameter) { |
555 |
if (value instanceof Double) { |
|
556 |
if ((Double)value == 0.0){ |
|
557 |
throw new InvalidEntryException(null); |
|
558 |
} |
|
559 |
values.put(param, value); |
|
560 |
} else { |
|
552 |
if (!param.isValidValue(value)) { |
|
561 | 553 |
throw new InvalidEntryException(null); |
562 | 554 |
} |
555 |
Object v = angleParameter.coerceValue(value); |
|
556 |
if ((Double)v == 0.0){ |
|
557 |
throw new InvalidEntryException(null); |
|
558 |
} |
|
559 |
values.put(param, v); |
|
563 | 560 |
} |
564 | 561 |
} |
565 | 562 |
|
Also available in: Unified diff