01: package net.refractions.udig.tools.edit.support;
02:
03: import com.vividsolutions.jts.geom.Coordinate;
04:
05: /**
06: * Describes the relationship between an arbitrary point to an edge in a {@link EditGeom}
07: *
08: * @author jones
09: * @since 1.1.0
10: */
11: public class ClosestEdge {
12: final double distanceToEdge;
13: final Point pointOnLine;
14: final int indexOfPrevious;
15: final EditGeom shape;
16: final PrimitiveShape part;
17: Coordinate addedCoord;
18:
19: public ClosestEdge(double distanceToEdge, int indexOfPrevious,
20: Point pointOnLine, PrimitiveShape part) {
21: this .distanceToEdge = distanceToEdge;
22: this .indexOfPrevious = indexOfPrevious;
23: this .pointOnLine = pointOnLine;
24: this .shape = part.getEditGeom();
25: this .part = part;
26: this .addedCoord = part.getEditBlackboard().toCoord(pointOnLine);
27: }
28:
29: /**
30: * @return Returns the distanceToEdge.
31: */
32: public double getDistanceToEdge() {
33: return distanceToEdge;
34: }
35:
36: /**
37: * @return Returns the indexOfPrevious.
38: */
39: public int getIndexOfPrevious() {
40: return indexOfPrevious;
41: }
42:
43: /**
44: * @return Returns the part.
45: */
46: public PrimitiveShape getPart() {
47: return part;
48: }
49:
50: /**
51: * @return Returns the pointOnLine.
52: */
53: public Point getPointOnLine() {
54: return pointOnLine;
55: }
56:
57: /**
58: * @return Returns the coordinate the will/has been added.
59: */
60: public Coordinate getAddedCoord() {
61: return addedCoord;
62: }
63:
64: /**
65: * @return Returns the shape.
66: */
67: public EditGeom getGeom() {
68: return shape;
69: }
70:
71: @Override
72: public String toString() {
73: StringBuffer buffer = new StringBuffer();
74: buffer.append("distance:"); //$NON-NLS-1$
75: buffer.append(distanceToEdge);
76: buffer.append(", point:"); //$NON-NLS-1$
77: buffer.append(pointOnLine);
78: buffer.append(", previous:"); //$NON-NLS-1$
79: buffer.append(indexOfPrevious);
80:
81: return buffer.toString();
82: }
83: }
|