Browse Source

REPORT-55121 【组件背景分离】组件复用-点九图填充设置弹窗的关闭按钮和取消按钮,其实还是确认&保存修改的效果

【问题原因】
1. BorderLineAndImagePane与TweakNinePointDialog共享了关于点九图位置的属性,拖拽改变点九分分割线的位置
就会直接改变BorderLineAndImagePane对应点九图字段的值
2. showWindow展示的对话框,其中的取消和关闭按钮总是会触发面板BorderLineAndImagePane的updatePane,从而将点九图的位置设置给了组件

需要将BorderLineAndImagePane与TweakNinePointDialog的数据做隔离,仅在点击确定按钮时
才将TweakNinePointDialog中已调整过的点九图分割线位置传递给BorderLineAndImagePane.

【改动思路】
【review建议】
feature/10.0
Starryi 3 years ago
parent
commit
716904551f
  1. 44
      designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java

44
designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java

@ -53,6 +53,7 @@ import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
/**
* @author Starryi
@ -79,10 +80,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
private NinePointImageTweakDialogPane tweakPane;
private ImageFileChooser imageFileChooser;
private int ninePointLeft = -1;
private int ninePointTop = -1;
private int ninePointRight = -1;
private int ninePointBottom = -1;
private int[] ninePoint = new int[] {-1, -1, -1, -1};
public BorderLineAndImagePane() {
this.initComponents();
@ -242,8 +240,9 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
@Override
public void stateChanged(ChangeEvent e) {
Image image = imagePreviewPane.getImage();
ninePointLeft = ninePointRight = (image != null ? image.getWidth(null) / 3 : -1);
ninePointTop = ninePointBottom = (image != null ? image.getHeight(null) / 3 : -1);
ninePoint = new int[4];
ninePoint[0] = ninePoint[2] = (image != null ? image.getWidth(null) / 3 : -1);
ninePoint[1] = ninePoint[3] = (image != null ? image.getHeight(null) / 3 : -1);
borderImageOpacityPane.populateBean(1.0);
if (image != null) {
tweakNinePointButton.setEnabled(true);
@ -260,10 +259,12 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
initNinePointTweakPaneIfNotExist();
if (imagePreviewPane.getImage() != null) {
tweakPane.previewPane.setNinePoint(ninePoint);
BasicDialog dialog = tweakPane.showWindow(SwingUtilities.getWindowAncestor(BorderLineAndImagePane.this));
dialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
ninePoint = Arrays.copyOf(tweakPane.previewPane.getNinePoint(), 4);
fireStateChanged();
}
});
@ -292,13 +293,11 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
this.tweakNinePointButton.setEnabled(true);
this.borderImageOpacityPane.populateBean(style.getBorderImageOpacity());
if (ninePoint != null && ninePoint.length == 4 && ninePoint[0] > 0 && ninePoint[1] > 0 && ninePoint[2] > 0 && ninePoint[3] > 0) {
ninePointLeft = ninePoint[0];
ninePointTop = ninePoint[1];
ninePointRight = ninePoint[2];
ninePointBottom = ninePoint[3];
this.ninePoint = Arrays.copyOf(ninePoint, 4);
} else {
ninePointLeft = ninePointRight = image.getWidth(null) / 3;
ninePointTop = ninePointBottom = image.getHeight(null) / 3;
this.ninePoint = new int[4];
this.ninePoint[0] = this.ninePoint[2] = image.getWidth(null) / 3;
this.ninePoint[1] = this.ninePoint[3] = image.getHeight(null) / 3;
}
getComponent(1).setVisible(false);
@ -331,7 +330,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
Image image = this.imagePreviewPane.getImage();
if (image != null) {
ImageBackground newImageBackground = new ImageFileBackground(this.imagePreviewPane.getImageWithSuffix(), Constants.IMAGE_EXTEND);
newImageBackground.setNinePoint(new int[] { ninePointLeft, ninePointTop, ninePointRight, ninePointBottom });
newImageBackground.setNinePoint(Arrays.copyOf(ninePoint, 4));
style.setBorderImage(newImageBackground);
style.setBorderImageOpacity((float)borderImageOpacityPane.updateBean());
}
@ -408,7 +407,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
}
private class NinePointImageTweakDialogPane extends BasicPane {
private final NinePointLinePreviewPane previewPane = new NinePointLinePreviewPane();
public final NinePointLinePreviewPane previewPane = new NinePointLinePreviewPane();
public NinePointImageTweakDialogPane() {
this.initComponents();
@ -444,6 +443,11 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
public final Color TEXT_COLOR = Color.WHITE;
public final int PADDING = 15;
private int ninePointLeft = -1;
private int ninePointTop = -1;
private int ninePointRight = -1;
private int ninePointBottom = -1;
private int imgWidth;
private int imgHeight;
private int scaleImgWidth;
@ -629,5 +633,17 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
public void mouseExited(MouseEvent e) {
}
public void setNinePoint(int[] ninePoint) {
ninePointLeft = ninePoint[0];
ninePointTop = ninePoint[1];
ninePointRight = ninePoint[2];
ninePointBottom = ninePoint[3];
}
public int[] getNinePoint() {
return new int[] { ninePointLeft, ninePointTop, ninePointRight, ninePointBottom };
}
}
}

Loading…
Cancel
Save