Revision 193 org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.polyline/src/main/java/org/gvsig/vectorediting/lib/prov/polyline/PolylineEditingProvider.java
PolylineEditingProvider.java | ||
---|---|---|
43 | 43 |
import org.gvsig.fmap.geom.primitive.Point; |
44 | 44 |
import org.gvsig.fmap.geom.primitive.Surface; |
45 | 45 |
import org.gvsig.fmap.geom.type.GeometryType; |
46 |
import org.gvsig.tools.ToolsLocator; |
|
46 | 47 |
import org.gvsig.tools.dynobject.DynObject; |
47 | 48 |
import org.gvsig.tools.exception.BaseException; |
49 |
import org.gvsig.tools.i18n.I18nManager; |
|
48 | 50 |
import org.gvsig.tools.service.spi.ProviderServices; |
49 | 51 |
import org.gvsig.vectorediting.lib.api.DrawingStatus; |
50 | 52 |
import org.gvsig.vectorediting.lib.api.EditingServiceParameter; |
... | ... | |
84 | 86 |
public PolylineEditingProvider(ProviderServices providerServices, |
85 | 87 |
DynObject parameters) { |
86 | 88 |
super(providerServices); |
89 |
|
|
90 |
// Initialize all provider variables. |
|
87 | 91 |
this.featureStore = |
88 | 92 |
(FeatureStore) parameters |
89 | 93 |
.getDynValue(EditingProviderFactory.FEATURE_STORE_FIELD); |
94 |
|
|
95 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
96 |
|
|
97 |
options = new LinkedHashMap<String, String>(); |
|
98 |
options.put(i18nManager.getTranslation("key_arc_mode"), "arc_mode"); |
|
99 |
options.put(i18nManager.getTranslation("key_line_mode"), "line_mode"); |
|
100 |
options.put(i18nManager.getTranslation("key_close_polyline"), |
|
101 |
"close_polyline"); |
|
102 |
options.put(i18nManager.getTranslation("key_finish"), "finish"); |
|
103 |
|
|
104 |
points = |
|
105 |
new DefaultEditingServiceParameter("points", "indicate_new_point", |
|
106 |
options, TYPE.LIST_POSITIONS, TYPE.OPTION); |
|
107 |
|
|
108 |
arcMode = false; |
|
109 |
finishPolyline = false; |
|
110 |
closeGeometry = false; |
|
90 | 111 |
} |
91 | 112 |
|
92 | 113 |
/** |
114 |
* Calculates polyline with stored values and last position received as |
|
115 |
* parameter. If last position is null calculates only with stored values. |
|
93 | 116 |
* |
94 |
* |
|
95 | 117 |
* @param lastPosition |
96 |
* @return |
|
97 |
* @throws VectorEditingException |
|
118 |
* of polyline. |
|
119 |
* @return A drawing status value with a list of geometries. See |
|
120 |
* {@link DrawingStatus#getGeometries()}. |
|
98 | 121 |
*/ |
99 | 122 |
private DrawingStatus calculatePolyline(Point lastPosition) |
100 | 123 |
throws VectorEditingException { |
... | ... | |
471 | 494 |
// Stop service; |
472 | 495 |
stop(); |
473 | 496 |
|
474 |
// Initialize all provider variables. |
|
475 | 497 |
values = new ArrayList<MyPolyLinePoint>(); |
476 |
|
|
477 |
options = new LinkedHashMap<String, String>(); |
|
478 |
options.put("A", "arc_mode"); |
|
479 |
options.put("L", "line_mode"); |
|
480 |
options.put("C", "close_polyline"); |
|
481 |
options.put("F", "finish"); |
|
482 |
|
|
483 |
points = |
|
484 |
new DefaultEditingServiceParameter("Points", "indicate_new_point", |
|
485 |
options, TYPE.LIST_POSITIONS, TYPE.OPTION); |
|
486 |
|
|
487 |
arcMode = false; |
|
488 |
finishPolyline = false; |
|
489 |
closeGeometry = false; |
|
490 |
|
|
491 | 498 |
} |
492 | 499 |
|
493 | 500 |
public void stop() { |
... | ... | |
503 | 510 |
Object value) throws InvalidEntryException { |
504 | 511 |
if (value instanceof String) { |
505 | 512 |
String option = (String) value; |
506 |
if (options.containsKey(option)) { |
|
513 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
514 |
|
|
515 |
if (option.equalsIgnoreCase(i18nManager |
|
516 |
.getTranslation("key_finish"))) { |
|
517 |
finishPolyline = true; |
|
518 |
return; |
|
519 |
} |
|
507 | 520 |
|
508 |
if (option.equalsIgnoreCase("F")) { |
|
509 |
finishPolyline = true; |
|
510 |
} |
|
521 |
if (values.size() >= 2) { |
|
511 | 522 |
|
512 |
if (values.size() >= 2) { |
|
523 |
if (option.equalsIgnoreCase(i18nManager |
|
524 |
.getTranslation("key_arc_mode"))) { |
|
513 | 525 |
|
514 |
if (option.equalsIgnoreCase("A")) { |
|
515 |
arcMode = true; |
|
516 |
} else if (option.equalsIgnoreCase("L")) { |
|
517 |
arcMode = false; |
|
518 |
} else if (option.equalsIgnoreCase("C")) { |
|
519 |
closeGeometry = true; |
|
520 |
finishPolyline = true; |
|
521 |
} |
|
526 |
arcMode = true; |
|
522 | 527 |
|
523 |
} |
|
528 |
} else if (option.equalsIgnoreCase(i18nManager |
|
529 |
.getTranslation("key_line_mode"))) { |
|
524 | 530 |
|
525 |
if (values.size() > 0) { |
|
526 |
values.get(values.size() - 1).setArcMode(arcMode); |
|
527 |
return; |
|
531 |
arcMode = false; |
|
532 |
|
|
533 |
} else if (option.equalsIgnoreCase(i18nManager |
|
534 |
.getTranslation("key_close_polyline"))) { |
|
535 |
|
|
536 |
closeGeometry = true; |
|
537 |
finishPolyline = true; |
|
528 | 538 |
} |
539 |
} |
|
529 | 540 |
|
530 |
} else { |
|
531 |
throw new InvalidEntryException(null); |
|
541 |
if (values.size() > 0) { |
|
542 |
values.get(values.size() - 1).setArcMode(arcMode); |
|
543 |
return; |
|
532 | 544 |
} |
545 |
|
|
533 | 546 |
} else if (param == points && value instanceof Point) { |
534 | 547 |
values.add(new MyPolyLinePoint((Point) value, arcMode)); |
548 |
return; |
|
535 | 549 |
} |
550 |
throw new InvalidEntryException(null); |
|
536 | 551 |
} |
537 | 552 |
|
538 | 553 |
public void setValue(Object value) throws InvalidEntryException { |
Also available in: Unified diff