From 3b2df497446786e5cdd932de9931d8b370e50e78 Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Thu, 18 Feb 2021 11:15:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=86=85=E9=83=A8=E7=B1=BB?= =?UTF-8?q?=E4=BB=A3=E6=9B=BF=E9=87=8D=E5=A4=8D=E7=9A=84=E6=96=B9=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()); + } + } + } }