Revision 2616
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.impl/src/main/java/org/gvsig/vectorediting/lib/impl/DefaultEditingProviderServices.java | ||
---|---|---|
66 | 66 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
67 | 67 |
import org.gvsig.fmap.mapcontext.layers.SpatialCache; |
68 | 68 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
69 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
|
69 | 70 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
70 | 71 |
import org.gvsig.tools.ToolsLocator; |
71 | 72 |
import org.gvsig.tools.exception.BaseException; |
72 | 73 |
import org.gvsig.tools.i18n.I18nManager; |
74 |
import org.gvsig.tools.lang.CloneableUtils; |
|
73 | 75 |
import org.gvsig.tools.service.spi.AbstractProviderServices; |
76 |
import org.gvsig.vectorediting.lib.api.EditingService; |
|
74 | 77 |
import org.gvsig.vectorediting.lib.spi.DefaultDrawingStatus; |
78 |
import org.gvsig.vectorediting.lib.spi.EditingProviderFactory; |
|
75 | 79 |
import org.gvsig.vectorediting.lib.spi.EditingProviderLocator; |
76 | 80 |
import org.gvsig.vectorediting.lib.spi.EditingProviderManager; |
77 | 81 |
import org.gvsig.vectorediting.lib.spi.EditingProviderServices; |
78 | 82 |
import org.slf4j.Logger; |
79 | 83 |
import org.slf4j.LoggerFactory; |
84 |
import org.gvsig.tools.swing.api.TransparencySupport; |
|
80 | 85 |
|
81 | 86 |
public class DefaultEditingProviderServices extends AbstractProviderServices |
82 | 87 |
implements EditingProviderServices { |
... | ... | |
84 | 89 |
private static final Logger LOGGER = LoggerFactory |
85 | 90 |
.getLogger(DefaultEditingProviderServices.class); |
86 | 91 |
|
92 |
public DefaultEditingProviderServices() { |
|
93 |
super(); |
|
94 |
} |
|
95 |
|
|
87 | 96 |
@Override |
88 | 97 |
public void insertFeatureIntoFeatureStore(Feature feature, |
89 | 98 |
FeatureStore featureStore) { |
... | ... | |
143 | 152 |
public EditableFeature createNewFeature(FeatureStore store){ |
144 | 153 |
try { |
145 | 154 |
EditableFeature f = store.createNewFeature(); |
146 |
f.copyFrom(this.getDefaultFeatureValues()); |
|
155 |
//FIXME: ?Deber?amos saltarnos la geometr?a? |
|
156 |
f.copyFrom(this.getDefaultFeatureValues(),(FeatureAttributeDescriptor t) -> !(t.isPrimaryKey() || (t.isIndexed() && !t.allowIndexDuplicateds()))); |
|
147 | 157 |
return f; |
148 | 158 |
} catch (DataException ex) { |
149 | 159 |
throw new RuntimeException("Can't create feature", ex); |
... | ... | |
399 | 409 |
Feature feature) throws DataException { |
400 | 410 |
EditableFeature editableFeature |
401 | 411 |
= featureStore.createNewFeature(feature.getType(), true); |
402 |
editableFeature.copyFrom(this.getDefaultFeatureValues()); |
|
412 |
editableFeature.copyFrom(this.getDefaultFeatureValues(), (FeatureAttributeDescriptor t) -> !(t.isPrimaryKey() || (t.isIndexed() && !t.allowIndexDuplicateds())));
|
|
403 | 413 |
|
404 | 414 |
editableFeature.copyFrom(feature, (FeatureAttributeDescriptor t) -> !(t.isPrimaryKey() || (t.isIndexed() && !t.allowIndexDuplicateds()))); |
405 | 415 |
return editableFeature; |
... | ... | |
737 | 747 |
|
738 | 748 |
Point measurePoint = GeometryUtils.createPoint(vertex, radius, angleRay1 + angle / 2); |
739 | 749 |
|
740 |
// drawingStatus.addStatus(measurePoint, textSymbol, new AngleFormat("DD�MM'").format(Math.toDegrees(angle)));
|
|
741 |
drawingStatus.addStatus(measurePoint, textSymbol, new AngleFormat("DD.ddd�").format(Math.toDegrees(angle)));
|
|
750 |
// drawingStatus.addStatus(measurePoint, textSymbol, GeometryUtils.formatAngle("%2d\u00B0 %2m\u2032", Math.toDegrees(angle)));
|
|
751 |
drawingStatus.addStatus(measurePoint, textSymbol, GeometryUtils.formatAngle("%5.3D\u00B0", Math.toDegrees(angle)));
|
|
742 | 752 |
|
743 | 753 |
} |
744 | 754 |
|
... | ... | |
751 | 761 |
|
752 | 762 |
@Override |
753 | 763 |
public EditableFeature getDefaultFeatureValues() { |
764 |
if(defaultFeatureValues == null){ |
|
765 |
Feature f = this.getService().getStore().getSampleFeature(); |
|
766 |
this.defaultFeatureValues = f.getCopy().getEditable(); |
|
767 |
} |
|
754 | 768 |
return this.defaultFeatureValues; |
755 | 769 |
} |
770 |
|
|
771 |
@Override |
|
772 |
public ISymbol getPreviewSymbol() { |
|
773 |
try { |
|
774 |
IVectorLegend legend = this.getService().getLegend(); |
|
775 |
ISymbol symbol = legend.getSymbolByFeature(getDefaultFeatureValues()); |
|
776 |
if(!(symbol instanceof TransparencySupport)) { |
|
777 |
return null; |
|
778 |
} |
|
779 |
symbol = (ISymbol) CloneableUtils.cloneQuietly(symbol); |
|
780 |
((TransparencySupport) symbol).setTransparency(0.5); |
|
781 |
return symbol; |
|
782 |
} catch (Exception e) { |
|
783 |
return null; |
|
784 |
} |
|
785 |
} |
|
786 |
|
|
787 |
@Override |
|
788 |
public ISymbol getPreviewSymbol(Feature feature) { |
|
789 |
try { |
|
790 |
IVectorLegend legend = this.getService().getLegend(); |
|
791 |
ISymbol symbol = legend.getSymbolByFeature(feature); |
|
792 |
if(!(symbol instanceof TransparencySupport)) { |
|
793 |
return null; |
|
794 |
} |
|
795 |
symbol = (ISymbol) CloneableUtils.cloneQuietly(symbol); |
|
796 |
((TransparencySupport) symbol).setTransparency(0.5); |
|
797 |
return symbol; |
|
798 |
} catch (Exception e) { |
|
799 |
return null; |
|
800 |
} |
|
801 |
} |
|
802 |
|
|
803 |
@Override |
|
804 |
public EditingService getService() { |
|
805 |
return (EditingService) super.getService(); |
|
806 |
} |
|
756 | 807 |
|
757 | 808 |
} |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.impl/src/main/java/org/gvsig/vectorediting/lib/impl/DefaultEditingService.java | ||
---|---|---|
25 | 25 |
package org.gvsig.vectorediting.lib.impl; |
26 | 26 |
|
27 | 27 |
import java.util.List; |
28 |
import java.util.logging.Level; |
|
29 |
import java.util.logging.Logger; |
|
30 | 28 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
31 | 29 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
32 |
|
|
33 | 30 |
import org.gvsig.fmap.geom.Geometry; |
34 | 31 |
import org.gvsig.fmap.geom.primitive.Point; |
35 |
import org.gvsig.tools.ToolsLocator;
|
|
32 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend;
|
|
36 | 33 |
import org.gvsig.tools.dynobject.DynClass; |
37 | 34 |
import org.gvsig.tools.dynobject.DynObject; |
38 | 35 |
import org.gvsig.tools.observer.BaseNotification; |
39 | 36 |
import org.gvsig.tools.observer.Notification; |
40 | 37 |
import org.gvsig.tools.observer.ObservableHelper; |
41 | 38 |
import org.gvsig.tools.observer.Observer; |
39 |
import org.gvsig.tools.service.AbstractService; |
|
42 | 40 |
import org.gvsig.tools.service.Manager; |
43 | 41 |
import org.gvsig.tools.service.ServiceException; |
42 |
import org.gvsig.tools.service.spi.AbstractProviderServices; |
|
44 | 43 |
import org.gvsig.vectorediting.lib.api.DrawingStatus; |
45 | 44 |
import org.gvsig.vectorediting.lib.api.EditingLocator; |
46 | 45 |
import org.gvsig.vectorediting.lib.api.EditingService; |
... | ... | |
52 | 51 |
import org.gvsig.vectorediting.lib.api.exceptions.StopServiceException; |
53 | 52 |
import org.gvsig.vectorediting.lib.spi.EditingProvider; |
54 | 53 |
import org.gvsig.vectorediting.lib.spi.EditingProviderFactory; |
54 |
import org.gvsig.vectorediting.lib.spi.EditingProviderLocator; |
|
55 |
import org.gvsig.vectorediting.lib.spi.EditingProviderManager; |
|
56 |
import org.gvsig.vectorediting.lib.spi.EditingProviderServices; |
|
55 | 57 |
|
56 |
public class DefaultEditingService implements EditingService { |
|
58 |
public class DefaultEditingService extends AbstractService implements EditingService {
|
|
57 | 59 |
|
58 |
EditingProvider provider; |
|
59 | 60 |
private final ObservableHelper observableHelper; |
60 |
private final DynObject parameters; |
|
61 |
// private final DynObject parameters;
|
|
61 | 62 |
|
62 |
public DefaultEditingService(EditingProvider provider, DynObject parameters) { |
|
63 |
this.parameters = parameters; |
|
64 |
this.provider = provider; |
|
63 |
// public DefaultEditingService(EditingProvider provider, DynObject parameters) { |
|
64 |
// this.parameters = parameters; |
|
65 |
// this.provider = provider; |
|
66 |
// this.observableHelper = new ObservableHelper(); |
|
67 |
// } |
|
68 |
|
|
69 |
DefaultEditingService(DynObject arg0, EditingProviderServices editingProviderServices) throws ServiceException { |
|
70 |
this.init(arg0, editingProviderServices); |
|
71 |
((AbstractProviderServices)editingProviderServices).setService(this); |
|
65 | 72 |
this.observableHelper = new ObservableHelper(); |
66 | 73 |
} |
67 | 74 |
|
68 | 75 |
@Override |
76 |
protected EditingProvider getProvider() { |
|
77 |
return (EditingProvider) super.getProvider(); |
|
78 |
} |
|
79 |
|
|
80 |
@Override |
|
69 | 81 |
public Manager getManager() { |
70 | 82 |
return null; |
71 | 83 |
} |
... | ... | |
73 | 85 |
@Override |
74 | 86 |
public DrawingStatus getDrawingStatus(Point mousePosition) |
75 | 87 |
throws DrawServiceException { |
76 |
return provider.getDrawingStatus(mousePosition);
|
|
88 |
return getProvider().getDrawingStatus(mousePosition);
|
|
77 | 89 |
} |
78 | 90 |
|
79 | 91 |
@Override |
80 | 92 |
public List<EditingServiceParameter> getParameters() { |
81 |
return provider.getParameters();
|
|
93 |
return getProvider().getParameters();
|
|
82 | 94 |
} |
83 | 95 |
|
84 | 96 |
@Override |
85 | 97 |
public EditingServiceParameter next() { |
86 |
EditingServiceParameter x = provider.next();
|
|
98 |
EditingServiceParameter x = getProvider().next();
|
|
87 | 99 |
this.updateObservers(NEXT_NOTIFICATION, x, null); |
88 | 100 |
return x; |
89 | 101 |
} |
90 | 102 |
|
91 | 103 |
@Override |
92 | 104 |
public void setValue(Object value) throws InvalidEntryException { |
93 |
provider.setValue(value);
|
|
105 |
getProvider().setValue(value);
|
|
94 | 106 |
this.updateObservers(PARAMETER_CHANGED1_NOTIFICATION, value, null); |
95 | 107 |
} |
96 | 108 |
|
97 | 109 |
@Override |
98 | 110 |
public void stop() throws StopServiceException { |
99 |
provider.stop();
|
|
111 |
getProvider().stop();
|
|
100 | 112 |
this.updateObservers(STOP_NOTIFICATION, null, null); |
101 | 113 |
} |
102 | 114 |
|
103 | 115 |
@Override |
104 | 116 |
public void finishAndStore() throws FinishServiceException { |
105 |
provider.finishAndStore();
|
|
117 |
getProvider().finishAndStore();
|
|
106 | 118 |
this.updateObservers(FINISH_AND_STORE_NOTIFICATION, null, null); |
107 | 119 |
} |
108 | 120 |
|
109 | 121 |
@Override |
110 | 122 |
public Geometry finish() throws FinishServiceException { |
111 |
Geometry x = provider.finish();
|
|
123 |
Geometry x = getProvider().finish();
|
|
112 | 124 |
this.updateObservers(FINISH_NOTIFICATION, x, null); |
113 | 125 |
return x; |
114 | 126 |
} |
115 | 127 |
|
116 | 128 |
@Override |
117 | 129 |
public void start() throws StartServiceException, InvalidEntryException { |
118 |
this.provider.start();
|
|
130 |
this.getProvider().start();
|
|
119 | 131 |
this.updateObservers(START_NOTIFICATION, null, null); |
120 | 132 |
} |
121 | 133 |
|
122 | 134 |
@Override |
123 | 135 |
public String getName() { |
124 |
return provider.getName();
|
|
136 |
return getProvider().getName();
|
|
125 | 137 |
} |
126 | 138 |
|
127 | 139 |
@Override |
128 | 140 |
public void setValue(EditingServiceParameter parameter, Object value) throws InvalidEntryException { |
129 |
provider.setValue(parameter, value);
|
|
141 |
getProvider().setValue(parameter, value);
|
|
130 | 142 |
this.updateObservers(PARAMETER_CHANGED2_NOTIFICATION, parameter, value); |
131 | 143 |
} |
132 | 144 |
|
133 | 145 |
@Override |
134 | 146 |
public boolean isEnabled(EditingServiceParameter parameter) { |
135 |
return provider.isEnabled(parameter);
|
|
147 |
return getProvider().isEnabled(parameter);
|
|
136 | 148 |
} |
137 | 149 |
|
138 | 150 |
@Override |
139 | 151 |
public void activate() { |
140 |
provider.activate();
|
|
152 |
getProvider().activate();
|
|
141 | 153 |
this.updateObservers(ACTIVATE_NOTIFICATION, null, null); |
142 | 154 |
} |
143 | 155 |
|
144 | 156 |
@Override |
145 | 157 |
public Object getValue(EditingServiceParameter parameter) { |
146 |
return provider.getValue(parameter);
|
|
158 |
return getProvider().getValue(parameter);
|
|
147 | 159 |
} |
148 | 160 |
|
149 | 161 |
@Override |
... | ... | |
168 | 180 |
|
169 | 181 |
@Override |
170 | 182 |
public void setDefaultFeatureValues(EditableFeature feature) { |
171 |
this.provider.setDefaultFeatureValues(feature);
|
|
183 |
this.getProvider().setDefaultFeatureValues(feature);
|
|
172 | 184 |
} |
173 | 185 |
|
174 | 186 |
@Override |
175 | 187 |
public EditableFeature getDefaultFeatureValues() { |
176 |
return this.provider.getDefaultFeatureValues();
|
|
188 |
return this.getProvider().getDefaultFeatureValues();
|
|
177 | 189 |
} |
178 | 190 |
|
179 | 191 |
@Override |
180 | 192 |
public FeatureStore getStore() { |
181 |
return (FeatureStore) this.parameters.getDynValue(EditingProviderFactory.FEATURE_STORE_FIELD);
|
|
193 |
return (FeatureStore) this.getServiceParameters().getDynValue(EditingProviderFactory.FEATURE_STORE_FIELD);
|
|
182 | 194 |
} |
183 | 195 |
|
184 | 196 |
@Override |
197 |
public IVectorLegend getLegend() { |
|
198 |
return (IVectorLegend) this.getServiceParameters().getDynValue(EditingProviderFactory.LEGEND_FIELD); |
|
199 |
} |
|
200 |
|
|
201 |
@Override |
|
185 | 202 |
public String getDescription() { |
186 |
String name = this.provider.getName();
|
|
203 |
String name = this.getProvider().getName();
|
|
187 | 204 |
try { |
188 | 205 |
DynObject params = EditingLocator.getManager().createServiceParameters(name); |
189 | 206 |
DynClass dynclass = params.getDynClass(); |
... | ... | |
192 | 209 |
return name; |
193 | 210 |
} |
194 | 211 |
} |
212 |
|
|
213 |
@Override |
|
214 |
protected EditingProviderManager getProviderManager() { |
|
215 |
return EditingProviderLocator.getProviderManager(); |
|
216 |
} |
|
217 |
|
|
218 |
@Override |
|
219 |
public void setShowPreviewSymbol(boolean showPreviewSymbol) { |
|
220 |
getProvider().setShowPreviewSymbol(showPreviewSymbol); |
|
221 |
} |
|
195 | 222 |
} |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.impl/src/main/java/org/gvsig/vectorediting/lib/impl/DefaultEditingManager.java | ||
---|---|---|
25 | 25 |
package org.gvsig.vectorediting.lib.impl; |
26 | 26 |
|
27 | 27 |
import org.gvsig.fmap.dal.exception.DataException; |
28 |
import org.slf4j.Logger; |
|
29 |
import org.slf4j.LoggerFactory; |
|
30 |
|
|
31 | 28 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
32 | 29 |
import org.gvsig.fmap.mapcontext.MapContext; |
30 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
|
33 | 31 |
import org.gvsig.tools.dynobject.DynObject; |
34 | 32 |
import org.gvsig.tools.service.AbstractManager; |
35 | 33 |
import org.gvsig.tools.service.Service; |
... | ... | |
42 | 40 |
import org.gvsig.vectorediting.lib.spi.EditingProviderFactory; |
43 | 41 |
import org.gvsig.vectorediting.lib.spi.EditingProviderLocator; |
44 | 42 |
import org.gvsig.vectorediting.lib.spi.EditingProviderServices; |
43 |
import org.slf4j.Logger; |
|
44 |
import org.slf4j.LoggerFactory; |
|
45 | 45 |
|
46 | 46 |
public class DefaultEditingManager extends AbstractManager implements |
47 | 47 |
EditingManager { |
... | ... | |
55 | 55 |
|
56 | 56 |
public Service getService(DynObject arg0) throws ServiceException { |
57 | 57 |
EditingProviderServices editingProviderServices = new DefaultEditingProviderServices(); |
58 |
EditingProvider provider = (EditingProvider) EditingProviderLocator.getProviderManager() |
|
59 |
.createProvider(arg0, editingProviderServices); |
|
60 |
FeatureStore store = (FeatureStore) arg0.getDynValue(EditingProviderFactory.FEATURE_STORE_FIELD); |
|
61 |
try { |
|
62 |
editingProviderServices.setDefaultFeatureValues(store.createNewFeature()); |
|
63 |
} catch (DataException ex) { |
|
64 |
} |
|
65 |
return new DefaultEditingService(provider, arg0); |
|
58 |
DefaultEditingService service = new DefaultEditingService(arg0, editingProviderServices); |
|
59 |
|
|
60 |
// DefaultEditingProviderServices editingProviderServices = new DefaultEditingProviderServices(); |
|
61 |
// EditingProvider provider = (EditingProvider) EditingProviderLocator.getProviderManager() |
|
62 |
// .createProvider(arg0, editingProviderServices); |
|
63 |
// FeatureStore store = (FeatureStore) arg0.getDynValue(EditingProviderFactory.FEATURE_STORE_FIELD); |
|
64 |
// try { |
|
65 |
// editingProviderServices.setDefaultFeatureValues(store.createNewFeature()); |
|
66 |
// } catch (DataException ex) { |
|
67 |
// } |
|
68 |
// DefaultEditingService service = new DefaultEditingService(provider, arg0); |
|
69 |
// editingProviderServices.setService(service); |
|
70 |
return service; |
|
66 | 71 |
} |
67 | 72 |
|
68 | 73 |
public EditingServiceInfo getServiceInfo(String serviceName) |
... | ... | |
73 | 78 |
|
74 | 79 |
@Override |
75 | 80 |
public EditingService getEditingService(String name, |
76 |
FeatureStore featureStore, MapContext mapContext) { |
|
81 |
FeatureStore featureStore, MapContext mapContext, IVectorLegend legend) {
|
|
77 | 82 |
try { |
78 | 83 |
DynObject params = this.createServiceParameters(name); |
79 | 84 |
params.setDynValue(EditingProviderFactory.FEATURE_STORE_FIELD, |
80 | 85 |
featureStore); |
81 | 86 |
params.setDynValue(EditingProviderFactory.MAPCONTEXT_FIELD, mapContext); |
87 |
if(legend != null && params.getDynClass().getDynField(EditingProviderFactory.LEGEND_FIELD)!=null){ |
|
88 |
params.setDynValue(EditingProviderFactory.LEGEND_FIELD, legend); |
|
89 |
} |
|
82 | 90 |
return (EditingService) this.getService(params); |
83 | 91 |
} catch (ServiceException e) { |
84 | 92 |
String msg = |
... | ... | |
91 | 99 |
|
92 | 100 |
return null; |
93 | 101 |
} |
102 |
|
|
103 |
@Override |
|
104 |
public EditingService getEditingService(String name, FeatureStore featureStore, MapContext mapContext) { |
|
105 |
return getEditingService(name, featureStore, mapContext, null); |
|
106 |
} |
|
94 | 107 |
|
108 |
|
|
109 |
|
|
95 | 110 |
} |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.point/src/main/java/org/gvsig/vectorediting/lib/prov/point/PointEditingProvider.java | ||
---|---|---|
26 | 26 |
|
27 | 27 |
import java.util.ArrayList; |
28 | 28 |
import java.util.List; |
29 |
|
|
30 | 29 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
31 | 30 |
import org.gvsig.fmap.geom.Geometry; |
32 | 31 |
import org.gvsig.fmap.geom.GeometryLocator; |
33 | 32 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
34 | 33 |
import org.gvsig.fmap.geom.primitive.Point; |
35 | 34 |
import org.gvsig.fmap.geom.type.GeometryType; |
36 |
import org.gvsig.tools.ToolsLocator; |
|
37 | 35 |
import org.gvsig.tools.dynobject.DynObject; |
38 |
import org.gvsig.tools.i18n.I18nManager; |
|
39 | 36 |
import org.gvsig.tools.service.spi.ProviderServices; |
40 | 37 |
import org.gvsig.vectorediting.lib.api.EditingServiceParameter; |
41 | 38 |
import org.gvsig.vectorediting.lib.api.EditingServiceParameter.TYPE; |
... | ... | |
54 | 51 |
public class PointEditingProvider extends AbstractEditingProvider |
55 | 52 |
implements EditingProvider { |
56 | 53 |
|
57 |
private EditingProviderServices editingProviderServices = |
|
54 |
private final EditingProviderServices editingProviderServices =
|
|
58 | 55 |
(EditingProviderServices) getProviderServices(); |
59 | 56 |
|
60 |
private EditingServiceParameter point; |
|
57 |
private final EditingServiceParameter point;
|
|
61 | 58 |
|
62 | 59 |
private Point valuePoint; |
63 | 60 |
|
64 |
private FeatureStore featureStore; |
|
61 |
private final FeatureStore featureStore;
|
|
65 | 62 |
|
66 | 63 |
public PointEditingProvider(ProviderServices services, |
67 | 64 |
DynObject parameters) { |
... | ... | |
75 | 72 |
"indicate_new_point", TYPE.POSITION); |
76 | 73 |
} |
77 | 74 |
|
75 |
@Override |
|
78 | 76 |
public DefaultDrawingStatus getDrawingStatus(Point mousePosition) |
79 | 77 |
throws DrawServiceException { |
80 | 78 |
return null; |
81 | 79 |
} |
82 | 80 |
|
81 |
@Override |
|
83 | 82 |
public void stop() throws StopServiceException { |
84 | 83 |
valuePoint = null; |
85 | 84 |
} |
86 | 85 |
|
87 | 86 |
private boolean isValidValue(EditingServiceParameter param, Object value) { |
88 |
return (value instanceof Point) ? true : false;
|
|
87 |
return (value instanceof Point); |
|
89 | 88 |
} |
90 | 89 |
|
90 |
@Override |
|
91 | 91 |
public EditingServiceParameter next() { |
92 | 92 |
if (valuePoint == null) { |
93 | 93 |
return this.point; |
... | ... | |
95 | 95 |
return null; |
96 | 96 |
} |
97 | 97 |
|
98 |
@Override |
|
98 | 99 |
public List<EditingServiceParameter> getParameters() { |
99 | 100 |
List<EditingServiceParameter> list = |
100 |
new ArrayList<EditingServiceParameter>();
|
|
101 |
new ArrayList<>(); |
|
101 | 102 |
list.add(point); |
102 | 103 |
return list; |
103 | 104 |
} |
... | ... | |
107 | 108 |
validateAndInsertValue(parameter, value); |
108 | 109 |
} |
109 | 110 |
|
111 |
@Override |
|
110 | 112 |
public void setValue(Object value) throws InvalidEntryException { |
111 | 113 |
EditingServiceParameter param = next(); |
112 | 114 |
validateAndInsertValue(param, value); |
... | ... | |
123 | 125 |
} |
124 | 126 |
|
125 | 127 |
|
128 |
@Override |
|
126 | 129 |
public void finishAndStore() throws FinishServiceException { |
127 |
Geometry geometry = null;
|
|
130 |
Geometry geometry; |
|
128 | 131 |
try { |
129 | 132 |
geometry = finish(); |
130 | 133 |
editingProviderServices.insertGeometryIntoFeatureStore(geometry, |
... | ... | |
135 | 138 |
} |
136 | 139 |
} |
137 | 140 |
|
141 |
@Override |
|
138 | 142 |
public void start() throws StartServiceException { |
139 | 143 |
this.valuePoint = null; |
140 | 144 |
} |
141 | 145 |
|
146 |
@Override |
|
142 | 147 |
public String getName() { |
143 | 148 |
return PointEditingProviderFactory.PROVIDER_NAME; |
144 | 149 |
} |
145 | 150 |
|
151 |
@Override |
|
146 | 152 |
public Geometry finish() throws FinishServiceException { |
147 | 153 |
Point geometry = null; |
148 | 154 |
try { |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.point/src/main/java/org/gvsig/vectorediting/lib/prov/point/PointEditingProviderFactory.java | ||
---|---|---|
25 | 25 |
package org.gvsig.vectorediting.lib.prov.point; |
26 | 26 |
|
27 | 27 |
import org.gvsig.fmap.geom.Geometry; |
28 |
import org.gvsig.tools.ToolsLocator; |
|
29 |
import org.gvsig.tools.dynobject.DynClass; |
|
30 | 28 |
import org.gvsig.tools.dynobject.DynObject; |
31 |
import org.gvsig.tools.service.spi.AbstractProviderFactory; |
|
32 | 29 |
import org.gvsig.tools.service.spi.Provider; |
33 | 30 |
import org.gvsig.tools.service.spi.ProviderServices; |
34 | 31 |
import org.gvsig.vectorediting.lib.api.EditingServiceInfo; |
32 |
import org.gvsig.vectorediting.lib.spi.AbstractEditingProviderFactory; |
|
35 | 33 |
import org.gvsig.vectorediting.lib.spi.DefaultEditingServiceinfo; |
36 |
import org.gvsig.vectorediting.lib.spi.EditingProviderFactory; |
|
37 | 34 |
|
38 |
public class PointEditingProviderFactory extends AbstractProviderFactory |
|
39 |
implements EditingProviderFactory { |
|
35 |
public class PointEditingProviderFactory extends AbstractEditingProviderFactory { |
|
40 | 36 |
|
41 | 37 |
public final static String PROVIDER_NAME = "insert-point"; |
42 | 38 |
|
43 | 39 |
public final static String PROVIDER_DESCRIPTION = |
44 | 40 |
"Inserts points on the view"; |
45 | 41 |
|
42 |
public PointEditingProviderFactory() { |
|
43 |
super(PROVIDER_NAME, PROVIDER_DESCRIPTION); |
|
44 |
} |
|
45 |
|
|
46 | 46 |
@Override |
47 | 47 |
public Provider doCreate(DynObject parameters, ProviderServices services) { |
48 | 48 |
return new PointEditingProvider(services, parameters); |
49 | 49 |
} |
50 | 50 |
|
51 | 51 |
@Override |
52 |
public DynObject createParameters() { |
|
53 |
DynObject parameters = super.createParameters(); |
|
54 |
parameters.setDynValue(PROVIDER_NAME_FIELD, PROVIDER_NAME); |
|
55 |
return parameters; |
|
56 |
} |
|
57 |
|
|
58 | 52 |
public EditingServiceInfo getServiceInfo() { |
59 | 53 |
EditingServiceInfo serviceInfo = |
60 | 54 |
new DefaultEditingServiceinfo(PROVIDER_NAME, "", true, null, |
... | ... | |
63 | 57 |
return serviceInfo; |
64 | 58 |
} |
65 | 59 |
|
66 |
public void initialize() { |
|
67 |
|
|
68 |
} |
|
69 |
|
|
70 |
@Override |
|
71 |
protected DynClass createParametersDynClass() { |
|
72 |
DynClass dynclass = |
|
73 |
ToolsLocator.getDynObjectManager().createDynClass(PROVIDER_NAME, |
|
74 |
PROVIDER_DESCRIPTION); |
|
75 |
|
|
76 |
dynclass.addDynFieldString(PROVIDER_NAME_FIELD); |
|
77 |
dynclass.addDynFieldObject(FEATURE_STORE_FIELD); |
|
78 |
dynclass.addDynFieldObject(MAPCONTEXT_FIELD); |
|
79 |
|
|
80 |
return dynclass; |
|
81 |
} |
|
82 |
|
|
83 | 60 |
} |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.split/src/main/java/org/gvsig/vectorediting/lib/prov/split/operation/CurveSplitOperation.java | ||
---|---|---|
56 | 56 |
* we have to join them. If any intersection points are equal to first or |
57 | 57 |
* last vertex do nothing. |
58 | 58 |
*/ |
59 |
@Override |
|
59 | 60 |
public Geometry split(Geometry geometryToBeSplitted, Geometry splitter) |
60 | 61 |
throws GeometryOperationNotSupportedException, |
61 | 62 |
GeometryOperationException, GeometryException { |
... | ... | |
125 | 126 |
Point lastPoint = |
126 | 127 |
curveToBeSplitted.getVertex(curveToBeSplitted.getNumVertices()-1); |
127 | 128 |
|
128 |
if (firstPoint.equals(lastPoint)) { |
|
129 |
return true; |
|
130 |
} |
|
131 |
return false; |
|
129 |
return firstPoint.equals(lastPoint); |
|
132 | 130 |
} |
133 | 131 |
} |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.split/src/main/java/org/gvsig/vectorediting/lib/prov/split/operation/ArcSplitOperation.java | ||
---|---|---|
26 | 26 |
|
27 | 27 |
import java.util.ArrayList; |
28 | 28 |
import java.util.Collections; |
29 |
import java.util.Comparator; |
|
30 | 29 |
import java.util.List; |
31 |
|
|
32 |
import org.slf4j.Logger; |
|
33 |
import org.slf4j.LoggerFactory; |
|
34 |
|
|
35 | 30 |
import org.gvsig.fmap.geom.Geometry; |
36 | 31 |
import org.gvsig.fmap.geom.GeometryLocator; |
37 | 32 |
import org.gvsig.fmap.geom.GeometryManager; |
... | ... | |
43 | 38 |
import org.gvsig.fmap.geom.primitive.Arc; |
44 | 39 |
import org.gvsig.fmap.geom.primitive.Point; |
45 | 40 |
import org.gvsig.tools.exception.BaseException; |
41 |
import org.slf4j.Logger; |
|
42 |
import org.slf4j.LoggerFactory; |
|
46 | 43 |
|
47 | 44 |
/** |
48 | 45 |
* @author llmarques |
... | ... | |
50 | 47 |
*/ |
51 | 48 |
public class ArcSplitOperation implements SplitOperation { |
52 | 49 |
|
53 |
private static Logger logger = LoggerFactory
|
|
50 |
private static final Logger LOGGER = LoggerFactory
|
|
54 | 51 |
.getLogger(ArcSplitOperation.class); |
55 | 52 |
|
56 | 53 |
/* |
... | ... | |
62 | 59 |
* 4. Iterate over ordered intersection points and create splitted arcs. |
63 | 60 |
* Stop iteration when all intersections points have been iterated. |
64 | 61 |
*/ |
62 |
@Override |
|
65 | 63 |
public Geometry split(Geometry geometryToBeSplitted, Geometry splitter) |
66 | 64 |
throws GeometryOperationNotSupportedException, |
67 | 65 |
GeometryOperationException, CreateGeometryException { |
... | ... | |
105 | 103 |
double radius = center.distance(arcToBeSplitted.getEndPoint()); |
106 | 104 |
|
107 | 105 |
// Order intersection points by angle to create arcs correctly |
108 |
List<Point> orderedIntersectionPoints = new ArrayList<Point>();
|
|
106 |
List<Point> orderedIntersectionPoints = new ArrayList<>(); |
|
109 | 107 |
for (int i = 0; i < multiIntersection.getPrimitivesNumber(); i++) { |
110 | 108 |
orderedIntersectionPoints.add(multiIntersection.getPointAt(i)); |
111 | 109 |
} |
112 | 110 |
|
113 | 111 |
// Sort by angle |
114 |
Collections.sort(orderedIntersectionPoints, |
|
115 |
new Comparator<Point>() { |
|
116 |
|
|
117 |
public int compare(Point p1, Point p2) { |
|
118 |
double angle1 = 0; |
|
119 |
double angle2 = 0; |
|
120 |
try { |
|
121 |
angle1 = SplitOperationUtils.getAngle(center, p1); |
|
122 |
angle2 = SplitOperationUtils.getAngle(center, p2); |
|
123 |
} catch (BaseException e) { |
|
124 |
logger |
|
125 |
.warn("Problems getting angle between center and" |
|
112 |
Collections.sort(orderedIntersectionPoints, (Point p1, Point p2) -> { |
|
113 |
double angle1; |
|
114 |
double angle2; |
|
115 |
try { |
|
116 |
angle1 = SplitOperationUtils.getAngle(center, p1); |
|
117 |
angle2 = SplitOperationUtils.getAngle(center, p2); |
|
118 |
} catch (BaseException e) { |
|
119 |
LOGGER |
|
120 |
.warn("Problems getting angle between center and" |
|
126 | 121 |
+ " one intersection point"); |
127 |
return 0; |
|
128 |
} |
|
129 |
return Double.compare(angle1, angle2); |
|
130 |
} |
|
131 |
}); |
|
122 |
return 0; |
|
123 |
} |
|
124 |
return Double.compare(angle1, angle2); |
|
125 |
}); |
|
132 | 126 |
|
133 | 127 |
MultiCurve splittedArcs = geoManager.createMultiCurve(subtype); |
134 | 128 |
|
... | ... | |
166 | 160 |
Point endPoint = arc.getEndPoint(); |
167 | 161 |
Point centerPoint = arc.getCenterPoint(); |
168 | 162 |
|
169 |
if(initPoint.equals(endPoint) || centerPoint == null){ |
|
170 |
return true; |
|
171 |
} |
|
172 |
return false; |
|
163 |
return initPoint.equals(endPoint) || centerPoint == null; |
|
173 | 164 |
} |
174 | 165 |
} |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.split/src/main/java/org/gvsig/vectorediting/lib/prov/split/operation/LineSplitOperation.java | ||
---|---|---|
56 | 56 |
* we have to join them. If any intersection points are equal to first or |
57 | 57 |
* last vertex do nothing. |
58 | 58 |
*/ |
59 |
@Override |
|
59 | 60 |
public Geometry split(Geometry geometryToBeSplitted, Geometry splitter) |
60 | 61 |
throws GeometryOperationNotSupportedException, |
61 | 62 |
GeometryOperationException, CreateGeometryException { |
... | ... | |
122 | 123 |
Point lastPoint = |
123 | 124 |
lineToBeSplitted.getVertex(lineToBeSplitted.getNumVertices()-1); |
124 | 125 |
|
125 |
if (firstPoint.equals(lastPoint)) { |
|
126 |
return true; |
|
127 |
} |
|
128 |
return false; |
|
126 |
return firstPoint.equals(lastPoint); |
|
129 | 127 |
} |
130 | 128 |
} |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.split/src/main/java/org/gvsig/vectorediting/lib/prov/split/operation/splitsurface/SplitGraphNode.java | ||
---|---|---|
81 | 81 |
edges.remove(edge); |
82 | 82 |
} |
83 | 83 |
|
84 |
@Override |
|
84 | 85 |
public String toString() { |
85 |
StringBuffer sb = new StringBuffer("Node[");
|
|
86 |
StringBuilder sb = new StringBuilder("Node[");
|
|
86 | 87 |
sb.append(coord.x).append(":").append(coord.y); |
87 | 88 |
sb.append(", ").append(label); |
88 | 89 |
sb.append(", ").append(getEdges()); |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.split/src/main/java/org/gvsig/vectorediting/lib/prov/split/operation/splitsurface/SurfaceSplitOperation.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
package org.gvsig.vectorediting.lib.prov.split.operation.splitsurface; |
26 | 26 |
|
27 |
import java.util.ArrayList; |
|
28 |
import java.util.Iterator; |
|
29 |
import java.util.List; |
|
30 |
|
|
31 | 27 |
import com.vividsolutions.jts.algorithm.CGAlgorithms; |
32 | 28 |
import com.vividsolutions.jts.geom.Coordinate; |
33 | 29 |
import com.vividsolutions.jts.geom.CoordinateArrays; |
... | ... | |
40 | 36 |
import com.vividsolutions.jts.geom.Polygon; |
41 | 37 |
import com.vividsolutions.jts.geomgraph.DirectedEdge; |
42 | 38 |
import com.vividsolutions.jts.geomgraph.Node; |
43 |
|
|
39 |
import java.util.ArrayList; |
|
40 |
import java.util.Arrays; |
|
41 |
import java.util.Iterator; |
|
42 |
import java.util.List; |
|
44 | 43 |
import org.gvsig.fmap.geom.Geometry; |
45 | 44 |
import org.gvsig.fmap.geom.GeometryLocator; |
46 | 45 |
import org.gvsig.fmap.geom.GeometryManager; |
... | ... | |
93 | 92 |
* @author Mauricio Pazos, Axios Engineering |
94 | 93 |
* @since 1.1.0 |
95 | 94 |
*/ |
95 |
@Override |
|
96 | 96 |
public Geometry split(Geometry geometryToBeSplitted, Geometry splitter) |
97 | 97 |
throws GeometryOperationNotSupportedException, |
98 | 98 |
GeometryOperationException { |
... | ... | |
133 | 133 |
|
134 | 134 |
final GeometryFactory gf = jtsMultiPoligon.getFactory(); |
135 | 135 |
com.vividsolutions.jts.geom.Geometry result; |
136 |
List<com.vividsolutions.jts.geom.Geometry> splittedGeometries = new ArrayList<com.vividsolutions.jts.geom.Geometry>();
|
|
136 |
List<com.vividsolutions.jts.geom.Geometry> splittedGeometries = new ArrayList<>(); |
|
137 | 137 |
for (int i = 0; i < jtsMultiPoligon.getNumGeometries(); i++) { |
138 | 138 |
com.vividsolutions.jts.geom.Geometry jtsGeom = jtsMultiPoligon.getGeometryN(i); |
139 | 139 |
com.vividsolutions.jts.geom.Geometry splittedGeometry; |
... | ... | |
155 | 155 |
result = splittedGeometries.get(0); |
156 | 156 |
} else { |
157 | 157 |
Polygon[] array = |
158 |
splittedGeometries.toArray(new Polygon[splittedGeometries |
|
159 |
.size()]); |
|
158 |
splittedGeometries.toArray(new Polygon[splittedGeometries.size()]); |
|
160 | 159 |
result = gf.createMultiPolygon(array); |
161 | 160 |
} |
162 | 161 |
return result; |
... | ... | |
199 | 198 |
*/ |
200 | 199 |
private List<LinearRing> findUnsplittedHoles(SplitGraph graph, |
201 | 200 |
GeometryFactory gf) { |
202 |
final List<LinearRing> unsplittedHoles = new ArrayList<LinearRing>(2);
|
|
201 |
final List<LinearRing> unsplittedHoles = new ArrayList<>(2); |
|
203 | 202 |
|
204 |
final List<SplitEdge> edges = new ArrayList<SplitEdge>();
|
|
203 |
final List<SplitEdge> edges = new ArrayList<>(); |
|
205 | 204 |
for (Iterator it = graph.getEdgeIterator(); it.hasNext();) { |
206 | 205 |
SplitEdge edge = (SplitEdge) it.next(); |
207 | 206 |
edges.add(edge); |
208 | 207 |
} |
209 | 208 |
|
210 |
for (Iterator it = edges.iterator(); it.hasNext();) { |
|
211 |
SplitEdge edge = (SplitEdge) it.next(); |
|
209 |
for (SplitEdge edge : edges) { |
|
212 | 210 |
if (edge.isHoleEdge()) { |
213 | 211 |
Coordinate[] coordinates = edge.getCoordinates(); |
214 | 212 |
Coordinate start = coordinates[0]; |
... | ... | |
231 | 229 |
* @return |
232 | 230 |
*/ |
233 | 231 |
private List<List<SplitEdge>> findRings(SplitGraph graph) { |
234 |
final List<List<SplitEdge>> rings = new ArrayList<List<SplitEdge>>();
|
|
232 |
final List<List<SplitEdge>> rings = new ArrayList<>(); |
|
235 | 233 |
|
236 | 234 |
DirectedEdge startEdge; |
237 | 235 |
// build each ring starting with the first edge belonging to the |
... | ... | |
272 | 270 |
|
273 | 271 |
private List<SplitEdge> buildRing(final SplitGraph graph, |
274 | 272 |
final DirectedEdge startEdge) { |
275 |
final List<SplitEdge> ring = new ArrayList<SplitEdge>();
|
|
273 |
final List<SplitEdge> ring = new ArrayList<>(); |
|
276 | 274 |
|
277 | 275 |
// follow this tessellation direction while possible, |
278 | 276 |
// switch to the opposite when not, and continue with |
... | ... | |
336 | 334 |
private List<Polygon> buildSimplePolygons(List<List<SplitEdge>> allRings, |
337 | 335 |
List<LinearRing> unsplittedHoles, GeometryFactory gf) { |
338 | 336 |
|
339 |
List<Polygon> polygons = new ArrayList<Polygon>(allRings.size());
|
|
337 |
List<Polygon> polygons = new ArrayList<>(allRings.size()); |
|
340 | 338 |
|
341 | 339 |
for (List<SplitEdge> edgeList : allRings) { |
342 | 340 |
Polygon poly = buildPolygon(edgeList, gf); |
343 | 341 |
List<LinearRing> thisPolyHoles = |
344 |
new ArrayList<LinearRing>(unsplittedHoles.size());
|
|
342 |
new ArrayList<>(unsplittedHoles.size()); |
|
345 | 343 |
for (LinearRing holeRing : unsplittedHoles) { |
346 | 344 |
if (poly.covers(holeRing)) { |
347 | 345 |
thisPolyHoles.add(holeRing); |
... | ... | |
365 | 363 |
} |
366 | 364 |
|
367 | 365 |
private Polygon buildPolygon(List<SplitEdge> edgeList, GeometryFactory gf) { |
368 |
List<Coordinate> coords = new ArrayList<Coordinate>();
|
|
366 |
List<Coordinate> coords = new ArrayList<>(); |
|
369 | 367 |
Coordinate[] lastCoordinates = null; |
370 | 368 |
for (SplitEdge edge : edgeList) { |
371 | 369 |
Coordinate[] coordinates = edge.getCoordinates(); |
... | ... | |
379 | 377 |
} |
380 | 378 |
} |
381 | 379 |
lastCoordinates = coordinates; |
382 |
for (int i = 0; i < coordinates.length; i++) { |
|
383 |
Coordinate coord = coordinates[i]; |
|
384 |
coords.add(coord); |
|
385 |
} |
|
380 |
coords.addAll(Arrays.asList(coordinates)); |
|
386 | 381 |
} |
387 | 382 |
Coordinate[] shellCoords = new Coordinate[coords.size()]; |
388 | 383 |
coords.toArray(shellCoords); |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.split/src/main/java/org/gvsig/vectorediting/lib/prov/split/operation/splitsurface/SplitEdgeStar.java | ||
---|---|---|
43 | 43 |
*/ |
44 | 44 |
package org.gvsig.vectorediting.lib.prov.split.operation.splitsurface; |
45 | 45 |
|
46 |
import java.util.ArrayList; |
|
47 |
import java.util.Iterator; |
|
48 |
import java.util.List; |
|
49 |
|
|
50 | 46 |
import com.vividsolutions.jts.algorithm.Angle; |
51 | 47 |
import com.vividsolutions.jts.algorithm.CGAlgorithms; |
52 | 48 |
import com.vividsolutions.jts.geom.Coordinate; |
... | ... | |
54 | 50 |
import com.vividsolutions.jts.geomgraph.DirectedEdgeStar; |
55 | 51 |
import com.vividsolutions.jts.geomgraph.EdgeEnd; |
56 | 52 |
import com.vividsolutions.jts.util.Assert; |
53 |
import java.util.ArrayList; |
|
54 |
import java.util.Iterator; |
|
55 |
import java.util.List; |
|
57 | 56 |
|
58 | 57 |
/** |
59 | 58 |
* A {@link DirectedEdgeStar} for the {@link SplitGraphNode nodes} in a {@link SplitGraph} |
... | ... | |
218 | 217 |
return angle; |
219 | 218 |
} |
220 | 219 |
|
220 |
@Override |
|
221 | 221 |
public String toString() { |
222 |
StringBuffer sb = new StringBuffer("SplitEdgeStar[degree: ");
|
|
222 |
StringBuilder sb = new StringBuilder("SplitEdgeStar[degree: ");
|
|
223 | 223 |
sb.append(getDegree()).append(", edges: "); |
224 | 224 |
for( Iterator it = getEdges().iterator(); it.hasNext(); ) { |
225 | 225 |
DirectedEdge de = (DirectedEdge) it.next(); |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.split/src/main/java/org/gvsig/vectorediting/lib/prov/split/operation/splitsurface/SplitGraphNodeFactory.java | ||
---|---|---|
58 | 58 |
*/ |
59 | 59 |
class SplitGraphNodeFactory extends NodeFactory { |
60 | 60 |
|
61 |
@Override |
|
61 | 62 |
public Node createNode( Coordinate coord ) { |
62 | 63 |
return new SplitGraphNode(coord, new SplitEdgeStar()); |
63 | 64 |
} |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.split/src/main/java/org/gvsig/vectorediting/lib/prov/split/operation/splitsurface/SplitGraph.java | ||
---|---|---|
43 | 43 |
*/ |
44 | 44 |
package org.gvsig.vectorediting.lib.prov.split.operation.splitsurface; |
45 | 45 |
|
46 |
import java.util.ArrayList; |
|
47 |
import java.util.List; |
|
48 |
|
|
49 |
import org.slf4j.LoggerFactory; |
|
50 |
|
|
51 | 46 |
import com.vividsolutions.jts.geom.Coordinate; |
52 | 47 |
import com.vividsolutions.jts.geom.CoordinateArrays; |
53 | 48 |
import com.vividsolutions.jts.geom.Geometry; |
... | ... | |
63 | 58 |
import com.vividsolutions.jts.geomgraph.PlanarGraph; |
64 | 59 |
import com.vividsolutions.jts.geomgraph.Position; |
65 | 60 |
import com.vividsolutions.jts.geomgraph.Quadrant; |
61 |
import java.util.ArrayList; |
|
62 |
import java.util.List; |
|
63 |
import org.slf4j.LoggerFactory; |
|
66 | 64 |
|
67 | 65 |
/** |
68 | 66 |
* A {@link PlanarGraph} that builds itself from a {@link Polygon} and a |
... | ... | |
70 | 68 |
* <p> |
71 | 69 |
* The resulting graph will have the following characteristics: |
72 | 70 |
* <ul> |
73 |
* <li>It will contain as many edges as linestrings in the boundary of the intersection geometry |
|
74 |
* between the polygon and the splitting line string. |
|
75 |
* <li>All edges will be labelled {@link Location#BOUNDARY} at {@link Position#ON}</li> |
|
76 |
* <li>The edges from the polygon's exterior ring will be labelled {@link Location#EXTERIOR} at the |
|
77 |
* {@link Position#LEFT}, {@link Location#INTERIOR} at {@link Position#RIGHT}</li> |
|
78 |
* <li>The edges from the polygon's holes will be labelled {@link Location#INTERIOR} at the |
|
79 |
* {@link Position#LEFT}, {@link Location#EXTERIOR} at {@link Position#RIGHT}</li> |
|
71 |
* <li>It will contain as many edges as linestrings in the boundary of the |
|
72 |
* intersection geometry between the polygon and the splitting line string. |
|
73 |
* <li>All edges will be labelled {@link Location#BOUNDARY} at |
|
74 |
* {@link Position#ON}</li> |
|
75 |
* <li>The edges from the polygon's exterior ring will be labelled |
|
76 |
* {@link Location#EXTERIOR} at the |
|
77 |
* {@link Position#LEFT}, {@link Location#INTERIOR} at |
|
78 |
* {@link Position#RIGHT}</li> |
|
79 |
* <li>The edges from the polygon's holes will be labelled |
|
80 |
* {@link Location#INTERIOR} at the |
|
81 |
* {@link Position#LEFT}, {@link Location#EXTERIOR} at |
|
82 |
* {@link Position#RIGHT}</li> |
|
80 | 83 |
* </ul> |
81 | 84 |
* <p> |
82 |
* Note the provided polygon may result modified as the result of {@link Polygon#normalize()}, |
|
83 |
* which is called in order to ensure propper orientation of the shell and holes. |
|
85 |
* Note the provided polygon may result modified as the result of |
|
86 |
* {@link Polygon#normalize()}, which is called in order to ensure propper |
|
87 |
* orientation of the shell and holes. |
|
84 | 88 |
* </p> |
85 | 89 |
* </p> |
86 | 90 |
* |
... | ... | |
92 | 96 |
|
93 | 97 |
private static final NodeFactory NODE_FACTORY = new SplitGraphNodeFactory(); |
94 | 98 |
|
95 |
private final Polygon polygon;
|
|
99 |
private final Polygon polygon; |
|
96 | 100 |
|
97 |
private final LineString splitter;
|
|
101 |
private final LineString splitter; |
|
98 | 102 |
|
99 |
public SplitGraph( Polygon polygon, LineString splitter ) {
|
|
103 |
public SplitGraph(Polygon polygon, LineString splitter) {
|
|
100 | 104 |
super(NODE_FACTORY); |
101 | 105 |
this.polygon = polygon; |
102 | 106 |
// after normalize() we know the shell is oriented CW and the holes CCW |
... | ... | |
106 | 110 |
buildGraph(); |
107 | 111 |
} |
108 | 112 |
|
109 |
private LineString normalizeSplitter( final LineString original ) {
|
|
113 |
private LineString normalizeSplitter(final LineString original) {
|
|
110 | 114 |
// ensure the splitter has no endpoints lying inside the polygon |
111 |
LineString splitter = removeInteriorEndPoints(polygon, original);
|
|
115 |
LineString normalizedSplitter = removeInteriorEndPoints(polygon, original);
|
|
112 | 116 |
// endure the splitter is directed clockwise, as its going |
113 | 117 |
// to become part of the shell boundary when the tesselation |
114 | 118 |
// process eliminates other shell edges from the graph |
115 |
Coordinate[] splitterCoords = splitter.getCoordinates();
|
|
119 |
Coordinate[] splitterCoords = normalizedSplitter.getCoordinates();
|
|
116 | 120 |
Coordinate coord0 = splitterCoords[0]; |
117 | 121 |
Coordinate coord1 = splitterCoords[1]; |
118 | 122 |
|
... | ... | |
126 | 130 |
if (isCounterClockWise) { |
127 | 131 |
CoordinateArrays.reverse(splitterCoords); |
128 | 132 |
GeometryFactory gf = original.getFactory(); |
129 |
splitter = gf.createLineString(splitterCoords);
|
|
133 |
normalizedSplitter = gf.createLineString(splitterCoords);
|
|
130 | 134 |
} |
131 |
return splitter;
|
|
135 |
return normalizedSplitter;
|
|
132 | 136 |
} |
133 | 137 |
|
134 | 138 |
/** |
135 |
* Removes the given edge and its related {@link DirectedEdge}'s from this graph |
|
139 |
* Removes the given edge and its related {@link DirectedEdge}'s from this |
|
140 |
* graph |
|
136 | 141 |
* |
137 | 142 |
* @param edge the edge to remove |
138 |
* @throws IllegalArgumentException if no enclosing DirectedEdge is found for <code>edge</code> |
|
143 |
* @throws IllegalArgumentException if no enclosing DirectedEdge is found |
|
144 |
* for <code>edge</code> |
|
139 | 145 |
* @see #remove(DirectedEdge) |
140 | 146 |
*/ |
141 |
public void remove( final SplitEdge edge ) {
|
|
147 |
public void remove(final SplitEdge edge) {
|
|
142 | 148 |
DirectedEdge edgeEnd = (DirectedEdge) findEdgeEnd(edge); |
143 | 149 |
if (edgeEnd == null) { |
144 | 150 |
throw new IllegalArgumentException("No enclosing edge end found for " + edge); |
... | ... | |
147 | 153 |
} |
148 | 154 |
|
149 | 155 |
/** |
150 |
* Removes a DirectedEdge, its sym and its {@link SplitEdge} from this graph. May lead to the
|
|
151 |
* graph containing dangling nodes. |
|
156 |
* Removes a DirectedEdge, its sym and its {@link SplitEdge} from this |
|
157 |
* graph. May lead to the graph containing dangling nodes.
|
|
152 | 158 |
* |
153 | 159 |
* @param edgeEnd |
154 | 160 |
*/ |
155 |
public void remove( final DirectedEdge edgeEnd ) {
|
|
161 |
public void remove(final DirectedEdge edgeEnd) {
|
|
156 | 162 |
if (edgeEnd == null) { |
157 | 163 |
throw new NullPointerException(); |
158 | 164 |
} |
... | ... | |
174 | 180 |
} |
175 | 181 |
|
176 | 182 |
/** |
177 |
* Builds a linestrnig from splitter such that it contains no endpoints lying inside the polygon |
|
183 |
* Builds a linestrnig from splitter such that it contains no endpoints |
|
184 |
* lying inside the polygon |
|
178 | 185 |
* |
179 | 186 |
* @param polygon |
180 | 187 |
* @param splitter |
181 | 188 |
* @return |
182 | 189 |
*/ |
183 |
private LineString removeInteriorEndPoints( Polygon polygon, LineString splitter ) {
|
|
190 |
private LineString removeInteriorEndPoints(Polygon polygon, LineString splitter) {
|
|
184 | 191 |
final Coordinate[] coords = splitter.getCoordinates(); |
185 | 192 |
final GeometryFactory gf = splitter.getFactory(); |
186 | 193 |
int useFrom; |
187 | 194 |
int useTo; |
188 | 195 |
|
189 |
for( useFrom = 0; useFrom < coords.length; useFrom++ ) {
|
|
196 |
for (useFrom = 0; useFrom < coords.length; useFrom++) {
|
|
190 | 197 |
Point p = gf.createPoint(coords[useFrom]); |
191 | 198 |
if (!polygon.contains(p)) { |
192 | 199 |
break; |
193 | 200 |
} |
194 | 201 |
} |
195 |
for( useTo = coords.length - 1; useTo >= useFrom; useTo-- ) {
|
|
202 |
for (useTo = coords.length - 1; useTo >= useFrom; useTo--) {
|
|
196 | 203 |
Point p = gf.createPoint(coords[useTo]); |
197 | 204 |
if (!polygon.contains(p)) { |
198 | 205 |
break; |
... | ... | |
237 | 244 |
Geometry nodedShell = polygon.getExteriorRing().difference(splitter); |
238 | 245 |
|
239 | 246 |
LineString[] interiorRings = new LineString[polygon.getNumInteriorRing()]; |
240 |
for( int i = 0; i < polygon.getNumInteriorRing(); i++ ) {
|
|
247 |
for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
|
|
241 | 248 |
LineString interiorRingN = polygon.getInteriorRingN(i); |
242 | 249 |
interiorRings[i] = interiorRingN; |
243 | 250 |
} |
... | ... | |
256 | 263 |
addEdges(intersectingLineStrings, Location.BOUNDARY, Location.INTERIOR, Location.INTERIOR); |
257 | 264 |
} |
258 | 265 |
|
259 |
private void addEdges( Geometry linearGeom, int onLoc, int leftLoc, int rightLoc ) {
|
|
266 |
private void addEdges(Geometry linearGeom, int onLoc, int leftLoc, int rightLoc) {
|
|
260 | 267 |
final int nParts = linearGeom.getNumGeometries(); |
261 | 268 |
Geometry currGeom; |
262 | 269 |
Coordinate[] coords; |
263 |
List edges = new ArrayList(); |
|
264 |
for( int i = 0; i < nParts; i++ ) {
|
|
270 |
List edgesToAdd = new ArrayList();
|
|
271 |
for (int i = 0; i < nParts; i++) {
|
|
265 | 272 |
currGeom = linearGeom.getGeometryN(i); |
266 | 273 |
coords = currGeom.getCoordinates(); |
267 |
if (coords.length<2) |
|
268 |
continue; |
|
274 |
if (coords.length < 2) { |
|
275 |
continue; |
|
276 |
} |
|
269 | 277 |
Label label = new Label(onLoc, leftLoc, rightLoc); |
270 | 278 |
Edge edge = new SplitEdge(coords, label); |
271 |
edges.add(edge); |
|
279 |
edgesToAdd.add(edge);
|
|
272 | 280 |
} |
273 | 281 |
// for each edge in the list, adds two DirectedEdge, one reflecting |
274 | 282 |
// the given edge and other the opposite |
275 |
try{ |
|
276 |
super.addEdges(edges);
|
|
277 |
}catch (Exception e) { |
|
278 |
LoggerFactory.getLogger(this.getClass()).error(e.getLocalizedMessage(),e);
|
|
279 |
}
|
|
283 |
try {
|
|
284 |
super.addEdges(edgesToAdd);
|
|
285 |
} catch (Exception e) {
|
|
286 |
LoggerFactory.getLogger(this.getClass()).error(e.getLocalizedMessage(), e);
|
|
287 |
}
|
|
280 | 288 |
} |
281 | 289 |
|
282 | 290 |
} |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.split/src/main/java/org/gvsig/vectorediting/lib/prov/split/operation/splitsurface/SplitEdge.java | ||
---|---|---|
64 | 64 |
|
65 | 65 |
private int[] getLabelLocations() { |
66 | 66 |
int[] locations = new int[3]; |
67 |
Label label = getLabel();
|
|
68 |
locations[Position.ON] = label.getLocation(0, Position.ON);
|
|
69 |
locations[Position.LEFT] = label.getLocation(0, Position.LEFT);
|
|
70 |
locations[Position.RIGHT] = label.getLocation(0, Position.RIGHT);
|
|
67 |
Label lbl = getLabel();
|
|
68 |
locations[Position.ON] = lbl.getLocation(0, Position.ON);
|
|
69 |
locations[Position.LEFT] = lbl.getLocation(0, Position.LEFT);
|
|
70 |
locations[Position.RIGHT] = lbl.getLocation(0, Position.RIGHT);
|
|
71 | 71 |
return locations; |
72 | 72 |
} |
73 | 73 |
|
... | ... | |
86 | 86 |
return (loc[Position.LEFT] == Location.INTERIOR && loc[Position.RIGHT] == Location.INTERIOR); |
87 | 87 |
} |
88 | 88 |
|
89 |
@Override |
|
89 | 90 |
public String toString() { |
90 |
StringBuffer sb = new StringBuffer("Edge[label=");
|
|
91 |
StringBuilder sb = new StringBuilder("Edge[label=");
|
|
91 | 92 |
sb.append(getLabel()).append(", "); |
92 | 93 |
Coordinate[] coords = getCoordinates(); |
93 |
for( int i = 0; i < coords.length; i++ ) {
|
|
94 |
sb.append(coords[i].x).append(",").append(coords[i].y).append(" ");
|
|
94 |
for (Coordinate coord : coords) {
|
|
95 |
sb.append(coord.x).append(",").append(coord.y).append(" ");
|
|
95 | 96 |
} |
96 | 97 |
sb.append("]"); |
97 | 98 |
return sb.toString(); |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.split/src/main/java/org/gvsig/vectorediting/lib/prov/split/operation/SplitOperation.java | ||
---|---|---|
37 | 37 |
public interface SplitOperation { |
38 | 38 |
|
39 | 39 |
/** |
40 |
* Splits the geometry by a other splitter geometry. If splitter does not
|
|
41 |
* intersect geometry return original geometry.
|
|
40 |
* Splits the geometry by a other splitter geometry.If splitter does not |
|
41 |
intersect geometry return original geometry. |
|
42 | 42 |
* |
43 | 43 |
* @param geometryToBeSplitted |
44 | 44 |
* to be splitted |
... | ... | |
46 | 46 |
* the geometry that splits other geometries |
47 | 47 |
* @return If splitter does not intersect return original geometry, else |
48 | 48 |
* return splitted geometry. |
49 |
* @throws org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException |
|
50 |
* @throws org.gvsig.fmap.geom.operation.GeometryOperationException |
|
51 |
* @throws org.gvsig.fmap.geom.exception.CreateGeometryException |
|
49 | 52 |
* @throws GeometryException |
50 | 53 |
*/ |
51 | 54 |
public Geometry split(Geometry geometryToBeSplitted, Geometry splitter) |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.split/src/main/java/org/gvsig/vectorediting/lib/prov/split/operation/SplitOperationUtils.java | ||
---|---|---|
26 | 26 |
|
27 | 27 |
import java.util.HashMap; |
28 | 28 |
import java.util.Map; |
29 |
|
|
30 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
31 | 29 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
30 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
32 | 31 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
33 | 32 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
34 | 33 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
... | ... | |
42 | 41 |
*/ |
43 | 42 |
public class SplitOperationUtils { |
44 | 43 |
|
45 |
private static Map<Integer, SplitOperation> operations = |
|
44 |
private static final Map<Integer, SplitOperation> operations =
|
|
46 | 45 |
new HashMap<Integer, SplitOperation>(); |
47 | 46 |
|
48 | 47 |
private SplitOperationUtils() { |
... | ... | |
71 | 70 |
// FIXME: Deletes method when geometry manager has this utility method. |
72 | 71 |
public static Point createPoint(double x, double y, int subtype) |
73 | 72 |
throws CreateGeometryException { |
74 |
Point point = null; |
|
75 |
point = |
|
76 |
(Point) GeometryLocator.getGeometryManager().create(TYPES.POINT, |
|
77 |
subtype); |
|
73 |
Point point = (Point) GeometryLocator.getGeometryManager().create(TYPES.POINT, subtype); |
|
78 | 74 |
point.setX(x); |
79 | 75 |
point.setY(y); |
80 | 76 |
return point; |
... | ... | |
286 | 282 |
} |
287 | 283 |
|
288 | 284 |
/** |
289 |
* Method use to know what segment intersect with projected point. Due to
|
|
290 |
* accuracy of doubles it is necessary to create a buffer of line to know if
|
|
291 |
* it intersects.
|
|
285 |
* Method use to know what segment intersect with projected point.Due to |
|
286 |
accuracy of doubles it is necessary to create a buffer of line to know if |
|
287 |
it intersects. |
|
292 | 288 |
* |
293 | 289 |
* @param curve |
294 | 290 |
* segment of line |
295 | 291 |
* @param projectedPoint |
296 | 292 |
* of line |
297 | 293 |
* @return true if segment intersects with projected point, else false. |
294 |
* @throws org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException |
|
295 |
* @throws org.gvsig.fmap.geom.operation.GeometryOperationException |
|
298 | 296 |
*/ |
299 | 297 |
public static boolean intersects(Curve curve, Point projectedPoint) |
300 | 298 |
throws GeometryOperationNotSupportedException, |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.split/src/main/java/org/gvsig/vectorediting/lib/prov/split/SplitEditingProviderFactory.java | ||
---|---|---|
25 | 25 |
package org.gvsig.vectorediting.lib.prov.split; |
26 | 26 |
|
27 | 27 |
import org.gvsig.fmap.geom.Geometry; |
28 |
import org.gvsig.tools.ToolsLocator; |
|
29 |
import org.gvsig.tools.dynobject.DynClass; |
|
30 | 28 |
import org.gvsig.tools.dynobject.DynObject; |
31 |
import org.gvsig.tools.service.spi.AbstractProviderFactory; |
|
32 | 29 |
import org.gvsig.tools.service.spi.Provider; |
33 | 30 |
import org.gvsig.tools.service.spi.ProviderServices; |
34 | 31 |
import org.gvsig.vectorediting.lib.api.EditingServiceInfo; |
32 |
import org.gvsig.vectorediting.lib.spi.AbstractEditingProviderFactory; |
|
35 | 33 |
import org.gvsig.vectorediting.lib.spi.DefaultEditingServiceinfo; |
36 |
import org.gvsig.vectorediting.lib.spi.EditingProviderFactory; |
|
37 | 34 |
|
38 | 35 |
/** |
39 | 36 |
* @author llmarques |
40 | 37 |
* |
41 | 38 |
*/ |
42 |
public class SplitEditingProviderFactory extends AbstractProviderFactory |
|
43 |
implements EditingProviderFactory { |
|
39 |
public class SplitEditingProviderFactory extends AbstractEditingProviderFactory { |
|
44 | 40 |
|
45 | 41 |
public final static String PROVIDER_NAME = "modify-split"; |
46 | 42 |
|
47 | 43 |
public final static String PROVIDER_DESCRIPTION = |
48 | 44 |
"Splits geometries through line"; |
49 | 45 |
|
50 |
public void initialize() { |
|
46 |
public SplitEditingProviderFactory() { |
|
47 |
super(PROVIDER_NAME, PROVIDER_DESCRIPTION); |
|
51 | 48 |
} |
52 | 49 |
|
50 |
@Override |
|
53 | 51 |
public EditingServiceInfo getServiceInfo() { |
54 | 52 |
EditingServiceInfo serviceInfo = |
55 | 53 |
new DefaultEditingServiceinfo(PROVIDER_NAME, "", false, null, |
... | ... | |
68 | 66 |
return new SplitEditingProvider(services, parameters); |
69 | 67 |
} |
70 | 68 |
|
71 |
@Override |
|
72 |
protected DynClass createParametersDynClass() { |
|
73 |
DynClass dynclass = |
|
74 |
ToolsLocator.getDynObjectManager().createDynClass(PROVIDER_NAME, |
|
75 |
PROVIDER_DESCRIPTION); |
|
76 |
|
|
77 |
dynclass.addDynFieldString(PROVIDER_NAME_FIELD); |
|
78 |
dynclass.addDynFieldObject(FEATURE_STORE_FIELD); |
|
79 |
dynclass.addDynFieldObject(MAPCONTEXT_FIELD); |
|
80 |
|
|
81 |
return dynclass; |
|
82 |
} |
|
83 |
|
|
84 |
@Override |
|
85 |
public DynObject createParameters() { |
|
86 |
DynObject parameters = super.createParameters(); |
|
87 |
parameters.setDynValue(PROVIDER_NAME_FIELD, PROVIDER_NAME); |
|
88 |
return parameters; |
|
89 |
} |
|
90 | 69 |
} |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.split/src/main/java/org/gvsig/vectorediting/lib/prov/split/SplitEditingProvider.java | ||
---|---|---|
28 | 28 |
import java.util.HashMap; |
29 | 29 |
import java.util.List; |
30 | 30 |
import java.util.Map; |
31 |
|
|
32 | 31 |
import org.gvsig.fmap.dal.exception.DataException; |
33 | 32 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
34 | 33 |
import org.gvsig.fmap.dal.feature.Feature; |
... | ... | |
49 | 48 |
import org.gvsig.fmap.geom.type.GeometryType; |
50 | 49 |
import org.gvsig.tools.ToolsLocator; |
51 | 50 |
import org.gvsig.tools.dispose.DisposableIterator; |
51 |
import org.gvsig.tools.dispose.DisposeUtils; |
|
52 | 52 |
import org.gvsig.tools.dynobject.DynObject; |
53 | 53 |
import org.gvsig.tools.exception.BaseException; |
54 | 54 |
import org.gvsig.tools.service.spi.ProviderServices; |
55 |
import org.gvsig.tools.visitor.VisitCanceledException; |
|
56 |
import org.gvsig.tools.visitor.Visitor; |
|
57 | 55 |
import org.gvsig.vectorediting.lib.api.DrawingStatus; |
58 | 56 |
import org.gvsig.vectorediting.lib.api.EditingServiceParameter; |
59 | 57 |
import org.gvsig.vectorediting.lib.api.exceptions.DrawServiceException; |
... | ... | |
77 | 75 |
public class SplitEditingProvider extends AbstractEditingProvider implements |
78 | 76 |
EditingProvider { |
79 | 77 |
|
80 |
private EditingServiceParameter selection; |
|
78 |
private final EditingServiceParameter selection;
|
|
81 | 79 |
|
82 |
private EditingServiceParameter splitGeometry; |
|
80 |
private final EditingServiceParameter splitGeometry;
|
|
83 | 81 |
|
84 |
private FeatureStore featureStore; |
|
82 |
private final FeatureStore featureStore;
|
|
85 | 83 |
|
86 | 84 |
private Map<EditingServiceParameter, Object> values; |
87 | 85 |
|
88 | 86 |
/** |
89 | 87 |
* Default constructor. |
90 | 88 |
* |
91 |
* @param providerServices
|
|
89 |
* @param services
|
|
92 | 90 |
* available services for this provider |
93 | 91 |
* @param parameters |
94 | 92 |
* of this provider |
... | ... | |
110 | 108 |
EditingServiceParameter.TYPE.GEOMETRY); |
111 | 109 |
} |
112 | 110 |
|
111 |
@Override |
|
113 | 112 |
public EditingServiceParameter next() { |
114 | 113 |
if (values.get(selection) == null) { |
115 | 114 |
return selection; |
... | ... | |
119 | 118 |
return null; |
120 | 119 |
} |
121 | 120 |
|
121 |
@Override |
|
122 | 122 |
public DrawingStatus getDrawingStatus(Point mousePosition) |
123 | 123 |
throws DrawServiceException { |
124 | 124 |
return null; |
125 | 125 |
} |
126 | 126 |
|
127 |
@Override |
|
127 | 128 |
public void stop() throws StopServiceException { |
128 | 129 |
if (values != null) { |
129 | 130 |
values.clear(); |
130 | 131 |
} |
131 | 132 |
} |
132 | 133 |
|
134 |
@Override |
|
133 | 135 |
public List<EditingServiceParameter> getParameters() { |
134 | 136 |
List<EditingServiceParameter> parameters = |
135 |
new ArrayList<EditingServiceParameter>();
|
|
137 |
new ArrayList<>(); |
|
136 | 138 |
parameters.add(selection); |
137 | 139 |
parameters.add(splitGeometry); |
138 | 140 |
return parameters; |
... | ... | |
143 | 145 |
validateAndInsertValue(parameter, value); |
144 | 146 |
} |
145 | 147 |
|
148 |
@Override |
|
146 | 149 |
public void setValue(Object value) throws InvalidEntryException { |
147 | 150 |
EditingServiceParameter parameter = next(); |
148 | 151 |
validateAndInsertValue(parameter, value); |
... | ... | |
158 | 161 |
FeatureSelection featureSelection = (FeatureSelection) value; |
159 | 162 |
|
160 | 163 |
try { |
161 |
featureSelection.accept(new Visitor() { |
|
162 |
|
|
163 |
public void visit(Object obj) |
|
164 |
throws VisitCanceledException, BaseException { |
|
165 |
Feature feature = (Feature) obj; |
|
166 |
Geometry geometry = feature.getDefaultGeometry(); |
|
167 |
GeometryType geoType = geometry.getGeometryType(); |
|
168 |
|
|
169 |
if (geoType.isTypeOf(POINT) |
|
164 |
featureSelection.accept((Object obj) -> { |
|
165 |
Feature feature = (Feature) obj; |
|
166 |
Geometry geometry = feature.getDefaultGeometry(); |
|
167 |
GeometryType geoType = geometry.getGeometryType(); |
|
168 |
|
|
169 |
if (geoType.isTypeOf(POINT) |
|
170 | 170 |
|| geoType.isTypeOf(MULTIPOINT)) { |
171 |
throw new InvalidEntryException(null); |
|
172 |
} |
|
171 |
throw new InvalidEntryException(null); |
|
173 | 172 |
} |
174 | 173 |
}); |
175 | 174 |
|
... | ... | |
208 | 207 |
(FeatureSelection) values.get(selection); |
209 | 208 |
|
210 | 209 |
try { |
211 |
featureSelection.accept(new Visitor() { |
|
212 |
|
|
213 |
public void visit(Object obj) throws VisitCanceledException, |
|
214 |
BaseException { |
|
215 |
Feature feature = (Feature) obj; |
|
216 |
Geometry geometry = feature.getDefaultGeometry(); |
|
217 |
|
|
218 |
Geometry intersection = geometry.intersection(curve); |
|
219 |
|
|
220 |
if (intersection == null |
|
210 |
featureSelection.accept((Object obj) -> { |
|
211 |
Feature feature = (Feature) obj; |
|
212 |
Geometry geometry = feature.getDefaultGeometry(); |
|
213 |
|
|
214 |
Geometry intersection = geometry.intersection(curve); |
|
215 |
|
|
216 |
if (intersection == null |
|
221 | 217 |
|| (!intersection.getGeometryType().isTypeOf(POINT) |
222 | 218 |
&& !intersection.getGeometryType().isTypeOf(MULTIPOINT) |
223 | 219 |
&& !intersection.getGeometryType().isTypeOf(CURVE) |
224 | 220 |
&& !intersection.getGeometryType().isTypeOf(MULTICURVE))) { |
225 |
throw new VectorEditingException(); |
|
226 |
} |
|
221 |
throw new VectorEditingException(); |
|
227 | 222 |
} |
228 | 223 |
}); |
229 | 224 |
return true; |
... | ... | |
232 | 227 |
} |
233 | 228 |
} |
234 | 229 |
|
230 |
@Override |
|
235 | 231 |
public Geometry finish() throws FinishServiceException { |
236 | 232 |
return null; |
237 | 233 |
} |
238 | 234 |
|
235 |
@Override |
|
239 | 236 |
public void finishAndStore() throws FinishServiceException { |
240 | 237 |
|
241 | 238 |
if (values != null) { |
... | ... | |
336 | 333 |
} catch (BaseException e) { |
337 | 334 |
throw new FinishServiceException(e); |
338 | 335 |
} finally { |
339 |
it.dispose();
|
|
340 |
featureSelection.dispose();
|
|
336 |
DisposeUtils.disposeQuietly(it);
|
|
337 |
DisposeUtils.disposeQuietly(featureSelection);
|
|
341 | 338 |
} |
342 | 339 |
} |
343 | 340 |
} |
... | ... | |
366 | 363 |
return null; |
367 | 364 |
} |
368 | 365 |
|
366 |
@Override |
|
369 | 367 |
public void start() throws StartServiceException, InvalidEntryException { |
370 |
values = new HashMap<EditingServiceParameter, Object>(); |
|
368 |
values = new HashMap<>(); |
Also available in: Unified diff