Revision 91 org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/src/main/java/org/gvsig/vectorediting/app/mainplugin/BaseEditingServiceExtension.java
BaseEditingServiceExtension.java | ||
---|---|---|
10 | 10 |
import org.gvsig.andami.plugins.Extension; |
11 | 11 |
import org.gvsig.app.project.documents.view.ViewDocument; |
12 | 12 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
13 |
import org.gvsig.fmap.geom.Geometry; |
|
14 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
15 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
16 |
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException; |
|
17 |
import org.gvsig.fmap.geom.type.GeometryTypeNotValidException; |
|
18 | 13 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
19 | 14 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
20 | 15 |
import org.gvsig.vectorediting.lib.api.EditingLocator; |
... | ... | |
65 | 60 |
return null; |
66 | 61 |
} |
67 | 62 |
|
68 |
private boolean isApplicable(GeometryType[] supportedTypes, GeometryType geometryType) { |
|
69 |
if (supportedTypes != null) { |
|
70 |
for (int i = 0; i < supportedTypes.length; i++) { |
|
71 |
if (supportedTypes[i].isTypeOf(geometryType)) { |
|
72 |
return true; |
|
73 |
} |
|
74 |
} |
|
75 |
} |
|
76 |
return false; |
|
77 |
} |
|
78 |
|
|
79 |
protected boolean isApplicable(GeometryType[] supportedTypes, int shapeType) { |
|
80 |
GeometryType type = loadGeometryType(shapeType, Geometry.SUBTYPES.GEOM2D); |
|
81 |
return isApplicable(supportedTypes, type); |
|
82 |
} |
|
83 |
|
|
84 |
protected GeometryType[] loadGeometryTypes(int[] types) { |
|
85 |
GeometryType[] supportedTypes = null; |
|
86 |
if (types == null) { |
|
87 |
supportedTypes = new GeometryType[0]; |
|
88 |
} |
|
89 |
else { |
|
90 |
supportedTypes = new GeometryType[types.length]; |
|
91 |
for (int i = 0; i < types.length; i++) { |
|
92 |
supportedTypes[i] = loadGeometryType(types[i], Geometry.SUBTYPES.GEOM2D); |
|
93 |
} |
|
94 |
} |
|
95 |
return supportedTypes; |
|
96 |
} |
|
97 |
|
|
98 |
private GeometryType loadGeometryType(int type, int subtype) { |
|
99 |
try { |
|
100 |
return GeometryLocator.getGeometryManager() |
|
101 |
.getGeometryType(type, subtype); |
|
102 |
} |
|
103 |
catch (GeometryTypeNotSupportedException e) { |
|
104 |
throw new RuntimeException("Error getting the Geometry type with type = " |
|
105 |
+ type + ", subtype = " + subtype, e); |
|
106 |
} |
|
107 |
catch (GeometryTypeNotValidException e) { |
|
108 |
throw new RuntimeException("Error getting the Geometry type with type = " |
|
109 |
+ type + ", subtype = " + subtype, e); |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 | 63 |
} |
Also available in: Unified diff