예제 #1
0
 public Point locate() {
   LineConnection line = ownerConnection();
   int segment = Math.min(fSegment, line.pointCount() - 2);
   Point p1 = line.pointAt(segment);
   Point p2 = line.pointAt(segment + 1);
   return new Point((p1.x + p2.x) / 2, (p1.y + p2.y) / 2);
 }
예제 #2
0
  public void invokeStep(int x, int y, int anchorX, int anchorY, DrawingView view) {
    LineConnection line = ownerConnection();
    Point p1 = line.pointAt(fSegment);
    Point p2 = line.pointAt(fSegment + 1);
    int ddx = x - fLastX;
    int ddy = y - fLastY;

    Point np1;
    Point np2;
    if (isVertical(p1, p2)) {
      int cx = constrainX(p1.x + ddx);
      np1 = new Point(cx, p1.y);
      np2 = new Point(cx, p2.y);
    } else {
      int cy = constrainY(p1.y + ddy);
      np1 = new Point(p1.x, cy);
      np2 = new Point(p2.x, cy);
    }
    line.setPointAt(np1, fSegment);
    line.setPointAt(np2, fSegment + 1);
    fLastX = x;
    fLastY = y;
  }