package com.fr.widgettheme.util; import com.fr.design.designer.IntervalConstants; import com.fr.design.gui.frpane.FontSizeComboPane; import com.fr.design.gui.frpane.UIPercentDragPane; import com.fr.design.gui.ibutton.UIColorButton; import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.style.color.NewColorSelectBox; import com.fr.design.widget.FRWidgetFactory; import javax.swing.JPanel; import java.awt.Component; /** * 创建控件样式组合配置面板的工具类 * * @author obo * @since 11.0 * Created on 2023/12/21 */ public class WidgetStyleComponentCombiner { private static final double F = TableLayout.FILL; private static final double P = TableLayout.PREFERRED; private WidgetStyleComponentCombiner() { } /** * 组合主题文本样式配置面板 * 包含字体大小下拉框和字体颜色按钮 * * @param fontSizePane 字体大小配置 * @param fontColorButton 字体颜色配置 * @param bold 粗体 * @param italic 斜体 * @return 文本样式面板 */ public static JPanel combineTextStyleComponent(FontSizeComboPane fontSizePane, UIColorButton fontColorButton, UIToggleButton bold, UIToggleButton italic) { Component[][] components = {{fontSizePane, fontColorButton, bold, italic}}; double[] rowSize = {P}; double[] columnSize = {F, P, P, P}; int[][] rowCount = {{1, 1, 1, 1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 5, 5); } /** * 组合主题文本样式配置面板 * 包含字体大小下拉框和字体颜色按钮 * * @param fontNameSelectBox 字体名配置 * @param fontSizePane 字体大小配置 * @param fontColorButton 字体颜色配置 * @param bold 粗体 * @param italic 斜体 * @return 文本样式面板 */ public static JPanel combineTextStyleComponent(UIComboBox fontNameSelectBox, FontSizeComboPane fontSizePane, UIColorButton fontColorButton, UIToggleButton bold, UIToggleButton italic) { Component[][] components = { {fontNameSelectBox, null, null, null}, {fontSizePane, fontColorButton, bold, italic} }; double[] rowSize = {P, P}; double[] columnSize = {F, P, P, P}; int[][] rowCount = { {1, 1, 1, 1}, {1, 1, 1, 1} }; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 5, 5); } /** * 组合控件背景配置面板 * * @param colorSelectBox 颜色下拉框 * @param alphaDragPane 透明度 * @param columnWidth 列宽 * @return 文本样式面板 */ public static JPanel combineWidgetBackgroundComponent(NewColorSelectBox colorSelectBox, UIPercentDragPane alphaDragPane, double columnWidth) { Component[][] components = { {colorSelectBox}, {FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Form_Widget-Style_Alpha"))}, {alphaDragPane} }; double[] rowSize = {P, P, P}; double[] columnSize = {columnWidth}; int[][] rowCount = {{1}, {1}, {1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); } /** * 组合控件边框配置面板 * * @param lineComboBox 字体大小配置 * @param lineComboColorSelectBox 字体颜色配置 * @return 文本样式面板 */ public static JPanel combineWidgetBorderComponent(LineComboBox lineComboBox, NewColorSelectBox lineComboColorSelectBox) { return combineWidgetBorderComponent(lineComboBox, lineComboColorSelectBox, P); } /** * 组合控件边框配置面板 * * @param lineComboBox 字体大小配置 * @param lineComboColorSelectBox 字体颜色配置 * @param columnWidth 指定的列宽 * @return 文本样式面板 */ public static JPanel combineWidgetBorderComponent(LineComboBox lineComboBox, NewColorSelectBox lineComboColorSelectBox, double columnWidth) { Component[][] components = { {lineComboBox}, {lineComboColorSelectBox} }; double[] rowSize = {P, P}; double[] columnSize = {columnWidth}; int[][] rowCount = {{1}, {1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); } }