Browse Source

Pull request #13333: REPORT-107972 按钮组、下拉复选框、颜色选择框、树适配dpi切换

Merge in DESIGN/design from ~LEVY.XIE/design:newui to newui

* commit 'cbc073dab0da298547d4647828e8cf46936ed370':
  REPORT-107972 按钮组、颜色选择框、树适配dpi切换
  REPORT-107972 按钮组、颜色选择框、树适配dpi切换
newui
Levy.Xie-解安森 6 months ago
parent
commit
84028d1a91
  1. 39
      designer-base/src/main/java/com/fine/theme/light/ui/FineButtonGroupUI.java
  2. 15
      designer-base/src/main/java/com/fine/theme/light/ui/FineRoundBorder.java
  3. 49
      designer-base/src/main/java/com/fine/theme/light/ui/FineSelectBoxUI.java
  4. 112
      designer-base/src/main/java/com/fine/theme/light/ui/FineToggleButtonUI.java
  5. 16
      designer-base/src/main/java/com/fine/theme/utils/FineClientProperties.java
  6. 49
      designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java
  7. 61
      designer-base/src/main/java/com/fr/design/gui/ibutton/FiveButtonLayout.java
  8. 66
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java
  9. 6
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java
  10. 1
      designer-base/src/main/java/com/fr/design/gui/icombobox/DictionaryComboBox.java
  11. 4
      designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java
  12. 76
      designer-base/src/main/java/com/fr/design/gui/icombobox/LineComboBox.java
  13. 32
      designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBox.java
  14. 15
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/FineTreeCellRender.java
  15. 1
      designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java
  16. 25
      designer-base/src/main/java/com/fr/design/style/AbstractSelectBox.java
  17. 12
      designer-base/src/main/java/com/fr/design/style/color/ColorCell.java
  18. 28
      designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java
  19. 2
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLaf.properties
  20. 19
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties
  21. 22
      designer-base/src/test/java/com/fr/design/gui/storybook/components/ButtonGroupStoryBoard.java
  22. 7
      designer-base/src/test/java/com/fr/design/gui/storybook/components/ComboBoxStoryBoard.java
  23. 44
      designer-base/src/test/java/com/fr/design/gui/storybook/components/SelectBoxStoryBoard.java
  24. 15
      designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotUITabGroup.java

39
designer-base/src/main/java/com/fine/theme/light/ui/FineButtonGroupUI.java

@ -0,0 +1,39 @@
package com.fine.theme.light.ui;
import com.fine.theme.utils.FineUIUtils;
import javax.swing.JComponent;
import javax.swing.border.LineBorder;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.PanelUI;
/**
* 按钮组UI应用于
*
* @author Levy.Xie
* @since 11.0
* Created on 2023/12/15
*/
public class FineButtonGroupUI extends PanelUI {
/**
* 创建UI
*
* @param c 组件
* @return ComponentUI
*/
public static ComponentUI createUI(JComponent c) {
return new FineButtonGroupUI();
}
@Override
public void installUI(JComponent c) {
super.installUI(c);
c.setBorder(new LineBorder(FineUIUtils.getUIColor("defaultBorderColor", "Component.borderColor")));
}
@Override
public void uninstallUI(JComponent c) {
super.uninstallUI(c);
}
}

15
designer-base/src/main/java/com/fine/theme/light/ui/FineRoundBorder.java

