Browse Source

REPORT-107972 设计器样式翻新-按钮组布局更新、补充StoryBook

newui
Levy.Xie-解安森 11 months ago
parent
commit
7bac4184b6
  1. 37
      designer-base/src/main/java/com/fine/theme/light/ui/FineCheckBoxUI.java
  2. 309
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java
  3. 59
      designer-base/src/main/java/com/fr/design/gui/ibutton/UITabGroup.java
  4. 5
      designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java
  5. 2
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java
  6. 2
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/TabbedPane.java
  7. 4
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties
  8. 68
      designer-base/src/test/java/com/fr/design/gui/storybook/ButtonTabStoryBoard.java
  9. 58
      designer-base/src/test/java/com/fr/design/gui/storybook/CheckBoxStoryBoard.java
  10. 43
      designer-base/src/test/java/com/fr/design/gui/storybook/ComboBoxStoryBoard.java
  11. 3
      designer-base/src/test/java/com/fr/design/gui/storybook/Storybook.java
  12. 3
      designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotUITabGroup.java
  13. 3
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java
  14. 4
      designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java

37
designer-base/src/main/java/com/fine/theme/light/ui/FineCheckBoxUI.java

@ -0,0 +1,37 @@
package com.fine.theme.light.ui;
import com.fine.theme.icon.LazyIcon;
import com.formdev.flatlaf.ui.FlatCheckBoxUI;
import javax.swing.AbstractButton;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
/**
* 提供 {@link javax.swing.JCheckBox} 的UI类
*
* @author Levy.Xie
* @since 11.0
* Created on 2023/12/14
*/
public class FineCheckBoxUI extends FlatCheckBoxUI {
public static ComponentUI createUI(JComponent c) {
return new FineCheckBoxUI(false);
}
protected FineCheckBoxUI(boolean shared) {
super(shared);
}
@Override
public void installDefaults(AbstractButton b) {
super.installDefaults(b);
b.setIcon(new LazyIcon("checkbox_unchecked"));
b.setSelectedIcon(new LazyIcon("checkbox_checked"));
b.setRolloverIcon(new LazyIcon("checkbox_hovered"));
b.setDisabledIcon(new LazyIcon("checkbox_unchecked").disabled());
b.setDisabledSelectedIcon(new LazyIcon("checkbox_checked").disabled());
}
}

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

