queue.clearDragging();
// add circle obstacle
double xDiff = Math.abs(e.getX() - dragStart.getX());
double yDiff = Math.abs(e.getY() - dragStart.getY());
int radius = (int) Math.round(Math.hypot(xDiff, yDiff));
CircleObstacle obstacle = new CircleObstacle(
(int) Math.round(dragStart.getX()),
(int) Math.round(dragStart.getY()), radius);
queue.addPersistent(obstacle.drawObject());
obstacles.add(obstacle);
break;
}
default: {
// add rectangle obstacle
queue.clearDragging();
// add rectangle obstacle
RectangleObstacle obstacle = new RectangleObstacle(
(int) Math.round(dragStart.getX()),
(int) Math.round(dragStart.getY()), (int) Math.round(e
.getX() - dragStart.getX()), (int) Math.round(e
.getY() - dragStart.getY()));
queue.addPersistent(obstacle.drawObject());
obstacles.add(obstacle);
break;
}
}
}