Skip to content

Commit

Permalink
GH-232 fix regression dragging line and ink annotation outside of pag…
Browse files Browse the repository at this point in the history
…e bounds.
  • Loading branch information
Patrick Corless committed May 11, 2023
1 parent fb8eaf1 commit 3e187e3
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -561,14 +561,23 @@ public void setBounds(int x, int y, int width, int height) {
protected Rectangle limitAnnotationPosition(int x, int y, int width, int height) {
Rectangle currentBounds = new Rectangle(x, y, width, height);
Rectangle pageBounds = pageViewComponent.getBounds();
// todo fix dx/dy offset as they are only need by line and ink which should be reworked.
if (!pageBounds.contains(currentBounds)) {
currentBounds.x = Math.max(currentBounds.x, pageBounds.x);
currentBounds.y = Math.max(currentBounds.y, pageBounds.y);
if (currentBounds.x < pageBounds.x){
currentBounds.x = pageBounds.x;
dx = 0;
}
if (currentBounds.y < pageBounds.y){
currentBounds.y = pageBounds.y;
dy = 0;
}
if (currentBounds.x + currentBounds.width > pageBounds.width) {
currentBounds.x = pageBounds.width - currentBounds.width;
dx = 0;
}
if (currentBounds.y + currentBounds.height > pageBounds.height) {
currentBounds.y = pageBounds.height - currentBounds.height;
dy = 0;
}
return currentBounds;
}
Expand Down

0 comments on commit 3e187e3

Please sign in to comment.