Browse Source

Merge pull request #3568 in DESIGN/design from bugfix/10.0 to feature/10.0

* commit '2b365f5c3489fbb0448a7725a40369ddfce84e29':
  使用内部类代替重复的方法
  CHART-18139 修改富文本字段样式
feature/10.0
superman 4 years ago
parent
commit
3be9208808
  1. 31
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldButton.java

31
designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldButton.java

@ -3,9 +3,11 @@ package com.fr.van.chart.designer.component.richText;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.data.util.function.DataFunction; import com.fr.data.util.function.DataFunction;
import com.fr.design.gui.ibutton.UIButton; 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.gui.ibutton.UIToggleButton;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; 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.FirstFunction;
import com.fr.plugin.chart.base.format.AttrTooltipDurationFormat; import com.fr.plugin.chart.base.format.AttrTooltipDurationFormat;
import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat;
@ -15,9 +17,12 @@ import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.plaf.ButtonUI;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
@ -26,6 +31,7 @@ import java.text.Format;
public class VanChartFieldButton extends JPanel { public class VanChartFieldButton extends JPanel {
private static final Icon ADD_ICON = BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png"); 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 W = 200;
private static final int H = 24; private static final int H = 24;
@ -134,9 +140,17 @@ public class VanChartFieldButton extends JPanel {
} }
}; };
} }
public ButtonUI getUI() {
return new FieldButtonUI();
}
}; };
addButton = new UIButton(ADD_ICON); addButton = new UIButton(ADD_ICON) {
public ButtonUI getUI() {
return new FieldButtonUI();
}
};
addButton.addMouseListener(new MouseAdapter() { addButton.addMouseListener(new MouseAdapter() {
@ -163,7 +177,7 @@ public class VanChartFieldButton extends JPanel {
double[] rowSize = {p}; double[] rowSize = {p};
double[] columnSize = {e, d}; 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)); content.setPreferredSize(new Dimension(W, H));
return content; return content;
@ -172,4 +186,17 @@ public class VanChartFieldButton extends JPanel {
public void setSelectedState(boolean selected) { public void setSelectedState(boolean selected) {
fieldButton.setSelected(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());
}
}
}
} }

Loading…
Cancel
Save