@ -1,10 +1,10 @@
package com.fine.theme.light.ui;
import com.fine.theme.utils.FineUIUtils;
import com.formdev.flatlaf.ui.FlatRoundBorder;
import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable;
import com.fr.design.event.HoverAware;
import javax.swing.UIManager;
import java.awt.Color;
import java.awt.Component;
import java.awt.Paint;
@ -20,13 +20,13 @@ import java.awt.Paint;
public class FineRoundBorder extends FlatRoundBorder {
@Styleable(dot = true)
protected Color borderColor = UIManager.getColor("defaultBorderColor");
protected Color borderColor = FineUIUtils.getUIColor("defaultBorderColor", "Component.borderColor");
@Styleable(dot = true)
protected Color disabledBorderColor = UIManager.getColor("defaultBorderColor");
protected Color disabledBorderColor = FineUIUtils.getUIColor("defaultBorderColor", "Component.disabledBorderColor");
@Styleable(dot = true)
protected Color highlightBorderColor = UIManager.getColor("defaultHighlightBorderColor");
protected Color highlightBorderColor = FineUIUtils.getUIColor("defaultHighlightBorderColor", "Component.focusedBorderColor");
@Styleable(dot = true)
protected Color focusColor = UIManager.getColor("defaultBorderFocusShadow");
protected Color focusColor = FineUIUtils.getUIColor("defaultBorderFocusShadow", "Component.focusedBorderColor");
@Override
protected Paint getBorderColor(Component c) {
@ -45,11 +45,6 @@ public class FineRoundBorder extends FlatRoundBorder {
return focusColor;
}
@Override
protected int getFocusWidth(Component c) {
return focusWidth;
}
protected Color getHoverBorderColor() {
return highlightBorderColor;
}

49
designer-base/src/main/java/com/fine/theme/light/ui/FineSelectBoxUI.java

@ -0,0 +1,49 @@
package com.fine.theme.light.ui;
import com.fine.theme.utils.FineUIUtils;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.PanelUI;
import java.awt.Dimension;
/**
* 选择框面板UI应用于 {@link com.fr.design.style.AbstractSelectBox}
*
* @author Levy.Xie
* @since 11.0
* Created on 2023/12/15
*/
public class FineSelectBoxUI extends PanelUI {
private static final int DEFAULT_BOX_HEIGHT = 24;
protected int boxHeight;
/**
* 创建UI
*
* @param c 组件
* @return ComponentUI
*/
public static ComponentUI createUI(JComponent c) {
return new FineSelectBoxUI();
}
@Override
public void installUI(JComponent c) {
super.installUI(c);
boxHeight = FineUIUtils.getAndScaleInt("ComboBox.comboHeight", DEFAULT_BOX_HEIGHT);
c.setBorder(new FineRoundBorder());
}
@Override
public void uninstallUI(JComponent c) {
super.uninstallUI(c);
}
@Override
public Dimension getPreferredSize(JComponent c) {
return new Dimension(c.getWidth(), boxHeight);
}
}

112
designer-base/src/main/java/com/fine/theme/light/ui/FineToggleButtonUI.java

@ -1,9 +1,11 @@
package com.fine.theme.light.ui;
import com.fine.theme.utils.FineUIUtils;
import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable;
import com.formdev.flatlaf.ui.FlatToggleButtonUI;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.fr.design.gui.ibutton.UIButton;
import org.jetbrains.annotations.Nullable;
import javax.swing.AbstractButton;
@ -14,10 +16,12 @@ import javax.swing.plaf.ComponentUI;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import static com.formdev.flatlaf.FlatClientProperties.BUTTON_TYPE;
import static com.formdev.flatlaf.FlatClientProperties.BUTTON_TYPE_TAB;
import static com.formdev.flatlaf.FlatClientProperties.TAB_BUTTON_SELECTED_BACKGROUND;
import static com.fine.theme.utils.FineClientProperties.BUTTON_TYPE_GROUP;
import static com.fine.theme.utils.FineClientProperties.BUTTON_TYPE;
import static com.fine.theme.utils.FineClientProperties.BUTTON_TYPE_TAB;
import static com.fine.theme.utils.FineClientProperties.TAB_BUTTON_SELECTED_BACKGROUND;
import static com.formdev.flatlaf.FlatClientProperties.clientPropertyColor;
/**
@ -34,6 +38,15 @@ public class FineToggleButtonUI extends FlatToggleButtonUI {
@Styleable(dot = true)
protected int tabArc;
@Styleable(dot = true)
protected Color groupBackground;
@Styleable(dot = true)
protected Color groupSelectedBackground;
@Styleable(dot = true)
protected Color groupSelectedForeground;
public static ComponentUI createUI(JComponent c) {
return FlatUIUtils.canUseSharedUI(c)
? FlatUIUtils.createSharedUI(FlatToggleButtonUI.class, () -> new FineToggleButtonUI(true))
@ -48,6 +61,9 @@ public class FineToggleButtonUI extends FlatToggleButtonUI {
protected void installDefaults(AbstractButton b) {
super.installDefaults(b);
tabArc = UIManager.getInt("ToggleButton.tab.arc");
groupBackground = FineUIUtils.getUIColor("ToggleButton.group.background", "ToggleButton.background");
groupSelectedBackground = FineUIUtils.getUIColor("ToggleButton.group.selectedBackground", "ToggleButton.selectedBackground");
groupSelectedForeground = FineUIUtils.getUIColor("ToggleButton.group.selectedForeground", "ToggleButton.selectedForeground");
}
@ -63,30 +79,82 @@ public class FineToggleButtonUI extends FlatToggleButtonUI {
return c instanceof JToggleButton && BUTTON_TYPE_TAB.equals(getButtonTypeStr((JToggleButton) c));
}
static boolean isGroupButton(Component c) {
return c instanceof UIButton && BUTTON_TYPE_GROUP.equals(getButtonTypeStr((UIButton) c));
}
@Override
public void paint(Graphics g, JComponent c) {
if (isGroupButton(c) || isTabButton(c)) {
((AbstractButton)c).setMargin(FineUIUtils.getUIInsets("ToggleButton.compact.margin", "ToggleButton.margin"));
}
super.paint(g, c);
}
@Override
protected void paintBackground(Graphics g, JComponent c) {
if (isTabButton(c)) {
int height = c.getHeight();
int width = c.getWidth();
boolean selected = ((AbstractButton) c).isSelected();
Color enabledColor = selected ? clientPropertyColor(c, TAB_BUTTON_SELECTED_BACKGROUND, tabSelectedBackground) : null;
// use component background if explicitly set
if (enabledColor == null) {
Color bg = c.getBackground();
if (isCustomBackground(bg))
enabledColor = bg;
}
paintTabButton(g, c);
} else if (isGroupButton(c)) {
paintGroupButton(g, c);
} else {
super.paintBackground(g, c);
}
}
// paint background
Color background = buttonStateColor(c, enabledColor,
null, tabFocusBackground, tabHoverBackground, null);
if (background != null) {
g.setColor(background);
g.fillRoundRect(0, 0, width, height, tabArc, tabArc);
protected void paintTabButton(Graphics g, JComponent c) {
int height = c.getHeight();
int width = c.getWidth();
boolean selected = ((AbstractButton) c).isSelected();
Color enabledColor = selected ? clientPropertyColor(c, TAB_BUTTON_SELECTED_BACKGROUND, tabSelectedBackground) : null;
// use component background if explicitly set
if (enabledColor == null) {
Color bg = c.getBackground();
if (isCustomBackground(bg)) {
enabledColor = bg;
}
} else
super.paintBackground(g, c);
}
// paint background
Color background = buttonStateColor(c, enabledColor,
null, tabFocusBackground, tabHoverBackground, null);
if (background != null) {
g.setColor(background);
g.fillRoundRect(0, 0, width, height, tabArc, tabArc);
}
}
protected void paintGroupButton(Graphics g, JComponent c) {
Color background = getBackground(c);
if (background == null) {
return;
}
Graphics2D g2 = (Graphics2D) g.create();
try {
FlatUIUtils.setRenderingHints(g2);
g2.setColor(FlatUIUtils.deriveColor(background, getBackgroundBase(c, true)));
float focusWidth = FlatUIUtils.getBorderFocusWidth(c);
FlatUIUtils.paintComponentBackground(g2, 0, 0, c.getWidth(), c.getHeight(), focusWidth, 0);
} finally {
g2.dispose();
}
}
@Override
protected Color getForeground(JComponent c) {
if (isGroupButton(c) && ((AbstractButton)c).isSelected()) {
return groupSelectedForeground;
}
return super.getForeground(c);
}
@Override
protected Color getBackground(JComponent c) {
if (isGroupButton(c)) {
return ((AbstractButton)c).isSelected() ? groupSelectedBackground : groupBackground;
}
return super.getBackground(c);
}
}

16
designer-base/src/main/java/com/fine/theme/utils/FineClientProperties.java

@ -0,0 +1,16 @@
package com.fine.theme.utils;
import com.formdev.flatlaf.FlatClientProperties;
/**
* FR-UI中使用的各类属性
*
* @author Levy.Xie
* @since 11.0
* Created on 2023/12/15
*/
public interface FineClientProperties extends FlatClientProperties {
String BUTTON_TYPE_GROUP = "group";
}

49
designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java

@ -8,6 +8,7 @@ import javax.swing.UIManager;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Composite;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
@ -93,6 +94,54 @@ public class FineUIUtils {
return (value instanceof Integer) ? (Integer) value : UIManager.getInt(defaultKey);
}
/**
* 获取key指定的int值并根据dpi进行缩放
*
* @param key int所在的key
* @param defaultKey 后备key
* @return 长度
*/
public static int getAndScaleInt(String key, String defaultKey) {
int intNum = getUIInt(key, defaultKey);
return FineUIScale.scale(intNum);
}
/**
* 获取key指定的int值并根据dpi进行缩放
*
* @param key int所在的key
* @param defaultInt 默认值
* @return 长度
*/
public static int getAndScaleInt(String key, int defaultInt) {
int intNum = FlatUIUtils.getUIInt(key, defaultInt);
return FineUIScale.scale(intNum);
}
/**
* 通过key获取UI的边距如果没有则使用后备key获取
*
* @param key 边距key
* @param defaultKey 边距后备key
* @return 边距
*/
public static Insets getUIInsets(String key, String defaultKey) {
Insets margin = UIManager.getInsets(key);
return (margin != null) ? margin : UIManager.getInsets(defaultKey);
}
/**
* 通过key获取UI的边距如果没有则使用后备边距
*
* @param key 边距key
* @param defaultInsets 后备边距
* @return 边距
*/
public static Insets getUIInsets(String key, Insets defaultInsets) {
Insets margin = UIManager.getInsets(key);
return (margin != null) ? margin : defaultInsets;
}
/**
* 绘制混合图像含圆角背景色设置
*

61
designer-base/src/main/java/com/fr/design/gui/ibutton/FiveButtonLayout.java

@ -1,61 +0,0 @@
package com.fr.design.gui.ibutton;
import java.awt.*;
/**
* Created with IntelliJ IDEA.
* User: pony
* Date: 13-5-27
* Time: 下午4:51
* To change this template use File | Settings | File Templates.
*/
public class FiveButtonLayout extends GridLayout {
private static final double SECOND_ROW = 1.25;
public FiveButtonLayout(int rows) {
super(rows, 3, 1, 1);
}
/**
* 容器布局
*
* @param parent 容器
*/
public void layoutContainer(Container parent) {
synchronized (parent.getTreeLock()) {
Insets insets = parent.getInsets();
int ncomponents = parent.getComponentCount();
int nrows = 2;
int ncols = 3;
if (ncomponents == 3) {
nrows = 1;
ncols = 3;
}
if (ncomponents == 0) {
return;
}
if (nrows > 0) {
ncols = (ncomponents + nrows - 1) / nrows;
} else {
nrows = (ncomponents + ncols - 1) / ncols;
}
int w = parent.getWidth() - (insets.left + insets.right);
int h = parent.getHeight() - (insets.top + insets.bottom);
w = (w - (ncols - 1)) / ncols;
h = (h - (nrows - 1)) / nrows;
for (int i = 0, x = insets.left, y = insets.top; i < ncols; i++, x += w + 1) {
parent.getComponent(i).setBounds(x, y, w, h);
}
int line2w = (int) (SECOND_ROW * w);
int secondRowCount = ncomponents - ncols;
int startx = (parent.getWidth() - line2w * secondRowCount - secondRowCount - 1) / 2;
for (int i = ncols, x = startx, y = insets.top + h + 1; i < ncomponents; i++, x += line2w + 1) {
parent.getComponent(i).setBounds(x, y, line2w, h);
}
}
}
}

66
designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java

@ -3,10 +3,8 @@ package com.fr.design.gui.ibutton;
import com.fine.swing.ui.layout.Column;
import com.fine.swing.ui.layout.Row;
import com.fine.swing.ui.layout.Spacer;
import com.fine.theme.light.ui.FineRoundBorder;
import com.fine.theme.light.ui.RectangleButtonUI;
import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIUtils;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.UIObserver;
@ -16,27 +14,24 @@ import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import javax.swing.Icon;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.UIManager;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.RoundRectangle2D;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.fine.swing.ui.layout.Layouts.cell;
import static com.fine.theme.utils.FineClientProperties.BUTTON_TYPE_GROUP;
import static com.fine.theme.utils.FineClientProperties.BUTTON_TYPE;
public class UIButtonGroup<T> extends Column implements GlobalNameObserver, UIObserver {
private static final String UI_CLASS_ID = "ButtonGroupUI";
private static final long serialVersionUID = 1L;
private static final int TEXT_LENGTH = 3;
private static final int BUTTON_SIZE = 2;
@ -169,6 +164,11 @@ public class UIButtonGroup<T> extends Column implements GlobalNameObserver, UIOb
initLayout(getCols());
}
@Override
public String getUIClassID() {
return UI_CLASS_ID;
}
protected int[] getCols() {
return new int[]{labelButtonList.size()};
}
@ -190,18 +190,17 @@ public class UIButtonGroup<T> extends Column implements GlobalNameObserver, UIOb
add(createDivider());
}
}
this.setBorder(getGroupBorder());
}
private Spacer createDivider() {
Spacer spacer = new Spacer(1);
Spacer spacer = new Spacer(FineUIScale.scale(1));
spacer.setBorder(new LineBorder(FineUIUtils.getUIColor("defaultBorderColor", "Component.borderColor")));
return spacer;
}
protected void initButton(UIToggleButton labelButton) {
labelButton.setUI(new TabButtonUI(false));
labelButton.setBorderPainted(false);
labelButton.putClientProperty(BUTTON_TYPE, BUTTON_TYPE_GROUP);
adjustButton(labelButton);
UIComponentUtils.setLineWrap(labelButton);
labelButtonList.add(labelButton);
@ -216,18 +215,6 @@ public class UIButtonGroup<T> extends Column implements GlobalNameObserver, UIOb
}
}
protected Border getGroupBorder() {
return new FineRoundBorder();
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
FlatUIUtils.setRenderingHints(g);
int arc = FineUIUtils.getUIInt("Button.group.arc", "Component.arc");
g.setClip(new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), arc, arc));
}
public boolean hasClick() {
return isClick;
}
@ -252,37 +239,6 @@ public class UIButtonGroup<T> extends Column implements GlobalNameObserver, UIOb
labelButtonList.forEach(b -> b.setEnabled(enabled));
}
private static class TabButtonUI extends RectangleButtonUI {
protected int minimumWidth;
protected int minimumHeight;
protected TabButtonUI(boolean shared) {
super(shared);
}
public static ComponentUI createUI(JComponent c) {
return new TabButtonUI(false);
}
@Override
public void installUI(JComponent c) {
super.installUI(c);
background = UIManager.getColor("Button.group.background");
pressedBackground = UIManager.getColor("Button.group.pressedBackground");
selectedBackground = UIManager.getColor("Button.group.selectedBackground");
pressedForeground = UIManager.getColor("Button.group.pressedForeground");
selectedForeground = UIManager.getColor("Button.group.selectedForeground");
minimumWidth = UIManager.getInt("Button.group.minimumWidth");
minimumHeight = UIManager.getInt("Button.group.minimumHeight");
}
@Override
public Dimension getMinimumSize(JComponent c) {
return new Dimension(minimumWidth, minimumHeight);
}
}
public void setGlobalName(String name) {
buttonGroupName = name;
}

