private PPath redrawArrows(double... curve) { double[] sub = subdivide(curve, ARROW_LENGTH); double x1 = sub[0]; double y1 = sub[1]; double x4 = sub[6]; double y4 = sub[7]; Point2D e = makeDistanceFromOrigin(x1 - x4, y1 - y4, ARROW_LENGTH); x1 = x4 + e.getX(); y1 = y4 + e.getY(); // arrow tails double m = (y4 - y1) / (x4 - x1); double at_x1 = x1 + m * ARROW_WIDTH / Math.sqrt(m * m + 1); double at_y1 = y1 - ARROW_WIDTH / Math.sqrt(m * m + 1); double at_x2 = x1 - m * ARROW_WIDTH / Math.sqrt(m * m + 1); double at_y2 = y1 + ARROW_WIDTH / Math.sqrt(m * m + 1); a1.reset(); a1.moveTo((float) at_x1, (float) at_y1); a1.lineTo((float) at_x2, (float) at_y2); a1.lineTo((float) x4, (float) y4); a1.lineTo((float) at_x1, (float) at_y1); return a1; }
private void redrawAll() { l1.setOffset(h1.getXOffset() + h1.getWidth() / 2, l1.getYOffset()); l2.setOffset(h2.getXOffset() + h2.getWidth() / 2, l2.getYOffset()); n1.setOffset(h1.getXOffset(), n1.getYOffset()); n2.setOffset(h2.getXOffset(), n2.getYOffset()); Point2D c1 = n1.getFullBounds().getCenter2D(); Point2D c2 = n2.getFullBounds().getCenter2D(); double dist = Math.abs(n2.getXOffset() - N - n1.getXOffset()); double t = dist < F ? dist / F : 1; Point2D t1 = translate(rotate(new Point2D.Double(R[0] * (1 - t), 0), -A[0]), c1); Point2D t2 = translate(rotate(new Point2D.Double(R[1], 0), -A[1]), clipX(c2, c1)); t2 = translate( makeDistanceFromOrigin( t2.getX() - c1.getX(), t2.getY() - c1.getY(), dist(t2, c1) * (1 - t)), c1); k1.centerBoundsOnPoint(t1.getX(), t1.getY()); k2.centerBoundsOnPoint(t2.getX(), t2.getY()); arc.reset(); arc.moveTo((float) c1.getX(), (float) c1.getY()); arc.curveTo( (float) t1.getX(), (float) t1.getY(), (float) t2.getX(), (float) t2.getY(), (float) c2.getX(), (float) c2.getY()); redrawArrows( c1.getX(), c1.getY(), t1.getX(), t1.getY(), t2.getX(), t2.getY(), c2.getX(), c2.getY()); }