Revision 2109 org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.ellipse/src/main/java/org/gvsig/vectorediting/lib/prov/ellipse/EllipseCenterAxesEditingProvider.java

View differences:

EllipseCenterAxesEditingProvider.java
21 21
 * For any additional information, do not hesitate to contact us
22 22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23 23
 */
24

  
25 24
package org.gvsig.vectorediting.lib.prov.ellipse;
26 25

  
26
import org.gvsig.fmap.dal.exception.DataException;
27 27
import org.gvsig.fmap.geom.Geometry;
28 28
import org.gvsig.fmap.geom.GeometryLocator;
29 29
import org.gvsig.fmap.geom.aggregate.MultiCurve;
......
33 33
import org.gvsig.fmap.geom.type.GeometryType;
34 34
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
35 35
import org.gvsig.tools.dynobject.DynObject;
36
import org.gvsig.tools.locator.LocatorException;
36 37
import org.gvsig.tools.service.spi.ProviderServices;
37 38
import org.gvsig.vectorediting.lib.api.exceptions.FinishServiceException;
38 39
import org.gvsig.vectorediting.lib.spi.DefaultDrawingStatus;
......
42 43
import org.gvsig.vectorediting.lib.spi.EditingProviderServices;
43 44

  
44 45
public class EllipseCenterAxesEditingProvider extends FilledEllipseCenterAxesEditingProvider implements
45
EditingProvider {
46
        EditingProvider {
46 47

  
47 48
    public EllipseCenterAxesEditingProvider(ProviderServices services,
48
        DynObject parameters) {
49
            DynObject parameters) {
49 50
        super(services, parameters);
50 51
    }
51 52

  
52
        public Geometry finish() throws FinishServiceException {
53
    @Override
54
    public Geometry finish() throws FinishServiceException {
53 55
        if (values != null) {
54 56

  
55
            EditingProviderServices editingProviderServices =
56
                (EditingProviderServices) getProviderServices();
57
            EditingProviderServices editingProviderServices
58
                    = (EditingProviderServices) getProviderServices();
57 59

  
58 60
            Point centerValue = (Point) values.get(center);
59 61
            Point pointAxis1Value = (Point) values.get(pointAxisA);
60
            double lengthAxis2Value = (Double) values.get(lengthAxisB);
62
            double lengthSemiaxis2Value = (Double) values.get(lengthSemiaxisB);
61 63

  
62 64
            if ((center != null)
63
                && (pointAxis1Value != null) && (lengthAxis2Value > 0)) {
65
                    && (pointAxis1Value != null) && (lengthSemiaxis2Value > 0)) {
64 66

  
65

  
66 67
                try {
67 68
                    int subtype = editingProviderServices.getSubType(featureStore);
68 69
                    GeometryType storeGeomType = editingProviderServices.getGeomType(featureStore);
69 70

  
70
                    PeriEllipse periEllipse =
71
                        (PeriEllipse) GeometryLocator.getGeometryManager().create(Geometry.TYPES.PERIELLIPSE, subtype);
72
                    
73
                    
71
                    PeriEllipse periEllipse
72
                            = (PeriEllipse) GeometryLocator.getGeometryManager().create(Geometry.TYPES.PERIELLIPSE, subtype);
73

  
74 74
                    Point firstPointAxis = calculateOpositePointAxis(centerValue, pointAxis1Value, subtype);
75
                    
76
                    periEllipse.setPoints(firstPointAxis, pointAxis1Value, lengthAxis2Value / 2);
77 75

  
76
                    periEllipse.setPoints(firstPointAxis, pointAxis1Value, lengthSemiaxis2Value);
77

  
78 78
                    if (storeGeomType.isTypeOf(MULTICURVE)) {
79 79
                        MultiCurve multicurve;
80
                        multicurve =
81
                            GeometryLocator.getGeometryManager().createMultiCurve(
82
                                storeGeomType.getSubType());
80
                        multicurve
81
                                = GeometryLocator.getGeometryManager().createMultiCurve(
82
                                        storeGeomType.getSubType());
83 83
                        multicurve.addCurve((PeriEllipse) periEllipse);
84 84
                        return multicurve;
85 85
                    }
86 86

  
87 87
                    return periEllipse;
88
                } catch (Exception e) {
88
                } catch (DataException | CreateGeometryException | LocatorException e) {
89 89
                    throw new FinishServiceException(e);
90 90
                }
91 91
            }
......
93 93
        return null;
94 94
    }
95 95

  
96

  
96
    @Override
97 97
    public String getName() {
98 98
        return EllipseCenterAxesEditingProviderFactory.PROVIDER_NAME;
99 99
    }
......
108 108
     */
109 109
    @Override
110 110
    protected void addTemporaryGeometryToDrawingStatus(DefaultDrawingStatus drawingStatus, Point firstPointAxis1Value,
111
        Point secondPointAxis1Value, int subtype, double distance) throws CreateGeometryException {
111
            Point secondPointAxis1Value, int subtype, double distance) throws CreateGeometryException {
112 112
        PeriEllipse periEllipse = (PeriEllipse) GeometryLocator.getGeometryManager().create(Geometry.TYPES.PERIELLIPSE, subtype);
113 113
        periEllipse.setPoints(firstPointAxis1Value, secondPointAxis1Value, distance);
114 114

  
......
117 117
        drawingStatus.addStatus(periEllipse, lineSymbolEditing, "");
118 118
    }
119 119

  
120

  
121 120
}

Also available in: Unified diff