double distSquare = Line2D.ptSegDistSq(v[e[i].source].x, v[e[i].source].y, v[e[i].target].x, v[e[i].target].y, v[j].x, v[j].y);
double distSquare = Line2D.ptSegDistSq(v[e[i].source].x, v[e[i].source].y, v[e[i].target].x, v[e[i].target].y, v[j].x, v[j].y);
for (int j = 0; j < edges.length; j++) { double distSquare = Line2D.ptSegDistSq(v[e[edges[j]].source].x, v[e[edges[j]].source].y, v[e[edges[j]].target].x, v[e[edges[j]].target].y, v[i].x, v[i].y);
double distSquare = Line2D.ptSegDistSq(v[e[i].source].x, v[e[i].source].y, v[e[i].target].x, v[e[i].target].y, v[j].x, v[j].y);
double distSquare = Line2D.ptSegDistSq(v[e[edges[j]].source].x, v[e[edges[j]].source].y, v[e[edges[j]].target].x, v[e[edges[j]].target].y, v[i].x, v[i].y);
double distSquare = Line2D.ptSegDistSq(v[e[edges[j]].source].x, v[e[edges[j]].source].y, v[e[edges[j]].target].x, v[e[edges[j]].target].y, v[i].x, v[i].y);
/** * Report the minimum square distance from a point to a rectangle. * * @param r provided rectangle * @param x abscissa of point * @param y ordinate of point * @return square of minimum distance */ public static double ptDistanceSq (Rectangle r, double x, double y) { if (r.contains(x, y)) { return 0; } double d = Double.MAX_VALUE; final int x1 = r.x; final int x2 = (r.x + r.width) - 1; final int y1 = r.y; final int y2 = (r.y + r.height) - 1; d = Math.min(d, Line2D.ptSegDistSq(x1, y1, x2, y1, x, y)); d = Math.min(d, Line2D.ptSegDistSq(x1, y2, x2, y2, x, y)); d = Math.min(d, Line2D.ptSegDistSq(x1, y1, x1, y2, x, y)); d = Math.min(d, Line2D.ptSegDistSq(x2, y1, x2, y2, x, y)); return d; }
/** * Returns whether a specified local location is a part of the connection widget. It checks whether the location is * close to the control-points-based path (up to 4px from the line), * close to the anchors (defined by AnchorShape) or * close to the control points (PointShape). * @param localLocation the local locaytion * @return true, if the location is a part of the connection widget */ public boolean isHitAt (Point localLocation) { if (! super.isHitAt (localLocation)) return false; List<Point> controlPoints = getControlPoints (); for (int i = 0; i < controlPoints.size () - 1; i++) { Point point1 = controlPoints.get (i); Point point2 = controlPoints.get (i + 1); double dist = Line2D.ptSegDistSq (point1.x, point1.y, point2.x, point2.y, localLocation.x, localLocation.y); if (dist < HIT_DISTANCE_SQUARE) return true; } return getControlPointHitAt (localLocation) >= 0; }
/** * Returns whether a specified local location is a part of the connection widget. It checks whether the location is * close to the control-points-based path (up to 4px from the line), * close to the anchors (defined by AnchorShape) or * close to the control points (PointShape). * @param localLocation the local locaytion * @return true, if the location is a part of the connection widget */ public boolean isHitAt (Point localLocation) { if (! super.isHitAt (localLocation)) return false; List<Point> controlPoints = getControlPoints (); for (int i = 0; i < controlPoints.size () - 1; i++) { Point point1 = controlPoints.get (i); Point point2 = controlPoints.get (i + 1); double dist = Line2D.ptSegDistSq (point1.x, point1.y, point2.x, point2.y, localLocation.x, localLocation.y); if (dist < HIT_DISTANCE_SQUARE) return true; } return getControlPointHitAt (localLocation) >= 0; }
double minDist = line.ptSegDistSq(p); double dist = line.ptSegDistSq(p);
int i = 0; for (Line2D l : lines) { double d = l.ptSegDistSq(pos); if (d < minDistSq) { minDistSq = d;
double x3 = X.doubleValue(i) * ratio; double y3 = Y.doubleValue(i); final double dsq = Line2D.ptSegDistSq(x1, y1, x3, y3, x2, y2); if (dsq <= yTolerance) {
mxPoint pe = edgeState.getAbsolutePoint(1); Line2D line = new Line2D.Double(p0.getPoint(), pe.getPoint()); double minDist = line.ptSegDistSq(x, y); double dist = line.ptSegDistSq(x, y);
mxPoint pe = edgeState.getAbsolutePoint(1); Line2D line = new Line2D.Double(p0.getPoint(), pe.getPoint()); double minDist = line.ptSegDistSq(x, y); double dist = line.ptSegDistSq(x, y);
for (int i = 0; i < newpoints.size() - 1; ++i) double d2 = Line2D.ptSegDistSq(newpoints.get(i).getX(), newpoints.get(i).getY(), newpoints.get(i + 1).getX(), newpoints.get(i + 1).getY(), mxp.getX(), mxp.getY()); if (dist2 > d2)