@ -1,7 +1,11 @@
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.FineUIUtils;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver;
@ -11,10 +15,9 @@ import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.UIManager;
@ -22,9 +25,6 @@ import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.LayoutManager;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@ -34,7 +34,9 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIObserver {
import static com.fine.swing.ui.layout.Layouts.cell;
public class UIButtonGroup<T> extends Column implements GlobalNameObserver, UIObserver {
private static final long serialVersionUID = 1L;
private static final int TEXT_LENGTH = 3;
private static final int BUTTON_SIZE = 2;
@ -46,7 +48,6 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
private String buttonGroupName = StringUtils.EMPTY;
private boolean isToolBarComponent = false;
private boolean isClick;
protected int totalButtonSize = 0;
private UIObserverListener uiObserverListener;
private boolean autoFireStateChanged = true;
@ -67,10 +68,7 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
if (!ArrayUtils.isEmpty(objects) && iconArray.length == objects.length) {
this.objectList = Arrays.asList(objects);
}
labelButtonList = new ArrayList<UIToggleButton>(iconArray.length);
totalButtonSize = iconArray.length;
this.setLayout(getGridLayout(iconArray.length));
this.setBorder(getGroupBorder());
labelButtonList = new ArrayList<>(iconArray.length);
for (int i = 0; i < iconArray.length; i++) {
final int index = i;
Icon icon = iconArray[i];
@ -96,18 +94,16 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
return false;
}
};
initButton(labelButton, i);
initButton(labelButton);
}
initLayout(getCols());
}
public UIButtonGroup(Icon[][] iconArray, T[] objects) {
if (!ArrayUtils.isEmpty(objects) && iconArray.length == objects.length) {
this.objectList = Arrays.asList(objects);
}
totalButtonSize = iconArray.length;
labelButtonList = new ArrayList<UIToggleButton>(iconArray.length);
this.setLayout(getGridLayout(iconArray.length));
this.setBorder(getGroupBorder());
labelButtonList = new ArrayList<>(iconArray.length);
for (int i = 0; i < iconArray.length; i++) {
final int index = i;
Icon[] icon = iconArray[i];
@ -133,50 +129,17 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
return false;
}
};
initButton(labelButton, i);
}
}
public boolean hasClick() {
return isClick;
}
public void setClickState(boolean changeFlag) {
isClick = changeFlag;
}
public void setForToolBarButtonGroup(boolean isToolBarComponent) {
this.isToolBarComponent = isToolBarComponent;
if (isToolBarComponent) {
for (UIToggleButton uiToggleButton : labelButtonList) {
uiToggleButton.set4ToolbarButton();
}
}
repaint();
}
/**
* setEnabled
*
* @param enabled
*/
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
for (int i = 0; i < labelButtonList.size(); i++) {
labelButtonList.get(i).setEnabled(enabled);
initButton(labelButton);
}
initLayout(getCols());
}
public UIButtonGroup(String[] textArray, T[] objects) {
if (!ArrayUtils.isEmpty(objects) && textArray.length == objects.length) {
this.objectList = Arrays.asList(objects);
}
totalButtonSize = textArray.length;
currentButtonSize = textArray.length;
labelButtonList = new ArrayList<UIToggleButton>(textArray.length);
this.setLayout(getGridLayout(textArray.length));
this.setBorder(getGroupBorder());
labelButtonList = new ArrayList<>(textArray.length);
for (int i = 0; i < textArray.length; i++) {
final int index = i;
final UIToggleButton labelButton = new UIToggleButton(textArray[i]) {
@ -201,10 +164,94 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
}
};
initButton(labelButton, i);
initButton(labelButton);
}
initLayout(getCols());
}
protected int[] getCols() {
return new int[]{labelButtonList.size()};
}
protected void initLayout(int[] cols) {
int currentIndex = 0;
for (int row = 0; row < cols.length; row++) {
int col = cols[row];
Row rowContainer = new Row();
for (int j = 0; j < col; j++) {
rowContainer.add(cell(labelButtonList.get(currentIndex)).weight(1.0));
currentIndex++;
if (j != col - 1) {
rowContainer.add(createDivider());
}
}
add(rowContainer);
if (row != cols.length - 1) {
add(createDivider());
}
}
this.setBorder(getGroupBorder());
}
private Spacer createDivider() {
Spacer spacer = new Spacer(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);
adjustButton(labelButton);
UIComponentUtils.setLineWrap(labelButton);
labelButtonList.add(labelButton);
}
private void adjustButton(UIToggleButton labelButton) {
if (labelButton.getText().length() > TEXT_LENGTH && currentButtonSize > BUTTON_SIZE) {
Dimension dimension = labelButton.getPreferredSize();
dimension.height <<= 1;
labelButton.setPreferredSize(dimension);
}
}
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;
}
public void setClickState(boolean changeFlag) {
isClick = changeFlag;
}
public void setForToolBarButtonGroup(boolean isToolBarComponent) {
this.isToolBarComponent = isToolBarComponent;
if (isToolBarComponent) {
for (UIToggleButton uiToggleButton : labelButtonList) {
uiToggleButton.set4ToolbarButton();
}
}
repaint();
}
@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
labelButtonList.forEach(b -> b.setEnabled(enabled));
}
private static class TabButtonUI extends RectangleButtonUI {
protected int minimumWidth;
@ -236,94 +283,18 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
}
}
public void setGlobalName(String name) {
buttonGroupName = name;
}
protected void initButton(UIToggleButton labelButton) {
initButton(labelButton, 0);
}
protected void initButton(UIToggleButton labelButton, int buttonIndex) {
labelButton.setUI(new TabButtonUI(false));
paintInnerBorder(labelButton, buttonIndex);
adjustButton(labelButton, buttonIndex);
UIComponentUtils.setLineWrap(labelButton);
labelButtonList.add(labelButton);
this.add(labelButton);
}
/**
* 绘制按钮组内边框
*
* @param labelButton 按钮
* @param index 按钮序号
*/
protected void paintInnerBorder(UIToggleButton labelButton, int index) {
LayoutManager layout = getLayout();
int leftBorder = 0;
int bottomBorder = 0;
if (layout instanceof GridLayout) {
GridLayout gridLayout = (GridLayout) layout;
int rows = gridLayout.getRows();
int columns = gridLayout.getColumns();
rows = getActualColumnRow(rows, columns, totalButtonSize);
columns = getActualColumnRow(columns, rows, totalButtonSize);
int columnIndex = index % columns;
int rowIndex = index / columns;
// 非首列,绘制左边框
leftBorder = (columnIndex != 0) ? 1 : 0;
// 非末行,绘制底边框
bottomBorder = (rows > 1 && rowIndex < rows - 1) ? 1 : 0;
} else {
leftBorder = (index != 0) ? 1 : 0;
}
labelButton.setBorderPainted((leftBorder | bottomBorder) != 0);
labelButton.setBorder((leftBorder | bottomBorder) != 0 ?
BorderFactory.createMatteBorder(0, leftBorder, bottomBorder, 0, UIManager.getColor("defaultBorderColor")) :
null);
}
private int getActualColumnRow(int origin, int divider, int total) {
return (origin == 0 || divider == 0) ? (int) Math.ceil((double) total / divider) : origin;
}
private void adjustButton(UIToggleButton labelButton, int index) {
if (labelButton.getText().length() > TEXT_LENGTH && currentButtonSize > BUTTON_SIZE) {
Dimension dimension = labelButton.getPreferredSize();
dimension.height <<= 1;
labelButton.setPreferredSize(dimension);
}
}
protected Border getGroupBorder() {
return new FineRoundBorder();
}
protected LayoutManager getGridLayout(int number) {
return new GridLayout(0, number, 0, 0);
}
@Override
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
FlatUIUtils.setRenderingHints(g2d);
int arc = UIManager.getInt("Button.group.arc");
g2d.clip(new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), arc, arc));
super.paint(g);
}
public void setAutoFireStateChanged(boolean autoFireStateChanged) {
this.autoFireStateChanged = autoFireStateChanged;
}
/**
* setSelectedItem
* 设置选择对象
*
* @param ob
* @param ob 选择对象
*/
public void setSelectedItem(T ob) {
if (objectList == null) {
@ -334,9 +305,9 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
}
/**
* getSelectedItem
* 获取选择对象
*
* @return
* @return 选择对象
*/
public T getSelectedItem() {
if (selectedIndex == -1) {
@ -348,12 +319,18 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
/**
* getSelectedIndex
*
* @return
* @return 获取选中序号
*/
public int getSelectedIndex() {
return selectedIndex;
}
/**
* 设置选中序号
*
* @param newSelectedIndex 选中序号
* @param fireChanged 是否联动事件
*/
public void setSelectedIndex(int newSelectedIndex, boolean fireChanged) {
if (selectedIndex != newSelectedIndex) {
selectedIndex = newSelectedIndex;
@ -369,7 +346,7 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
/**
* setSelectedIndex
*
* @param newSelectedIndex
* @param newSelectedIndex 选中序号
*/
public void setSelectedIndex(int newSelectedIndex) {
setSelectedIndex(newSelectedIndex, false);
@ -395,8 +372,8 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
/**
* getButton
*
* @param index
* @return
* @param index 序号
* @return 按钮
*/
public UIToggleButton getButton(int index) {
return labelButtonList.get(index);
@ -413,11 +390,8 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
}
}
/**
* 注册全局属性名字监听器
*
* @param listener 观察者监听事件
*/
public void registerNameListener(GlobalNameListener listener) {
globalNameListener = listener;
@ -425,8 +399,6 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
/**
* 是否响应名字监听事件
*
* @return
*/
public boolean shouldResponseNameListener() {
return true;
@ -442,76 +414,41 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
return true;
}
/**
* @param l
* @param l 监听器
*/
public void addChangeListener(ChangeListener l) {
listenerList.add(ChangeListener.class, l);
for (int i = 0; i < labelButtonList.size(); i++) {
labelButtonList.get(i).addChangeListener(l);
}
labelButtonList.forEach(b -> b.addChangeListener(l));
}
/**
* @param l
* @param l 监听器
*/
public void removeChangeListener(ChangeListener l) {
listenerList.remove(ChangeListener.class, l);
for (int i = 0; i < labelButtonList.size(); i++) {
labelButtonList.get(i).removeChangeListener(l);
}
labelButtonList.forEach(b -> b.removeChangeListener(l));
}
/**
* @param l
* @param l 监听器
*/
public void addActionListener(ActionListener l) {
for (int i = 0; i < labelButtonList.size(); i++) {
labelButtonList.get(i).addActionListener(l);
}
labelButtonList.forEach(b -> b.addActionListener(l));
}
/**
* @param l
* @param l 监听器
*/
public void removeActionListener(ActionListener l) {
for (int i = 0; i < labelButtonList.size(); i++) {
labelButtonList.get(i).removeActionListener(l);
}
labelButtonList.forEach(b -> b.removeActionListener(l));
}
/**
* populate
* populate 渲染
*/
public void populateBean() {
fireStateChanged();
}
/**
* main
*
* @param args
*/
public static void main(String... args) {
// JFrame jf = new JFrame("test");
// jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// JPanel content = (JPanel) jf.getContentPane();
// content.setLayout(new BorderLayout());
// Icon[] a1 = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"),
// BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png")};
// Integer[] a2 = new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT};
// UIButtonGroup<Integer> bb = new UIButtonGroup<Integer>(a1, a2);
// bb.setBounds(20, 20, bb.getPreferredSize().width, bb.getPreferredSize().height);
// bb.setSelectedIndex(0);
// bb.setEnabled(false);
// content.add(bb);
// GUICoreUtils.centerWindow(jf);
// jf.setSize(400, 400);
// jf.setVisible(true);
}
}

59
designer-base/src/main/java/com/fr/design/gui/ibutton/UITabGroup.java

@ -1,22 +1,15 @@
package com.fr.design.gui.ibutton;
import javax.swing.*;
import java.awt.*;
import javax.swing.Icon;
import java.util.Arrays;
/**
* 多行的Tab按钮组默认为2行
*/
public class UITabGroup extends UIButtonGroup<Integer> {
private boolean isOneLineTab = false;
private boolean isDrawLine = true;
private static final int BUTTON_NUMBER = 5;
private static final int SEVEN_NUMBER = 7;
/**
* 标签页改变
*
* @param index 序号
*/
public void tabChanged(int index) {
}
private static final int DEFAULT_ROW_COUNT = 2;
private static final int ROW_MAX_LIMIT = 4;
public UITabGroup(Icon[] iconArray) {
super(iconArray, new Integer[iconArray.length]);
@ -29,31 +22,29 @@ public class UITabGroup extends UIButtonGroup<Integer> {
}
@Override
protected LayoutManager getGridLayout(int number) {
if (number < BUTTON_NUMBER || isOneLineTab) {
return super.getGridLayout(number);
} else if (number == BUTTON_NUMBER || number == SEVEN_NUMBER) {
return new FiveButtonLayout(2);
} else {
return new GridLayout(2, 3, 0, 0);
}
}
public void setOneLineTab(boolean isOneLineTab) {
this.isOneLineTab = isOneLineTab;
public void setSelectedIndex(int newSelectedIndex, boolean fireChanged) {
super.setSelectedIndex(newSelectedIndex, false);
tabChanged(newSelectedIndex);
}
protected boolean isDrawLine() {
return isDrawLine;
}
public void tabChanged(int index) {
public void setDrawLine(boolean isDrawLine) {
this.isDrawLine = isDrawLine;
}
@Override
public void setSelectedIndex(int newSelectedIndex, boolean fireChanged) {
super.setSelectedIndex(newSelectedIndex, false);
tabChanged(newSelectedIndex);
protected int[] getCols() {
int buttons = labelButtonList.size();
if (buttons < ROW_MAX_LIMIT) {
return new int[]{buttons};
}
int[] cols = new int[DEFAULT_ROW_COUNT];
if (buttons % DEFAULT_ROW_COUNT == 0) {
Arrays.fill(cols, buttons / DEFAULT_ROW_COUNT);
} else {
Arrays.fill(cols, buttons / DEFAULT_ROW_COUNT + 1);
cols[cols.length - 1] = buttons % cols[0];
}
return cols;
}
}

5
designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java

@ -36,32 +36,27 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser
public UICheckBox(String string) {
super(string);
setUI(new UICheckBoxUI());
initListener();
}
public UICheckBox() {
super();
setUI(new UICheckBoxUI());
initListener();
}
public UICheckBox(String locText, boolean b) {
super(locText, b);
setUI(new UICheckBoxUI());
initListener();
}
public UICheckBox(String locText, boolean b, boolean markMnemonic) {
super(locText, b);
setUI(new UICheckBoxUI());
initListener();
this.markMnemonic = markMnemonic;
}
public UICheckBox(String text, Icon icon) {
super(text, icon);
setUI(new UICheckBoxUI());
initListener();
}

2
designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java

@ -42,8 +42,6 @@ public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> {
public CellStyleEditPane() {
super();
tabPane.setOneLineTab(true);
tabPane.setDrawLine(false);
tabPane.setLayout(new GridLayout(1, 3, 0, 0));
}

2
designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/TabbedPane.java

@ -46,8 +46,6 @@ public class TabbedPane extends JPanel {
cardLayout.show(tabContentPane, names[buttonGroup.getSelectedIndex()]);
}
};
buttonGroup.setDrawLine(true);
cardLayout = new CardLayout();
tabContentPane = new JPanel(cardLayout) {
@Override

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

@ -44,7 +44,7 @@
#---- UI delegates ----
ButtonUI = com.formdev.flatlaf.ui.FlatButtonUI
CheckBoxUI = com.formdev.flatlaf.ui.FlatCheckBoxUI
CheckBoxUI = com.fine.theme.light.ui.FineCheckBoxUI
CheckBoxMenuItemUI = com.formdev.flatlaf.ui.FlatCheckBoxMenuItemUI
ColorChooserUI = com.formdev.flatlaf.ui.FlatColorChooserUI
ComboBoxUI = com.fine.theme.light.ui.FineComboBoxUI
@ -188,7 +188,7 @@ tooltip.disabled=#A3ADBD
Button.border = com.formdev.flatlaf.ui.FlatButtonBorder
Button.arc = 6
Button.minimumWidth = 72
Button.margin = 2,14,2,14
Button.margin = 2,4,2,4
Button.iconTextGap = 4
Button.rollover = true
Button.defaultButtonFollowsFocus = false

68
designer-base/src/test/java/com/fr/design/gui/storybook/ButtonTabStoryBoard.java

@ -0,0 +1,68 @@
package com.fr.design.gui.storybook;
import com.fine.theme.icon.LazyIcon;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UITabGroup;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.theme.edit.ui.TabbedPane;
import com.fr.stable.ArrayUtils;
import javax.swing.*;
import static com.fine.swing.ui.layout.Layouts.*;
/**
* Tab按钮组
*
* @author Levy.Xie
* @since 11.0
* Created on 2023/12/14
*/
public class ButtonTabStoryBoard extends StoryBoard {
public ButtonTabStoryBoard() {
super("切换按钮组");
add(
cell(new UILabel("单行文字按钮")).with(it -> it.setFont(labelFont.deriveFont(14f))),
cell(new UIButtonGroup<>(new String[]{"按钮1", "按钮2", "按钮3"})),
cell(new UILabel("单行图标按钮")).with(it -> it.setFont(labelFont.deriveFont(14f))),
cell(new UIButtonGroup<>(iconArray())),
cell(new UILabel("选中切换图标按钮")).with(it -> it.setFont(labelFont.deriveFont(14f))),
cell(new UIButtonGroup<>(iconArrayWithWhite())),
cell(new UILabel("多行按钮-偶数场景-6按钮")).with(it -> it.setFont(labelFont.deriveFont(14f))),
cell(new UITabGroup(sixTextArray())),
cell(new UILabel("多行按钮-奇数场景-5按钮")).with(it -> it.setFont(labelFont.deriveFont(14f))),
cell(new UITabGroup(fiveTextArray())),
cell(new UILabel("多行按钮-奇数场景-7按钮")).with(it -> it.setFont(labelFont.deriveFont(14f))),
cell(new UITabGroup(sevenTextArray())),
flex()
);
}
private static Icon[] iconArray() {
return ArrayUtils.toArray(
new LazyIcon("edit"),
new LazyIcon("preview"),
new LazyIcon("connection")
);
}
private Icon[][] iconArrayWithWhite() {
return ArrayUtils.toArray(
ArrayUtils.toArray(new LazyIcon("edit"), new LazyIcon("copy")),
ArrayUtils.toArray(new LazyIcon("preview"), new LazyIcon("save"))
);
}
private String[] fiveTextArray() {
return ArrayUtils.toArray("按钮1", "按钮2", "按钮3", "按钮4", "按钮5");
}
private String[] sevenTextArray() {
return ArrayUtils.toArray("按钮1", "按钮2", "按钮3", "按钮4", "按钮5", "按钮6", "按钮7");
}
private String[] sixTextArray() {
return ArrayUtils.toArray("按钮1", "按钮2", "按钮3", "按钮4", "按钮5", "按钮6");
}
}

58
designer-base/src/test/java/com/fr/design/gui/storybook/CheckBoxStoryBoard.java

@ -0,0 +1,58 @@
package com.fr.design.gui.storybook;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import java.awt.*;
import static com.fine.swing.ui.layout.Layouts.*;
import static com.fine.swing.ui.layout.Layouts.row;
/**
* 复选按钮
*
* @author Levy.Xie
* @since 11.0
* Created on 2023/12/14
*/
public class CheckBoxStoryBoard extends StoryBoard {
public CheckBoxStoryBoard() {
super("复选按钮");
add(
cell(new UILabel("水平布局")).with(it -> it.setFont(labelFont.deriveFont(14f))),
row(10,
cell(new UICheckBox("测试1")),
cell(new UICheckBox("测试2")),
cell(new UICheckBox("测试3"))
),
fix(5),
cell(new UILabel("垂直布局")).with(it -> it.setFont(labelFont.deriveFont(14f))),
column(5,
cell(new UICheckBox("测试1")),
cell(new UICheckBox("测试2")),
cell(new UICheckBox("测试3"))
),
fix(5),
cell(new UILabel("禁用状态")).with(it -> it.setFont(labelFont.deriveFont(14f))),
row(10,
cell(getDisabledStatus(new UICheckBox("测试"))),
cell(getDisabledSelectedStatus(new UICheckBox("测试")))
),
flex()
);
}
private Component getDisabledStatus(UICheckBox c) {
c.setEnabled(false);
return c;
}
private Component getDisabledSelectedStatus(UICheckBox c) {
c.setSelected(true);
c.setEnabled(false);
return c;
}
}

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

@ -0,0 +1,43 @@
package com.fr.design.gui.storybook;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.stable.ArrayUtils;
import java.awt.*;
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/14
*/
public class ComboBoxStoryBoard extends StoryBoard {
public ComboBoxStoryBoard() {
super("下拉选择框");
add(
cell(new UILabel("普通状态")).with(it -> it.setFont(labelFont.deriveFont(14f))),
cell(new UIComboBox(
ArrayUtils.toArray("测试1", "测试2", "测试3", "测试4")
)),
cell(new UILabel("禁用状态")).with(it -> it.setFont(labelFont.deriveFont(14f))),
cell(getDisabledStatus()),
flex()
);
}
private Component getDisabledStatus() {
UIComboBox box = new UIComboBox(
ArrayUtils.toArray("测试1", "测试2", "测试3", "测试4")
);
box.setEnabled(false);
return box;
}
}

3
designer-base/src/test/java/com/fr/design/gui/storybook/Storybook.java

@ -92,6 +92,9 @@ public class Storybook {
components.add(new StoryBookComponent("HeadGroup", new UIHeadGroupStoryBoard()));
components.add(new StoryBookComponent("ToggleButton", new ToggleButtonStoryBoard()));
components.add(new StoryBookComponent("EastRegionContainer", new EastRegionContainer()));
components.add(new StoryBookComponent("ButtonTabGroup", new ButtonTabStoryBoard()));
components.add(new StoryBookComponent("CheckBox", new CheckBoxStoryBoard()));
components.add(new StoryBookComponent("ComboBox", new ComboBoxStoryBoard()));
return components.toArray(new StoryBookComponent[0]);
}

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

@ -32,7 +32,6 @@ public class VanChartCustomPlotUITabGroup extends UITabGroup{
super(textArray);
}
@Override
protected LayoutManager getGridLayout(int number) {
//这个地方可以顺便获取list个数
listNum = number;
@ -53,7 +52,7 @@ public class VanChartCustomPlotUITabGroup extends UITabGroup{
}
@Override
protected void initButton(UIToggleButton labelButton, int buttonIndex) {
protected void initButton(UIToggleButton labelButton) {
int ButtonWidth = WIDTH / 3;
if (listNum <= 1){

3
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java

@ -34,9 +34,6 @@ public class CustomStylePane extends MultiTabPane<Style> {
public CustomStylePane() {
super();
tabPane.setOneLineTab(true);
tabPane.setDrawLine(false);
tabPane.setLayout(new GridLayout(1, 3, 0, 0));
}
public static void main(String[] args) {

4
designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java

@ -99,10 +99,10 @@ public class ReportColumnsPane extends BasicPane{
onOffButtonGroup = new UIButtonGroup(textArray) {
@Override
protected void initButton(UIToggleButton labelButton, int index) {
protected void initButton(UIToggleButton labelButton) {
labelButton.setSize(new Dimension(60,20));
labelButton.setPreferredSize(new Dimension(60, 20));
super.initButton(labelButton, index);
super.initButton(labelButton);
}
};
onOffButtonGroup.addActionListener(onOffListener);

Loading…
Cancel
Save