Statistics
| Revision:

gvsig-vectorediting / 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 @ 2616

History | View | Annotate | Download (21.8 KB)

1 159 llmarques
/**
2
 * gvSIG. Desktop Geographic Information System.
3 63 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 57 llmarques
 */
24 159 llmarques
25 57 llmarques
package org.gvsig.vectorediting.lib.prov.polyline;
26
27
import java.util.ArrayList;
28 192 llmarques
import java.util.LinkedHashMap;
29 57 llmarques
import java.util.List;
30 192 llmarques
import java.util.Map;
31 2616 fdiaz
import org.gvsig.euclidean.EuclideanManager;
32 57 llmarques
import org.gvsig.fmap.dal.exception.DataException;
33
import org.gvsig.fmap.dal.feature.FeatureStore;
34
import org.gvsig.fmap.geom.Geometry;
35
import org.gvsig.fmap.geom.GeometryLocator;
36
import org.gvsig.fmap.geom.GeometryManager;
37 2616 fdiaz
import org.gvsig.fmap.geom.GeometryUtils;
38 57 llmarques
import org.gvsig.fmap.geom.aggregate.MultiCurve;
39 575 fdiaz
import org.gvsig.fmap.geom.aggregate.MultiLine;
40 2616 fdiaz
import org.gvsig.fmap.geom.exception.CreateGeometryException;
41 575 fdiaz
import org.gvsig.fmap.geom.primitive.Arc;
42 57 llmarques
import org.gvsig.fmap.geom.primitive.Curve;
43
import org.gvsig.fmap.geom.primitive.Line;
44 95 fdiaz
import org.gvsig.fmap.geom.primitive.OrientablePrimitive;
45 57 llmarques
import org.gvsig.fmap.geom.primitive.Point;
46
import org.gvsig.fmap.geom.primitive.Surface;
47
import org.gvsig.fmap.geom.type.GeometryType;
48 333 fdiaz
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
49 193 llmarques
import org.gvsig.tools.ToolsLocator;
50 57 llmarques
import org.gvsig.tools.dynobject.DynObject;
51 146 llmarques
import org.gvsig.tools.exception.BaseException;
52 193 llmarques
import org.gvsig.tools.i18n.I18nManager;
53 57 llmarques
import org.gvsig.tools.service.spi.ProviderServices;
54 2616 fdiaz
import org.gvsig.tools.util.ToolsUtilLocator;
55 57 llmarques
import org.gvsig.vectorediting.lib.api.DrawingStatus;
56
import org.gvsig.vectorediting.lib.api.EditingServiceParameter;
57
import org.gvsig.vectorediting.lib.api.EditingServiceParameter.TYPE;
58 61 llmarques
import org.gvsig.vectorediting.lib.api.exceptions.DrawServiceException;
59
import org.gvsig.vectorediting.lib.api.exceptions.FinishServiceException;
60 62 llmarques
import org.gvsig.vectorediting.lib.api.exceptions.InvalidEntryException;
61 63 fdiaz
import org.gvsig.vectorediting.lib.api.exceptions.StartServiceException;
62 108 llmarques
import org.gvsig.vectorediting.lib.api.exceptions.VectorEditingException;
63 57 llmarques
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 333 fdiaz
import org.gvsig.vectorediting.lib.spi.EditingProviderLocator;
69
import org.gvsig.vectorediting.lib.spi.EditingProviderManager;
70 57 llmarques
import org.gvsig.vectorediting.lib.spi.EditingProviderServices;
71 2616 fdiaz
import org.slf4j.Logger;
72
import org.slf4j.LoggerFactory;
73 57 llmarques
74 575 fdiaz
public class PolylineEditingProvider extends AbstractEditingProvider implements EditingProvider {
75 57 llmarques
76 2616 fdiaz
    private static final Logger LOGGER = LoggerFactory.getLogger(PolylineEditingProvider.class);
77
78 575 fdiaz
    protected EditingProviderServices editingProviderServices = (EditingProviderServices) getProviderServices();
79 57 llmarques
80 240 llmarques
    protected EditingServiceParameter points;
81 70 llmarques
82 240 llmarques
    protected Map<String, String> options;
83 57 llmarques
84 192 llmarques
    private boolean arcMode;
85 57 llmarques
86 192 llmarques
    private boolean finishPolyline;
87
88
    private boolean closeGeometry;
89
90 146 llmarques
    private List<MyPolyLinePoint> values;
91 57 llmarques
92 146 llmarques
    protected FeatureStore featureStore;
93 2616 fdiaz
94 575 fdiaz
    public PolylineEditingProvider(ProviderServices providerServices, DynObject parameters) {
95 146 llmarques
        super(providerServices);
96 193 llmarques
97
        // Initialize all provider variables.
98 575 fdiaz
        this.featureStore = (FeatureStore) parameters.getDynValue(EditingProviderFactory.FEATURE_STORE_FIELD);
99 193 llmarques
100
        I18nManager i18nManager = ToolsLocator.getI18nManager();
101 202 llmarques
102 2616 fdiaz
        options = new LinkedHashMap<>();
103 193 llmarques
        options.put(i18nManager.getTranslation("key_arc_mode"), "arc_mode");
104
        options.put(i18nManager.getTranslation("key_line_mode"), "line_mode");
105 227 llmarques
        options.put(i18nManager.getTranslation("key_close"), "close_polyline");
106 193 llmarques
        options.put(i18nManager.getTranslation("key_finish"), "finish");
107 437 fdiaz
        options.put(i18nManager.getTranslation("key_remove_last_point"), "remove_last_point");
108 193 llmarques
109 575 fdiaz
        String consoleMsg = editingProviderServices.makeConsoleMessage("indicate_new_point", options);
110 437 fdiaz
111 193 llmarques
        points =
112 575 fdiaz
            new DefaultEditingServiceParameter("insert_point", consoleMsg, options, TYPE.LIST_POSITIONS, TYPE.OPTION);
113 193 llmarques
114
        arcMode = false;
115
        finishPolyline = false;
116
        closeGeometry = false;
117 146 llmarques
    }
118 61 llmarques
119 146 llmarques
    /**
120 193 llmarques
     * Calculates polyline with stored values and last position received as
121 2616 fdiaz
     * parameter.If last position is null calculates only with stored values.
122 146 llmarques
     *
123
     * @param lastPosition
124 193 llmarques
     *            of polyline.
125
     * @return A drawing status value with a list of geometries. See
126
     *         {@link DrawingStatus#getGeometries()}.
127 2616 fdiaz
     * @throws org.gvsig.vectorediting.lib.api.exceptions.VectorEditingException
128
     * @throws org.gvsig.fmap.geom.exception.CreateGeometryException
129
     * @throws org.gvsig.fmap.dal.exception.DataException
130 146 llmarques
     */
131 2616 fdiaz
    protected Line calculatePolyline(Point lastPosition) throws VectorEditingException, CreateGeometryException, DataException {
132 333 fdiaz
        DefaultDrawingStatus drawingStatus = new DefaultDrawingStatus();
133 2616 fdiaz
        return calculatePolyline(lastPosition, drawingStatus);
134
135
    }
136
    protected Line calculatePolyline(Point lastPosition, DefaultDrawingStatus drawingStatus) throws VectorEditingException, CreateGeometryException, DataException {
137
        GeometryManager geomManager = GeometryLocator.getGeometryManager();
138
        GeometryType storeGeomType = editingProviderServices.getGeomType(featureStore);
139
        Line line = geomManager.createLine(storeGeomType.getSubType());
140
        Line previewLine = geomManager.createLine(storeGeomType.getSubType());
141
142
        EuclideanManager euclideanManager = ToolsUtilLocator.getEuclideanManager();
143 575 fdiaz
        EditingProviderManager editingProviderManager = EditingProviderLocator.getProviderManager();
144 2616 fdiaz
145
        ISymbol previewSymbol = this.getPreviewSymbol();
146
//        drawingStatus.setPreviewSymbol(previewSymbol);
147 333 fdiaz
        ISymbol lineSymbolEditing = editingProviderManager.getSymbol("line-symbol-editing");
148
        ISymbol auxiliaryLineSymbolEditing = editingProviderManager.getSymbol("auxiliary-line-symbol-editing");
149
        ISymbol auxiliaryPointSymbolEditing = editingProviderManager.getSymbol("auxiliary-point-symbol-editing");
150
151 2616 fdiaz
        Point antPoint = null;
152 146 llmarques
        Double antm = null;
153
        Double antb = null;
154
        Double m = null;
155
        Double b = null;
156
        Point center = null;
157
        double radius = 0.0;
158
        double startAngle = 0.0;
159
        double endAngle = 0.0;
160
        double angleExt = 0.0;
161 2616 fdiaz
        double sweepAngle = 0.0;
162 146 llmarques
        boolean right = false;
163
        boolean addGeom = false;
164 57 llmarques
165 146 llmarques
        Curve lineAntPointToPoint = null;
166 2616 fdiaz
        Point point = null;
167
        Point nextPoint = null;
168
169
        if (values.size() > 0) {
170 146 llmarques
            for (int i = 0; i < values.size(); i++) {
171 57 llmarques
172 146 llmarques
                MyPolyLinePoint polyLinePoint = values.get(i);
173
                MyPolyLinePoint polyLineNextPoint = getNextPoint(i);
174 2616 fdiaz
                point = polyLinePoint.getPoint();
175
                previewLine.addVertex(point);
176
                line.addVertex(point);
177 57 llmarques
178 146 llmarques
                if (polyLineNextPoint == null) {
179
                    nextPoint = lastPosition;
180
                    addGeom = true;
181
                } else {
182
                    nextPoint = polyLineNextPoint.getPoint();
183
                }
184 57 llmarques
185 146 llmarques
                if (nextPoint == null) {
186 2616 fdiaz
                    drawingStatus.addStatus(previewLine, lineSymbolEditing, "");
187
                    drawingStatus.addStatus(previewLine, previewSymbol, "");
188
                    if(line.getNumVertices()>1){
189
                        return line;
190
                    } else {
191
                        return null;
192
                    }
193 146 llmarques
                }
194 2616 fdiaz
195
196 575 fdiaz
                try {
197
                    if (polyLinePoint.isArcMode()) {
198
                        int subtype = editingProviderServices.getSubType(featureStore);
199 57 llmarques
200 2616 fdiaz
                        lineAntPointToPoint = GeometryUtils.createLine(point, nextPoint, subtype);
201 57 llmarques
202 575 fdiaz
                        Double[] lineParams = editingProviderServices.getLineParams(point, nextPoint);
203 146 llmarques
                        m = lineParams[0];
204
                        b = lineParams[1];
205
                        Point[] pointPerpendicular =
206 575 fdiaz
                            editingProviderServices.getPerpendicular(antm, antb, point, subtype);
207
                        Line linePointPerpendicular = geomManager.createLine(subtype);
208
                        linePointPerpendicular.setPoints(pointPerpendicular[0], pointPerpendicular[1]);
209 57 llmarques
210 575 fdiaz
                        Point midPoint = editingProviderServices.getMidPoint(point, nextPoint, subtype);
211
                        Point[] bisector = editingProviderServices.getPerpendicular(m, b, midPoint, subtype);
212 178 llmarques
                        Line lineBisector = geomManager.createLine(subtype);
213 146 llmarques
                        lineBisector.setPoints(bisector[0], bisector[1]);
214 57 llmarques
215 575 fdiaz
                        center = editingProviderServices.getIntersection(bisector, pointPerpendicular, subtype);
216 57 llmarques
217 2616 fdiaz
                        double coefDirection = 1.0;
218
                        if(antPoint != null){
219
                            coefDirection = GeometryUtils.getCoefDirection(antPoint, point, nextPoint);
220
                        }
221
222 146 llmarques
                        if (center != null) {
223 2616 fdiaz
                            startAngle = GeometryUtils.calculateAngle(center, point);
224 57 llmarques
225 146 llmarques
                            radius = center.distance(point);
226 2616 fdiaz
227
                            //calculate sweepAngle
228
                            sweepAngle = GeometryUtils.calculateAngle(center, point, nextPoint);
229
230
                            if (coefDirection < 0) {
231
                                sweepAngle = -(2 * Math.PI - sweepAngle);
232
                            }
233
234
                            if (Math.signum(coefDirection) != Math.signum(sweepAngle)) {
235
                                sweepAngle = -(2 * Math.PI - sweepAngle);
236
                            }
237
238
239 146 llmarques
                        } else {
240 2616 fdiaz
                            String msg
241
                                    =
242 575 fdiaz
                                String.format("Can't get intersection between bisector" + " [(%1$s,%2$s),(%3$s,%4$s)]"
243
                                    + " and perperdicular" + " [(%5$s,%6$s),(%7$s,%8$s)]", bisector[0].getX(),
244
                                    bisector[0].getY(), bisector[1].getX(), bisector[1].getY(),
245
                                    pointPerpendicular[0].getX(), pointPerpendicular[0].getY(),
246
                                    pointPerpendicular[1].getX(), pointPerpendicular[1].getY());
247 57 llmarques
248 146 llmarques
                            throw new DrawServiceException(msg, null);
249
                        }
250 57 llmarques
251 2616 fdiaz
                        Arc arco = GeometryUtils.createArc(
252
                                center,
253
                                radius,
254
                                startAngle,
255
                                sweepAngle,
256
                                GEOM2D);
257
                        antPoint = GeometryUtils.createPoint(center, radius, startAngle+sweepAngle-(sweepAngle/1000));
258 57 llmarques
259 575 fdiaz
                        antm = -(nextPoint.getX() - center.getX()) / (nextPoint.getY() - center.getY());
260
                        if (antm == Double.POSITIVE_INFINITY) {
261
                            antb = Double.NEGATIVE_INFINITY;
262
                            if (nextPoint.getX() == 0) {
263
                                antb = 0.0;
264 146 llmarques
                            }
265 575 fdiaz
                        } else if (antm == Double.NEGATIVE_INFINITY) {
266
                            antb = Double.POSITIVE_INFINITY;
267
                            if (nextPoint.getX() == 0) {
268
                                antb = 0.0;
269
                            }
270
                        } else {
271
                            antb = nextPoint.getY() - (antm * nextPoint.getX());
272 146 llmarques
                        }
273
274 575 fdiaz
                        // Draw geometries.
275
                        if (addGeom) {
276
                            drawingStatus.addStatus(point, auxiliaryPointSymbolEditing, "");
277
                            drawingStatus.addStatus(nextPoint, auxiliaryPointSymbolEditing, "");
278
                            drawingStatus.addStatus(center, auxiliaryPointSymbolEditing, "");
279
                            drawingStatus.addStatus(lineAntPointToPoint, auxiliaryLineSymbolEditing, "");
280 146 llmarques
                        }
281 2616 fdiaz
282
                        Point vertexAnt = null;
283
                        MultiLine multiline = arco.toLines();
284
                        for (int n = 0; n < multiline.getPrimitivesNumber(); n++) {
285
                            Line arcLine = (Line) multiline.getPrimitiveAt(n);
286
                            if (arcLine.getNumVertices() > 0 && vertexAnt != null && arcLine.getVertex(0) != vertexAnt) {
287
                                arcLine.flip();
288
                            }
289
                            for (int j = 0; j < arcLine.getNumVertices()-1; j++) {
290
                                if ((vertexAnt == null) || !vertexAnt.equals(arcLine.getVertex(j))) {
291
                                    line.addVertex(arcLine.getVertex(j));
292
                                    previewLine.addVertex(arcLine.getVertex(j));
293
                                    vertexAnt = arcLine.getVertex(j);
294
                                }
295
                            }
296
                            nextPoint = arcLine.getVertex(arcLine.getNumVertices()-1);
297
                        }
298 575 fdiaz
                    } else {
299
                        int subtype = editingProviderServices.getSubType(featureStore);
300 2616 fdiaz
301 333 fdiaz
                        if (addGeom) {
302
                            drawingStatus.addStatus(point, auxiliaryPointSymbolEditing, "");
303
                            drawingStatus.addStatus(nextPoint, auxiliaryPointSymbolEditing, "");
304
                        }
305
306 2616 fdiaz
                        antPoint = point;
307
                        //FIXME: Esto es para el c?lculo del posible arco posterior.
308 575 fdiaz
                        Double[] antLineParams = editingProviderServices.getLineParams(point, nextPoint);
309
                        antm = antLineParams[0];
310
                        antb = antLineParams[1];
311
                        right = (nextPoint.getX() >= point.getX());
312 146 llmarques
                    }
313 575 fdiaz
                } catch (Exception e) {
314
                    throw new DrawServiceException(e);
315 146 llmarques
                }
316 57 llmarques
            }
317 2616 fdiaz
            if(nextPoint != null) {
318
                line.addVertex(nextPoint);
319
                previewLine.addVertex(nextPoint);
320
                nextPoint = null;
321
            }
322
323
            drawingStatus.addStatus(previewLine, lineSymbolEditing, "");
324
            drawingStatus.addStatus(previewLine, previewSymbol, "");
325
            if(line.getNumVertices()>1){
326
                return line;
327
            } else {
328
                return null;
329
            }
330 146 llmarques
        }
331
        return null;
332
    }
333 2616 fdiaz
334
335 220 llmarques
    protected Geometry closeGeometryIfNecessary(Geometry geometry) {
336 227 llmarques
        if (!isClose(geometry) && (geometry != null)) {
337 192 llmarques
338
            if (geometry instanceof Surface) {
339
                Surface surface = (Surface) geometry;
340
                Point firstp = surface.getVertex(0);
341
                firstp = (Point) firstp.cloneGeometry();
342
                surface.addVertex(firstp);
343
                return surface;
344
            } else if (geometry instanceof Curve) {
345
                Curve line = (Curve) geometry;
346
                Point firstp = line.getVertex(0);
347
                firstp = (Point) firstp.cloneGeometry();
348
                line.addVertex(firstp);
349
                return line;
350
            }
351 146 llmarques
        }
352 192 llmarques
        return geometry;
353 146 llmarques
    }
354 57 llmarques
355 2616 fdiaz
    @Override
356 575 fdiaz
    public DrawingStatus getDrawingStatus(Point mousePosition) throws DrawServiceException {
357 333 fdiaz
358 146 llmarques
        try {
359 2616 fdiaz
            DefaultDrawingStatus drawingStatus = new DefaultDrawingStatus();
360
            Geometry geom = calculatePolyline(mousePosition, drawingStatus);
361
            return drawingStatus;
362 333 fdiaz
363 146 llmarques
        } catch (Exception e) {
364 61 llmarques
            throw new DrawServiceException(e);
365 57 llmarques
        }
366
    }
367 61 llmarques
368 2616 fdiaz
    @Override
369 146 llmarques
    public void finishAndStore() throws FinishServiceException {
370
        try {
371
            Geometry geometry = finish();
372
            if (geometry != null) {
373 575 fdiaz
                editingProviderServices.insertGeometryIntoFeatureStore(geometry, featureStore);
374 146 llmarques
            }
375
        } catch (Exception e) {
376
            throw new FinishServiceException(e);
377
        }
378 57 llmarques
    }
379 61 llmarques
380 2616 fdiaz
    @Override
381 146 llmarques
    public Geometry finish() throws FinishServiceException {
382
        try {
383
            GeometryManager geomManager = GeometryLocator.getGeometryManager();
384 575 fdiaz
            GeometryType storeGeomType = editingProviderServices.getGeomType(featureStore);
385 2616 fdiaz
386
            Line line = calculatePolyline(null);
387
            if(line == null){
388
                return null;
389
            }
390 146 llmarques
391 192 llmarques
            if (closeGeometry) {
392 220 llmarques
                line = (Line) closeGeometryIfNecessary(line);
393 192 llmarques
            }
394
395 146 llmarques
            if (storeGeomType.isTypeOf(MULTICURVE)) {
396 575 fdiaz
                MultiCurve multiCurve = geomManager.createMultiCurve(storeGeomType.getSubType());
397 227 llmarques
                multiCurve.addCurve(line);
398 146 llmarques
                return multiCurve;
399
            } else {
400
                return line;
401
            }
402 192 llmarques
403 146 llmarques
        } catch (BaseException e) {
404
            throw new FinishServiceException(e);
405
        }
406 70 llmarques
    }
407 61 llmarques
408 2616 fdiaz
    @Override
409 146 llmarques
    public String getName() {
410
        return PolylineEditingProviderFactory.PROVIDER_NAME;
411
    }
412 61 llmarques
413 146 llmarques
    private MyPolyLinePoint getNextPoint(int i) {
414 227 llmarques
        if (!values.isEmpty() && (i < (values.size() - 1))) {
415 146 llmarques
            return values.get(i + 1);
416 57 llmarques
        }
417 146 llmarques
        return null;
418 57 llmarques
    }
419 61 llmarques
420 2616 fdiaz
    private MyPolyLinePoint getPreviousPoint(int i) {
421
        if (!values.isEmpty() && (i > 0)) {
422
            return values.get(i - 1);
423
        }
424
        return null;
425
    }
426
427
    @Override
428 146 llmarques
    public List<EditingServiceParameter> getParameters() {
429 2616 fdiaz
        List<EditingServiceParameter> list = new ArrayList<>();
430 146 llmarques
        list.add(points);
431
        return list;
432 57 llmarques
    }
433 61 llmarques
434 192 llmarques
    private boolean isClose(Geometry geometry) {
435 61 llmarques
436 192 llmarques
        if (geometry != null) {
437
438
            if (geometry instanceof OrientablePrimitive) {
439 575 fdiaz
                OrientablePrimitive orientablePrimitive = (OrientablePrimitive) geometry;
440 192 llmarques
                Point firstPoint = orientablePrimitive.getVertex(0);
441 575 fdiaz
                Point lastPoint = orientablePrimitive.getVertex(orientablePrimitive.getNumVertices() - 1);
442 192 llmarques
                if (firstPoint.equals(lastPoint)) {
443
                    return true;
444
                }
445 146 llmarques
            }
446
        }
447
        return false;
448 57 llmarques
    }
449
450 2616 fdiaz
    @Override
451 146 llmarques
    public EditingServiceParameter next() {
452 192 llmarques
        if (finishPolyline) {
453
            return null;
454
        } else {
455
            return points;
456
        }
457 70 llmarques
458 57 llmarques
    }
459
460 2616 fdiaz
    @Override
461 146 llmarques
    public void start() throws StartServiceException {
462 192 llmarques
        // Stop service;
463 146 llmarques
        stop();
464 192 llmarques
465 2616 fdiaz
        values = new ArrayList<>();
466 146 llmarques
    }
467 57 llmarques
468 2616 fdiaz
    @Override
469 146 llmarques
    public void stop() {
470
        if (values != null) {
471
            values.clear();
472
        }
473
        arcMode = false;
474 192 llmarques
        finishPolyline = false;
475
        closeGeometry = false;
476 77 llmarques
    }
477 61 llmarques
478 575 fdiaz
    private void validateAndInsertValue(EditingServiceParameter param, Object value) throws InvalidEntryException {
479 146 llmarques
        if (value instanceof String) {
480 192 llmarques
            String option = (String) value;
481 193 llmarques
            I18nManager i18nManager = ToolsLocator.getI18nManager();
482 202 llmarques
483 575 fdiaz
            if (option.equalsIgnoreCase(i18nManager.getTranslation("key_finish"))) {
484 193 llmarques
                finishPolyline = true;
485
                return;
486
            }
487 192 llmarques
488 437 fdiaz
            if (values.size() > 0) {
489 575 fdiaz
                if (option.equalsIgnoreCase(i18nManager.getTranslation("key_remove_last_point"))) {
490
                    arcMode = values.get(values.size() - 1).isArcMode();
491
                    if (values.size() > 2) {
492
                        values.get(values.size() - 2).setArcMode(arcMode);
493
                    } else {
494
                        arcMode = false;
495
                    }
496
                    values.remove(values.size() - 1);
497 437 fdiaz
                    return;
498
                }
499
            }
500
501 193 llmarques
            if (values.size() >= 2) {
502 192 llmarques
503 575 fdiaz
                if (option.equalsIgnoreCase(i18nManager.getTranslation("key_arc_mode"))) {
504 192 llmarques
505 193 llmarques
                    arcMode = true;
506 192 llmarques
507 575 fdiaz
                } else if (option.equalsIgnoreCase(i18nManager.getTranslation("key_line_mode"))) {
508 146 llmarques
509 193 llmarques
                    arcMode = false;
510
511 575 fdiaz
                } else if (option.equalsIgnoreCase(i18nManager.getTranslation("key_close"))) {
512 193 llmarques
513
                    closeGeometry = true;
514
                    finishPolyline = true;
515 192 llmarques
                }
516 227 llmarques
            } else {
517 209 llmarques
                throw new InvalidEntryException(null);
518 193 llmarques
            }
519 192 llmarques
520 193 llmarques
            if (values.size() > 0) {
521
                values.get(values.size() - 1).setArcMode(arcMode);
522
                return;
523 146 llmarques
            }
524 193 llmarques
525 227 llmarques
        } else if ((param == points) && (value instanceof Point)) {
526 2616 fdiaz
             Point vertex = ((Point) value).cloneGeometry();
527
            values.add(new MyPolyLinePoint(vertex, arcMode));
528 193 llmarques
            return;
529 63 fdiaz
        }
530 193 llmarques
        throw new InvalidEntryException(null);
531 146 llmarques
    }
532 70 llmarques
533 2204 fdiaz
    @Override
534
    public void setValue(EditingServiceParameter parameter, Object value) throws InvalidEntryException {
535
        validateAndInsertValue(parameter, value);
536
    }
537
538 2616 fdiaz
    @Override
539 146 llmarques
    public void setValue(Object value) throws InvalidEntryException {
540
        EditingServiceParameter param = next();
541
        validateAndInsertValue(param, value);
542 57 llmarques
    }
543
544 2444 fdiaz
    @Override
545
    public Object getValue(EditingServiceParameter parameter) {
546
        if(parameter == points){
547
            return values;
548
        }
549
        return null;
550
    }
551 2616 fdiaz
552 57 llmarques
}