From 317e2e00c0e4862f13ace5ef1ac958cfee24db38 Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Thu, 18 Feb 2021 10:47:21 +0800 Subject: [PATCH] =?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;