gvsig-vectorediting / org.gvsig.vectorediting / trunk / org.gvsig.vectorediting / org.gvsig.vectorediting.lib / org.gvsig.vectorediting.lib.prov / org.gvsig.vectorediting.lib.prov.stretch / src / main / java / org / gvsig / vectorediting / lib / prov / stretch / operation / LineStretchOperation.java @ 320
History | View | Annotate | Download (2.01 KB)
1 |
package org.gvsig.vectorediting.lib.prov.stretch.operation; |
---|---|
2 |
|
3 |
import java.awt.geom.AffineTransform; |
4 |
import java.util.ArrayList; |
5 |
import java.util.List; |
6 |
|
7 |
import org.gvsig.fmap.geom.Geometry; |
8 |
import org.gvsig.fmap.geom.GeometryLocator; |
9 |
import org.gvsig.fmap.geom.GeometryManager; |
10 |
import org.gvsig.fmap.geom.aggregate.MultiSurface; |
11 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
12 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
13 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
14 |
import org.gvsig.fmap.geom.primitive.Line; |
15 |
import org.gvsig.fmap.geom.primitive.OrientablePrimitive; |
16 |
import org.gvsig.fmap.geom.primitive.Point; |
17 |
import org.gvsig.fmap.geom.primitive.Primitive; |
18 |
|
19 |
|
20 |
public class LineStretchOperation implements StretchOperation{ |
21 |
|
22 |
public LineStretchOperation() {
|
23 |
// TODO Auto-generated constructor stub
|
24 |
} |
25 |
|
26 |
public Geometry transform(AffineTransform at, Primitive geom, Geometry roi) |
27 |
throws GeometryOperationNotSupportedException,
|
28 |
GeometryOperationException { |
29 |
OrientablePrimitive primitive = (OrientablePrimitive)(geom.cloneGeometry()); |
30 |
for (int j = 0; j < primitive.getNumVertices(); j++) { |
31 |
Point point = primitive.getVertex(j);
|
32 |
if (roi.intersects(point) || roi.contains(point)) {
|
33 |
point.transform(at); |
34 |
StretchOperationUtils.setVertex(primitive, j, point); |
35 |
|
36 |
} |
37 |
} |
38 |
return primitive;
|
39 |
} |
40 |
|
41 |
public List<Point> getSelectedVertex(Primitive geom, Geometry roi) |
42 |
throws GeometryOperationNotSupportedException, GeometryOperationException, CreateGeometryException {
|
43 |
OrientablePrimitive primitive = (OrientablePrimitive)(geom.cloneGeometry()); |
44 |
List<Point> vertexList = new ArrayList<Point>(); |
45 |
for (int j = 0; j < primitive.getNumVertices(); j++) { |
46 |
Point point = primitive.getVertex(j);
|
47 |
if (roi.intersects(point) || roi.contains(point)) {
|
48 |
vertexList.add(point); |
49 |
} |
50 |
} |
51 |
return vertexList;
|
52 |
} |
53 |
} |