Browse Source

REPORT-55672 悬浮元素-新建模板第一次添加的悬浮元素不能移动位置

【问题原因】
resizingBackupBounds仅在拖拽改变尺寸,光标改变时初始化,所以导致拖拽移动时,出现NPE
【改动思路】
resizingBackupBounds只在等比例尺寸缩放拖拽改变尺寸时需要
final/10.0
Starryi 3 years ago
parent
commit
907cca3f83
  1. 14
      designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java

14
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 currentWidth = currentRight - currentLeft;
int currentHeight = currentBottom - currentTop; int currentHeight = currentBottom - currentTop;
if (cursorType == Cursor.NW_RESIZE_CURSOR || cursorType == Cursor.NE_RESIZE_CURSOR || cursorType == Cursor.SE_RESIZE_CURSOR || cursorType == Cursor.SW_RESIZE_CURSOR) {
if (aspectRatio && resizingBackupBounds != null) {
int backupWidth= resizingBackupBounds[2]; int backupWidth= resizingBackupBounds[2];
int backupHeight= resizingBackupBounds[3]; 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) {
double currentDiagonal = Math.pow(currentWidth, 2) + Math.pow(currentHeight, 2); double currentDiagonal = Math.pow(currentWidth, 2) + Math.pow(currentHeight, 2);
double backupDiagonal = Math.pow(backupWidth, 2) + Math.pow(backupHeight, 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.setTopDistance(topDistance);
floatElement.setHeight(FU.valueOfPix(currentBottom, resolution).subtract(floatY1_fu)); 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; currentWidth = backupWidth * currentHeight / backupHeight;
currentRight = currentLeft + currentWidth; currentRight = currentLeft + currentWidth;
FU floatX1_fu = FU.valueOfPix(currentLeft, resolution); FU floatX1_fu = FU.valueOfPix(currentLeft, resolution);
@ -465,7 +468,10 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
floatElement.setLeftDistance(leftDistance); floatElement.setLeftDistance(leftDistance);
floatElement.setWidth(FU.valueOfPix(currentRight, resolution).subtract(floatX1_fu)); 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; currentHeight = backupHeight * currentWidth / backupWidth;
currentBottom = currentTop + currentHeight; currentBottom = currentTop + currentHeight;
FU floatY1_fu = FU.valueOfPix(currentTop, resolution); FU floatY1_fu = FU.valueOfPix(currentTop, resolution);

Loading…
Cancel
Save