diff --git a/build.gradle b/build.gradle index 4ebe9558d3..7201922fe8 100644 --- a/build.gradle +++ b/build.gradle @@ -90,7 +90,7 @@ allprojects { implementation 'com.github.weisj:jsvg:1.2.0' implementation 'com.formdev:flatlaf:3.4' implementation 'com.formdev:flatlaf-extras:3.4' - implementation 'com.fanruan.vito:gui-inspector:1.0.1' + implementation 'com.fanruan.vito:gui-inspector:1.0.2' implementation 'com.fine.swing.ui:layout:1.0-SNAPSHOT' testImplementation 'org.easymock:easymock:3.5.1' testImplementation 'org.powermock:powermock-module-junit4:1.7.1' diff --git a/designer-base/src/main/java/com/fine/theme/utils/FineLayoutBuilder.java b/designer-base/src/main/java/com/fine/theme/utils/FineLayoutBuilder.java new file mode 100644 index 0000000000..11d7137ec4 --- /dev/null +++ b/designer-base/src/main/java/com/fine/theme/utils/FineLayoutBuilder.java @@ -0,0 +1,155 @@ +package com.fine.theme.utils; + +import com.fine.swing.ui.layout.Column; +import com.fine.swing.ui.layout.Layouts; +import com.fine.swing.ui.layout.Row; +import com.fine.swing.ui.layout.Spacer; +import com.fr.design.foldablepane.UIExpandablePane; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.collections.combination.Pair; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import static com.fine.swing.ui.layout.Layouts.cell; + +/** + * 设计器典型布局构建器 + * + * @author Levy.Xie + * @since 11.0 + * Created on 2024/05/08 + */ +public class FineLayoutBuilder { + + /** + * 创建标准行列表格布局,行内元素均匀分布 + * + * @param elePerRow 每行元素数 + * @param rowSpacing 行内间距 + * @param colSpacing 列内间距 + * @param componentList 组件 + * @return 表格面板 + */ + public static Column createCommonTableLayout(int elePerRow, int rowSpacing, int colSpacing, List componentList) { + int rowNum = componentList.size() / elePerRow + 1; + Iterator iterator = componentList.iterator(); + + Column column = new Column(); + column.setSpacing(colSpacing); + + Row currentRow; + for (int i = 0; i < rowNum; i++) { + currentRow = new Row(); + currentRow.setSpacing(rowSpacing); + for (int j = 0; j < elePerRow; j++) { + Layouts.populate(currentRow, cell( + iterator.hasNext() ? iterator.next() : new Spacer(1) + ).weight(1)); + } + column.add(currentRow); + } + return column; + } + + /** + * 兼容TableLayout配置项,生成网格布局面板 + * + * @param colSpacing 间距 + * @param components 组件二维数组,内部每个一维数组均为行内组件,一维数组元素需与weight严格对应 + * @param weight 行内权重列表,形如[0.4,0.6] 即首个元素占比0.4,第二个元素占比0.6 + * @return 面板 + */ + public static JPanel compatibleTableLayout(int colSpacing, Component[][] components, double[] weight) { + Column column = new Column(); + column.setSpacing(colSpacing); + try { + for (Component[] componentArray : components) { + Row row = new Row(); + List visibleComponents = Arrays.stream(componentArray) + .filter(com -> com != null && com.isVisible()).collect(Collectors.toList()); + if (visibleComponents.size() >= 1) { + // 仅当存在可见组件时处理布局 + dealWithVisibleComponents(weight, column, componentArray, row, visibleComponents); + } + } + return asBorderLayoutWrapped(column); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, "[Designer] create layout failed."); + } + return new JPanel(); + } + + private static void dealWithVisibleComponents(double[] weight, Column column, Component[] value, Row row, List components) { + if (components.size() == 1 && value[0] != null) { + // 仅存在首个元素,则该元素自适应占满整行 + Layouts.populate(row, cell(components.get(0)).weight(1)); + } else { + // 其他场景,按权重分配布局,以适配原TableLayout形式 + for (int j = 0; j < value.length; j++) { + Component component = value[j]; + if (component == null) { + component = new Spacer(1); + } + Layouts.populate(row, cell(component).weight(weight[j])); + } + } + column.add(row); + } + + /** + * 创建竖向排列的扩展面板列表 + * + * @param spacing 间距 + * @param elements 面板元素,含标题、面板 + * @return 竖向排列面板 + */ + @SafeVarargs + public static Column createVerticalExpandPaneLayout(int spacing, Pair... elements) { + UIExpandablePane[] panes = IntStream.range(0, elements.length) + .mapToObj(i -> { + Pair pair = elements[i]; + if (i != elements.length - 1) { + return new UIExpandablePane(pair.getFirst(), pair.getSecond(), true); + } + return new UIExpandablePane(pair.getFirst(), pair.getSecond()); + }) + .toArray(UIExpandablePane[]::new); + return createVerticalLayout(spacing, panes); + } + + /** + * 创建垂直布局面板 + * + * @param spacing 间距 + * @param elements 面板元素 + * @return 面板 + */ + public static Column createVerticalLayout(int spacing, JPanel... elements) { + Column column = new Column(); + column.setSpacing(spacing); + for (JPanel element : elements) { + column.add(element); + } + return column; + } + + /** + * 组件包装于BorderLayout中 + * + * @param component 组件 + * @return 包装后的面板 + */ + public static JPanel asBorderLayoutWrapped(Component component) { + JPanel panel = new JPanel(new BorderLayout()); + panel.add(component); + return panel; + } + +} diff --git a/designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java b/designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java index 8fd013916b..4cf5637d94 100644 --- a/designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java +++ b/designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java @@ -31,6 +31,7 @@ public interface FineUIStyle { String LABEL_TIP = "tipLabel"; String PLAIN_BUTTON = "plainButton"; String TOGGLE_GROUP = "inToggleGroup"; + String COMPACT_BUTTON = "compactButton"; String MENU_TOOL_BAR = "menuToolBar"; String MENU_ITEM_TOOL_BAR = "menuItemToolBar"; diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index 093d3079f4..bfbc5c2347 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -1,5 +1,6 @@ package com.fr.design.actions.file; +import com.fine.theme.utils.FineLayoutBuilder; import com.fine.theme.utils.FineUIScale; import com.fine.theme.utils.FineUIStyle; import com.fine.theme.utils.FineUIUtils; @@ -15,7 +16,6 @@ import com.fr.design.dialog.DialogActionListener; import com.fr.design.editor.editor.IntegerEditor; import com.fr.design.file.SaveSomeTemplatePane; import com.fr.design.gui.frpane.FineTabbedPane; -import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIColorButton; import com.fr.design.gui.ibutton.UINoThemeColorButton; @@ -54,7 +54,6 @@ import com.fr.io.attr.ImageExportAttr; import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; import com.fr.report.ReportConfigManager; -import com.fr.stable.ArrayUtils; import com.fr.stable.Constants; import com.fr.stable.os.OperatingSystem; import com.fr.third.apache.logging.log4j.Level; @@ -299,7 +298,7 @@ public class PreferencePane extends BasicPane { // 启动页配置 cell(createStartupPagePane()) ).weight(1).getComponent(); - UIScrollPane generalScrollPane = patchScroll(generalPane); + JPanel generalScrollPane = patchScroll(FineLayoutBuilder.asBorderLayoutWrapped(generalPane)); // 高级面板 JPanel advancePane = column(SETTING_V_GAP, @@ -327,7 +326,7 @@ public class PreferencePane extends BasicPane { cell(createDesignerStartupPane()) ).weight(1).getComponent(); useUniverseDBMCheckbox = new UICheckBox(i18nText("Fine-Design_Basic_Use_Universe_Database_Manager")); - UIScrollPane adviceScrollPane = patchScroll(advancePane); + JPanel adviceScrollPane = patchScroll(advancePane); // 版本管理面板 //初始化vcs总面板 @@ -339,7 +338,7 @@ public class PreferencePane extends BasicPane { // vcsPane createVcsSettingPane(vcsPane, vcsParentPane, cardLayout); //添加滚动条 - UIScrollPane vcsScrollPane = patchScroll(vcsPane); + JPanel vcsScrollPane = patchScroll(vcsPane); //配置面板作为vcs总面板的一张卡片 vcsParentPane.add(vcsScrollPane, VcsMovePanel.SETTING); @@ -428,10 +427,10 @@ public class PreferencePane extends BasicPane { } @NotNull - private UIScrollPane patchScroll(JPanel generalPane) { + private JPanel patchScroll(JPanel generalPane) { UIScrollPane uiScrollPane = new UIScrollPane(generalPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); uiScrollPane.setBorder(new ScaledEmptyBorder(10, 10, 10, 10)); - return uiScrollPane; + return FineLayoutBuilder.asBorderLayoutWrapped(uiScrollPane); } private void createVcsSettingPane(JPanel generalPane, JPanel parentPane, CardLayout cardLayout) { diff --git a/designer-base/src/main/java/com/fr/design/actions/help/AboutDialog.java b/designer-base/src/main/java/com/fr/design/actions/help/AboutDialog.java index 121d9ece9c..4d55af0306 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/AboutDialog.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/AboutDialog.java @@ -2,7 +2,7 @@ package com.fr.design.actions.help; import com.fine.theme.utils.FineUIScale; import com.fine.theme.utils.FineUIStyle; -import com.fr.design.gui.frpane.UITabbedPane; +import com.fr.design.gui.frpane.FineTabbedPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; @@ -46,11 +46,12 @@ public class AboutDialog extends JDialog implements ActionListener { FineUIStyle.setStyle(okButton, FineUIStyle.STYLE_PRIMARY); okButton.addActionListener(this); - tabbedPane = new UITabbedPane(); sysPane = new SystemInfoPane(); - tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_About"), aboutPanel); - tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("FIne-Design_Basic_System"), sysPane); + tabbedPane = FineTabbedPane.builder() + .addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_About"), aboutPanel) + .addTab(com.fr.design.i18n.Toolkit.i18nText("FIne-Design_Basic_System"), sysPane) + .build(); buttonPanel = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); buttonPanel.add(okButton); @@ -79,7 +80,7 @@ public class AboutDialog extends JDialog implements ActionListener { this.getRootPane().setDefaultButton(okButton); - this.setSize(FineUIScale.scale(new Dimension(defaultPane.getPreferredSize().width, 600))); + this.setSize(FineUIScale.scale(new Dimension(defaultPane.getPreferredSize().width, 620))); GUICoreUtils.centerWindow(this); } @@ -96,6 +97,6 @@ public class AboutDialog extends JDialog implements ActionListener { private SystemInfoPane sysPane; private JPanel buttonPanel; - private UITabbedPane tabbedPane; + private FineTabbedPane tabbedPane; private UIButton okButton; } diff --git a/designer-base/src/main/java/com/fr/design/condition/LiteConditionPane.java b/designer-base/src/main/java/com/fr/design/condition/LiteConditionPane.java index a6dc6aa107..22e71aef4e 100644 --- a/designer-base/src/main/java/com/fr/design/condition/LiteConditionPane.java +++ b/designer-base/src/main/java/com/fr/design/condition/LiteConditionPane.java @@ -435,7 +435,7 @@ public abstract class LiteConditionPane extends BasicBeanPa JPanel buttonPane = initButtonPane(); JScrollPane treeScrollPane = iniTreeScrollPane(); // 滚动面板不能直接加入row-col布局,需设定宽高 - treeScrollPane.setPreferredSize(FineUIScale.scale(new Dimension(600, 250))); + treeScrollPane.setPreferredSize(FineUIScale.scale(new Dimension(600, 240))); JPanel previewPane = column( cell(northButtonPane), row( @@ -571,8 +571,8 @@ public abstract class LiteConditionPane extends BasicBeanPa row(5, cell(andRadioButton).weight(0.5), cell(orRadioButton).weight(0.5) - ).weight(0.25), - flex(0.5), + ).weight(0.35), + flex(0.4), row(5, cell(addButton).weight(0.5), cell(modifyButton).weight(0.5) diff --git a/designer-base/src/main/java/com/fr/design/foldablepane/UIExpandablePane.java b/designer-base/src/main/java/com/fr/design/foldablepane/UIExpandablePane.java index 2432915650..140aa74c83 100644 --- a/designer-base/src/main/java/com/fr/design/foldablepane/UIExpandablePane.java +++ b/designer-base/src/main/java/com/fr/design/foldablepane/UIExpandablePane.java @@ -1,12 +1,19 @@ package com.fr.design.foldablepane; +import com.formdev.flatlaf.util.ScaledEmptyBorder; +import com.fr.design.border.FineBorderFactory; + import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Color; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.column; +import static com.fine.swing.ui.layout.Layouts.fix; + /** * Created by MoMeak on 2017/7/5. @@ -31,18 +38,22 @@ public class UIExpandablePane extends JPanel { this.headWidth = headWidth; this.headHeight = headHeight; this.contentPanel = contentPanel; - initComponents(); + initComponents(false); } public UIExpandablePane(String title, JPanel contentPanel) { + this(title, contentPanel, false); + } + + public UIExpandablePane(String title, JPanel contentPanel, boolean withUnderline) { super(); this.title = title; this.headHeight = headHeight; this.contentPanel = contentPanel; - initComponents(); + initComponents(withUnderline); } - private void initComponents() { + private void initComponents(boolean withUnderline) { this.setLayout(new BorderLayout()); headerPanel = new HeaderPane(title); @@ -50,6 +61,15 @@ public class UIExpandablePane extends JPanel { setcontentPanelontentPanelBorder(); this.add(headerPanel, BorderLayout.NORTH); this.add(contentPanel, BorderLayout.CENTER); + if (withUnderline) { + this.add(column( + cell(headerPanel), cell(contentPanel).with(it -> it.setBorder(new ScaledEmptyBorder(0, 0, 10, 0))), + fix(1).with(it -> it.setBorder(FineBorderFactory.createDefaultUnderlineBorder()))) + .getComponent()); + } else { + this.add(column(cell(headerPanel), cell(contentPanel)).getComponent()); + } + setOpaque(false); } diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/FineTabbedPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/FineTabbedPane.java index 54b01f2d48..9fd7620c7f 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/FineTabbedPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/FineTabbedPane.java @@ -5,6 +5,7 @@ import com.fine.theme.utils.FineUIStyle; import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.design.gui.ibutton.UIButtonGroup; +import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.event.ChangeListener; import java.awt.BorderLayout; @@ -32,9 +33,9 @@ public class FineTabbedPane extends Column { private JPanel centerPane; private final float headRatio; private final UIButtonGroup tabGroup; - private final Map tabComponents; + private final Map tabComponents; - private FineTabbedPane(Map tabComponents, float headRatio, int[] tabLayout) { + private FineTabbedPane(Map tabComponents, float headRatio, int[] tabLayout) { this.headRatio = headRatio; this.tabComponents = tabComponents; @@ -60,7 +61,7 @@ public class FineTabbedPane extends Column { public static class TabPaneBuilder { private int[] tabLayout; private float headRatio = 0.5f; - private final Map tabComponents = new LinkedHashMap<>(); + private final Map tabComponents = new LinkedHashMap<>(); /** * 设置头部居中比例,0-1之间 @@ -117,14 +118,17 @@ public class FineTabbedPane extends Column { private void initLayout() { cards = new CardLayout(); centerPane = new JPanel(cards); - tabComponents.forEach((key, value) -> centerPane.add(value, key)); + tabComponents.forEach((key, value) -> { + value.setOpaque(false); + centerPane.add(value, key); + }); float flexRatio = (1 - headRatio) / 2; add( row( flex(flexRatio), cell(tabGroup).weight(headRatio), flex(flexRatio) ), fix(5), - cell(centerPane).with(it -> FineUIStyle.setStyle(it, FineUIStyle.LIGHT_GREY)) + cell(centerPane).weight(1).with(it -> FineUIStyle.setStyle(it, FineUIStyle.LIGHT_GREY)) ); setBorder(new ScaledEmptyBorder(10, 10, 10, 10)); } diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/UICorrelationComboBoxPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/UICorrelationComboBoxPane.java index 79dece5057..ac94b82499 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/UICorrelationComboBoxPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/UICorrelationComboBoxPane.java @@ -1,8 +1,7 @@ package com.fr.design.gui.frpane; -import com.fr.base.BaseUtils; +import com.fine.theme.icon.LazyIcon; import com.fr.design.beans.BasicBeanPane; -import com.fr.design.constants.UIConstants; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionListener; import com.fr.design.dialog.UIDialog; @@ -225,9 +224,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver { } protected void initAddButton() { - addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); - addButton.setBorderType(UIButton.OTHER_BORDER); - addButton.setOtherBorder(UIConstants.BS, UIConstants.LINE_COLOR); + addButton = new UIButton(new LazyIcon("add")); } private void initAddButtonListener() { diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/UICorrelationPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/UICorrelationPane.java index 3a23a478c3..dde2337196 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/UICorrelationPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/UICorrelationPane.java @@ -19,7 +19,7 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.table.TableCellEditor; -import com.fr.base.BaseUtils; +import com.fine.theme.icon.LazyIcon; import com.fr.design.constants.UIConstants; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; @@ -212,7 +212,7 @@ public class UICorrelationPane extends JPanel implements UIObserver { } protected void initAddButton() { - addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")) { + addButton = new UIButton(new LazyIcon("add")) { public boolean shouldResponseChangeListener() { return false; } diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxRenderer.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxRenderer.java index 0903070dc0..07cb941293 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxRenderer.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxRenderer.java @@ -36,7 +36,6 @@ public class UIComboBoxRenderer extends DefaultListCellRenderer { renderer.setForeground(list.getForeground()); renderer.setBackground(list.getBackground()); } - renderer.setText(" " + renderer.getText()); return renderer; } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java b/designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java index 2485b4de4e..d26cf47e61 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java @@ -1,7 +1,10 @@ package com.fr.design.gui.style; +import com.fine.theme.utils.FineLayoutBuilder; +import com.fine.theme.utils.FineUIScale; +import com.fine.theme.utils.FineUIStyle; +import com.fine.theme.utils.FineUIUtils; import com.fr.base.CoreDecimalFormat; -import com.fr.base.GraphHelper; import com.fr.base.Style; import com.fr.base.TextFormat; import com.fr.data.core.FormatField; @@ -10,7 +13,6 @@ import com.fr.design.event.UIObserverListener; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.i18n.Toolkit; import com.fr.design.border.UIRoundedBorder; -import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.UIConstants; import com.fr.design.event.GlobalNameListener; import com.fr.design.event.GlobalNameObserver; @@ -18,26 +20,19 @@ import com.fr.design.gui.icombobox.TextFontComboBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; import com.fr.general.ComparatorUtils; import com.fr.stable.StringUtils; import java.awt.BorderLayout; -import java.awt.CardLayout; import java.awt.Color; import java.awt.Component; -import java.awt.Dimension; -import java.awt.FontMetrics; -import java.awt.Graphics; import java.math.RoundingMode; import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.SwingConstants; -import javax.swing.UIManager; import javax.swing.border.Border; import javax.swing.border.TitledBorder; import java.awt.event.ItemEvent; @@ -53,13 +48,7 @@ import java.text.SimpleDateFormat; */ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObserver { private static final long serialVersionUID = 724330854437726751L; - - private static final int LABEL_X = 4; - private static final int LABEL_Y = 18; - private static final int LABEL_DELTA_WIDTH = 8; - private static final int LABEL_HEIGHT = 15; //标签背景的范围 private static final int CURRENCY_FLAG_POINT = 6; - private static final Border LEFT_BORDER = BorderFactory.createEmptyBorder(0, 30, 0, 0); private static final Integer[] TYPES = new Integer[]{ FormatContents.NULL, FormatContents.NUMBER, @@ -85,6 +74,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObse private boolean isRightFormat; private boolean isDate = false; private GlobalNameListener globalNameListener = null; + private JPanel self = this; /** * Constructor. @@ -98,14 +88,10 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObse } protected void initComponents(Integer[] types) { - this.setLayout(new BorderLayout(0, 4)); + this.setLayout(new BorderLayout()); initSampleLabel(); - contentPane = new JPanel(new BorderLayout(0, 4)) { - @Override - public Dimension getPreferredSize() { - return new Dimension(super.getPreferredSize().width, 65); - } - }; + contentPane = new JPanel(); + contentPane.setLayout(new BorderLayout(0, FineUIScale.scale(10))); typeComboBox = new UIComboBox(types); UIComboBoxRenderer render = createComBoxRender(); typeComboBox.setRenderer(render); @@ -113,7 +99,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObse typeComboBox.setGlobalName("typeComboBox"); contentPane.add(sampleLabel, BorderLayout.NORTH); - txtCenterPane = new JPanel(new BorderLayout()); + txtCenterPane = new JPanel(new BorderLayout(0, FineUIScale.scale(10))); textField = new TextFontComboBox(); textField.addItemListener(textFieldItemListener); textField.setEditable(true); @@ -122,58 +108,38 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObse contentPane.add(txtCenterPane, BorderLayout.CENTER); - centerPane = new JPanel(new CardLayout()); - centerPane.add(new JPanel(), "hide"); - centerPane.setPreferredSize(new Dimension(0, 0)); - centerPane.add(contentPane, "show"); - + centerPane = new JPanel(new BorderLayout()); + centerPane.add(contentPane); frFontPane = new FRFontPane(); UILabel font = new UILabel(Toolkit.i18nText("Fine-Design_Form_FR_Font"), SwingConstants.LEFT); JPanel fontPane = new JPanel(new BorderLayout()); fontPane.add(font, BorderLayout.NORTH); - typeComboBox.setPreferredSize(new Dimension(155,20)); JPanel typePane = new JPanel(new BorderLayout()); typePane.add(typeComboBox, BorderLayout.CENTER); - typePane.setBorder(LEFT_BORDER); -// centerPane.setBorder(LEFT_BORDER); - frFontPane.setBorder(LEFT_BORDER); JPanel option = new JPanel(new BorderLayout()); option.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Option"), SwingConstants.LEFT), BorderLayout.WEST); roundingBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Base_Option_Half_Up")); - roundingBox.setBorder(BorderFactory.createEmptyBorder(0, 40, 0, 0)); - roundingBox.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - } - }); roundingBox.setGlobalName("roundingBox"); option.add(roundingBox, BorderLayout.CENTER); - optionPane = new JPanel(new CardLayout()); - optionPane.add(new JPanel(), "hide"); - optionPane.setPreferredSize(new Dimension(0, 0)); - optionPane.add(option, "show"); + optionPane = new JPanel(new BorderLayout()); + optionPane.add(option); Component[][] components = getComponent(fontPane, centerPane, typePane); this.add(createContentPane(components), BorderLayout.CENTER); } protected JPanel createContentPane (Component[][] components) { - double f = TableLayout.FILL; - double p = TableLayout.PREFERRED; - double[] rowSize = {p, p, p, p, p}; - double[] columnSize = {p, f}; - int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; - return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_MEDIUM); + return FineLayoutBuilder.compatibleTableLayout(10, components, new double[]{1.2, 3}); } protected Component[][] getComponent (JPanel fontPane, JPanel centerPane, JPanel typePane) { return new Component[][]{ new Component[]{null, null}, - new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Format"), SwingConstants.LEFT), typePane}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Format")), typePane}, new Component[]{centerPane, null}, new Component[]{optionPane, null}, new Component[]{fontPane, frFontPane}, @@ -194,41 +160,17 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObse } private void initSampleLabel() { + Color labelColor = FineUIUtils.getUIColor("Label.tipColor", "inactiveCaption"); Border interBorder = new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 4); String title = Toolkit.i18nText("Fine-Design_Report_Base_StyleFormat_Sample"); - Border border = BorderFactory.createTitledBorder(interBorder, title, TitledBorder.LEFT, 0, null, UIConstants.LINE_COLOR); - sampleLabel = new UILabel(FormatField.getInstance().getFormatValue()) { - - @Override - public void paint(Graphics g) { - super.paint(g); - int width = getWidth(); - Color original = g.getColor(); - g.setColor(getBackground()); - g.fillRect(LABEL_X, LABEL_Y, width - LABEL_DELTA_WIDTH, LABEL_HEIGHT); - g.setColor(UIConstants.LINE_COLOR); - FontMetrics cellFM = g.getFontMetrics(); - int textWidth = cellFM.stringWidth(getText()); - GraphHelper.drawString(g, getText(), (width - textWidth) / 2, 26); - g.setColor(original); - } - }; + Border border = BorderFactory.createTitledBorder(interBorder, title, TitledBorder.LEFT, 0, null, labelColor); + sampleLabel = new UILabel(FormatField.getInstance().getFormatValue()); sampleLabel.setHorizontalAlignment(UILabel.CENTER); sampleLabel.setBorder(border); + FineUIStyle.setStyle(sampleLabel, FineUIStyle.LABEL_TIP); } - @Override - /** - * 得到合适的大小 - */ - public Dimension getPreferredSize() { - if (this.typeComboBox.getSelectedIndex() == FormatContents.NULL) { - return typeComboBox.getPreferredSize(); - } - return super.getPreferredSize(); - } - /** * 弹出框标题 * @@ -340,7 +282,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObse */ private void refreshPreviewLabel() { this.sampleLabel.setText(FormatField.getInstance().getFormatValue()); - this.sampleLabel.setForeground(UIManager.getColor("Label.foreground")); + FineUIStyle.setStyle(sampleLabel, FineUIStyle.LABEL_TIP); try { isRightFormat = true; if (StringUtils.isEmpty(String.valueOf(textField.getSelectedItem()))) { @@ -369,38 +311,30 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObse if (e.getStateChange() == ItemEvent.SELECTED) { int contents = getFormatContents(); String[] items = FormatField.getInstance().getFormatArray(contents, false); - CardLayout cardLayout = (CardLayout) centerPane.getLayout(); if (isTextOrNull()) { - centerPane.setPreferredSize(new Dimension(0, 0)); - cardLayout.show(centerPane, "hide"); + centerPane.setVisible(false); } else { textField.removeAllItems(); textField.setItemArray(items); textField.setSelectedIndex(0); - centerPane.setPreferredSize(new Dimension(270, 65)); - cardLayout.show(centerPane, "show"); + centerPane.setVisible(true); } - CardLayout optionLayout = ((CardLayout) optionPane.getLayout()); if (getFormatContents() == FormatContents.PERCENT) { - optionPane.setPreferredSize(new Dimension(100, 20)); - optionLayout.show(optionPane, "show"); + optionPane.setVisible(true); } else { - optionPane.setPreferredSize(new Dimension(0, 0)); - optionLayout.show(optionPane, "hide"); + optionPane.setVisible(false); roundingBox.setSelected(false); } + self.repaint(); } } }; - ItemListener textFieldItemListener = new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) { - refreshPreviewLabel(); - } + ItemListener textFieldItemListener = e -> { + if (e.getStateChange() == ItemEvent.SELECTED) { + refreshPreviewLabel(); } }; diff --git a/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties b/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties index 51042cb0b2..d20add6df5 100644 --- a/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties +++ b/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties @@ -1310,4 +1310,7 @@ CellOtherSetPane.height=$Component.defaultHeight background: null; \ hoverBackground : null; \ selectedBackground : null; \ - pressedBackground : null \ No newline at end of file + pressedBackground : null + +[style]ToggleButton.compactButton = \ + margin: 2,0,2,0 \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java index 297245960d..0949b792a4 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java @@ -4,6 +4,7 @@ package com.fr.design.mainframe; +import com.fine.theme.utils.FineUIScale; import com.fr.base.BaseUtils; import com.fr.base.chart.BaseChartCollection; import com.fr.chart.chartattr.ChartCollection; @@ -21,8 +22,7 @@ import com.fr.design.utils.gui.GUICoreUtils; import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.SwingWorker; -import java.awt.BorderLayout; -import java.awt.Component; +import java.awt.*; public class ChartPropertyPane extends BaseChartPropertyPane { @@ -44,6 +44,8 @@ public class ChartPropertyPane extends BaseChartPropertyPane { protected void initComponent() { this.setLayout(new BorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + // 外部轮廓大小固定,适配滚动面板 + this.setPreferredSize(FineUIScale.scale(new Dimension(getWidth(), 900))); } @Override diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/AbstractChartAttrPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/AbstractChartAttrPane.java index c3beef7570..e3dff4837a 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/AbstractChartAttrPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/AbstractChartAttrPane.java @@ -4,8 +4,7 @@ package com.fr.design.mainframe.chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; -import javax.swing.*; -import java.awt.*; +import java.awt.BorderLayout; public abstract class AbstractChartAttrPane extends AbstractAttrNoScrollPane { public abstract void populate(ChartCollection collection); @@ -30,7 +29,6 @@ public abstract class AbstractChartAttrPane extends AbstractAttrNoScrollPane { protected void initContentPane() { leftContentPane = createContentPane(); - leftContentPane.setBorder(BorderFactory.createMatteBorder(10, 0, 0, 0, original)); this.add(leftContentPane, BorderLayout.CENTER); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java index 8b1c293282..5261223840 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java @@ -1,5 +1,8 @@ package com.fr.design.mainframe.chart.gui; +import com.fine.theme.icon.LazyIcon; +import com.fine.theme.utils.FineLayoutBuilder; +import com.fine.theme.utils.FineUIStyle; import com.fr.base.BaseUtils; import com.fr.chart.base.AttrChangeConfig; import com.fr.chart.chartattr.ChartCollection; @@ -24,15 +27,12 @@ import com.fr.plugin.chart.vanchart.VanChart; import com.fr.stable.StringUtils; import com.fr.van.chart.config.DefaultStyleHelper4Van; -import javax.swing.BorderFactory; -import javax.swing.BoxLayout; import javax.swing.JPanel; import javax.swing.SwingUtilities; import java.awt.BorderLayout; +import java.awt.Component; import java.awt.Dimension; -import java.awt.FlowLayout; import java.awt.Graphics; -import java.awt.GridLayout; import java.awt.Image; import java.awt.Rectangle; import java.awt.event.ActionEvent; @@ -46,7 +46,15 @@ import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.HashSet; +import java.util.List; import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.column; +import static com.fine.swing.ui.layout.Layouts.flex; +import static com.fine.swing.ui.layout.Layouts.row; /** * 图表 类型 增删 控制按钮界面. @@ -103,38 +111,32 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen this.setLayout(new BorderLayout()); initButton(); - buttonPane = new JPanel(); - this.add(buttonPane, BorderLayout.CENTER); - - JPanel northPane = new JPanel(); - this.add(northPane, BorderLayout.NORTH); - - northPane.setLayout(new BorderLayout()); - northPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); - - JPanel button = new JPanel(); - button.setPreferredSize(new Dimension(89, 20)); - button.setLayout(new GridLayout(1, 4, 3, 0)); - button.add(addButton); - button.add(copyButton); - button.add(moveForwardButton); - button.add(moveBackButton); - northPane.add(button, BorderLayout.WEST); - northPane.add(configButton, BorderLayout.EAST); + buttonPane = new JPanel(new BorderLayout()); + this.add(column(10, + row(5, + cell(addButton).weight(0.5), + cell(copyButton).weight(0.5), + cell(moveForwardButton).weight(0.5), + cell(moveBackButton).weight(0.5), + flex(2), + cell(configButton).weight(0.5) + ), + cell(buttonPane) + ).getComponent() + ); initConfigCreator(); - // Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); } private void initButton() { - addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); - configButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/config.png")); - copyButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/m_edit/copy.png")); + addButton = new UIButton(new LazyIcon("add")); + configButton = new UIButton(new LazyIcon("tool_config")); + copyButton = new UIButton(new LazyIcon("tool_copy")); copyButton.setToolTipText(Toolkit.i18nText("Fine-Design_Basic_Action_Copy")); - moveForwardButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/control/left.png")); + moveForwardButton = new UIButton(new LazyIcon("move_left")); moveForwardButton.setToolTipText(Toolkit.i18nText("Fine-Design_Report_HF_Move_Left")); - moveBackButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/control/right.png")); + moveBackButton = new UIButton(new LazyIcon("move_right")); moveBackButton.setToolTipText(Toolkit.i18nText("Fine-Design_Report_HF_Move_Right")); initAddButton(); initConfigButton(); @@ -151,7 +153,6 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen } private void initAddButton() { - addButton.setPreferredSize(new Dimension(20, 20)); addButton.addActionListener((e) -> { String name = getNewChartName(); ChartProvider chart = getChangeStateNewChart(); @@ -168,12 +169,10 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen } private void initConfigButton() { - configButton.setPreferredSize(new Dimension(20, 20)); configButton.addActionListener((e) -> showConfigDialog()); } private void initCopyButton() { - copyButton.setPreferredSize(new Dimension(20, 20)); copyButton.addActionListener((e) -> { String name = getCopyChartName(); ChartProvider chart = getCopyChart(); @@ -182,8 +181,6 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen } private void initMoveButton() { - moveForwardButton.setPreferredSize(new Dimension(20, 20)); - moveBackButton.setPreferredSize(new Dimension(20, 20)); moveForwardButton.addActionListener((e) -> moveForwardChart()); moveBackButton.addActionListener((e) -> moveBackChart()); } @@ -335,18 +332,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen return; } northPane.removeAll(); - northPane.setLayout(new BoxLayout(northPane, BoxLayout.Y_AXIS)); - - JPanel pane = null; - for (int i = 0; i < indexList.size(); i++) { - if (i % COL_COUNT == 0) { - pane = new JPanel(new FlowLayout(FlowLayout.LEFT)); - northPane.add(pane); - } - - pane.add(indexList.get(i)); - } - + northPane.add(FineLayoutBuilder.createCommonTableLayout(COL_COUNT, 10, 10, indexList)); this.revalidate(); } @@ -355,22 +341,12 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen return; } northPane.removeAll(); - northPane.setLayout(new BoxLayout(northPane, BoxLayout.Y_AXIS)); - - JPanel pane = null; - - for (int i = 0; i < indexList.size(); i++) { - if (i % COL_COUNT == 0) { - pane = new JPanel(new FlowLayout(FlowLayout.LEFT)); - northPane.add(pane); - } - if (i != index) { - pane.add(indexList.get(i)); - } else { - pane.add(currentEditingEditor); - } - } + List components = IntStream.range(0, indexList.size()) + .mapToObj(i -> i == index ? currentEditingEditor : indexList.get(i)) + .collect(Collectors.toList()); + northPane.add(FineLayoutBuilder.createCommonTableLayout(COL_COUNT, 10, 10, components)); this.revalidate(); + } /** @@ -518,6 +494,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen } } }); + FineUIStyle.setStyle(this, FineUIStyle.COMPACT_BUTTON); } public String getButtonName() { @@ -530,10 +507,6 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen buttonName = name; } - public Dimension getPreferredSize() { - return new Dimension(B_W, B_H); - } - private void paintDeleteButton(Graphics g2d) { Rectangle2D bounds = this.getBounds(); diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java index bd94ff561a..8505b81e93 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java @@ -1,5 +1,7 @@ package com.fr.design.mainframe.chart.gui; +import com.fine.theme.utils.FineUIScale; +import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.chartx.attr.ChartProvider; @@ -58,8 +60,8 @@ public class ChartTypePane extends AbstractChartAttrPane { @Override protected JPanel createContentPane() { initButtonListener(); - JPanel content = new JPanel(new BorderLayout()); - + JPanel content = new JPanel(new BorderLayout(0, FineUIScale.scale(10))); + content.setBorder(new ScaledEmptyBorder(10, 0, 0, 0)); buttonPane = new ChartTypeButtonPane(this); buttonPane.refreshChartInForm(inForm); content.add(buttonPane, BorderLayout.NORTH); diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/ChartDataFilterPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/ChartDataFilterPane.java index c24a192441..4dcf5193ec 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/ChartDataFilterPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/ChartDataFilterPane.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.chart.gui.data; +import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.base.Utils; import com.fr.base.chart.chartdata.TopDefinitionProvider; import com.fr.chart.chartattr.ChartCollection; @@ -10,23 +11,20 @@ import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.TableLayout; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.style.AbstractChartTabPane; import com.fr.design.mainframe.chart.gui.style.ThirdTabPane; import com.fr.stable.StringUtils; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; -import javax.swing.BorderFactory; import javax.swing.JPanel; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import java.util.ArrayList; import java.util.List; import java.awt.BorderLayout; -import java.awt.Component; import java.awt.Dimension; -import java.awt.FlowLayout; + +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.column; +import static com.fine.swing.ui.layout.Layouts.row; /** * 图表数据 分类 系列 过滤界面. @@ -57,20 +55,15 @@ public class ChartDataFilterPane extends ThirdTabPane { protected void initTabPane() { super.initTabPane(); - tabPane.setPreferredSize(new Dimension(221, 25)); } protected void initLayout() { this.setLayout(new BorderLayout()); if (!paneList.isEmpty()) { - JPanel pane = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0)); if (nameArray.length > 1) { - pane.add(tabPane); - this.add(pane, BorderLayout.NORTH); - centerPane.setBorder(BorderFactory.createEmptyBorder(10,0,0,0)); + this.add(tabPane, BorderLayout.NORTH); } - centerPane.setBorder(null); } this.add(centerPane, BorderLayout.CENTER); } @@ -129,8 +122,6 @@ public class ChartDataFilterPane extends ThirdTabPane { this.removeAll(); paneList = initPaneList4NoPresent(plot4Pane, parentPane); initAllPane(); - tabPane.setPreferredSize(new Dimension(221, 25)); - centerPane.setPreferredSize(new Dimension(getContentPaneWidth(), 200)); this.validate(); } @@ -213,19 +204,10 @@ public class ChartDataFilterPane extends ThirdTabPane { protected void layoutContentPane() { super.layoutContentPane(); - leftcontentPane.setBorder(BorderFactory.createEmptyBorder()); } public void reloaPane(JPanel pane){ super.reloaPane(pane); - leftcontentPane.setBorder(BorderFactory.createEmptyBorder()); - } - - @Override - public Dimension getPreferredSize() { - Dimension dim = super.getPreferredSize(); - dim.height = FIL_HEIGHT; - return dim; } @Override @@ -238,51 +220,37 @@ public class ChartDataFilterPane extends ThirdTabPane { protected JPanel initOtherPane() { onlyPreData = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Only_Use_Before_Records")); - JPanel panel1 = new JPanel(new BorderLayout()); - JPanel panel2 = new JPanel(new BorderLayout()); - panel1.add(onlyPreData, BorderLayout.NORTH); preDataNum = new UITextField(); UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Records_Num")); combineOther = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Data_CombineOther")); combineOther.setSelected(true); - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {p,f}; - double[] rowSize = {p, p}; - Component[][] components = new Component[][]{ - new Component[]{label,preDataNum}, - new Component[]{combineOther,null} - }; - - preDataNumPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); - preDataNumPane.setBorder(BorderFactory.createEmptyBorder(10,15,0,0)); //默认不显示 + preDataNumPane = column(10, + row(cell(label).weight(1.2), cell(preDataNum).weight(3)), + cell(combineOther) + ).getComponent(); preDataNumPane.setVisible(false); - panel1.add(preDataNumPane, BorderLayout.CENTER); notShowNull = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Data_Not_Show_Cate")); - panel2.add(notShowNull, BorderLayout.NORTH); - onlyPreData.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - checkBoxUse(); - } - }); + onlyPreData.addChangeListener(e -> checkBoxUse()); present = new PresentComboBox() { protected void fireChange() { fire(); } }; - presentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Style_Present") ,present); - panel2.add(presentPane, BorderLayout.SOUTH); - - double[] column = {f}; - double[] row = {p, p}; - Component[][] coms = new Component[][]{ - new Component[]{panel1}, - new Component[]{panel2} - }; - return TableLayout4VanChartHelper.createGapTableLayoutPane(coms, row,column); + presentPane = row( + cell( + new UILabel(Toolkit.i18nText("Fine-Design_Chart_Style_Present")) + ).weight(1.2), cell(present).weight(3) + ).getComponent(); + + return column(10, + cell(onlyPreData), + cell(preDataNumPane), + cell(notShowNull), + cell(presentPane) + ).with(it -> it.setBorder(new ScaledEmptyBorder(10, 0, 0, 0))).getComponent(); } @@ -394,12 +362,10 @@ public class ChartDataFilterPane extends ThirdTabPane { protected void layoutContentPane() { super.layoutContentPane(); - leftcontentPane.setBorder(BorderFactory.createEmptyBorder()); } public void reloaPane(JPanel pane){ super.reloaPane(pane); - leftcontentPane.setBorder(BorderFactory.createEmptyBorder()); } @Override @@ -413,51 +379,37 @@ public class ChartDataFilterPane extends ThirdTabPane { protected JPanel initOtherPane() { onlyPreData = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Only_Use_Before_Records")); - JPanel panel1 = new JPanel(new BorderLayout()); - JPanel panel2 = new JPanel(new BorderLayout()); - panel1.add(onlyPreData, BorderLayout.NORTH); preDataNum = new UITextField(); UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Records_Num")); combineOther = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Data_CombineOther")); combineOther.setSelected(true); - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {p,f}; - double[] rowSize = {p, p}; - Component[][] components = new Component[][]{ - new Component[]{label,preDataNum}, - new Component[]{combineOther,null} - }; - - preDataNumPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); - preDataNumPane.setBorder(BorderFactory.createEmptyBorder(10,15,0,0)); //默认不显示 + preDataNumPane = column(10, + row(cell(label).weight(1.2), cell(preDataNum).weight(3)), + cell(combineOther) + ).getComponent(); preDataNumPane.setVisible(false); - panel1.add(preDataNumPane, BorderLayout.CENTER); notShowNull = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Data_Not_Show_Series")); - panel2.add(notShowNull, BorderLayout.NORTH); - onlyPreData.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - checkBoxUse(); - } - }); + onlyPreData.addChangeListener(e -> checkBoxUse()); present = new PresentComboBox() { protected void fireChange() { fire(); } }; - presentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Style_Present") ,present); - panel2.add(presentPane, BorderLayout.SOUTH); - - double[] column = {f}; - double[] row = {p, p}; - Component[][] coms = new Component[][]{ - new Component[]{panel1}, - new Component[]{panel2} - }; - return TableLayout4VanChartHelper.createGapTableLayoutPane(coms, row,column); + presentPane = row( + cell( + new UILabel(Toolkit.i18nText("Fine-Design_Chart_Style_Present")) + ).weight(1.2), cell(present).weight(3) + ).getComponent(); + + return column(10, + cell(onlyPreData), + cell(preDataNumPane), + cell(notShowNull), + cell(presentPane) + ).with(it -> it.setBorder(new ScaledEmptyBorder(10, 0, 0, 0))).getComponent(); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/DatabaseTableDataPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/DatabaseTableDataPane.java index 40983c56b5..e89a0eaaf9 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/DatabaseTableDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/DatabaseTableDataPane.java @@ -1,28 +1,26 @@ package com.fr.design.mainframe.chart.gui.data; -import com.fr.base.BaseUtils; +import com.fine.theme.icon.LazyIcon; import com.fr.base.TableData; import com.fr.data.impl.NameTableData; -import com.fr.design.constants.LayoutConstants; -import com.fr.design.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.TableDataComboBox; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.utils.gui.UIComponentUtils; import com.fr.log.FineLoggerFactory; -import javax.swing.BorderFactory; -import javax.swing.JPanel; -import javax.swing.border.LineBorder; import java.awt.BorderLayout; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.flex; +import static com.fine.swing.ui.layout.Layouts.row; + public class DatabaseTableDataPane extends BasicPane{ private static final long serialVersionUID = 5316016202202932242L; private TableDataComboBox tableNameCombox; @@ -38,21 +36,16 @@ public class DatabaseTableDataPane extends BasicPane{ initTableCombox(); initReviewButton(); - this.setLayout(new BorderLayout(0,0)); - if (label != null) { - this.add(label, BorderLayout.WEST); - } - - JPanel pane = new JPanel(new BorderLayout(LayoutConstants.HGAP_LARGE,0)); - pane.add(tableNameCombox,BorderLayout.CENTER); - pane.add(reviewButton,BorderLayout.EAST); - - this.add(UIComponentUtils.wrapWithBorderLayoutPane(pane),BorderLayout.CENTER); + this.setLayout(new BorderLayout()); + this.add( + row( + cell(label).weight(1.2), cell(tableNameCombox).weight(2.4), flex(0.1), cell(reviewButton).weight(0.5) + ).getComponent(), BorderLayout.CENTER + ); setBorder(); } protected void setBorder () { - this.setBorder(BorderFactory.createEmptyBorder(0,24,0,15)); } /** * 返回选中的数据源. @@ -101,15 +94,14 @@ public class DatabaseTableDataPane extends BasicPane{ } private void initReviewButton() { - reviewButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/search.png")); - reviewButton.setBorder(new LineBorder(UIConstants.LINE_COLOR)); + reviewButton = new UIButton(new LazyIcon("search")); reviewButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { - TableDataWrapper tableDataWrappe = tableNameCombox.getSelectedItem(); - if ( tableDataWrappe != null) { + TableDataWrapper tableDataWrapper = tableNameCombox.getSelectedItem(); + if ( tableDataWrapper != null) { try { - tableDataWrappe.previewData(); + tableDataWrapper.previewData(); } catch (Exception e1) { FineLoggerFactory.getLogger().error(e1.getMessage(), e1); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java index 9943c79631..6bf18a70eb 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java @@ -1,25 +1,26 @@ package com.fr.design.mainframe.chart.gui.data; +import com.fine.theme.utils.FineUIScale; +import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.chart.chartattr.ChartCollection; import com.fr.design.beans.FurtherBasicBeanPane; -import com.fr.design.chartx.data.DataLayoutHelper; -import com.fr.design.constants.LayoutConstants; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.frpane.UIComboBoxPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.mode.ChartEditContext; -import com.fr.design.utils.gui.GUICoreUtils; import com.fr.van.chart.designer.AbstractVanChartScrollPane; -import javax.swing.BorderFactory; import javax.swing.JPanel; import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; import java.util.ArrayList; import java.util.List; +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.row; +import static com.fr.design.constants.LayoutConstants.LEFT_WEIGHT; +import static com.fr.design.constants.LayoutConstants.RIGHT_WEIGHT; + /** * 一般数据界面 * @author kunsnat E-mail:kunsnat@gmail.com @@ -62,19 +63,14 @@ public class NormalChartDataPane extends DataContentsPane { JPanel contentPane = new JPanel(new BorderLayout()); dataPane = new UIComboBoxPane() { protected void initLayout() { - this.setLayout(new BorderLayout(ChartEditContext.normalMode() ? LayoutConstants.HGAP_LARGE : 0,6)); + this.setLayout(new BorderLayout(0, FineUIScale.scale(10))); + setBorder(new ScaledEmptyBorder(10, 0, 0, 0)); if (ChartEditContext.supportReportData()) { - JPanel northPane = new JPanel(new BorderLayout(LayoutConstants.HGAP_LARGE, 0)); - northPane.add(jcb, BorderLayout.CENTER); - UILabel label1 = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Source")); - label1.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); - northPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{jcb, null, null, label1, null})); - if (ChartEditContext.normalMode()) { - northPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 8)); - } else { - northPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20)); - } - this.add(northPane, BorderLayout.NORTH); + UILabel dataSourceLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Source")); + this.add(row( + cell(dataSourceLabel).weight(LEFT_WEIGHT), + cell(jcb).weight(RIGHT_WEIGHT) + ).getComponent(), BorderLayout.NORTH); } this.add(cardPane, BorderLayout.CENTER); @@ -95,7 +91,6 @@ public class NormalChartDataPane extends DataContentsPane { } }; contentPane.add(dataPane, BorderLayout.CENTER); - dataPane.setBorder(BorderFactory.createEmptyBorder(10 ,0, 0, 0)); return contentPane; } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java index 82240bc6d2..0c84c65e63 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.chart.gui.data; +import com.fine.theme.utils.FineUIScale; import com.fr.base.TableData; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; @@ -9,23 +10,16 @@ import com.fr.data.impl.NameTableData; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; -import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; -import com.fr.design.utils.gui.UIComponentUtils; import com.fr.stable.StringUtils; -import javax.swing.BorderFactory; import java.awt.BorderLayout; -import java.awt.Dimension; public class TableDataPane extends FurtherBasicBeanPane{ private static final long serialVersionUID = 4740461028440155147L; - private static final int TOP = -5; - private static final int TABLE_DATA_LABEL_LINE_WRAP_WIDTH = 65; - private static final int TABLE_DATA_PANE_WIDTH = 246; private DatabaseTableDataPane tableDataPane; private AbstractTableDataContentPane dataContentPane; @@ -37,14 +31,12 @@ public class TableDataPane extends FurtherBasicBeanPane{ public TableDataPane(ChartDataPane parent) { this.parent = parent; + setLayout(new BorderLayout(0, FineUIScale.scale(10))); initDataPane(); } private void initDataPane() { - UILabel label = new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Table_Data")); - UIComponentUtils.setLineWrap(label, TABLE_DATA_LABEL_LINE_WRAP_WIDTH); - UIComponentUtils.setPreferedWidth(label, ChartDataPane.LABEL_WIDTH); - + UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Table_Data")); tableDataPane = new DatabaseTableDataPane(label) { @Override protected void userEvent() { @@ -52,9 +44,6 @@ public class TableDataPane extends FurtherBasicBeanPane{ checkBoxUse(); } }; - - tableDataPane.setPreferredSize(new Dimension(TABLE_DATA_PANE_WIDTH , tableDataPane.getPreferredSize().height)); - this.setBorder(BorderFactory.createEmptyBorder(TOP,0,0,0)); this.add(tableDataPane, BorderLayout.NORTH); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/AbstractReportDataContentPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/AbstractReportDataContentPane.java index 1073f0e410..2e1f486ccf 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/AbstractReportDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/AbstractReportDataContentPane.java @@ -53,7 +53,6 @@ public abstract class AbstractReportDataContentPane extends BasicBeanPane addNewCatePane()); } /** @@ -100,37 +86,29 @@ public class CategoryPlotMoreCateReportDataContentPane extends CategoryPlotRepor } private TinyFormulaPane addNewCatePane() { - final TinyFormulaPane pane = initCategoryBox(StringUtils.EMPTY); - pane.setPreferredSize(new Dimension(100, 16)); - - pane.registerChangeListener(uiobListener); - - formualList.add(pane); + final TinyFormulaPane formulaPane = initCategoryBox(StringUtils.EMPTY); - final JPanel newButtonPane = new JPanel(); - newButtonPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); - newButtonPane.add(pane); - - UIButton delButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/toolbarbtn/close.png")); - newButtonPane.add(delButton); + formulaPane.registerChangeListener(uiobListener); + formualList.add(formulaPane); + UIButton delButton = new UIButton(new LazyIcon("close")); + JPanel newButtonPane = row( + cell(formulaPane).weight(3.7), flex(0.1), cell(delButton).weight(0.4) + ).with(it -> it.setBorder(new ScaledEmptyBorder(10, 0, 0, 0))).getComponent(); boxPane.add(newButtonPane); - delButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - boxPane.remove(newButtonPane); - formualList.remove(pane); - checkComponent(); - relayoutPane(); - } + delButton.addActionListener(e -> { + boxPane.remove(newButtonPane); + formualList.remove(formulaPane); + checkComponent(); + relayoutPane(); }); delButton.registerChangeListener(uiobListener); checkComponent(); relayoutPane(); - return pane; + return formulaPane; } private void checkAddButton() { diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotReportDataContentPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotReportDataContentPane.java index fb315b84ed..944f7d2825 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotReportDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotReportDataContentPane.java @@ -5,25 +5,27 @@ import com.fr.chart.chartattr.Bar2DPlot; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartdata.NormalReportDataDefinition; import com.fr.chart.chartdata.SeriesDefinition; +import com.fr.design.border.FineBorderFactory; +import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.formula.DefaultTinyFormulaPane; import com.fr.design.formula.TinyFormulaPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.data.ChartDataFilterPane; -import com.fr.stable.StringUtils; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; -import javax.swing.BorderFactory; -import javax.swing.JPanel; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import java.awt.BorderLayout; -import java.awt.Dimension; import java.util.List; +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.column; +import static com.fine.swing.ui.layout.Layouts.fix; +import static com.fine.swing.ui.layout.Layouts.flex; +import static com.fine.swing.ui.layout.Layouts.row; + public class CategoryPlotReportDataContentPane extends AbstractReportDataContentPane { - protected static final int PRE_WIDTH = 210; protected TinyFormulaPane categoryName; protected ChartDataFilterPane filterPane; @@ -35,30 +37,24 @@ public class CategoryPlotReportDataContentPane extends AbstractReportDataContent public CategoryPlotReportDataContentPane(ChartDataPane parent) { initEveryPane(); categoryName = initCategoryBox(Toolkit.i18nText("Fine-Design_Chart_Category_Name")); - categoryName.setPreferredSize(new Dimension(236,30)); - categoryName.setBorder(BorderFactory.createEmptyBorder(0,24,0,20)); - this.add(categoryName, "0,0,1,0"); + this.setLayout(new BorderLayout()); filterPane = new ChartDataFilterPane(new Bar2DPlot(), parent); - JPanel panel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"),filterPane); - panel.setBorder(getSidesBorder()); - filterPane.setBorder(getFilterPaneBorder()); - this.add(panel, "0,6,1,4"); } + this.add(column( + cell(categoryName), + fix(10).with(it -> it.setBorder(FineBorderFactory.createDefaultUnderlineBorder())), + cell(new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"),filterPane)) + ).getComponent()); + } protected TinyFormulaPane initCategoryBox(final String leftLabel) { TinyFormulaPane categoryName = new DefaultTinyFormulaPane() { @Override protected void initLayout() { - this.setLayout(new BorderLayout(4, 0)); - - if(StringUtils.isNotEmpty(leftLabel)) { - UILabel label1 = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Category_Name")); - label1.setPreferredSize(new Dimension(75, 20)); - this.add(label1, BorderLayout.WEST); - } - - formulaTextField.setPreferredSize(new Dimension(100, 20)); - this.add(formulaTextField, BorderLayout.CENTER); - this.add(formulaTextFieldButton, BorderLayout.EAST); + UILabel label = new UILabel(leftLabel); + this.setLayout(new BorderLayout()); + this.add(row( + cell(label).weight(1.2), cell(formulaTextField).weight(2), flex(0.1), cell(formulaTextFieldButton).weight(0.4) + ).getComponent()); } public void okEvent() { diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java index 7432dfcce1..0f2e21a6a4 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java @@ -1,28 +1,25 @@ package com.fr.design.mainframe.chart.gui.data.table; -import com.fr.base.BaseUtils; +import com.fine.theme.icon.LazyIcon; +import com.fine.theme.utils.FineLayoutBuilder; +import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.base.chart.chartdata.TopDefinitionProvider; import com.fr.chart.chartattr.Bar2DPlot; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartdata.NormalTableDataDefinition; +import com.fr.design.border.FineBorderFactory; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.data.ChartDataHelper; -import com.fr.design.utils.gui.GUICoreUtils; -import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JPanel; import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; @@ -30,6 +27,11 @@ import java.awt.event.ItemListener; import java.util.ArrayList; import java.util.List; +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.column; +import static com.fine.swing.ui.layout.Layouts.flex; +import static com.fine.swing.ui.layout.Layouts.row; + /** * 多分类轴 的数据集定义界面. * @@ -38,9 +40,6 @@ import java.util.List; */ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableDataContentPane implements UIObserver { private static final long serialVersionUID = -3305681053750642843L; - private static final int COMBOX_GAP = 8; - private static final int COMBOX_WIDTH = 95; - private static final int COMBOX_HEIGHT = 20; private JPanel boxPane; @@ -59,40 +58,37 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD public CategoryPlotMoreCateTableDataContentPane(ChartDataPane parent) { categoryCombox = new UIComboBox(); - categoryCombox.setPreferredSize(new Dimension(COMBOX_WIDTH,COMBOX_HEIGHT)); - - JPanel categoryPane = new JPanel(new BorderLayout(4, 0)); - categoryPane.setBorder(BorderFactory.createMatteBorder(0, 0, 6, 1, getBackground())); - UILabel categoryLabel = new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Category")); - categoryLabel.setPreferredSize(new Dimension(85,COMBOX_HEIGHT)); - - addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); - addButton.setPreferredSize(new Dimension(20, COMBOX_HEIGHT)); - - categoryPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{categoryCombox, addButton, null, categoryLabel, null})); - - categoryPane.setBorder(BorderFactory.createEmptyBorder(0,24,10,15)); + UILabel categoryLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Category")); + addButton = new UIButton(new LazyIcon("add")); boxPane = new JPanel(); boxPane.setLayout(new BoxLayout(boxPane, BoxLayout.Y_AXIS)); - categoryPane.add(boxPane, BorderLayout.SOUTH); + JPanel categoryPane = column(10, + row( + cell(categoryLabel).weight(1.2), + cell(categoryCombox).weight(2.4), + flex(0.1), + cell(addButton).weight(0.5) + ), + cell(boxPane) + ).with(it -> it.setBorder(FineBorderFactory.createDefaultUnderlineBorder())).getComponent(); + this.setLayout(new BorderLayout()); - this.add(categoryPane, BorderLayout.NORTH); - this.add(getJSeparator()); seriesTypeComboxPane = new SeriesTypeUseComboxPane(parent, new Bar2DPlot()); - this.add(seriesTypeComboxPane, BorderLayout.SOUTH); + this.add(FineLayoutBuilder.createVerticalLayout(10, categoryPane, seriesTypeComboxPane)); addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (boxList.size() < 2) { - addNewCombox(); + addNewComboBox(); relayoutPane(); } checkSeriseUse(categoryCombox.getSelectedItem() != null); + checkComponent(); } }); @@ -112,49 +108,39 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD addButton.setEnabled(hasUse); } - private UIComboBox addNewCombox() { - final JPanel buttonPane = new JPanel(); - buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2)); - - final UIComboBox combox = new UIComboBox(); - combox.setPreferredSize(new Dimension(COMBOX_WIDTH, COMBOX_HEIGHT)); + private UIComboBox addNewComboBox() { + final UIComboBox comboBox = new UIComboBox(); int count = categoryCombox.getItemCount(); for (int i = 0; i < count; i++) { - combox.addItem(categoryCombox.getItemAt(i)); + comboBox.addItem(categoryCombox.getItemAt(i)); } - combox.registerChangeListener(uiobListener); - combox.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - makeToolTipUse(combox); - } - }); + comboBox.registerChangeListener(uiobListener); + comboBox.addItemListener(e -> makeToolTipUse(comboBox)); + + comboBox.setSelectedItem(categoryCombox.getItemAt(0)); + makeToolTipUse(comboBox); - combox.setSelectedItem(categoryCombox.getItemAt(0)); - makeToolTipUse(combox); + UIButton delButton = new UIButton(new LazyIcon("close")); + JPanel buttonPane = row( + flex(1.2), cell(comboBox).weight(2.4), flex(0.1), cell(delButton).weight(0.5) + ).with(it -> it.setBorder(new ScaledEmptyBorder(0, 0, 10, 0))).getComponent(); - buttonPane.add(combox); - UIButton delButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/toolbarbtn/close.png")); - buttonPane.add(delButton); boxPane.add(buttonPane); - boxList.add(combox); + boxList.add(comboBox); checkComponent(); - delButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - boxPane.remove(buttonPane); - boxList.remove(combox); - checkComponent(); - relayoutPane(); - } + delButton.addActionListener(e -> { + boxPane.remove(buttonPane); + boxList.remove(comboBox); + checkComponent(); + relayoutPane(); }); delButton.registerChangeListener(uiobListener); - return combox; + return comboBox; } private void checkAddButton() { @@ -223,7 +209,7 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD NormalTableDataDefinition normal = (NormalTableDataDefinition) top; int size = normal.getMoreCateSize(); for (int i = 0; i < size; i++) { - UIComboBox box = addNewCombox(); + UIComboBox box = addNewComboBox(); box.setSelectedItem(normal.getMoreCateWithIndex(i)); } } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotTableDataContentPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotTableDataContentPane.java index 7d12e3e52d..270f3ffa71 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotTableDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotTableDataContentPane.java @@ -6,22 +6,21 @@ import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartdata.NormalTableDataDefinition; import com.fr.chart.chartdata.TopDefinition; import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.chart.gui.ChartDataPane; -import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; import com.fr.design.i18n.Toolkit; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; -import javax.swing.*; -import java.awt.*; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; +import java.awt.BorderLayout; import java.util.List; +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.column; +import static com.fine.swing.ui.layout.Layouts.row; + /** * 属性表, 矩形类的 数据集 数据界面. * @author kunsnat E-mail:kunsnat@gmail.com @@ -40,29 +39,24 @@ public class CategoryPlotTableDataContentPane extends AbstractTableDataContentPa public CategoryPlotTableDataContentPane(ChartDataPane parent) { categoryCombox = new UIComboBox(); - JPanel categoryPane = new JPanel(new BorderLayout(4,0)); - categoryPane.setBorder(BorderFactory.createMatteBorder(0, 0, 6, 1, getBackground())); - UILabel label1 = new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Style_Category")) ; - label1.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH,ChartDataPane.LABEL_HEIGHT)); - categoryCombox.setPreferredSize(new Dimension(100,20)); + UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Style_Category")) ; categoryCombox.addItem(Toolkit.i18nText("Fine-Design_Chart_Use_None")); - categoryPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{categoryCombox,null,null,label1,null})); - categoryPane.setPreferredSize(new Dimension(246,30)); - categoryPane.setBorder(BorderFactory.createEmptyBorder(0,24,10,15)); - this.setLayout(new BorderLayout()); - - this.add(categoryPane, BorderLayout.NORTH); - - this.add(getJSeparator()); seriesTypeComboxPane = new SeriesTypeUseComboxPane(parent, new Bar2DPlot()); - this.add(seriesTypeComboxPane, BorderLayout.SOUTH); - categoryCombox.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - checkSeriseUse(categoryCombox.getSelectedItem() != null); - makeToolTipUse(categoryCombox); - } + this.setLayout(new BorderLayout()); + + this.add(column(10, + row( + cell(label).weight(1.2), cell(categoryCombox).weight(3) + ), + cell(seriesTypeComboxPane) + ).getComponent() + ); + + categoryCombox.addItemListener(e -> { + checkSeriseUse(categoryCombox.getSelectedItem() != null); + makeToolTipUse(categoryCombox); }); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldValuePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldValuePane.java index 889e6f5302..f3d326f8dc 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldValuePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldValuePane.java @@ -6,17 +6,14 @@ import com.fr.chart.chartdata.OneValueCDDefinition; import com.fr.data.util.function.AbstractDataFunction; import com.fr.data.util.function.NoneFunction; import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.border.FineBorderFactory; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.extended.chart.UIComboBoxWithNone; -import javax.swing.BorderFactory; import javax.swing.JPanel; import java.util.List; import java.awt.BorderLayout; @@ -25,6 +22,11 @@ import java.awt.Dimension; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.column; +import static com.fine.swing.ui.layout.Layouts.fix; +import static com.fine.swing.ui.layout.Layouts.row; + /** * 属性表 数据集 系列名使用 系列值 界面. * @@ -45,9 +47,6 @@ public class SeriesNameUseFieldValuePane extends FurtherBasicBeanPane it.setBorder(FineBorderFactory.createDefaultUnderlineBorder())) + ).getComponent(); this.setLayout(new BorderLayout()); this.add(centerPane, BorderLayout.CENTER); } private void initCenterPaneWithOutCaculateSummary() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {f}; - double[] rowSize = {p, p, p, p}; UILabel label1 = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Series_Name")); - label1.setPreferredSize(getLabelDimension()); UILabel label2 = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Series_Value")); - label2.setPreferredSize(getLabelDimension()); - UILabel label3 = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Summary_Method")); - label3.setPreferredSize(getLabelDimension()); - Component[][] components = getUseComponentWithOutSummary(label1, label2, label3); - - centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 4, 6); - centerPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 1)); + centerPane = column(10, + row( + cell(label1).weight(1), cell(seriesName).weight(2) + ), + row( + cell(label2).weight(1), cell(seriesValue).weight(2) + ), + fix(1).with(it -> it.setBorder(FineBorderFactory.createDefaultUnderlineBorder())) + ).getComponent(); this.setLayout(new BorderLayout()); this.add(centerPane, BorderLayout.CENTER); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesTypeUseComboxPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesTypeUseComboxPane.java index cf78e59ffb..2a78359109 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesTypeUseComboxPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesTypeUseComboxPane.java @@ -1,30 +1,32 @@ package com.fr.design.mainframe.chart.gui.data.table; +import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.base.chart.chartdata.TopDefinitionProvider; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartdata.MoreNameCDDefinition; import com.fr.chart.chartdata.OneValueCDDefinition; import com.fr.design.beans.BasicBeanPane; -import com.fr.design.constants.LayoutConstants; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.data.ChartDataFilterPane; -import com.fr.design.utils.gui.GUICoreUtils; -import javax.swing.BorderFactory; import javax.swing.JPanel; import java.util.List; import java.awt.BorderLayout; import java.awt.CardLayout; -import java.awt.Component; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.column; +import static com.fine.swing.ui.layout.Layouts.fix; +import static com.fine.swing.ui.layout.Layouts.row; + /** * 属性表: 柱形, 饼图 数据集界面, "系列名使用"界面. * @@ -98,32 +100,21 @@ public class SeriesTypeUseComboxPane extends BasicBeanPane { } protected void initLayout() { - this.setLayout(new BorderLayout(4, LayoutConstants.VGAP_MEDIUM)); - JPanel northPane = new JPanel(new BorderLayout(4, 0)); - + this.setLayout(new BorderLayout()); //使用系列名/系列值选项面板 UILabel seriesLabel = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Series_Name_From")); - seriesLabel.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); - JPanel borderLayoutPane = GUICoreUtils.createBorderLayoutPane(new Component[]{content, null, null, seriesLabel, null}); - northPane.add(borderLayoutPane); - northPane.setBorder(BorderFactory.createEmptyBorder(10, 24, 0, 16)); - this.add(northPane, BorderLayout.NORTH); - - //系列名/系列值配置面板 - cardPane.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 15)); - this.add(cardPane, BorderLayout.CENTER); //数据筛选 dataScreeningPane = new ChartDataFilterPane(this.initplot, parent); - JPanel panel = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), 250, 24, dataScreeningPane); - panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 15)); - dataScreeningPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); - this.add(panel, BorderLayout.SOUTH); - } - public Dimension getPreferredSize() { - Dimension preferredSize = super.getPreferredSize(); - return new Dimension(246, (int) preferredSize.getHeight()); + this.add(column( + row( + cell(seriesLabel).weight(1), cell(content).weight(2) + ), + fix(10), + cell(cardPane), + cell(new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), dataScreeningPane)) + ).with(it -> it.setBorder(new ScaledEmptyBorder(10, 0, 0, 0))).getComponent()); } /** diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java index 63b259e7aa..89281390d0 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java @@ -1,8 +1,8 @@ package com.fr.design.mainframe.chart.gui.style; -import com.fr.base.BaseUtils; +import com.fine.theme.icon.LazyIcon; +import com.fine.theme.utils.FineLayoutBuilder; import com.fr.base.FRContext; -import com.fr.base.Utils; import com.fr.chart.base.TextAttr; import com.fr.design.constants.LayoutConstants; import com.fr.design.dialog.BasicPane; @@ -18,7 +18,6 @@ import com.fr.design.utils.DesignUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.FRFont; import com.fr.general.GeneralUtils; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; import javax.swing.JPanel; import javax.swing.SwingConstants; @@ -193,8 +192,8 @@ public class ChartTextAttrPane extends BasicPane { protected void initState() { fontNameComboBox = new UIComboBox(DesignUtils.getAvailableFontFamilyNames4Report()); fontSizeComboBox = new UIComboBox(getFontSizeComboBoxModel()); - bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); - italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); + bold = new UIToggleButton(new LazyIcon("bold")); + italic = new UIToggleButton(new LazyIcon("italic")); initFontColorState(); } @@ -217,11 +216,7 @@ public class ChartTextAttrPane extends BasicPane { } protected JPanel getContentPane(JPanel buttonPane) { - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] columnSize = {f, e}; - - return TableLayout4VanChartHelper.createGapTableLayoutPane(getComponents(buttonPane), getRowSize(), columnSize); + return FineLayoutBuilder.compatibleTableLayout(10, getComponents(buttonPane), new double[]{1.2, 3}); } protected double[] getRowSize() { diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithThemeStyle.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithThemeStyle.java index 345d57de8a..76862a7577 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithThemeStyle.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithThemeStyle.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.chart.gui.style; +import com.fine.theme.utils.FineUIScale; import com.fr.chart.base.TextAttr; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; @@ -7,7 +8,6 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.van.chart.designer.TableLayout4VanChartHelper; -import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.SwingConstants; import java.awt.BorderLayout; @@ -33,7 +33,7 @@ public class ChartTextAttrPaneWithThemeStyle extends ChartTextAttrPane { } protected JPanel getContentPane(JPanel buttonPane) { - JPanel panel = new JPanel(new BorderLayout(0, 10)); + JPanel panel = new JPanel(new BorderLayout(0, FineUIScale.scale(10))); preButton = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Follow_Theme"), Toolkit.i18nText("Fine-Design_Chart_Custom")}); @@ -46,7 +46,6 @@ public class ChartTextAttrPaneWithThemeStyle extends ChartTextAttrPane { textFontPane = TableLayout4VanChartHelper.createGapTableLayoutPane(getComponents(buttonPane), getRowSize(), columnSize); panel.add(preButtonPane, BorderLayout.CENTER); panel.add(textFontPane, BorderLayout.SOUTH); - panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); return panel; } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ColorSelectBoxWithThemeStyle.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ColorSelectBoxWithThemeStyle.java index db59476792..412266358a 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ColorSelectBoxWithThemeStyle.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ColorSelectBoxWithThemeStyle.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.chart.gui.style; +import com.fine.theme.utils.FineLayoutBuilder; import com.fr.chart.base.ColorWithThemeStyle; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButtonGroup; @@ -7,13 +8,10 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.design.style.color.ColorSelectBox; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; import javax.swing.JPanel; -import javax.swing.SwingConstants; import java.awt.BorderLayout; import java.awt.Component; -import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -40,7 +38,7 @@ public class ColorSelectBoxWithThemeStyle extends BasicPane { private void initContent() { - UILabel text = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color"), SwingConstants.LEFT); + UILabel text = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")); Component[][] components = ChartEditContext.supportTheme() ? new Component[][]{ new Component[]{text, preButton}, new Component[]{null, colorSelectBox}, @@ -48,23 +46,17 @@ public class ColorSelectBoxWithThemeStyle extends BasicPane { new Component[]{text, colorSelectBox} }; - JPanel gapTableLayoutPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components); + JPanel gapTableLayoutPane = FineLayoutBuilder.compatibleTableLayout(10, components, new double[]{1.2, 3}); this.setLayout(new BorderLayout()); this.add(gapTableLayoutPane, BorderLayout.CENTER); } private void initListener() { - preButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - checkPreButton(); - } - }); + preButton.addActionListener(e -> checkPreButton()); } private void checkPreButton() { colorSelectBox.setVisible(preButton.getSelectedIndex() == CUSTOM); - this.setPreferredSize(ChartEditContext.supportTheme() && preButton.getSelectedIndex() == CUSTOM ? new Dimension(0, 55) : new Dimension(0, 23)); } public String title4PopupWindow() { diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ThirdTabPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ThirdTabPane.java index a58a889164..5afaded3f2 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ThirdTabPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ThirdTabPane.java @@ -3,29 +3,18 @@ package com.fr.design.mainframe.chart.gui.style; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; -import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicScrollPane; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.ibutton.UIButtonGroup; import javax.swing.JPanel; -import javax.swing.border.Border; import java.util.List; import java.awt.BorderLayout; import java.awt.CardLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; public abstract class ThirdTabPane extends BasicBeanPane{ private static final long serialVersionUID = 2298609199400393886L; - private static final int MIN_TAB_HEIGHT = 25; protected UIButtonGroup tabPane; protected String[] nameArray; public JPanel centerPane; @@ -57,54 +46,18 @@ public abstract class ThirdTabPane extends BasicBeanPane{ if (!paneList.isEmpty()) { tabPane = new UIButtonGroup(nameArray); tabPane.setSelectedIndex(0); - int prefHeight = tabPane.getPreferredSize().height; - int prefWidth = tabPane.getPreferredSize().width + 20; // 暂且加一个偏移量 - int minWidth = 60 * nameArray.length; - tabPane.setPreferredSize( - new Dimension(prefWidth > minWidth ? prefWidth : minWidth, - prefHeight > MIN_TAB_HEIGHT ? prefHeight : MIN_TAB_HEIGHT)); - tabPane.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - cardLayout.show(centerPane, nameArray[tabPane.getSelectedIndex()]); - } - }); - - centerPane.setBorder(myBorder); + tabPane.addActionListener(e -> cardLayout.show(centerPane, nameArray[tabPane.getSelectedIndex()])); } } protected void initLayout() { this.setLayout(new BorderLayout()); if (!paneList.isEmpty()) { - JPanel pane = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0)); - pane.add(tabPane); - this.add(pane, BorderLayout.NORTH); + this.add(tabPane, BorderLayout.NORTH); } this.add(centerPane, BorderLayout.CENTER); } - private Border myBorder = new Border() { - @Override - public void paintBorder(Component c, Graphics g, int x, int y, int width,int height) { - Graphics2D g2d = (Graphics2D)g; - g2d.setColor(UIConstants.LINE_COLOR); - g2d.drawLine(0, 0, 0, height); - g2d.drawLine(tabPane.getPreferredSize().width - 1, 0, width - 2, 0); - g2d.drawLine(0, height - 1, width - 2, height - 1); - } - - @Override - public boolean isBorderOpaque() { - return false; - } - - @Override - public Insets getBorderInsets(Component c) { - return new Insets(2, 2, 2, 2); - } - }; - /** * * @return 中间的内容面板的指定宽度 diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/axis/ChartCategoryPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/axis/ChartCategoryPane.java index c0842ab15e..0789ef53d6 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/axis/ChartCategoryPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/axis/ChartCategoryPane.java @@ -18,7 +18,6 @@ import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.Constants; import com.fr.van.chart.designer.component.format.FormatPaneWithOutFont; -import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.JSeparator; import java.awt.BorderLayout; @@ -134,7 +133,6 @@ public class ChartCategoryPane extends ChartAxisUsePane{ @Override protected void layoutContentPane() { leftcontentPane = createContentPane(); - leftcontentPane.setBorder(BorderFactory.createMatteBorder(5, 10, 5, 0, original)); this.add(leftcontentPane); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/AbstractPlotSeriesPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/AbstractPlotSeriesPane.java index e9b118df87..cf8f55bb79 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/AbstractPlotSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/AbstractPlotSeriesPane.java @@ -70,7 +70,6 @@ public abstract class AbstractPlotSeriesPane extends BasicBeanPane{ panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } - panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 15)); return panel; } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartTabPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartTabPane.java index 495c0409ad..05b353ea07 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartTabPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartTabPane.java @@ -1,5 +1,7 @@ package com.fr.design.mainframe.chart.gui.type; +import com.fine.theme.utils.FineUIScale; +import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.chart.chartattr.Chart; import com.fr.design.dialog.MultiTabPane; import com.fr.design.gui.ibutton.UIToggleButton; @@ -7,8 +9,9 @@ import com.fr.design.mainframe.chart.gui.style.legend.AutoSelectedPane; import com.fr.general.ComparatorUtils; import com.fr.stable.StringUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Graphics; /** * Created by Mitisky on 16/3/9. @@ -21,9 +24,9 @@ public abstract class ChartTabPane extends MultiTabPane { @Override protected void initLayout() { JPanel tabPanel = new JPanel(new BorderLayout()); - tabPanel.setBorder(BorderFactory.createMatteBorder(0, 5, 0, 10, getBackground())); tabPanel.add(tabPane, BorderLayout.CENTER); - this.setLayout(new BorderLayout(0, 4)); + this.setLayout(new BorderLayout(0, FineUIScale.scale(10))); + this.setBorder(new ScaledEmptyBorder(10, 0, 0, 0)); this.add(tabPanel, BorderLayout.NORTH); this.add(centerPane, BorderLayout.CENTER); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java index a542f100cb..57176c256c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java @@ -1,8 +1,10 @@ package com.fr.van.chart.column; +import com.fine.theme.utils.FineLayoutBuilder; import com.fr.base.background.ImageBackground; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; +import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.frpane.UINumberDragPaneWithPercent; import com.fr.design.gui.ibutton.UIButtonGroup; @@ -10,28 +12,19 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.chart.UISpinnerWithPx; import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.backgroundpane.ImageBackgroundQuickPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; -import com.fr.design.utils.gui.UIComponentUtils; -import com.fr.design.widget.FRWidgetFactory; import com.fr.plugin.chart.base.AttrSeriesImageBackground; import com.fr.plugin.chart.column.VanChartColumnPlot; import com.fr.stable.Constants; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartBeautyPane; import com.fr.van.chart.designer.component.VanChartBeautyPaneWithGradientBar; import com.fr.van.chart.designer.component.border.VanChartBorderPane; import com.fr.van.chart.designer.component.border.VanChartBorderWithRadiusPane; import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; -import javax.swing.BorderFactory; import javax.swing.JPanel; -import java.awt.BorderLayout; import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; /** * 新条形图系列界面 @@ -52,20 +45,13 @@ public class VanChartColumnSeriesPane extends VanChartAbstractPlotSeriesPane { } protected JPanel getContentInPlotType() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] columnSize = {f}; - double[] rowSize = {p,p,p,p,p,p,p,p,p,p}; - Component[][] components = new Component[][]{ - new Component[]{createSeriesStylePane(new double[]{p,p}, new double[]{f,e})}, - new Component[]{createBorderPane()}, - new Component[]{createStackedAndAxisPane()}, - new Component[]{createTrendLinePane()}, - }; - - contentPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - + contentPane = FineLayoutBuilder.createVerticalLayout(0, + createSeriesStylePane(), + createBorderPane(), + createStackedAndAxisPane(), + createTrendLinePane() + ); + contentPane = FineLayoutBuilder.asBorderLayoutWrapped(contentPane); return contentPane; } @@ -74,55 +60,26 @@ public class VanChartColumnSeriesPane extends VanChartAbstractPlotSeriesPane { return new VanChartBorderWithRadiusPane(true); } - private JPanel createSeriesStylePane(double[] row, double[] col) { - isFixedWidth = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_YES"), Toolkit.i18nText("Fine-Design_Chart_NO")}); + private JPanel createSeriesStylePane() { + isFixedWidth = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_YES"), Toolkit.i18nText("Fine-Design_Chart_NO")}); columnWidth = new UISpinnerWithPx(0,1000,1,0); - columnWidth.setBorder(BorderFactory.createEmptyBorder(0, (int)TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH + TableLayout4VanChartHelper.COMPONENT_INTERVAL,0,0)); seriesGap = new UINumberDragPaneWithPercent(-100, 100); categoryGap = new UINumberDragPaneWithPercent(0, 100); - isFillWithImage = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_YES"), Toolkit.i18nText("Fine-Design_Chart_NO")}); + isFillWithImage = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_YES"), Toolkit.i18nText("Fine-Design_Chart_NO")}); imagePane = new ImageBackgroundQuickPane(false); - imagePane.setBorder(BorderFactory.createEmptyBorder(0,(int)TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH + TableLayout4VanChartHelper.COMPONENT_INTERVAL,0,0)); - - JPanel panel1 = new JPanel(new BorderLayout()); - JPanel isFixedWidthPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Fixed_Column_Width"),isFixedWidth); - isFixedWidthPane.setBorder(BorderFactory.createEmptyBorder(0,0,6,0)); - panel1.add(isFixedWidthPane, BorderLayout.NORTH); - panel1.add(columnWidth, BorderLayout.CENTER); - - Component[][] components2 = new Component[][]{ - new Component[]{FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Gap_Series")),seriesGap}, - new Component[]{FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Gap_Category")),categoryGap}, + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Fixed_Column_Width")), isFixedWidth}, + new Component[]{null, columnWidth}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Gap_Series")), seriesGap}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Gap_Category")), categoryGap}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Filled_With_Image")), isFillWithImage}, + new Component[]{null, imagePane} }; - JPanel panel2 = TableLayout4VanChartHelper.createGapTableLayoutPane(components2, row, col); + JPanel borderPane = FineLayoutBuilder.compatibleTableLayout(10, components, new double[]{1.2, 3}); - UILabel fillImageLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Filled_With_Image")); - Component[][] components3 = new Component[][]{ - new Component[]{fillImageLabel, UIComponentUtils.wrapWithBorderLayoutPane(isFillWithImage)}, - }; - JPanel panel3 = TableLayout4VanChartHelper.createGapTableLayoutPane(components3, row, col); - - JPanel panel = new JPanel(new BorderLayout(0, 4)); - panel.add(panel1, BorderLayout.NORTH); - panel.add(panel2, BorderLayout.CENTER); - panel.add(panel3, BorderLayout.SOUTH); - - JPanel borderPane = new JPanel(new BorderLayout()); - borderPane.add(panel, BorderLayout.NORTH); - borderPane.add(imagePane, BorderLayout.CENTER); - isFixedWidth.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - checkColumnWidth(); - } - }); - isFillWithImage.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - checkImagePane(); - } - }); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), borderPane); + isFixedWidth.addActionListener(e -> checkColumnWidth()); + isFillWithImage.addActionListener(e -> checkImagePane()); + return new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Filled_With_Image"), borderPane); } private void checkAll() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/AbstractVanChartScrollPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/AbstractVanChartScrollPane.java index f5d592e025..9949862884 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/AbstractVanChartScrollPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/AbstractVanChartScrollPane.java @@ -14,23 +14,9 @@ public abstract class AbstractVanChartScrollPane extends BasicScrollPane { protected void layoutContentPane() { leftcontentPane = createContentPane(); - leftcontentPane.setBorder(BorderFactory.createMatteBorder(0, 5, 0, 10, original)); this.add(leftcontentPane); } - protected void setLeftContentPaneBounds(Container parent, UIScrollBar scrollBar, int beginY, int maxheight) { - int width = parent.getWidth(); - int height = parent.getHeight(); - if (leftcontentPane.getPreferredSize().height > maxheight) { - scrollBar.setBounds(width - scrollBar.getWidth() - 1, 0, 6, height); - leftcontentPane.setBounds(0, -beginY, width - 6, height + beginY); - leftcontentPane.setBorder(BorderFactory.createMatteBorder(0, 4, 0, 4, original)); - - } else { - leftcontentPane.setBounds(0, 0, width, height); - leftcontentPane.setBorder(BorderFactory.createMatteBorder(0, 4, 0, 10, original)); - } - } public void reloaPane(JPanel pane){ super.reloaPane(pane); leftcontentPane.setBorder(BorderFactory.createEmptyBorder()); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java index d89a7d31e5..ce4a6492b5 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java @@ -1,15 +1,16 @@ package com.fr.van.chart.designer.component; +import com.fine.theme.utils.FineLayoutBuilder; +import com.fine.theme.utils.FineUIScale; import com.fr.design.beans.BasicBeanPane; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.jxbrowser.JxUIPane; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.general.ComparatorUtils; @@ -22,7 +23,6 @@ import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; import com.fr.plugin.chart.base.format.AttrTooltipValueFormat; import com.fr.stable.StringUtils; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithCheckBox; @@ -52,6 +52,10 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.column; +import static com.fine.swing.ui.layout.Layouts.row; + /** * 数据点提示内容界面,含有通用设置、富文本编辑器、自定义JS界面 */ @@ -191,7 +195,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane(new String[]{ Toolkit.i18nText("Fine-Design_Chart_Common"), @@ -291,22 +289,18 @@ public class VanChartTooltipContentPane extends BasicBeanPane(Toolkit.i18nText("Fine-Design_Basic_Form_Layout"), createTitlePositionPane()), + new Pair<>(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), createTitleStylePane()), + new Pair<>(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane), + new Pair<>(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane), + new Pair<>(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), createDisplayStrategy()) + ); + return FineLayoutBuilder.asBorderLayoutWrapped(column); } protected VanChartBackgroundPane creatBackgroundPane(){ @@ -166,27 +160,21 @@ public class VanChartPlotLegendPane extends BasicPane { backgroundPane = creatBackgroundPane(); fixedCheckPane = createFixedCheckPane(); JPanel panel = new JPanel(); - panel.setLayout(new BorderLayout()); + panel.setLayout(new BorderLayout(0, FineUIScale.scale(10))); panel.add(createDisplayStrategy(), BorderLayout.CENTER); panel.add(fixedCheckPane, BorderLayout.SOUTH); - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] columnSize = {f, e}; - double[] rowSize = {p, p, p, p, p, p, p, p}; - - Component[][] components = new Component[][]{ - new Component[]{createTitlePositionPane(new double[]{p, p, p}, columnSize), null}, - new Component[]{createTitleStylePane(), null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane), null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane), null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel), null}, - }; - return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + Column column = FineLayoutBuilder.createVerticalExpandPaneLayout(0, + new Pair<>(Toolkit.i18nText("Fine-Design_Basic_Form_Layout"), createTitlePositionPane()), + new Pair<>(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), createTitleStylePane()), + new Pair<>(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane), + new Pair<>(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane), + new Pair<>(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel) + ); + return FineLayoutBuilder.asBorderLayoutWrapped(column); } - private JPanel createTitlePositionPane(double[] row, double[] col) { + private JPanel createTitlePositionPane() { String[] textArray = { Toolkit.i18nText("Fine-Design_Chart_Style_Alignment_Top"), Toolkit.i18nText("Fine-Design_Chart_Style_Alignment_Bottom"), @@ -213,7 +201,6 @@ public class VanChartPlotLegendPane extends BasicPane { customFloatPositionButton.setEventBannded(true); Component[][] components = new Component[][]{ - new Component[]{null, null}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Layout_Position")), location}, new Component[]{null, customFloatPositionButton} }; @@ -223,13 +210,12 @@ public class VanChartPlotLegendPane extends BasicPane { initPositionListener(); - JPanel positionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); + JPanel positionPane = FineLayoutBuilder.compatibleTableLayout(10, components, new double[]{1.2, 3}); - JPanel panel = new JPanel(new BorderLayout()); - panel.add(positionPane, BorderLayout.NORTH); - panel.add(layoutPane, BorderLayout.CENTER); + return column(10, + cell(positionPane), cell(layoutPane) + ).getComponent(); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Basic_Form_Layout"), panel); } private JPanel createLayoutPane() { @@ -237,16 +223,11 @@ public class VanChartPlotLegendPane extends BasicPane { new String[]{Toolkit.i18nText("Fine-Design_Chart_Layout_Flow"), Toolkit.i18nText("Fine-Design_Chart_Layout_Aligned")}, new LayoutType[]{LayoutType.FLOW, LayoutType.ALIGNED}); - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - Component[][] components = new Component[][]{ - new Component[]{null, null}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Arrange")), layoutButton} }; - return TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p, p}, new double[]{f, e}); + return FineLayoutBuilder.compatibleTableLayout(10, components, new double[]{1.2, 3}); } private void initPositionListener() { @@ -290,48 +271,34 @@ public class VanChartPlotLegendPane extends BasicPane { private JPanel createTitleStylePane() { textAttrPane = ChartEditContext.supportTheme() ? new ChartTextAttrPaneWithThemeStyle() : new ChartTextAttrPane(); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), textAttrPane); + return textAttrPane; } private JPanel createDisplayStrategy() { //区域显示策略 恢复用注释。开始删除。 maxProportion = new UINumberDragPaneWithPercent(0, 100, 1); customSize = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Auto"), Toolkit.i18nText("Fine-Design_Chart_Custom")}); + maxProportionPane = row( + cell(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Max_Proportion"))).weight(1.2), + cell(maxProportion).weight(3) + ).getComponent(); - JPanel limitSizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Area_Size"), customSize); - maxProportionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Max_Proportion"), maxProportion, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); - maxProportionPane.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0)); - JPanel panel = new JPanel(new BorderLayout()); - panel.add(limitSizePane, BorderLayout.NORTH); - panel.add(maxProportionPane, BorderLayout.CENTER); - - customSize.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - checkMaxProPortionUse(); - } - }); - return panel; - //区域显示策略 恢复用注释。结束删除。 - - //区域显示策略 恢复用注释。取消注释。 -// limitPane = new LimitPane(false); -// return limitPane; + customSize.addActionListener(e -> checkMaxProPortionUse()); + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Area_Size")), customSize}, + new Component[]{maxProportionPane, null} + }; + return FineLayoutBuilder.compatibleTableLayout(10, components, new double[]{1.2, 3}); } private JPanel createFixedCheckPane() { fixedCheck = new UICheckBox(Toolkit.i18nText("Fine-Engine_Chart_Open_Fixed_Display")); fixedCheckLabel = new UILabel(Toolkit.i18nText("Fine-Engine_Chart_Fixed_Display")); - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] columnSize = {f, e}; - double[] rowSize = {p, p}; Component[][] components = new Component[][]{ new Component[]{null, null}, new Component[]{fixedCheckLabel, fixedCheck} }; - return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); + return FineLayoutBuilder.compatibleTableLayout(0, components, new double[]{1.2, 3}); } protected void checkAllUse() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java index 3469e26246..925d2c38b6 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java @@ -1,10 +1,13 @@ package com.fr.van.chart.designer.style; +import com.fine.theme.icon.LazyIcon; +import com.fine.theme.utils.FineUIStyle; import com.fr.base.BaseFormula; -import com.fr.base.BaseUtils; import com.fr.base.Utils; import com.fr.chart.base.TextAttr; import com.fr.chartx.config.info.constant.ConfigType; +import com.fr.design.border.FineBorderFactory; +import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.formula.DefaultTinyFormulaPane; import com.fr.design.formula.TinyFormulaPane; import com.fr.design.gui.frpane.UIBubbleFloatPane; @@ -15,8 +18,6 @@ import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithThemeStyle; @@ -29,25 +30,24 @@ import com.fr.stable.Constants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.van.chart.designer.AbstractVanChartScrollPane; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartFloatPositionPane; import com.fr.van.chart.designer.component.background.VanChartBackgroundWithOutShadowWithRadiusPane; -import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JPanel; import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; import java.awt.Point; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.column; +import static com.fine.swing.ui.layout.Layouts.fix; +import static com.fine.swing.ui.layout.Layouts.row; + // 属性表-样式 标题界面 public class VanChartTitlePane extends AbstractVanChartScrollPane { private static final long serialVersionUID = -2438898431228882682L; @@ -96,131 +96,108 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { private void initComponents() { isTitleVisible = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Title_Visible")); tooltipLabel = new UILabel("" + Toolkit.i18nText("Fine-Design_Chart_Title_Tooltip") + ""); - tooltipLabel.setForeground(Color.gray); - tooltipLabel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); + FineUIStyle.setStyle(tooltipLabel, FineUIStyle.LABEL_TIP); tooltipLabel.setVisible(false); - - JPanel panel = new JPanel(); - panel.setLayout(new BorderLayout()); - panel.add(isTitleVisible, BorderLayout.NORTH); - panel.add(tooltipLabel, BorderLayout.CENTER); - titlePane = createTitlePane(); - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {f}; - double[] rowSize = {p, p, p}; - Component[][] components = new Component[][]{ - new Component[]{panel}, - new Component[]{titlePane} - }; - - JPanel panel1 = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); this.setLayout(new BorderLayout()); - this.add(panel1, BorderLayout.CENTER); + this.add(column( + cell(isTitleVisible), + cell(tooltipLabel), + cell(titlePane) + ).getComponent(), BorderLayout.CENTER); - isTitleVisible.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - checkTitlePaneUse(); - } - }); + isTitleVisible.addActionListener(e -> checkTitlePaneUse()); } } private JPanel createTitlePane() { backgroundPane = createBackgroundPane(); + return column( + cell(createTitleContentPane()), + fix(10).with(it -> it.setBorder(FineBorderFactory.createDefaultUnderlineBorder())), + cell(createTitlePositionPane()), + fix(10).with(it -> it.setBorder(FineBorderFactory.createDefaultUnderlineBorder())), + cell(createTitleStylePane()), + fix(10).with(it -> it.setBorder(FineBorderFactory.createDefaultUnderlineBorder())), + cell(new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane)), + fix(10).with(it -> it.setBorder(FineBorderFactory.createDefaultUnderlineBorder())), + cell(createDisplayStrategy()) + ).getComponent(); - - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] columnSize = {p, f}; - double[] column = {f, e}; - double[] rowSize = {p, p, p, p, p, p, p, p}; - Component[][] components = new Component[][]{ - new Component[]{createTitleContentPane(new double[]{p, p, p}, column), null}, - new Component[]{createTitlePositionPane(new double[]{p, p, p}, column), null}, - new Component[]{createTitleStylePane(), null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane), null}, - new Component[]{createDisplayStrategy(), null} - }; - - return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } protected VanChartBackgroundWithOutShadowWithRadiusPane createBackgroundPane() { return new VanChartBackgroundWithOutShadowWithRadiusPane(); } - private JPanel createTitleContentPane(double[] row, double[] col) { + private JPanel createTitleContentPane() { titleContent = new DefaultTinyFormulaPane(); useHtml = new UIToggleButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Html")); UIComponentUtils.setLineWrap(useHtml); - Component[][] components = new Component[][]{ - new Component[]{null, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Text"), SwingConstants.LEFT), titleContent}, - new Component[]{null, useHtml}, - }; - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content"), panel); + JPanel titleContentPane = column(10, + row( + cell(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Text"), SwingConstants.LEFT)).weight(1.2), + cell(titleContent).weight(3) + )).getComponent(); + return new UIExpandablePane( + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content"), titleContentPane); } - private JPanel createTitlePositionPane(double[] row, double[] col) { - Icon[] alignmentIconArray = {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")}; + private JPanel createTitlePositionPane() { + Icon[][] hAlignmentIconArray = {{new LazyIcon("h_left"), new LazyIcon("h_left").white()}, + {new LazyIcon("h_center"), new LazyIcon("h_center").white()}, + {new LazyIcon("h_right"), new LazyIcon("h_right").white()}}; Integer[] alignment = new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT}; - - alignmentPane = new UIButtonGroup(alignmentIconArray, alignment); + alignmentPane = new UIButtonGroup<>(hAlignmentIconArray, alignment); customFloatPositionButton = new UIToggleButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Float_Position")); UIComponentUtils.setLineWrap(customFloatPositionButton); customFloatPositionButton.setEventBannded(true); - Component[][] components = new Component[][]{ - new Component[]{null, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_BorderLayout_Constraints"), SwingConstants.LEFT), alignmentPane}, - new Component[]{null, customFloatPositionButton} - }; - customFloatPositionPane = new VanChartFloatPositionPane(); initPositionListener(); - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Form_Layout"), panel); + JPanel titlePositionPane = column(10, + row( + cell(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_BorderLayout_Constraints"))).weight(1.2), + cell(alignmentPane).weight(3) + ), + cell(customFloatPositionButton) + ).getComponent(); + + return new UIExpandablePane( + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Form_Layout"), titlePositionPane); } private JPanel createTitleStylePane() { textAttrPane = ChartEditContext.supportTheme() ? new ChartTextAttrPaneWithThemeStyle() : new ChartTextAttrPane(); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), textAttrPane); + return new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), textAttrPane); } private JPanel createDisplayStrategy() { //区域显示策略 恢复用注释。开始删除。 maxProportion = new UINumberDragPaneWithPercent(0, 100, 1); - limitSize = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Limit"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Not_Limit")}); + limitSize = new UIButtonGroup<>(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Limit"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Not_Limit")}); + maxProportionPane = row( + cell(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Max_Proportion"))).weight(1.2), + cell(maxProportion).weight(3) + ).getComponent(); - JPanel limitSizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area_Size"), limitSize); - maxProportionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Max_Proportion"), maxProportion, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); - maxProportionPane.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0)); JPanel panel = new JPanel(new BorderLayout()); - panel.add(limitSizePane, BorderLayout.NORTH); - panel.add(maxProportionPane, BorderLayout.CENTER); + panel.add(column(10, + row( + cell(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area_Size"))).weight(1.2), + cell(limitSize).weight(3) + ), + cell(maxProportionPane) - limitSize.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - checkMaxProPortionUse(); - } - }); + ).getComponent()); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel); + limitSize.addActionListener(e -> checkMaxProPortionUse()); - //区域显示策略 恢复用注释。结束删除。 + return new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel); - //区域显示策略 恢复用注释。取消注释。 -// limitPane = new LimitPane(); -// return limitPane; } private void initPositionListener() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaBackgroundPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaBackgroundPane.java index e6eb8c6131..9c332c3e5e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaBackgroundPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaBackgroundPane.java @@ -1,16 +1,15 @@ package com.fr.van.chart.designer.style.background; +import com.fine.theme.utils.FineLayoutBuilder; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; +import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.designer.AbstractVanChartScrollPane; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.background.VanChartBackgroundPane; import com.fr.van.chart.designer.component.background.VanChartBackgroundPaneWithThemeStyle; import com.fr.van.chart.designer.component.border.VanChartBorderWithRadiusPane; @@ -52,16 +51,11 @@ public class VanChartAreaBackgroundPane extends AbstractVanChartScrollPane implements AutoSele protected void initLayout() { - this.setLayout(new BorderLayout()); + this.setLayout(new BorderLayout(0, FineUIScale.scale(10))); if (!paneList.isEmpty()) { - JPanel pane = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0)); if (nameArray.length > 1) { - pane.add(tabPane); - tabPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); - this.add(pane, BorderLayout.NORTH); + this.add(cell(tabPane).getComponent(), BorderLayout.NORTH); } } - centerPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); this.add(centerPane, BorderLayout.CENTER); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/datasheet/VanChartDataSheetPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/datasheet/VanChartDataSheetPane.java index 045b6cd3fa..b795eff6c4 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/datasheet/VanChartDataSheetPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/datasheet/VanChartDataSheetPane.java @@ -1,13 +1,14 @@ package com.fr.van.chart.designer.style.datasheet; +import com.fine.swing.ui.layout.Column; +import com.fine.theme.utils.FineLayoutBuilder; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.DataSheet; import com.fr.chartx.config.info.constant.ConfigType; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.style.FormatPane; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithThemeStyle; @@ -18,8 +19,8 @@ import com.fr.plugin.chart.VanChartAttrHelper; import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; import com.fr.plugin.chart.base.VanChartConstants; import com.fr.plugin.chart.type.AxisType; +import com.fr.stable.collections.combination.Pair; import com.fr.van.chart.designer.AbstractVanChartScrollPane; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.border.VanChartBorderPane; import com.fr.van.chart.designer.component.border.VanChartBorderPaneWithPreStyle; import com.fr.van.chart.designer.component.format.FormatPaneWithNormalType; @@ -27,8 +28,6 @@ import com.fr.van.chart.designer.component.format.FormatPaneWithNormalType; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; /** * 样式-数据表 @@ -54,32 +53,22 @@ public class VanChartDataSheetPane extends AbstractVanChartScrollPane { private void initComponents() { isShowDataSheet = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Show_Data_Sheet")); dataSheetPane = createDataSheetPane(); - - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {f}; - double[] rowSize = {p, p, p}; Component[][] components = creatComponent(dataSheetPane); - JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + JPanel panel = FineLayoutBuilder.compatibleTableLayout(0, components, new double[]{1}); this.setLayout(new BorderLayout()); this.add(panel, BorderLayout.CENTER); - isShowDataSheet.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - checkDataSheetPaneUse(); - } - }); + isShowDataSheet.addActionListener(e -> checkDataSheetPaneUse()); } } protected Component[][] creatComponent(JPanel dataSheetPane) { - Component[][] components = new Component[][]{ + return new Component[][]{ new Component[]{isShowDataSheet}, new Component[]{dataSheetPane} }; - return components; } // 检查数据表界面是否可用. @@ -91,19 +80,12 @@ public class VanChartDataSheetPane extends AbstractVanChartScrollPane { textAttrPane = createChartTextAttrPane(); formatPane = new FormatPaneWithNormalType(); borderPane = createBorderPanePane(); + Column column = FineLayoutBuilder.createVerticalExpandPaneLayout(0, + new Pair<>(Toolkit.i18nText("Fine-Design_Report_Base_Format"), formatPane), + new Pair<>(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), textAttrPane), + new Pair<>(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane)); - double p = TableLayout.PREFERRED; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; - double[] columnSize = {d, e}; - double[] rowSize = {p, p, p}; - Component[][] components = new Component[][]{ - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Format"), formatPane), null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), textAttrPane), null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane), null}, - }; - - return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); + return FineLayoutBuilder.asBorderLayoutWrapped(column); } protected VanChartBorderPane createBorderPanePane() { @@ -150,7 +132,6 @@ public class VanChartDataSheetPane extends AbstractVanChartScrollPane { //数据表埋点 ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.DATA_TABLE, chart.getBuryingPointDataTableConfig()); -// plot.setDataSheet2PlotList(); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPiePlotLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPiePlotLabelPane.java index ac24b99510..09b719ab0a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPiePlotLabelPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPiePlotLabelPane.java @@ -1,11 +1,11 @@ package com.fr.van.chart.designer.style.label; import com.fr.chart.chartattr.Plot; +import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.i18n.Toolkit; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.AttrLabel; import com.fr.plugin.chart.base.AttrLabelDetail; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -25,14 +25,14 @@ public class VanChartPiePlotLabelPane extends VanChartPlotLabelPane { } protected void createLabelPane() { - setLabelPane(new JPanel(new BorderLayout(0, 4))); + setLabelPane(new JPanel(new BorderLayout())); setLabelDetailPane(new VanChartPieValueLabelDetailPane(getPlot(), getParentPane(), isInCondition())); - JPanel valuePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Value_Label"), getLabelDetailPane()); + JPanel valuePane = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Value_Label"), getLabelDetailPane(), true); getLabelPane().add(valuePane, BorderLayout.NORTH); if (!isInCondition()) { pieCategoryLabelPane = new VanChartPieCategoryLabelDetailPane(getPlot(), getParentPane(), isInCondition()); - JPanel categoryPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Category_Label"), pieCategoryLabelPane); + JPanel categoryPane = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Category_Label"), pieCategoryLabelPane); getLabelPane().add(categoryPane, BorderLayout.CENTER); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java index 0467fe3f5e..2cf72679f3 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java @@ -1,9 +1,12 @@ package com.fr.van.chart.designer.style.label; +import com.fine.theme.utils.FineLayoutBuilder; +import com.fine.theme.utils.FineUIScale; import com.fr.chart.chartattr.Plot; import com.fr.chartx.TwoTuple; import com.fr.design.beans.BasicBeanPane; import com.fr.design.dialog.BasicPane; +import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.ilable.UILabel; @@ -125,7 +128,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { double[] rowSize = getLabelPaneRowSize(plot, p); Component[][] components = getLabelPaneComponents(plot, p, columnSize); - return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + return FineLayoutBuilder.compatibleTableLayout(0, components, new double[]{1, 0}); } protected Component[][] getLabelPaneComponents(Plot plot, double p, double[] columnSize) { @@ -153,7 +156,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { protected JPanel createBorderAndBackgroundPane() { JPanel jPanel = new JPanel(); - jPanel.setLayout(new BorderLayout(0, 5)); + jPanel.setLayout(new BorderLayout(0, FineUIScale.scale(10))); jPanel.add(createLabelBorderPane(), BorderLayout.NORTH); jPanel.add(createLabelBackgroundPane(), BorderLayout.CENTER); return jPanel; @@ -161,7 +164,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { protected JPanel createLabelBorderPane() { borderPane = new VanChartBorderWithShapePane(); - borderPaneWithTitle = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane); + borderPaneWithTitle = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane, true); return borderPaneWithTitle; } @@ -179,7 +182,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { } }; - backgroundPaneWithTitle = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane); + backgroundPaneWithTitle = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane); return backgroundPaneWithTitle; } @@ -201,7 +204,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { } protected JPanel createTableLayoutPaneWithTitle(String title, JPanel panel) { - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(title, panel); + return new UIExpandablePane(title, panel); } protected TwoTuple getPositionNamesAndValues() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelPane.java index 4aed8c30a9..ab4340f361 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelPane.java @@ -1,11 +1,10 @@ package com.fr.van.chart.designer.style.label; +import com.fine.theme.utils.FineLayoutBuilder; import com.fr.chart.chartattr.Plot; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.AttrLabel; import com.fr.van.chart.designer.PlotFactory; @@ -14,8 +13,6 @@ import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; public class VanChartPlotLabelPane extends BasicPane { private static final long serialVersionUID = -1701936672446232396L; @@ -39,7 +36,7 @@ public class VanChartPlotLabelPane extends BasicPane { this.plot = plot; this.inCondition = inCondition; isLabelShow = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Use_Label")); - labelPane = new JPanel(new BorderLayout(0, 4)); + labelPane = new JPanel(new BorderLayout()); createLabelPane(); addComponents(); } @@ -86,22 +83,12 @@ public class VanChartPlotLabelPane extends BasicPane { if (inCondition) { return labelPane; } - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {f}; - double[] rowSize = {p, p}; Component[][] components = new Component[][]{ new Component[]{isLabelShow}, new Component[]{labelPane} }; - isLabelShow.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - checkBoxUse(); - } - }); - - JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - return panel; + isLabelShow.addActionListener(e -> checkBoxUse()); + return FineLayoutBuilder.compatibleTableLayout(0, components, new double[]{1}); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java index 0a5f7b8feb..470e9ead02 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java @@ -1,5 +1,7 @@ package com.fr.van.chart.designer.style.series; +import com.fine.theme.utils.FineLayoutBuilder; +import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.base.chart.chartdata.model.DataProcessor; import com.fr.base.chart.chartdata.model.LargeDataModel; import com.fr.base.chart.chartdata.model.NormalDataModel; @@ -9,14 +11,12 @@ import com.fr.chart.base.AttrFillStyle; import com.fr.chart.base.GradientStyle; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; -import com.fr.design.constants.LayoutConstants; +import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.frpane.UINumberDragPaneWithPercent; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.style.series.AbstractPlotSeriesPane; import com.fr.design.widget.FRWidgetFactory; @@ -42,15 +42,16 @@ import com.fr.van.chart.designer.component.border.VanChartBorderPane; import com.fr.van.chart.designer.other.VanChartInteractivePane; import com.fr.van.chart.pie.RadiusCardLayoutPane; -import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.BorderLayout; import java.awt.Component; +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.column; + /** * 图表样式-系列抽象界面 */ @@ -104,13 +105,9 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP scrollPane.setViewportView(getContentInPlotType()); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); } - JPanel panel = new JPanel(new BorderLayout()); - JPanel colorPane = getColorPane(); - if (colorPane != null) { - panel.add(colorPane, BorderLayout.NORTH); - } - panel.add(getContentInPlotType(), BorderLayout.CENTER); - return panel; + return column( + cell(getColorPane()), cell(getContentInPlotType()) + ).getComponent(); } /** @@ -135,8 +132,7 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP panel.add(vanChartFillStylePane, BorderLayout.CENTER); } setColorPaneContent(panel); - JPanel colorPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Color"), panel); - panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 0)); + JPanel colorPane = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Color"), panel, true); return panel.getComponentCount() == 0 ? null : colorPane; } @@ -184,23 +180,19 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP //边框(默认没有圆角) protected JPanel createBorderPane() { borderPane = createDiffBorderPane(); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane); + borderPane.setBorder(new ScaledEmptyBorder(0, 0, 10, 0)); + return new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane); } //半径界面 protected JPanel createRadiusPane(String title) { radiusPane = initRadiusPane(); - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {f, TableLayout4VanChartHelper.EDIT_AREA_WIDTH}; - double[] rowSize = {p}; UILabel label = FRWidgetFactory.createLineWrapLabel(title); - label.setVerticalAlignment(SwingConstants.TOP); Component[][] components = new Component[][]{ new Component[]{label, radiusPane}, }; - radiusPaneWithTitle = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, TableLayout4VanChartHelper.COMPONENT_INTERVAL, LayoutConstants.VGAP_LARGE); + radiusPaneWithTitle = FineLayoutBuilder.compatibleTableLayout(10, components, new double[]{1.2, 3}); return ((VanChartPlot) plot).isInCustom() ? null : radiusPaneWithTitle; } @@ -284,7 +276,7 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP //堆积和坐标轴设置(自定义柱形图等用到) protected JPanel createStackedAndAxisPane() { stackAndAxisEditPane = new VanChartStackedAndAxisListControlPane(); - stackAndAxisEditExpandablePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(stackAndAxisEditPane.getPaneTitle(), stackAndAxisEditPane); + stackAndAxisEditExpandablePane = new UIExpandablePane(stackAndAxisEditPane.getPaneTitle(), stackAndAxisEditPane); return stackAndAxisEditExpandablePane; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartPlotTooltipPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartPlotTooltipPane.java index 5f76337d67..5c7e7dd2ed 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartPlotTooltipPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartPlotTooltipPane.java @@ -1,12 +1,13 @@ package com.fr.van.chart.designer.style.tooltip; +import com.fine.theme.utils.FineLayoutBuilder; import com.fr.chart.chartattr.Plot; import com.fr.design.dialog.BasicPane; +import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.plugin.chart.base.AttrTooltip; @@ -20,8 +21,6 @@ import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; public class VanChartPlotTooltipPane extends BasicPane { private static final long serialVersionUID = 6087381131907589370L; @@ -47,28 +46,19 @@ public class VanChartPlotTooltipPane extends BasicPane { addComponents(plot); } - protected void addComponents(Plot plot) { + protected void addComponents(Plot plot) { isTooltipShow = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Use_Tooltip")); tooltipPane = createTooltipPane(plot); - - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {f}; - double[] rowSize = {p,p}; Component[][] components = new Component[][]{ new Component[]{isTooltipShow}, new Component[]{tooltipPane} }; - JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + JPanel panel = FineLayoutBuilder.compatibleTableLayout(0, components, new double[]{1}); this.setLayout(new BorderLayout()); this.add(panel,BorderLayout.CENTER); - isTooltipShow.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - checkBoxUse(); - } - }); + isTooltipShow.addActionListener(e -> checkBoxUse()); } protected JPanel createTooltipPane(Plot plot) { @@ -77,25 +67,18 @@ public class VanChartPlotTooltipPane extends BasicPane { initTooltipContentPane(plot); - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] columnSize = {f, e}; - double[] rowSize = {p,p,p,p,p,p,p,p,p}; - Component[][] components = createComponents(plot); - return TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); + return FineLayoutBuilder.compatibleTableLayout(0, components, new double[]{1}); } protected Component[][] createComponents(Plot plot) { - Component[][] components = new Component[][]{ + return new Component[][]{ new Component[]{tooltipContentPane,null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"),borderPane),null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane),null}, + new Component[]{new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Border"),borderPane, true),null}, + new Component[]{new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane, true),null}, new Component[]{createDisplayStrategy(plot),null}, }; - return components; } public VanChartStylePane getParentPane() { @@ -123,7 +106,7 @@ public class VanChartPlotTooltipPane extends BasicPane { components[2] = new Component[]{showAllSeries,null}; } JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components,rowSize,columnSize); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel); + return new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel); } protected String getShowAllSeriesLabelText() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPieSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPieSeriesPane.java index 6253190da2..52f865356d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPieSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPieSeriesPane.java @@ -2,6 +2,7 @@ package com.fr.van.chart.pie; import com.fr.chart.chartattr.Plot; +import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.frpane.UINumberDragPaneWithPercent; import com.fr.design.gui.ibutton.UIButtonGroup; @@ -69,7 +70,7 @@ public class VanChartPieSeriesPane extends VanChartAbstractPlotSeriesPane { JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel); + return new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel, true); } public void populateBean(Plot plot) { diff --git a/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnPane.java b/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnPane.java index d3378b8956..15df8e7fa5 100644 --- a/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnPane.java +++ b/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnPane.java @@ -108,7 +108,6 @@ public class DSColumnPane extends BasicPane { contentPane.add(tabbedPane, BorderLayout.CENTER); - this.setPreferredSize(new Dimension(610, 400)); } @Override