Revision 10450 branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/rules/RulePolygon.java
RulePolygon.java | ||
---|---|---|
42 | 42 |
|
43 | 43 |
import com.iver.cit.gvsig.fmap.core.FCircle2D; |
44 | 44 |
import com.iver.cit.gvsig.fmap.core.FEllipse2D; |
45 |
import com.iver.cit.gvsig.fmap.core.FGeometry; |
|
46 | 45 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
47 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
48 | 46 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
49 | 47 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
50 | 48 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
51 | 49 |
import com.iver.cit.gvsig.fmap.core.IRow; |
52 | 50 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
53 | 51 |
import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
54 |
import com.vividsolutions.jts.geom.Geometry;
|
|
52 |
import com.iver.cit.gvsig.fmap.edition.EditionEvent;
|
|
55 | 53 |
|
56 | 54 |
/** |
57 | 55 |
* @author fjp |
... | ... | |
61 | 59 |
*/ |
62 | 60 |
public class RulePolygon extends AbstractRule { |
63 | 61 |
|
64 |
public boolean validate(IRow row) { |
|
65 |
IFeature feat = (IFeature) row; |
|
62 |
public boolean validate(IRow row,int sourceType) { |
|
63 |
if (sourceType==EditionEvent.ALPHANUMERIC) |
|
64 |
return true; |
|
65 |
IFeature feat = (IFeature) row; |
|
66 | 66 |
IGeometry geom = feat.getGeometry(); |
67 | 67 |
if ((geom.getInternalShape() instanceof FCircle2D) |
68 | 68 |
|| (geom.getInternalShape() instanceof FEllipse2D)) { |
... | ... | |
70 | 70 |
} |
71 | 71 |
GeneralPathX gp = new GeneralPathX(); |
72 | 72 |
gp.append(geom.getPathIterator(null, FConverter.FLATNESS), true); |
73 |
|
|
73 |
|
|
74 | 74 |
if (gp.isClosed()) |
75 | 75 |
{ |
76 |
boolean bCCW =gp.isCCW();
|
|
76 |
boolean bCCW =gp.isCCW(); |
|
77 | 77 |
System.out.println("Counter ClockWise = " + bCCW); |
78 | 78 |
if (bCCW) |
79 | 79 |
{ |
... | ... | |
82 | 82 |
// IGeometry aux = ShapeFactory.createPolygon2D(gp); |
83 | 83 |
// Geometry jtsGeom = aux.toJTSGeometry(); |
84 | 84 |
// geom = FConverter.jts_to_igeometry(jtsGeom); |
85 |
|
|
85 |
|
|
86 | 86 |
geom = ShapeFactory.createPolygon2D(gp); |
87 |
}
|
|
87 |
} |
|
88 | 88 |
else |
89 | 89 |
{ |
90 | 90 |
geom = ShapeFactory.createPolygon2D((FPolyline2D)geom.getInternalShape()); |
91 | 91 |
} |
92 | 92 |
// IGeometry aux = ShapeFactory.createPolygon2D(gp); |
93 |
//
|
|
94 |
Geometry jtsGeom = geom.toJTSGeometry(); |
|
95 |
System.err.println(jtsGeom.toText()); |
|
96 |
//
|
|
93 |
// |
|
94 |
// Geometry jtsGeom = geom.toJTSGeometry();
|
|
95 |
// System.err.println(jtsGeom.toText());
|
|
96 |
// |
|
97 | 97 |
// geom = FConverter.jts_to_igeometry(jtsGeom); |
98 |
|
|
98 |
|
|
99 | 99 |
// gp.ensureOrientation(false); // Poligono exterior. |
100 |
|
|
100 |
|
|
101 | 101 |
// Area area = new Area(geom); |
102 | 102 |
// GeneralPathX gp2 = new GeneralPathX(); |
103 |
// gp2.append(area.getPathIterator(null), true);
|
|
103 |
// gp2.append(area.getPathIterator(null), true); |
|
104 | 104 |
// geom = ShapeFactory.createPolygon2D(gp2); |
105 |
|
|
105 |
|
|
106 | 106 |
feat.setGeometry(geom); |
107 | 107 |
return true; |
108 | 108 |
} |
Also available in: Unified diff