From 317e2e00c0e4862f13ace5ef1ac958cfee24db38 Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Thu, 18 Feb 2021 10:47:21 +0800 Subject: [PATCH 1/2] =?UTF-8?q?CHART-18139=20=E4=BF=AE=E6=94=B9=E5=AF=8C?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E5=AD=97=E6=AE=B5=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../richText/VanChartFieldButton.java | 44 ++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldButton.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldButton.java index ba3925501..db701d9fc 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldButton.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldButton.java @@ -2,10 +2,13 @@ package com.fr.van.chart.designer.component.richText; import com.fr.base.BaseUtils; import com.fr.data.util.function.DataFunction; +import com.fr.design.constants.UIConstants; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIButtonUI; import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.plugin.chart.base.FirstFunction; import com.fr.plugin.chart.base.format.AttrTooltipDurationFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat; @@ -15,9 +18,12 @@ import com.fr.van.chart.designer.TableLayout4VanChartHelper; import javax.swing.Icon; import javax.swing.JPanel; +import javax.swing.plaf.ButtonUI; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.Component; import java.awt.Dimension; +import java.awt.Graphics2D; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; @@ -120,6 +126,10 @@ public class VanChartFieldButton extends JPanel { } private void initComponents(String fieldName, VanChartFieldListener listener) { + Color pressedColor = UIConstants.ATTRIBUTE_PRESS; + Color hoverColor = new Color(232, 232, 232); + Color normalColor = UIConstants.ATTRIBUTE_NORMAL; + fieldButton = new UIToggleButton(fieldName) { protected MouseListener getMouseListener() { @@ -134,9 +144,39 @@ public class VanChartFieldButton extends JPanel { } }; } + + public ButtonUI getUI() { + + return new UIButtonUI() { + protected void doExtraPainting(UIButton b, Graphics2D g2d, int w, int h, String selectedRoles) { + if (isPressed(b) && b.isPressedPainted()) { + GUIPaintUtils.fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), pressedColor); + } else if (isRollOver(b)) { + GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), hoverColor); + } else if (b.isNormalPainted()) { + GUIPaintUtils.fillNormal(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), normalColor); + } + } + }; + } }; - addButton = new UIButton(ADD_ICON); + addButton = new UIButton(ADD_ICON) { + public ButtonUI getUI() { + + return new UIButtonUI() { + protected void doExtraPainting(UIButton b, Graphics2D g2d, int w, int h, String selectedRoles) { + if (isPressed(b) && b.isPressedPainted()) { + GUIPaintUtils.fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), pressedColor); + } else if (isRollOver(b)) { + GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), hoverColor); + } else if (b.isNormalPainted()) { + GUIPaintUtils.fillNormal(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), normalColor); + } + } + }; + } + }; addButton.addMouseListener(new MouseAdapter() { @@ -163,7 +203,7 @@ public class VanChartFieldButton extends JPanel { double[] rowSize = {p}; double[] columnSize = {e, d}; - JPanel content = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 0); + JPanel content = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 3, 0); content.setPreferredSize(new Dimension(W, H)); return content; From 3b2df497446786e5cdd932de9931d8b370e50e78 Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Thu, 18 Feb 2021 11:15:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=86=85=E9=83=A8?= =?UTF-8?q?=E7=B1=BB=E4=BB=A3=E6=9B=BF=E9=87=8D=E5=A4=8D=E7=9A=84=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../richText/VanChartFieldButton.java | 45 +++++++------------ 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldButton.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldButton.java index db701d9fc..bae96b2d7 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldButton.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldButton.java @@ -2,7 +2,6 @@ package com.fr.van.chart.designer.component.richText; import com.fr.base.BaseUtils; import com.fr.data.util.function.DataFunction; -import com.fr.design.constants.UIConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonUI; import com.fr.design.gui.ibutton.UIToggleButton; @@ -32,6 +31,7 @@ import java.text.Format; public class VanChartFieldButton extends JPanel { private static final Icon ADD_ICON = BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png"); + private static final Color HOVER_COLOR = new Color(232, 232, 232); private static final int W = 200; private static final int H = 24; @@ -126,10 +126,6 @@ public class VanChartFieldButton extends JPanel { } private void initComponents(String fieldName, VanChartFieldListener listener) { - Color pressedColor = UIConstants.ATTRIBUTE_PRESS; - Color hoverColor = new Color(232, 232, 232); - Color normalColor = UIConstants.ATTRIBUTE_NORMAL; - fieldButton = new UIToggleButton(fieldName) { protected MouseListener getMouseListener() { @@ -146,35 +142,13 @@ public class VanChartFieldButton extends JPanel { } public ButtonUI getUI() { - - return new UIButtonUI() { - protected void doExtraPainting(UIButton b, Graphics2D g2d, int w, int h, String selectedRoles) { - if (isPressed(b) && b.isPressedPainted()) { - GUIPaintUtils.fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), pressedColor); - } else if (isRollOver(b)) { - GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), hoverColor); - } else if (b.isNormalPainted()) { - GUIPaintUtils.fillNormal(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), normalColor); - } - } - }; + return new FieldButtonUI(); } }; addButton = new UIButton(ADD_ICON) { public ButtonUI getUI() { - - return new UIButtonUI() { - protected void doExtraPainting(UIButton b, Graphics2D g2d, int w, int h, String selectedRoles) { - if (isPressed(b) && b.isPressedPainted()) { - GUIPaintUtils.fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), pressedColor); - } else if (isRollOver(b)) { - GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), hoverColor); - } else if (b.isNormalPainted()) { - GUIPaintUtils.fillNormal(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), normalColor); - } - } - }; + return new FieldButtonUI(); } }; @@ -212,4 +186,17 @@ public class VanChartFieldButton extends JPanel { public void setSelectedState(boolean selected) { fieldButton.setSelected(selected); } + + private static class FieldButtonUI extends UIButtonUI { + + protected void doExtraPainting(UIButton b, Graphics2D g2d, int w, int h, String selectedRoles) { + if (isPressed(b) && b.isPressedPainted()) { + GUIPaintUtils.fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles)); + } else if (isRollOver(b)) { + GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), HOVER_COLOR); + } else if (b.isNormalPainted()) { + GUIPaintUtils.fillNormal(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted()); + } + } + } }