[fix] clicking away from points now longer causes an exception
This commit is contained in:
parent
80c0fa8568
commit
fc43b19db0
@ -215,7 +215,8 @@ public class FreeformFinSet extends FinSet {
|
|||||||
y0 = Double.NaN;
|
y0 = Double.NaN;
|
||||||
x1 = points.get(1).x;
|
x1 = points.get(1).x;
|
||||||
y1 = points.get(1).y;
|
y1 = points.get(1).y;
|
||||||
|
// } else if ( (0 > index) || (points.size() <= index) ){
|
||||||
|
// throw new IllegalFinPointException("Point Index not available!");
|
||||||
} else if (index == points.size() - 1) {
|
} else if (index == points.size() - 1) {
|
||||||
|
|
||||||
// Restrict point
|
// Restrict point
|
||||||
|
@ -381,13 +381,15 @@ public class FreeformFinSetConfig extends FinSetConfig {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pointIndex = getPoint(event);
|
final int pointIndex = getPoint(event);
|
||||||
|
|
||||||
if ( pointIndex >= 0) {
|
if ( pointIndex >= 0) {
|
||||||
dragIndex = pointIndex;
|
dragIndex = pointIndex;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int segmentIndex = getSegment(event);
|
final int segmentIndex = getSegment(event);
|
||||||
|
System.err.println(String.format(".... finpoint//segmentIndex: %d", segmentIndex));
|
||||||
if (segmentIndex >= 0) {
|
if (segmentIndex >= 0) {
|
||||||
Point2D.Double point = getCoordinates(event);
|
Point2D.Double point = getCoordinates(event);
|
||||||
finset.addPoint(segmentIndex );
|
finset.addPoint(segmentIndex );
|
||||||
@ -396,6 +398,8 @@ public class FreeformFinSetConfig extends FinSetConfig {
|
|||||||
finset.setPoint(dragIndex, point.x, point.y);
|
finset.setPoint(dragIndex, point.x, point.y);
|
||||||
} catch (IllegalFinPointException ignore) {
|
} catch (IllegalFinPointException ignore) {
|
||||||
// no-op
|
// no-op
|
||||||
|
} catch (ArrayIndexOutOfBoundsException ex) {
|
||||||
|
log.error("bad index while editing fin points!!", ex);
|
||||||
}
|
}
|
||||||
dragIndex = segmentIndex;
|
dragIndex = segmentIndex;
|
||||||
|
|
||||||
|
@ -274,10 +274,10 @@ public class FinPointFigure extends AbstractScaleFigure {
|
|||||||
|
|
||||||
double x0 = p.x;
|
double x0 = p.x;
|
||||||
double y0 = p.y;
|
double y0 = p.y;
|
||||||
double delta = BOX_WIDTH_PIXELS /*/ scale*/;
|
double delta = BOX_WIDTH_PIXELS / scale;
|
||||||
|
|
||||||
//System.out.println("Point: " + x0 + "," + y0);
|
//System.err.println(String.format("__Point: x=%.4f, y=%.4f", x0, y0));
|
||||||
//System.out.println("delta: " + (BOX_SIZE / scale));
|
//System.err.println(String.format("__delta: %.4f", BOX_WIDTH_PIXELS / scale));
|
||||||
|
|
||||||
Coordinate[] points = finset.getFinPoints();
|
Coordinate[] points = finset.getFinPoints();
|
||||||
for (int i = 1; i < points.length; i++) {
|
for (int i = 1; i < points.length; i++) {
|
||||||
@ -286,11 +286,13 @@ public class FinPointFigure extends AbstractScaleFigure {
|
|||||||
double x2 = points[i].x;
|
double x2 = points[i].x;
|
||||||
double y2 = points[i].y;
|
double y2 = points[i].y;
|
||||||
|
|
||||||
// System.out.println("point1:"+x1+","+y1+" point2:"+x2+","+y2);
|
//System.out.println("point1:"+x1+","+y1+" point2:"+x2+","+y2);
|
||||||
|
|
||||||
double u = Math.abs((x2 - x1) * (y1 - y0) - (x1 - x0) * (y2 - y1)) /
|
double u = Math.abs((x2 - x1) * (y1 - y0) - (x1 - x0) * (y2 - y1)) /
|
||||||
MathUtil.hypot(x2 - x1, y2 - y1);
|
MathUtil.hypot(x2 - x1, y2 - y1);
|
||||||
//System.out.println("Distance of segment " + i + " is " + u);
|
|
||||||
|
//System.err.println("Distance of segment " + i + " is " + u);
|
||||||
|
|
||||||
if (u < delta)
|
if (u < delta)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user