diff --git a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java index 0ae21bf4d5..1cb3e6242a 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java +++ b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java @@ -408,11 +408,11 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous int currentWidth = currentRight - currentLeft; int currentHeight = currentBottom - currentTop; - int backupWidth= resizingBackupBounds[2]; - int backupHeight= resizingBackupBounds[3]; - if (cursorType == Cursor.NW_RESIZE_CURSOR || cursorType == Cursor.NE_RESIZE_CURSOR || cursorType == Cursor.SE_RESIZE_CURSOR || cursorType == Cursor.SW_RESIZE_CURSOR) { - if (aspectRatio) { + if (aspectRatio && resizingBackupBounds != null) { + int backupWidth= resizingBackupBounds[2]; + int backupHeight= resizingBackupBounds[3]; + double currentDiagonal = Math.pow(currentWidth, 2) + Math.pow(currentHeight, 2); double backupDiagonal = Math.pow(backupWidth, 2) + Math.pow(backupHeight, 2); @@ -452,7 +452,10 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous floatElement.setTopDistance(topDistance); floatElement.setHeight(FU.valueOfPix(currentBottom, resolution).subtract(floatY1_fu)); - if (aspectRatio) { + if (aspectRatio && resizingBackupBounds != null) { + int backupWidth= resizingBackupBounds[2]; + int backupHeight= resizingBackupBounds[3]; + currentWidth = backupWidth * currentHeight / backupHeight; currentRight = currentLeft + currentWidth; FU floatX1_fu = FU.valueOfPix(currentLeft, resolution); @@ -465,7 +468,10 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous floatElement.setLeftDistance(leftDistance); floatElement.setWidth(FU.valueOfPix(currentRight, resolution).subtract(floatX1_fu)); - if (aspectRatio) { + if (aspectRatio && resizingBackupBounds != null) { + int backupWidth= resizingBackupBounds[2]; + int backupHeight= resizingBackupBounds[3]; + currentHeight = backupHeight * currentWidth / backupWidth; currentBottom = currentTop + currentHeight; FU floatY1_fu = FU.valueOfPix(currentTop, resolution);