6
designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java

@ -28,6 +28,7 @@ import java.awt.geom.RoundRectangle2D;
*/
public class UIToggleButton extends UIButton implements GlobalNameObserver{
private static final String UI_CLASS_ID = "ToggleButtonUI";
private static final int ICON_COUNT = 2;
private boolean isSelected;
private boolean isEventBannded = false;
@ -52,6 +53,11 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{
addMouseListener(getMouseListener());
}
@Override
public String getUIClassID() {
return UI_CLASS_ID;
}
/**
* 需要反白的按钮接口(组合按钮情况-UIButtonGroup)
* support icons[normalIcon, selectedIcon]

1
designer-base/src/main/java/com/fr/design/gui/icombobox/DictionaryComboBox.java

@ -27,7 +27,6 @@ public class DictionaryComboBox<T> extends UIComboBox {
}
private void initComboBox(Object[] keys, String[] displays, boolean editable){
this.setPreferredSize(new Dimension(60, 20));
this.keys = keys;
this.values = displays;
this.setModel(new DefaultComboBoxModel(keys));

4
designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java

@ -270,7 +270,9 @@ public class FRTreeComboBox extends UIComboBox {
*
*/
public void addPopupMenuListener(PopupMenuListener l) {
treePopup.addPopupMenuListener(l);
if (treePopup != null) {
treePopup.addPopupMenuListener(l);
}
}
private class TreeComboBoxRenderer extends DefaultListCellRenderer {

76
designer-base/src/main/java/com/fr/design/gui/icombobox/LineComboBox.java

@ -3,6 +3,7 @@
*/
package com.fr.design.gui.icombobox;
import com.fine.theme.utils.FineUIScale;
import com.fr.base.GraphHelper;
import com.fr.stable.Constants;
import com.fr.stable.StringUtils;
@ -17,6 +18,9 @@ import java.awt.geom.Point2D;
* Combobox for selecting line styles.
*/
public class LineComboBox extends UIComboBox {
private static final int LINE_HEIGHT = 16;
/**
* Constructor.
*
@ -48,7 +52,7 @@ public class LineComboBox extends UIComboBox {
* Set the selected line style.
*/
public void setSelectedLineStyle(int style) {
this.setSelectedItem(new Integer(style));
this.setSelectedItem(new Integer(style));
}
protected String toStringFromStyle(int style) {
@ -64,7 +68,7 @@ public class LineComboBox extends UIComboBox {
class LineCellRenderer extends UIComboBoxRenderer {
public Component getListCellRendererComponent(
JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel comp= (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
this.style = ((Integer) value).intValue();
String displayString = toStringFromStyle(style);
if (StringUtils.isNotEmpty(displayString)) {
@ -76,56 +80,56 @@ public class LineComboBox extends UIComboBox {
}
public void paint(Graphics g) {
super.paint(g);
if (StringUtils.isEmpty(toStringFromStyle(style))) {
super.paint(g);
if (StringUtils.isEmpty(toStringFromStyle(style))) {
Graphics2D g2d = (Graphics2D) g;
Dimension d = getSize();
g2d.setColor(getForeground());
GraphHelper.drawLine(g2d, 4, d.height / 2D, d.width - 8D, d.height / 2D, style);
if(isShowAxisWithLineStyle()) { // 带有坐标轴箭头的样式.
if (isShowAxisWithLineStyle()) { // 带有坐标轴箭头的样式.
drawArrow(g2d, new Point2D.Double(4, d.height / 2D), new Point2D.Double(d.width - 8D, d.height / 2D));
}
}
}
private void drawArrow(Graphics2D g2d, Point2D p0, Point2D p1) {
Point2D s = new Point2D.Double(p1.getX() - p0.getX(), p1.getY() - p0.getY());
Point2D t = new Point2D.Double();
double d1 = p0.distance(p1);
//d2-d5设定箭头的大小,p1-p2为坐标轴的延长线,p2-p5-p3-p6为箭头4个点的具体位置
double d2 = 9;
double d3 = 15;
double d4 = 7;
double d5 = 3;
t.setLocation(d2 * s.getX() / d1, d2 * s.getY() / d1);
Point2D p2 = new Point2D.Double(p1.getX() + t.getX(), p1.getY() + t.getY());
t.setLocation(d3 * s.getX() / d1, d3 * s.getY() / d1);
Point2D p3 = new Point2D.Double(p1.getX() + t.getX(), p1.getY() + t.getY());
t.setLocation(d4 * s.getX() / d1, d4 * s.getY() / d1);
Point2D p4 = new Point2D.Double(p1.getX() + t.getX(), p1.getY() + t.getY());
Point2D p5 = new Point2D.Double(p4.getX() + s.getY() / d1 * d5, p4.getY() - s.getX() / d1 * d5);
Point2D p6 = new Point2D.Double(p4.getX() - s.getY() / d1 * d5, p4.getY() + s.getX() / d1 * d5);
GeneralPath arrow = new GeneralPath();
arrow.moveTo((float) p2.getX() - 10, (float) p2.getY());
arrow.lineTo((float) p5.getX() - 10, (float) p5.getY());
arrow.lineTo((float) p3.getX() - 10, (float) p3.getY());
arrow.lineTo((float) p6.getX() - 10, (float) p6.getY());
arrow.closePath();
g2d.draw(arrow);
g2d.fill(arrow);
Point2D s = new Point2D.Double(p1.getX() - p0.getX(), p1.getY() - p0.getY());
Point2D t = new Point2D.Double();
double d1 = p0.distance(p1);
//d2-d5设定箭头的大小,p1-p2为坐标轴的延长线,p2-p5-p3-p6为箭头4个点的具体位置
double d2 = 9;
double d3 = 15;
double d4 = 7;
double d5 = 3;
t.setLocation(d2 * s.getX() / d1, d2 * s.getY() / d1);
Point2D p2 = new Point2D.Double(p1.getX() + t.getX(), p1.getY() + t.getY());
t.setLocation(d3 * s.getX() / d1, d3 * s.getY() / d1);
Point2D p3 = new Point2D.Double(p1.getX() + t.getX(), p1.getY() + t.getY());
t.setLocation(d4 * s.getX() / d1, d4 * s.getY() / d1);
Point2D p4 = new Point2D.Double(p1.getX() + t.getX(), p1.getY() + t.getY());
Point2D p5 = new Point2D.Double(p4.getX() + s.getY() / d1 * d5, p4.getY() - s.getX() / d1 * d5);
Point2D p6 = new Point2D.Double(p4.getX() - s.getY() / d1 * d5, p4.getY() + s.getX() / d1 * d5);
GeneralPath arrow = new GeneralPath();
arrow.moveTo((float) p2.getX() - 10, (float) p2.getY());
arrow.lineTo((float) p5.getX() - 10, (float) p5.getY());
arrow.lineTo((float) p3.getX() - 10, (float) p3.getY());
arrow.lineTo((float) p6.getX() - 10, (float) p6.getY());
arrow.closePath();
g2d.draw(arrow);
g2d.fill(arrow);
}
private boolean isShowAxisWithLineStyle() {
return style == Constants.LINE_CHART_MED_ARROW
|| style == Constants.LINE_CHART_THICK_ARROW || style == Constants.LINE_CHART_THIN_ARROW;
return style == Constants.LINE_CHART_MED_ARROW
|| style == Constants.LINE_CHART_THICK_ARROW || style == Constants.LINE_CHART_THIN_ARROW;
}
public Dimension getPreferredSize() {
return new Dimension(60, 16);
return new Dimension(getWidth(), FineUIScale.scale(LINE_HEIGHT));
}
public Dimension getMinimumSize() {

32
designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBox.java

@ -1,6 +1,8 @@
package com.fr.design.gui.icombobox;
import com.fine.theme.light.ui.FineComboBoxUI;
import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIUtils;
import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.UIObserver;
@ -10,7 +12,8 @@ import com.fr.design.event.HoverAware;
import javax.swing.ComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.ListCellRenderer;
import javax.swing.UIManager;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.plaf.ComboBoxUI;
import javax.swing.plaf.basic.ComboPopup;
import java.awt.Dimension;
@ -37,10 +40,6 @@ public class UIComboBox extends JComboBox implements UIObserver, GlobalNameObser
private static final long serialVersionUID = 1L;
private static final int SIZE = UIManager.getInt("ComboBox.comboHeight");
private static final int RENDER_FIX_SIZE = 5;
protected UIObserverListener uiObserverListener;
private String comboBoxName = "";
@ -102,12 +101,29 @@ public class UIComboBox extends JComboBox implements UIObserver, GlobalNameObser
hovered = true;
repaint();
}
@Override
public void mouseExited(MouseEvent e) {
hovered = false;
repaint();
}
});
this.addPopupMenuListener(new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
repaint();
}
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
}
});
}
}
@ -143,8 +159,10 @@ public class UIComboBox extends JComboBox implements UIObserver, GlobalNameObser
@Override
public Dimension getPreferredSize() {
//加5的原因在于:render里,每一个项前面了空了一格,要多几像素
return new Dimension(super.getPreferredSize().width + RENDER_FIX_SIZE, SIZE);
int renderFix = FineUIScale.scale(5);
int comboHeight = FineUIUtils.getAndScaleInt("ComboBox.comboHeight", 24);
//renderFix的原因在于:render里,每一个项前面了空了一格,要多几像素
return new Dimension(FineUIScale.scale(super.getPreferredSize().width) + renderFix, comboHeight);
}
public void refreshBoxItems(List list) {

15
designer-base/src/main/java/com/fr/design/gui/itree/filetree/FineTreeCellRender.java

@ -1,10 +1,13 @@
package com.fr.design.gui.itree.filetree;
import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIUtils;
import javax.swing.JTree;
import javax.swing.UIManager;
import javax.swing.BorderFactory;
import javax.swing.tree.DefaultTreeCellRenderer;
import java.awt.*;
import java.awt.Component;
import java.awt.Insets;
/**
* Tree子节点的渲染器
@ -17,14 +20,16 @@ public class FineTreeCellRender extends DefaultTreeCellRenderer {
private static final long serialVersionUID = 1L;
private static final Insets DEFAULT_TREE_RENDER_MARGIN = new Insets(2, 0, 2, 0);
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
Insets margins = UIManager.getInsets("Tree.rendererMargins");
Insets margins = FineUIUtils.getUIInsets("Tree.rendererMargins", DEFAULT_TREE_RENDER_MARGIN);
margins = FineUIScale.scale(margins);
this.setBorder(BorderFactory.createEmptyBorder(margins.top, margins.left,
margins.bottom, margins.right));
this.setIconTextGap(UIManager.getInt("Tree.iconTextGap"));
this.setIconTextGap(FineUIUtils.getAndScaleInt("Tree.iconTextGap", "CheckBox.iconTextGap"));
return this;
}
}

1
designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java

@ -92,7 +92,6 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
typeComboBox.setRenderer(createComBoxRender());
typeComboBox.addItemListener(itemListener);
typeComboBox.setGlobalName("typeComboBox");
typeComboBox.setPreferredSize(new Dimension(155,20));
}
private void initTextFontComboBox4GeneralFormats() {

25
designer-base/src/main/java/com/fr/design/style/AbstractSelectBox.java

@ -1,7 +1,8 @@
package com.fr.design.style;
import com.fine.theme.light.ui.FineRoundBorder;
import com.fine.theme.utils.FineUIScale;
import com.formdev.flatlaf.ui.FlatArrowButton;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.fr.design.event.HoverAware;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.style.background.BackgroundJComponent;
@ -29,18 +30,15 @@ import java.awt.event.MouseListener;
* 主要是 弹出界面的不同
*/
public abstract class AbstractSelectBox<T> extends AbstractPopBox implements MouseListener, HoverAware {
private static final String UI_CLASS_ID = "SelectBoxUI";
private static final long serialVersionUID = 2355250206956896774L;
private boolean rollOver;
private JButton triggerButton;
private final int boxSize = UIManager.getInt("ComboBox.comboHeight");
private final int buttonOffsetX = UIManager.getInt("ComboBox.selectBox.button.offsetX");
protected void initBox(int preWidth) {
// 初始化面板布局
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(new FineRoundBorder());
this.setPreferredSize(new Dimension(getWidth(), boxSize));
// 初始化组件
displayComponent = new BackgroundJComponent();
triggerButton = new SelectBoxButton();
@ -48,7 +46,7 @@ public abstract class AbstractSelectBox<T> extends AbstractPopBox implements Mou
JPanel displayPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
displayPane.setBorder(null);
displayPane.add(displayComponent, BorderLayout.CENTER);
displayComponent.setPreferredSize(new Dimension(preWidth, displayPane.getPreferredSize().height));
displayComponent.setSize(new Dimension(preWidth, displayPane.getPreferredSize().height));
// 添加事件监听
displayComponent.addMouseListener(mouseListener);
triggerButton.addMouseListener(mouseListener);
@ -100,6 +98,11 @@ public abstract class AbstractSelectBox<T> extends AbstractPopBox implements Mou
});
}
@Override
public String getUIClassID() {
return UI_CLASS_ID;
}
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
@ -149,12 +152,10 @@ public abstract class AbstractSelectBox<T> extends AbstractPopBox implements Mou
@Override
public Dimension getPreferredSize() {
return new Dimension(boxSize, boxSize);
}
@Override
public float getXOffset() {
return buttonOffsetX;
int outerHeight = FlatUIUtils.getUIInt("ComboBox.height", 24);
int buttonSize = FineUIScale.scale(outerHeight -
2 * FlatUIUtils.getUIInt("Component.borderWidth", 1));
return new Dimension(buttonSize, buttonSize);
}
}

12
designer-base/src/main/java/com/fr/design/style/color/ColorCell.java

@ -10,6 +10,7 @@ import java.awt.event.MouseEvent;
import javax.swing.JComponent;
import com.fine.theme.utils.FineUIScale;
import com.fr.design.DesignerEnvManager;
import com.fr.design.constants.UIConstants;
import com.fr.general.ComparatorUtils;
@ -25,9 +26,6 @@ public class ColorCell extends JComponent implements ColorSelectable {
*/
public ColorCell() {
enableEvents(AWTEvent.MOUSE_EVENT_MASK);
setPreferredSize(new Dimension(16, 16));
// setBorder(new LineBorder(Color.gray));
this.setCursor(new Cursor(Cursor.HAND_CURSOR));
}
@ -122,9 +120,15 @@ public class ColorCell extends JComponent implements ColorSelectable {
return getPreferredSize();
}
@Override
public Dimension getPreferredSize() {
int cellSize = FineUIScale.scale(16);
return new Dimension(cellSize, cellSize);
}
/**
* 选中颜色
* @param 颜色单元格
* @param colorCell
*
*/
@Override

28
designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java

@ -1,5 +1,7 @@
package com.fr.design.style.color;
import com.fine.theme.utils.FineUIScale;
import com.formdev.flatlaf.util.ScaledEmptyBorder;
import com.fr.base.FineColor;
import com.fr.base.theme.FineColorDeriveState;
import com.fr.base.theme.TemplateTheme;
@ -39,10 +41,7 @@ import java.util.List;
public class NewColorSelectPane extends BasicPane implements ColorSelectable {
private static final long serialVersionUID = -8634152305687249392L;
private static final int WIDTH = 216;
private static final int HEIGHT = 230;
private static final int DEFAULT_COLOR_HOR_INTERVAL = 4;
private static final int DEFAULT_COLOR_HOR_INTERVAL = FineUIScale.scale(4);
//颜色衍生的数量
private static final int DEFAULT_DERIVE_COUNT = 5;
@ -83,7 +82,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
initSelectButton(isSupportTransparent);
// center
JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
centerPane.setBorder(BorderFactory.createEmptyBorder(10, 6, 0, 6));
centerPane.setBorder(new ScaledEmptyBorder(10, 6, 0, 6));
this.add(centerPane, BorderLayout.CENTER);
menuColorPane = getMenuColorPane();
@ -97,7 +96,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
}
JPanel standardColorPane = new JPanel(new BorderLayout(0, 5));
standardColorPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
standardColorPane.setBorder(new ScaledEmptyBorder(10, 0, 0, 0));
standardColorPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Standard_Color")), BorderLayout.CENTER);
centerPane.add(standardColorPane);
JPanel colorSelectPane = createStandardColorPane();
@ -105,7 +104,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
// 增加最近使用 pane
JPanel row1Pane = new JPanel(new BorderLayout(0, 5));
row1Pane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
row1Pane.setBorder(new ScaledEmptyBorder(10, 0, 0, 0));
row1Pane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Used")), BorderLayout.CENTER);
centerPane.add(row1Pane);
// 最近使用
@ -128,9 +127,8 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
customButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
JPanel centerPane1 = new JPanel(new BorderLayout(0, 0));
centerPane1.setBorder(BorderFactory.createEmptyBorder(8, 0, 9, 0));
centerPane1.setBorder(new ScaledEmptyBorder(8, 0, 9, 0));
centerPane1.add(customButton, BorderLayout.CENTER);
customButton.setPreferredSize(new Dimension(197, 20));
centerPane.add(centerPane1);
}
@ -364,18 +362,6 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, color, this);
}
@Override
public Dimension getPreferredSize() {
int height = HEIGHT;
if (isSupportTransparent) {
height += 15;
}
if (isSupportThemeColor) {
height += 25;
}
return new Dimension(WIDTH, height);
}
/**
* 更新最近使用颜色
*/

2
designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLaf.properties

@ -44,4 +44,6 @@ ToolTipUI=com.fine.theme.light.ui.FineTooltipUI
TreeUI=com.fine.theme.light.ui.UIFlatTreeUI
ViewportUI=com.formdev.flatlaf.ui.FlatViewportUI
HeadGroupUI=com.fine.theme.light.ui.FineHeadGroupUI
ButtonGroupUI= com.fine.theme.light.ui.FineButtonGroupUI
SelectBoxUI= com.fine.theme.light.ui.FineSelectBoxUI

19
designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties

@ -41,7 +41,6 @@
[linux]light.font = "Noto SansCJK", "SimHei", "Arial", "Ubuntu"
[linux]semibold.font = "Noto SansCJK", "SimHei", "Arial", "Ubuntu"
#---- variables ----
Component.defaultHeight=24
Component.defaultVGap=10
@ -180,14 +179,6 @@ Button.toolbar.selectedBackground = $Button.selectedBackground
Button.toolbar.margin = 3,3,3,3
Button.toolbar.spacingInsets = 1,2,1,2
Button.group.background = #FFF
Button.group.selectedBackground = #2576EF
Button.group.pressedBackground = #2576EF
Button.group.selectedForeground = #FFF
Button.group.pressedForeground = #FFF
Button.group.minimumWidth = 32
Button.group.minimumHeight = 20
Button.group.arc = $Component.arc
#---- CheckBox ----
CheckBox.border = com.formdev.flatlaf.ui.FlatMarginBorder
@ -274,7 +265,7 @@ ComboBox.buttonEditableBackground = darken($ComboBox.background,2%)
ComboBox.buttonSeparatorColor = $ComboBox.background
ComboBox.buttonDisabledSeparatorColor = $Component.disabledBorderColor
ComboBox.buttonArrowColor = @buttonArrowColor
ComboBox.buttonDisabledArrowColor = @buttonDisabledArrowColor
ComboBox.buttonDisabledArrowColor = #a5acb7
ComboBox.buttonHoverArrowColor = #0A1C38
ComboBox.buttonPressedArrowColor = #0A1C38
@ -283,7 +274,7 @@ ComboBox.selectionInsets = 0,0,0,0
ComboBox.selectionArc = 0
ComboBox.borderCornerRadius = 3
ComboBox.comboHeight = 24
ComboBox.selectBox.button.offsetX = 2
ComboBox.selectBox.button.height = 22
#---- Component ----
@ -982,6 +973,7 @@ TitlePane.buttonPressedBackground = darken($TitlePane.background,8%,derived)
ToggleButton.border = $Button.border
ToggleButton.margin = $Button.margin
ToggleButton.compact.margin = 2,0,2,0
ToggleButton.iconTextGap = $Button.iconTextGap
ToggleButton.rollover = $Button.rollover
@ -1005,6 +997,11 @@ ToggleButton.tab.hoverBackground = $TabbedPane.hoverColor
ToggleButton.tab.focusBackground = #FFFFFF
ToggleButton.tab.arc = $Component.arc
#button type group
ToggleButton.group.background = #FFF
ToggleButton.group.selectedBackground = #2576EF
ToggleButton.group.selectedForeground = #FFF
#---- HeadGroup ----
HeadGroup.background= #E9ECF1
HeadGroup.arc= $Component.arc

22
designer-base/src/test/java/com/fr/design/gui/storybook/components/ButtonTabStoryBoard.java → designer-base/src/test/java/com/fr/design/gui/storybook/components/ButtonGroupStoryBoard.java

@ -21,8 +21,8 @@ import static com.fine.swing.ui.layout.Layouts.flex;
* Created on 2023/12/14
*/
@Story
public class ButtonTabStoryBoard extends StoryBoard {
public ButtonTabStoryBoard() {
public class ButtonGroupStoryBoard extends StoryBoard {
public ButtonGroupStoryBoard() {
super("切换按钮组");
add(
cell(new UILabel("单行文字按钮")).with(this::h3),
@ -33,7 +33,11 @@ public class ButtonTabStoryBoard extends StoryBoard {
cell(new UIButtonGroup<>(iconArrayWithWhite())),
cell(new UILabel("多行按钮-偶数场景-6按钮")).with(this::h3),
cell(new UITabGroup(sixTextArray())),
cell(new UILabel("多行按钮-奇数场景-5按钮")).with(this::h3),
cell(new UILabel("多行按钮-全部禁用")).with((this::h3)),
cell(getAllDisabledGroup()),
cell(new UILabel("多行按钮-部分禁用")).with((this::h3)),
cell(getPartDisabledGroup(0)),
cell(new UILabel("多行按钮-奇数场景-5按钮")).with((this::h3)),
cell(new UITabGroup(fiveTextArray())),
cell(new UILabel("多行按钮-奇数场景-7按钮")).with(this::h3),
cell(new UITabGroup(sevenTextArray())),
@ -67,4 +71,16 @@ public class ButtonTabStoryBoard extends StoryBoard {
private String[] sixTextArray() {
return ArrayUtils.toArray("按钮1", "按钮2", "按钮3", "按钮4", "按钮5", "按钮6");
}
private UITabGroup getAllDisabledGroup() {
UITabGroup group = new UITabGroup(sixTextArray());
group.setEnabled(false);
return group;
}
private UITabGroup getPartDisabledGroup(int index) {
UITabGroup group = new UITabGroup(sixTextArray());
group.getButton(index).setEnabled(false);
return group;
}
}

7
designer-base/src/test/java/com/fr/design/gui/storybook/components/ComboBoxStoryBoard.java

@ -1,9 +1,12 @@
package com.fr.design.gui.storybook.components;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.storybook.Story;
import com.fr.design.gui.storybook.StoryBoard;
import com.fr.stable.ArrayUtils;
import com.fr.stable.CoreConstants;
import java.awt.*;
@ -17,6 +20,7 @@ import static com.fine.swing.ui.layout.Layouts.flex;
* @since 11.0
* Created on 2023/12/14
*/
@Story
public class ComboBoxStoryBoard extends StoryBoard {
public ComboBoxStoryBoard() {
@ -29,6 +33,9 @@ public class ComboBoxStoryBoard extends StoryBoard {
)),
cell(new UILabel("禁用状态")).with(this::h3),
cell(getDisabledStatus()),
cell(new UILabel("线型下拉框")).with(this::h3),
cell(new LineComboBox(CoreConstants.UNDERLINE_STYLE_ARRAY)),
flex()
);
}

44
designer-base/src/test/java/com/fr/design/gui/storybook/components/SelectBoxStoryBoard.java

@ -0,0 +1,44 @@
package com.fr.design.gui.storybook.components;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.storybook.Story;
import com.fr.design.gui.storybook.StoryBoard;
import com.fr.design.style.background.texture.TextureSelectBox;
import com.fr.design.style.color.ColorSelectBox;
import com.fr.design.style.color.NewColorSelectPane;
import static com.fine.swing.ui.layout.Layouts.cell;
import static com.fine.swing.ui.layout.Layouts.flex;
/**
* @author Levy.Xie
* @since 11.0
* Created on 2023/12/18
*/
@Story
public class SelectBoxStoryBoard extends StoryBoard {
public SelectBoxStoryBoard() {
super("选择框面板");
add(
cell(new UILabel("颜色下拉选择面板")).with(this :: h3),
cell(new MockColorSelectBox(50)),
cell(new UILabel("纹理下拉选择面板")).with(this :: h3),
cell(new TextureSelectBox(50)),
flex()
);
}
private static class MockColorSelectBox extends ColorSelectBox {
public MockColorSelectBox(int preferredWidth) {
super(preferredWidth);
}
@Override
protected NewColorSelectPane getColorSelectPane() {
return new NewColorSelectPane(true, true);
}
}
}

15
designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotUITabGroup.java

@ -7,10 +7,8 @@ import com.fr.design.gui.ibutton.UIToggleButton;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.border.Border;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.LayoutManager;
@ -38,19 +36,6 @@ public class VanChartCustomPlotUITabGroup extends UITabGroup{
return new GridBagLayout();
}
@Override
protected void paintBorder(Graphics g) {
Border border = getBorder();
if (border != null) {
border.paintBorder(this, g, 0, 0, getWidth(), getHeight());
}
}
@Override
protected Border getGroupBorder() {
return BorderFactory.createEmptyBorder(1, 1, 1, 1);
}
@Override
protected void initButton(UIToggleButton labelButton) {

Loading…
Cancel
Save