From d87bc58e7ac85dd1556b949ee7001fbc6a8b20ce Mon Sep 17 00:00:00 2001 From: Starryi Date: Mon, 19 Jul 2021 13:44:52 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-53175=20-=20=E3=80=9010.0.18?= =?UTF-8?q?=E3=80=91=E7=BB=84=E4=BB=B6=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB?= =?UTF-8?q?=E4=B8=BA=E6=A0=87=E9=A2=98/=E8=83=8C=E6=99=AF/=E8=BE=B9?= =?UTF-8?q?=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 点九图编辑交互改动优化 【改动思路】 --- .../images/control/icon_cursor_drag_e.png | Bin 0 -> 503 bytes .../images/control/icon_cursor_drag_n.png | Bin 0 -> 522 bytes .../images/control/icon_cursor_drag_ne.png | Bin 0 -> 523 bytes .../images/control/icon_cursor_drag_nw.png | Bin 0 -> 511 bytes .../images/control/icon_cursor_drag_s.png | Bin 0 -> 522 bytes .../images/control/icon_cursor_drag_se.png | Bin 0 -> 511 bytes .../images/control/icon_cursor_drag_sw.png | Bin 0 -> 523 bytes .../images/control/icon_cursor_drag_w.png | Bin 0 -> 503 bytes .../gui/xpane/BorderLineAndImagePane.java | 329 ++++++++++-------- 9 files changed, 182 insertions(+), 147 deletions(-) create mode 100644 designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_e.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_n.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_ne.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_nw.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_s.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_se.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_sw.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_w.png diff --git a/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_e.png b/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_e.png new file mode 100644 index 0000000000000000000000000000000000000000..650567ee917c0105d1f6039dc43848d96bd2fe72 GIT binary patch literal 503 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1|*Mc$*~4fEa{HEjtmSN`?>!lvI6-QsS%!O zzP=1vKsE;hV|yk83y{SK#8N=az`(SC2`(bGfEmFCN!q^@OaLm*@^onge z9S3A(WMt;wxOvmwzT!iIe!yO_69r-l&0lYC&)-~ATl@9<+uP|JLUZiv?Zhus&vwX3 zVla4dqhUsDWaQ0fcXk#}ZcMvo#K5^YdV8L1N=nKfW|JrO9LzWCXU>>WC)}O*%VEpf zwQp4uCg`yox4H5mPgYj;^!@$y#Z1kQ7EGReS#kxNLaTU0aZ%B$KR-S;Uq65T{g+jt ztNoapRmImaXYBYiS>6BJr%#{uHMbdVJh`@W_UzxmadGz)7c74DkWIxeY zgN#1Ln=aCOl8$!OI((Hpk(Rijk?Ti;#F7aS&8r)-nhkjlsWF6{=<}7CEuopU@uj?| cbc-SbgY&z8dh)@{aiGxmboFyt=akR{0Ld!ErvLx| literal 0 HcmV?d00001 diff --git a/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_n.png b/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_n.png new file mode 100644 index 0000000000000000000000000000000000000000..1085265c0d7c8a0700bd095d84fd12411b771b2d GIT binary patch literal 522 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1|*Mc$*~4fEa{HEjtmSN`?>!lvI6-QsS%!O zzP=1vKsE;hV|yk83y{SK#8N=az`(SC2`(bGfEmFCN!q^@OaLmb^>lFzu@Fp7P!Rg_ z|Nnf^4&KfXzd1$=8hhgR*UhbeeQj;C!#2UfT^#{mKR-X8r>?%dxTmM5KJVV1o#Gig zj0A6e(Ej=Rd%kB(%$>jmtNtsTId$sS+n1M@S2whEKfd1SF1EsQ-O80O8BRE)oH>2^ z_q(&R&8-_h)$G_}{AdzG)+eT2WxozKv%hb?a%R5${Op&PmL9AA_QsOu(dkpCHmzK> z>K}uVZKLBCVHGzK2B|Y0EtS{T$M2ut+4<5uU=6#c%<{t#1vi;WSWo;;U@+l0$Hw)? zeOj~D!38r6Tvn(UWEt2fxHmU_b8IwjX87Eqe4$E!jnRyQRc&o!k#B&VhWGbLvzG3( ztN*vhIX3n$BRl(Xbulrq35x$6bMo@u`D=%-yTiUkK_ZJWQzT&Vh11jZ%QtV{T+b%S zb-1#!vb~{5a>>lLWl|XpZ<^WpzZn@DH+yaPUsqSRyzc+M*#2cbHhLEd-gb-YzuUTX x>)tPqkN2;9GPB89{6c|t!p}Vd9>P;sGISar+gN()&H_+`c)I$ztaD0e0su_R)W!e+ literal 0 HcmV?d00001 diff --git a/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_ne.png b/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_ne.png new file mode 100644 index 0000000000000000000000000000000000000000..8f8163a6fe2055317cb0f1750492a629fa376133 GIT binary patch literal 523 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2comUKs7M+SzC{oH>NS%G|u)CkWs zUtb0-Ae)1Mu|1Q41;}CqVksbIU|?Fn1Q!upz>HvnB-ci7v<51!^K@|xu@GE4`JmTf z2Z6TDp0~bS;97WT@q@J)eDk;;9c}+0Yx7IaiRI+g*-nb?dqZ+Rva&4P(i+pU%$J+@ z?7<|J&i^d#T^I7W+0-`AocsUw%{OZT%qlkNXe+MeS^ekZN`Xa7PfIY!9FmK<{ zyv;Xjmf0~ZIJkVnAO25QukBU1vpsjW?{T+UhevA}8ZHZlUohd?7GiO5vP!3!1kXL6 z%QlDic3cxZP|Tv)@21?#{DQOCM(*<5TaRa)c|P^b^UqA`L9WwMWf#xV{&&-6`zdaf zc}dpdg);RLZGwxr?H`J#2vpv<^i}KQ{$u+YznTgpUv>Jw85AR)u6{1-oD!M-G2comUKs7M+SzC{oH>NS%G|u)CkWs zUtb0-Ae)1Mu|1Q41;}CqVksbIU|?Fn1Q!upz>HvnB-ci7v<50J@^oqjKrwu9x=~Uf6l{ znRw^@@L56&J>MTZy?gifyXE(*%LOxM&C~3<)TY0E->IWh1(Xi%xw7iSHumO&hbwH> zZH-#H<7UpXFMi8|-RCIePd75)RK30|b6@d{orx0i``+6d>L-V6TGYg|=Jl@{3z>7F zp?l9?<2%a5;C)Jc0*is{)69Sjxm$CdntORP2`vj@Xv#mmDUXw3V$(6Z^aqDH5^6U_ zys2_v?R&guQgfhN;Ifn^VRPFDCqo=2hlbqU*Ia*H!@K41xyHYXChaZj(BN^lYn1!lvI6-QsS%!O zzP=1vKsE;hV|yk83y{SK#8N=az`(SC2`(bGfEmFCN!q^@OaLmb^>lFzu@Fp7P!Rg_ z|Nnf^4&KfXzd1$=8hhgR*UhbeeQj;C!#2UfT^#{mKR-X8r>?%dxTmM5KJVV1o#Gig zj0A6e(Ej=Rd%kB(%$>jmtNtsTId$sS+n1M@S2whEKfd1SF1EsQ-O80O8BRE)oH>2^ z_q(&R&8-_h)$G_}{AdzG)+eT2WxozKv%hb?a%R5${Op&PmL9AA_QsOu(dkpCHmzK> z>K}uVZKLBCVHGzK2B|Y0EtS{T$M2ut+4<5uU=6#c%<{t#1vi;WSWo;;U@+l0$Hw)? zeOj~D!38r6Tvn(UWEt2fxHmU_b8IwjX87Eqe4$E!jnRyQRc&o!k#B&VhWGbLvzG3( ztN*vhIX3n$BRl(Xbulrq35x$6bMo@u`D=%-yTiUkK_ZJWQzT&Vh11jZ%QtV{T+b%S zb-1#!vb~{5a>>lLWl|XpZ<^WpzZn@DH+yaPUsqSRyzc+M*#2cbHhLEd-gb-YzuUTX x>)tPqkN2;9GPB89{6c|t!p}Vd9>P;sGISar+gN()&H_+`c)I$ztaD0e0su_R)W!e+ literal 0 HcmV?d00001 diff --git a/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_se.png b/designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_se.png new file mode 100644 index 0000000000000000000000000000000000000000..af33c873df87c3b398599062040f9db362e55163 GIT binary patch literal 511 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2comUKs7M+SzC{oH>NS%G|u)CkWs zUtb0-Ae)1Mu|1Q41;}CqVksbIU|?Fn1Q!upz>HvnB-ci7v<50J@^oqjKrwu9x=~Uf6l{ znRw^@@L56&J>MTZy?gifyXE(*%LOxM&C~3<)TY0E->IWh1(Xi%xw7iSHumO&hbwH> zZH-#H<7UpXFMi8|-RCIePd75)RK30|b6@d{orx0i``+6d>L-V6TGYg|=Jl@{3z>7F zp?l9?<2%a5;C)Jc0*is{)69Sjxm$CdntORP2`vj@Xv#mmDUXw3V$(6Z^aqDH5^6U_ zys2_v?R&guQgfhN;Ifn^VRPFDCqo=2hlbqU*Ia*H!@K41xyHYXChaZj(BN^lYn1-G2comUKs7M+SzC{oH>NS%G|u)CkWs zUtb0-Ae)1Mu|1Q41;}CqVksbIU|?Fn1Q!upz>HvnB-ci7v<51!^K@|xu@GE4`JmTf z2Z6TDp0~bS;97WT@q@J)eDk;;9c}+0Yx7IaiRI+g*-nb?dqZ+Rva&4P(i+pU%$J+@ z?7<|J&i^d#T^I7W+0-`AocsUw%{OZT%qlkNXe+MeS^ekZN`Xa7PfIY!9FmK<{ zyv;Xjmf0~ZIJkVnAO25QukBU1vpsjW?{T+UhevA}8ZHZlUohd?7GiO5vP!3!1kXL6 z%QlDic3cxZP|Tv)@21?#{DQOCM(*<5TaRa)c|P^b^UqA`L9WwMWf#xV{&&-6`zdaf zc}dpdg);RLZGwxr?H`J#2vpv<^i}KQ{$u+YznTgpUv>Jw85AR)u6{1-oD!M!lvI6-QsS%!O zzP=1vKsE;hV|yk83y{SK#8N=az`(SC2`(bGfEmFCN!q^@OaLm*@^onge z9S3A(WMt;wxOvmwzT!iIe!yO_69r-l&0lYC&)-~ATl@9<+uP|JLUZiv?Zhus&vwX3 zVla4dqhUsDWaQ0fcXk#}ZcMvo#K5^YdV8L1N=nKfW|JrO9LzWCXU>>WC)}O*%VEpf zwQp4uCg`yox4H5mPgYj;^!@$y#Z1kQ7EGReS#kxNLaTU0aZ%B$KR-S;Uq65T{g+jt ztNoapRmImaXYBYiS>6BJr%#{uHMbdVJh`@W_UzxmadGz)7c74DkWIxeY zgN#1Ln=aCOl8$!OI((Hpk(Rijk?Ti;#F7aS&8r)-nhkjlsWF6{=<}7CEuopU@uj?| cbc-SbgY&z8dh)@{aiGxmboFyt=akR{0Ld!ErvLx| literal 0 HcmV?d00001 diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java index 6c19c9a63f..324213bc3d 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java @@ -20,7 +20,6 @@ import com.fr.design.gui.ibutton.UIButtonUI; import com.fr.design.gui.ibutton.UIColorButton; import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.itextfield.UIIntNumberField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -38,15 +37,28 @@ import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JFileChooser; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.plaf.basic.BasicButtonUI; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Cursor; +import java.awt.Desktop; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Point; +import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; @@ -434,13 +446,36 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { private class NinePointLinePreviewPane extends JPanel implements MouseMotionListener, MouseListener { public final Color BACKGROUND_PANE_COLOR = Color.WHITE; public final Color BACKGROUND_IMG_COLOR = Color.lightGray; - public final Color DIVIDER_BACKGROUND_COLOR = Color.WHITE; - public final Color DIVIDER_FOREGROUND_COLOR = Color.BLACK; - public final Color HINT_BACKGROUND_COLOR = new Color(255, 255, 255, 100); - public final Color HINT_FOREGROUND_COLOR = Color.RED; - public final Color HINT_LINE_BACKGROUND_COLOR = Color.WHITE; - public final Color HINT_LINE_FOREGROUND_COLOR = Color.RED; + public final Color DIVIDER_BACKGROUND_COLOR = new Color(235, 29, 31); + public final Color DIVIDER_FOREGROUND_COLOR = Color.WHITE; + public final Color HINT_BACKGROUND_COLOR = new Color(0, 215, 215); + public final Color HINT_FOREGROUND_COLOR = Color.WHITE; + public final int HINT_GAP = 5; public final int PADDING = 20; + public final Cursor E_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor( + IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_e.png"), + new Point(8, 8), "E_DRAG_CURSOR"); + public final Cursor S_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor( + IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_s.png"), + new Point(8, 8), "S_DRAG_CURSOR"); + public final Cursor W_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor( + IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_w.png"), + new Point(8, 8), "W_DRAG_CURSOR"); + public final Cursor N_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor( + IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_n.png"), + new Point(8, 8), "N_DRAG_CURSOR"); + public final Cursor NE_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor( + IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_ne.png"), + new Point(8, 8), "NE_DRAG_CURSOR"); + public final Cursor NW_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor( + IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_nw.png"), + new Point(8, 8), "NW_DRAG_CURSOR"); + public final Cursor SE_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor( + IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_se.png"), + new Point(8, 8), "SE_DRAG_CURSOR"); + public final Cursor SW_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor( + IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_sw.png"), + new Point(8, 8), "SW_DRAG_CURSOR"); private int ninePointLeft = -1; private int ninePointTop = -1; @@ -455,54 +490,17 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { private int scaleImgHeight; private int scaleImgX; private int scaleImgY; - private double scale = 1.0; + private double imageScale = 1.0; - private final UIIntNumberField topField = createNumberField(); - private final UIIntNumberField bottomField = createNumberField(); - private final UIIntNumberField leftField = createNumberField(); - private final UIIntNumberField rightField = createNumberField(); + private boolean draggingLeftDivider = false; + private boolean draggingRightDivider = false; + private boolean draggingTopDivider = false; + private boolean draggingBottomDivider = false; public NinePointLinePreviewPane() { this.setLayout(null); this.addMouseMotionListener(this); this.addMouseListener(this); - this.setFocusable(true); - this.add(topField); - this.add(bottomField); - this.add(leftField); - this.add(rightField); - - topField.addFocusListener(new FocusAdapter() { - @Override - public void focusLost(FocusEvent e) { - int value = (int) topField.getValue(); - onNinePointTopChanged(value); - } - }); - - bottomField.addFocusListener(new FocusAdapter() { - @Override - public void focusLost(FocusEvent e) { - int value = (int) bottomField.getValue(); - onNinePointBottomChanged(value); - } - }); - - leftField.addFocusListener(new FocusAdapter() { - @Override - public void focusLost(FocusEvent e) { - int value = (int) leftField.getValue(); - onNinePointLeftChanged(value); - } - }); - - rightField.addFocusListener(new FocusAdapter() { - @Override - public void focusLost(FocusEvent e) { - int value = (int) rightField.getValue(); - onNinePointRightChanged(value); - } - }); } @Override @@ -528,68 +526,115 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { scaleImgHeight = (int) (1.0F * scaleImgWidth * imgHeight / imgWidth); scaleImgX = autoFixAreaX; scaleImgY = (autoFixAreaHeight - scaleImgHeight) / 2 + autoFixAreaY; // 垂直居中 - scale = 1.0 * scaleImgWidth / imgWidth; + imageScale = 1.0 * scaleImgWidth / imgWidth; } else { scaleImgHeight = autoFixAreaHeight; scaleImgWidth = (int) (1.0F * scaleImgHeight * imgWidth / imgHeight); scaleImgX = (autoFixAreaWidth - scaleImgWidth) / 2 + autoFixAreaX; // 水平居中 scaleImgY = autoFixAreaY; - scale = 1.0 * scaleImgHeight / imgHeight; + imageScale = 1.0 * scaleImgHeight / imgHeight; } g2d.setColor(BACKGROUND_IMG_COLOR); g2d.fillRect(scaleImgX, scaleImgY, scaleImgWidth, scaleImgHeight); g2d.drawImage(image, scaleImgX, scaleImgY, scaleImgWidth, scaleImgHeight, null); - int scaleLeft = (int) (ninePointLeft * scale); - int scaleTop = (int) (ninePointTop * scale); - int scaleRight = (int) (ninePointRight * scale); - int scaleBottom = (int) (ninePointBottom * scale); + int scaleLeft = (int) (ninePointLeft * imageScale); + int scaleTop = (int) (ninePointTop * imageScale); + int scaleRight = (int) (ninePointRight * imageScale); + int scaleBottom = (int) (ninePointBottom * imageScale); double topYInPane = scaleImgY + scaleTop; double bottomYInPane = scaleImgY + scaleImgHeight - scaleBottom; double leftXInPane = scaleImgX + scaleLeft; double rightXInPane = scaleImgX + scaleImgWidth - scaleRight; - // 绘制分割线 - // 顶部 - drawLine(g2d, DIVIDER_BACKGROUND_COLOR, DIVIDER_FOREGROUND_COLOR, scaleImgX, topYInPane, scaleImgX + scaleImgWidth, topYInPane); - // 底部 - drawLine(g2d, DIVIDER_BACKGROUND_COLOR, DIVIDER_FOREGROUND_COLOR, scaleImgX, bottomYInPane, scaleImgX + scaleImgWidth, bottomYInPane); - // 左侧 - drawLine(g2d, DIVIDER_BACKGROUND_COLOR, DIVIDER_FOREGROUND_COLOR, leftXInPane, scaleImgY, leftXInPane, scaleImgY + scaleImgHeight); - // 右侧 - drawLine(g2d, DIVIDER_BACKGROUND_COLOR, DIVIDER_FOREGROUND_COLOR, rightXInPane, scaleImgY, rightXInPane, scaleImgY + scaleImgHeight); - - // 绘制分割线位置提示 - // 顶部 - drawLine(g2d, HINT_LINE_BACKGROUND_COLOR, HINT_LINE_FOREGROUND_COLOR, (leftXInPane + rightXInPane) / 2.0F, scaleImgY, (leftXInPane + rightXInPane) / 2.0F, topYInPane); - drawHint(g2d, Integer.toString(ninePointTop), (leftXInPane + rightXInPane) / 2.0F, (scaleImgY + topYInPane) / 2.0, topField); - // 底部 - drawLine(g2d, HINT_LINE_BACKGROUND_COLOR, HINT_LINE_FOREGROUND_COLOR, (leftXInPane + rightXInPane) / 2.0F, bottomYInPane, (leftXInPane + rightXInPane) / 2.0F, scaleImgY + scaleImgHeight); - drawHint(g2d, Integer.toString(ninePointBottom), (leftXInPane + rightXInPane) / 2.0F, (bottomYInPane + scaleImgY + scaleImgHeight) / 2.0, bottomField); - // 左侧 - drawLine(g2d, HINT_LINE_BACKGROUND_COLOR, HINT_LINE_FOREGROUND_COLOR, scaleImgX, (topYInPane + bottomYInPane) / 2.0, leftXInPane, (topYInPane + bottomYInPane) / 2.0); - drawHint(g2d, Integer.toString(ninePointLeft), (scaleImgX + leftXInPane) / 2.0, (topYInPane + bottomYInPane) / 2.0, leftField); - // 右侧 - drawLine(g2d, HINT_LINE_BACKGROUND_COLOR, HINT_LINE_FOREGROUND_COLOR, rightXInPane, (topYInPane + bottomYInPane) / 2.0, scaleImgX + scaleImgWidth, (topYInPane + bottomYInPane) / 2.0); - drawHint(g2d, Integer.toString(ninePointRight), (rightXInPane + scaleImgX + scaleImgWidth) / 2.0, (topYInPane + bottomYInPane) / 2.0, rightField); - } - - private void drawHint(Graphics2D g2d, String hint, double centerX, double centerY, UIIntNumberField hintField) { + // 顶部分割线 + drawDivider(g2d, scaleImgX, topYInPane, scaleImgX + scaleImgWidth, topYInPane, draggingTopDivider); + if (draggingTopDivider) { + // 顶部提示 + drawHint(g2d, ninePointTop + "px", leftXInPane, scaleImgY, scaleImgWidth - scaleLeft - scaleRight, scaleTop, false); + } + // 底部分割线 + drawDivider(g2d, scaleImgX, bottomYInPane, scaleImgX + scaleImgWidth, bottomYInPane, draggingBottomDivider); + if (draggingBottomDivider) { + // 底部提示 + drawHint(g2d, ninePointBottom + "px", leftXInPane, bottomYInPane, scaleImgWidth - scaleLeft - scaleRight, scaleBottom, false); + } + // 左侧分割线 + drawDivider(g2d, leftXInPane, scaleImgY, leftXInPane, scaleImgY + scaleImgHeight, draggingLeftDivider); + if (draggingLeftDivider) { + // 左侧提示 + drawHint(g2d, ninePointLeft + "px", scaleImgX, topYInPane, scaleLeft, scaleImgHeight - scaleTop - scaleBottom, true); + } + // 右侧分割线 + drawDivider(g2d, rightXInPane, scaleImgY, rightXInPane, scaleImgY + scaleImgHeight, draggingRightDivider); + if (draggingRightDivider) { + // 右侧提示 + drawHint(g2d, ninePointRight + "px", rightXInPane, topYInPane, scaleRight, scaleImgHeight - scaleTop - scaleBottom, true); + } + } + + private void drawHint(Graphics2D g2d, String hint, double x, double y, double width, double height, boolean horizontal) { FontMetrics metrics = GraphDrawHelper.getFontMetrics(g2d.getFont()); - double height = metrics.getAscent() + metrics.getDescent(); - double width = Math.max(metrics.stringWidth(" " + hint + " "), metrics.stringWidth(" 123 ")); + double hintTextHeight = Math.max(metrics.getAscent() + metrics.getDescent(), 16); + double hintTextWidth = Math.max(metrics.stringWidth(hint), metrics.stringWidth("123")); + double hintFrameRadius = hintTextHeight / 2; + double hintFrameHeight = hintTextHeight; + double hintFrameWidth = hintTextWidth + 2 * hintFrameRadius; + + double centerX = x + width / 2; + double centerY = y + height / 2; + + double indent = 1.0; + double shortLine = 4.0; + + if (horizontal) { + if (width > hintFrameWidth) { + g2d.setColor(HINT_BACKGROUND_COLOR); + GraphDrawHelper.draw(g2d, new Line2D.Double(x + indent, centerY, x + width - indent, centerY), Constants.LINE_THIN, 1.0F); + GraphDrawHelper.draw(g2d, new Line2D.Double(x + indent, centerY - shortLine, x + indent, centerY + shortLine), Constants.LINE_THIN, 1.0F); + GraphDrawHelper.draw(g2d, new Line2D.Double(x + width - indent, centerY - shortLine, x + width - indent, centerY + shortLine), Constants.LINE_THIN, 1.0F); + } - hintField.setBounds((int) (centerX - width / 2.0), (int) (centerY - height / 2.0), (int) width, (int) height); + double hintFrameX = centerX - hintFrameWidth / 2; + double hintFrameY = centerY + HINT_GAP; + + g2d.setColor(HINT_BACKGROUND_COLOR); + GraphDrawHelper.fill(g2d, new RoundRectangle2D.Double(hintFrameX, hintFrameY, hintFrameWidth, hintFrameHeight, hintFrameRadius * 2, hintFrameRadius * 2)); + + g2d.setColor(HINT_FOREGROUND_COLOR); + GraphDrawHelper.drawString(g2d, hint, hintFrameX + (hintFrameWidth - hintTextWidth) / 2, hintFrameY + (hintFrameHeight + hintTextHeight) / 2.0 - metrics.getDescent()); + } else { + if (height > hintFrameHeight) { + g2d.setColor(HINT_BACKGROUND_COLOR); + GraphDrawHelper.draw(g2d, new Line2D.Double(centerX, y + indent, centerX, y + height - indent), Constants.LINE_THIN, 1.0F); + GraphDrawHelper.draw(g2d, new Line2D.Double(centerX - shortLine, y + indent, centerX + shortLine, y + indent), Constants.LINE_THIN, 1.0F); + GraphDrawHelper.draw(g2d, new Line2D.Double(centerX - shortLine, y + height - indent, centerX + shortLine, y + height - indent), Constants.LINE_THIN, 1.0F); + } + + double hintFrameX = centerX + HINT_GAP; + double hintFrameY = centerY - hintFrameHeight / 2; + + g2d.setColor(HINT_BACKGROUND_COLOR); + GraphDrawHelper.fill(g2d, new RoundRectangle2D.Double(hintFrameX, hintFrameY, hintFrameWidth, hintFrameHeight, hintFrameRadius * 2, hintFrameRadius * 2)); + + g2d.setColor(HINT_FOREGROUND_COLOR); + GraphDrawHelper.drawString(g2d, hint, hintFrameX + (hintFrameWidth - hintTextWidth) / 2, hintFrameY + (hintFrameHeight + hintTextHeight) / 2.0 - metrics.getDescent()); + } } - private void drawLine(Graphics2D g2d, Color backgroundColor, Color foregroundColor, double x1, double y1, double x2, double y2) { - g2d.setColor(backgroundColor); - GraphDrawHelper.draw(g2d, new Line2D.Double(x1, y1, x2, y2), Constants.LINE_THIN, 2.0F); + private void drawDivider(Graphics2D g2d, double x1, double y1, double x2, double y2, boolean dragging) { + if (dragging) { + g2d.setColor(DIVIDER_BACKGROUND_COLOR); + GraphDrawHelper.draw(g2d, new Line2D.Double(x1, y1, x2, y2), Constants.LINE_THIN, 2.0F); - g2d.setColor(foregroundColor); - GraphDrawHelper.draw(g2d, new Line2D.Double(x1, y1, x2, y2), Constants.LINE_DASH, 1.0F); + g2d.setColor(DIVIDER_FOREGROUND_COLOR); + GraphDrawHelper.draw(g2d, new Line2D.Double(x1, y1, x2, y2), Constants.LINE_THIN, 1.0F); + } else { + g2d.setColor(DIVIDER_BACKGROUND_COLOR); + GraphDrawHelper.draw(g2d, new Line2D.Double(x1, y1, x2, y2), Constants.LINE_DASH, 1.0F); + } } @Override @@ -597,28 +642,22 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { int x = e.getX(); int y = e.getY(); - int cursorType = getCursor().getType(); + Cursor cursor = getCursor(); - switch (cursorType) { - case Cursor.W_RESIZE_CURSOR: { - int nextLeft = (int) ((x - scaleImgX) / scale); - this.onNinePointLeftChanged(nextLeft); - return; - } - case Cursor.E_RESIZE_CURSOR: { - int nextRight = (int) ((scaleImgX + scaleImgWidth - x) / scale); - this.onNinePointRightChanged(nextRight); - return; - } - case Cursor.N_RESIZE_CURSOR: { - int nextTop = (int) ((y - scaleImgY) / scale); - this.onNinePointTopChanged(nextTop); - return; - } - case Cursor.S_RESIZE_CURSOR: { - int nextBottom = (int) ((scaleImgY + scaleImgHeight - y) / scale); - this.onNinePointBottomChanged(nextBottom); - } + if (cursor == W_DRAG_CURSOR || cursor == NW_DRAG_CURSOR || cursor == SW_DRAG_CURSOR) { + int nextLeft = (int) ((x - scaleImgX) / imageScale); + this.onNinePointLeftChanged(nextLeft); + } else if (cursor == E_DRAG_CURSOR || cursor == NE_DRAG_CURSOR || cursor == SE_DRAG_CURSOR) { + int nextRight = (int) ((scaleImgX + scaleImgWidth - x) / imageScale); + this.onNinePointRightChanged(nextRight); + } + + if (cursor == N_DRAG_CURSOR || cursor == NE_DRAG_CURSOR || cursor == NW_DRAG_CURSOR) { + int nextTop = (int) ((y - scaleImgY) / imageScale); + this.onNinePointTopChanged(nextTop); + } else if (cursor == S_DRAG_CURSOR || cursor == SE_DRAG_CURSOR || cursor == SW_DRAG_CURSOR) { + int nextBottom = (int) ((scaleImgY + scaleImgHeight - y) / imageScale); + this.onNinePointBottomChanged(nextBottom); } } @@ -629,13 +668,13 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { int x = e.getX(); int y = e.getY(); - double scaleLeft = ninePointLeft * scale; - double scaleTop = ninePointTop * scale; - double scaleRight = ninePointRight * scale; - double scaleBottom = ninePointBottom * scale; + double scaleLeft = ninePointLeft * imageScale; + double scaleTop = ninePointTop * imageScale; + double scaleRight = ninePointRight * imageScale; + double scaleBottom = ninePointBottom * imageScale; // determine cursor - int cursorType = Cursor.DEFAULT_CURSOR; + Cursor cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); boolean hoveringLeftDivider = false; boolean hoveringRightDivider = false; @@ -649,18 +688,31 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { hoveringBottomDivider = Math.abs(y - (scaleImgY + scaleImgHeight - scaleBottom)) < 2; } - if (hoveringLeftDivider) { - cursorType = Cursor.W_RESIZE_CURSOR; + if (hoveringLeftDivider && hoveringTopDivider) { + cursor = NW_DRAG_CURSOR; + } else if (hoveringLeftDivider && hoveringBottomDivider) { + cursor = SW_DRAG_CURSOR; + } else if (hoveringRightDivider && hoveringTopDivider) { + cursor = NE_DRAG_CURSOR; + } else if (hoveringRightDivider && hoveringBottomDivider) { + cursor = SE_DRAG_CURSOR; + } else if (hoveringLeftDivider) { + cursor = W_DRAG_CURSOR; } else if (hoveringRightDivider) { - cursorType = Cursor.E_RESIZE_CURSOR; + cursor = E_DRAG_CURSOR; } else if (hoveringTopDivider) { - cursorType = Cursor.N_RESIZE_CURSOR; + cursor = N_DRAG_CURSOR; } else if (hoveringBottomDivider) { - cursorType = Cursor.S_RESIZE_CURSOR; + cursor = S_DRAG_CURSOR; } - needRepaint = getCursor().getType() != cursorType; - this.setCursor(Cursor.getPredefinedCursor(cursorType)); + draggingLeftDivider = hoveringLeftDivider; + draggingRightDivider = hoveringRightDivider; + draggingTopDivider = hoveringTopDivider; + draggingBottomDivider = hoveringBottomDivider; + + needRepaint = getCursor() != cursor; + this.setCursor(cursor); if (needRepaint) { repaint(); @@ -680,6 +732,10 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { @Override public void mouseReleased(MouseEvent e) { this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + this.draggingLeftDivider = false; + this.draggingRightDivider = false; + this.draggingTopDivider = false; + this.draggingBottomDivider = false; repaint(); } @@ -701,7 +757,6 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { value = imgHeight - ninePointBottom - MIN_NINE_POINT; } this.ninePointTop = value; - topField.setText(Integer.toString(value)); repaint(); } @@ -712,7 +767,6 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { value = imgHeight - ninePointTop - MIN_NINE_POINT; } this.ninePointBottom = value; - bottomField.setText(Integer.toString(value)); repaint(); } @@ -723,7 +777,6 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { value = imgWidth - ninePointRight - MIN_NINE_POINT; } this.ninePointLeft = value; - leftField.setText(Integer.toString(value)); repaint(); } @@ -734,32 +787,14 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { value = imgWidth - ninePointLeft - MIN_NINE_POINT; } this.ninePointRight = value; - rightField.setText(Integer.toString(value)); repaint(); } - private UIIntNumberField createNumberField() { - UIIntNumberField field = new UIIntNumberField(); - field.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); - field.setOpaque(true); - field.setMinValue(MIN_NINE_POINT); - field.setForeground(HINT_FOREGROUND_COLOR); - field.setBackground(HINT_BACKGROUND_COLOR); - field.setHorizontalAlignment(SwingConstants.CENTER); - return field; - } - - public void setNinePoint(int[] ninePoint) { ninePointLeft = ninePoint[0]; ninePointTop = ninePoint[1]; ninePointRight = ninePoint[2]; ninePointBottom = ninePoint[3]; - - leftField.setValue(ninePointLeft); - rightField.setValue(ninePointRight); - topField.setValue(ninePointTop); - bottomField.setValue(ninePointBottom); } public int[] getNinePoint() { From cc5eee3b51d9be0eb6830ab352637b4cf9dcb120 Mon Sep 17 00:00:00 2001 From: Starryi Date: Mon, 19 Jul 2021 13:46:18 +0800 Subject: [PATCH 2/3] =?UTF-8?q?REPORT-53175=20-=20=E3=80=9010.0.18?= =?UTF-8?q?=E3=80=91=E7=BB=84=E4=BB=B6=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB?= =?UTF-8?q?=E4=B8=BA=E6=A0=87=E9=A2=98/=E8=83=8C=E6=99=AF/=E8=BE=B9?= =?UTF-8?q?=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 设计器报表块预览优化:不显示行列头,否则当报表块较小时就无法预览到表格内容 【改动思路】 --- .../fr/design/mainframe/form/FormElementCaseDesigner.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java index 14895e90b3..7af39737dd 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java @@ -30,6 +30,7 @@ import com.fr.design.selection.Selectedable; import com.fr.design.selection.SelectionListener; import com.fr.form.FormElementCaseProvider; import com.fr.form.main.Form; +import com.fr.grid.Grid; import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.Selection; import com.fr.log.FineLoggerFactory; @@ -138,7 +139,10 @@ public class FormElementCaseDesigner g.fillRect(0, 0, size.width, size.height); g.setColor(oldColor); - this.elementCasePane.paintComponents(g); + Grid grid = this.elementCasePane != null ? this.elementCasePane.getGrid() : null; + if (grid != null) { + grid.paintAll(g); + } } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); From 1cb11fcd9f90cffcfae825856d51452ea1ae7d14 Mon Sep 17 00:00:00 2001 From: Starryi Date: Mon, 19 Jul 2021 16:22:43 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-55370=20=E3=80=9010.0.18=E5=86=92?= =?UTF-8?q?=E7=83=9F=E3=80=91=E5=8F=82=E6=95=B0=E6=8E=A7=E4=BB=B6TAb?= =?UTF-8?q?=E9=94=AE=E5=88=87=E6=8D=A2=E9=A1=BA=E5=BA=8F=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E6=9C=89=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 迭代中右侧栏面板改动,需要将尺寸相关的属性放到高级属性上方,因此 高级属性所在的XXXDefinePane被设置了BorderLayout.CENTER 约束。而参数面板的DefinePane中,位于中间的尺寸面板,也被设置了 BorderLayout.CENTER约束,导致尺寸面板的尺寸变为最大尺寸。 【改动思路】 1. 中间加一层Pane,打破CENTER约束里还有CENTER约束的情况,使得 位于右侧栏参数面板属性底部,来自插件的ExtraUI占据最大尺寸 2. 参数面板的尺寸属性也需要放置在高级属性上方,与控件保持一致 --- .../fr/design/parameter/RootDesignDefinePane.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java b/designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java index 5f45b57b09..2e96e6ed8d 100644 --- a/designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java @@ -62,13 +62,18 @@ public class RootDesignDefinePane extends AbstractDataModify { public void initComponent() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel inbuiltDefineContentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.add(inbuiltDefineContentPane, BorderLayout.NORTH); + designerWidth = new UIBoundSpinner(1, Integer.MAX_VALUE, 1); - JPanel advancePane = createAdvancePane(); - UIExpandablePane advanceExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, advancePane); - this.add(advanceExpandablePane, BorderLayout.NORTH); JPanel layoutPane = createBoundsPane(); UIExpandablePane layoutExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Size"), 280, 20, layoutPane); - this.add(layoutExpandablePane, BorderLayout.CENTER); + inbuiltDefineContentPane.add(layoutExpandablePane, BorderLayout.NORTH); + + JPanel advancePane = createAdvancePane(); + UIExpandablePane advanceExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, advancePane); + inbuiltDefineContentPane.add(advanceExpandablePane, BorderLayout.CENTER); + this.addExtraUIExpandablePaneFromPlugin(); } @@ -83,7 +88,7 @@ public class RootDesignDefinePane extends AbstractDataModify { panel.add(uiExpandablePane); } } - this.add(panel, BorderLayout.SOUTH); + this.add(panel, BorderLayout.CENTER); } public JPanel createBoundsPane() {