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;