Revision 5878 trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/InternalPolygonCADTool.java
InternalPolygonCADTool.java | ||
---|---|---|
51 | 51 |
import com.iver.andami.PluginServices; |
52 | 52 |
import com.iver.cit.gvsig.CADExtension; |
53 | 53 |
import com.iver.cit.gvsig.fmap.core.DefaultFeature; |
54 |
import com.iver.cit.gvsig.fmap.core.FGeometryCollection; |
|
54 | 55 |
import com.iver.cit.gvsig.fmap.core.FShape; |
55 | 56 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
56 | 57 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
... | ... | |
190 | 191 |
IFeature feat = (IFeature) row.getLinkedRow().cloneRow(); |
191 | 192 |
|
192 | 193 |
IGeometry geometry=feat.getGeometry(); |
193 |
geometry=createNewPolygon(geometry,(Point2D[])points.toArray(new Point2D[0])); |
|
194 |
if (geometry instanceof FGeometryCollection) { |
|
195 |
FGeometryCollection gc=(FGeometryCollection)geometry; |
|
196 |
geometry=createNewPolygonGC(gc,(Point2D[])points.toArray(new Point2D[0])); |
|
197 |
}else { |
|
198 |
geometry=createNewPolygon(geometry,(Point2D[])points.toArray(new Point2D[0])); |
|
199 |
} |
|
194 | 200 |
DefaultFeature df=new DefaultFeature(geometry,feat.getAttributes(), feat.getID()); |
195 | 201 |
DefaultRowEdited dre=new DefaultRowEdited(df,DefaultRowEdited.STATUS_MODIFIED,row.getIndex()); |
196 | 202 |
try { |
... | ... | |
260 | 266 |
newGp.lineTo(ps[ps.length-1].getX(),ps[ps.length-1].getY()); |
261 | 267 |
return ShapeFactory.createPolygon2D(newGp); |
262 | 268 |
} |
269 |
private IGeometry createNewPolygonGC(FGeometryCollection gp,Point2D[] ps) { |
|
270 |
ArrayList geoms=new ArrayList(); |
|
271 |
IGeometry[] geometries=gp.getGeometries(); |
|
272 |
for (int i = 0;i<geometries.length;i++) { |
|
273 |
geoms.add(geometries[i]); |
|
274 |
} |
|
275 |
GeneralPathX gpx=new GeneralPathX(); |
|
276 |
gpx.moveTo(ps[ps.length-1].getX(),ps[ps.length-1].getY()); |
|
277 |
for (int i=ps.length-2;i>=0;i--){ |
|
278 |
gpx.lineTo(ps[i].getX(),ps[i].getY()); |
|
279 |
geoms.add(ShapeFactory.createPolyline2D(gpx)); |
|
280 |
gpx=new GeneralPathX(); |
|
281 |
gpx.moveTo(ps[i].getX(),ps[i].getY()); |
|
282 |
} |
|
283 |
gpx.lineTo(ps[ps.length-1].getX(),ps[ps.length-1].getY()); |
|
284 |
geoms.add(ShapeFactory.createPolyline2D(gpx)); |
|
285 |
FGeometryCollection gc=new FGeometryCollection((IGeometry[])geoms.toArray(new IGeometry[0])); |
|
286 |
gc.setGeometryType(FShape.POLYGON); |
|
287 |
return gc; |
|
288 |
} |
|
263 | 289 |
public String getName() { |
264 | 290 |
return PluginServices.getText(this,"internal_polygon_"); |
265 | 291 |
} |
Also available in: Unified diff