rect.setBottomRight(p);
if (!rect.contains(newPos)) {
// Keep the item inside the scene rect.
newPos.setX(Math.min(rect.right(), Math.max(newPos.x(), rect
.left())));
newPos.setY(Math.min(rect.bottom(), Math.max(newPos.y(), rect
.top())));
}
long x = Math.round(newPos.x() / scene.tileSize)
* scene.tileSize;
long y = Math.round(newPos.y() / scene.tileSize)