コード例 #1
0
ファイル: RectangleTool.java プロジェクト: ta-apps/GpsPrune
 @Override
 protected void handlePress(MouseEvent e) {
   super.handlePress(e);
   DrawingItem item = getItem();
   DragHandle handle = getHandle();
   if (handle != null && item != null) {
     int index = (Integer) handle.getData();
     Double p = item.getPoints().get(Math.abs(index - 1)); // opposite is the anchor
     anchor = new Double(p.getX(), p.getY());
   }
 }
コード例 #2
0
ファイル: RectangleTool.java プロジェクト: ta-apps/GpsPrune
    @Override
    protected void handleDrag(MouseEvent e) {
      DragHandle handle = getHandle();
      DrawingItem item = getItem();
      if (anchor != null && handle != null && handle.getType() == DragHandle.TYPE_POINT) {

        Double p1 = item.getPoints().get(0);
        Double p2 = item.getPoints().get(1);
        Double p3 = getMapPoint(getInverslyRotatedPoint(e));

        if (p3.x < anchor.x) p1.x = p3.x;
        else if (p3.x > anchor.x) p2.x = p3.x;

        if (p3.y > anchor.y) p2.y = p3.y;
        else if (p3.y < anchor.y) p1.y = p3.y;

        item.setPoints(Arrays.asList(new Point2D.Double[] {p1, p2}));
      }
    }