obo
11 months ago
8 changed files with 107 additions and 100 deletions
@ -1,72 +0,0 @@
|
||||
package com.fr.widgettheme.theme.panel; |
||||
|
||||
import com.fr.design.gui.ibutton.UIColorButton; |
||||
import com.fr.design.gui.frpane.FontSizeComboPane; |
||||
import com.fr.widgettheme.theme.widget.style.ThemeTextStyle; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.Box; |
||||
import javax.swing.JPanel; |
||||
import java.awt.Color; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.util.Vector; |
||||
|
||||
/** |
||||
* 控件文本样式配置面板 |
||||
* 包含文本字体大小和字体颜色 |
||||
* |
||||
* @author oBo |
||||
* @since 11.0 |
||||
* Created on 2023/12/13 |
||||
*/ |
||||
public class WidgetTextStylePane extends JPanel { |
||||
|
||||
private final FontSizeComboPane fontSizePane; |
||||
|
||||
private final UIColorButton fontColorButton; |
||||
|
||||
public WidgetTextStylePane(int preferredWidth) { |
||||
this(null, preferredWidth); |
||||
} |
||||
|
||||
public WidgetTextStylePane(Vector<Integer> fontSizes, int preferredWidth) { |
||||
this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); |
||||
this.setBorder(BorderFactory.createEmptyBorder()); |
||||
fontSizePane = new FontSizeComboPane(fontSizes); |
||||
fontColorButton = new UIColorButton(); |
||||
fontSizePane.setPreferredSize(new Dimension(preferredWidth, fontSizePane.getPreferredSize().height)); |
||||
this.add(fontSizePane); |
||||
add(Box.createHorizontalStrut(5)); |
||||
this.add(fontColorButton); |
||||
} |
||||
|
||||
public void setTextStyle(ThemeTextStyle themeTextStyle) { |
||||
this.fontSizePane.setValue(themeTextStyle.getFontSize()); |
||||
this.fontColorButton.setColor(themeTextStyle.getFontColor()); |
||||
} |
||||
|
||||
public ThemeTextStyle getTextStyle() { |
||||
ThemeTextStyle themeTextStyle = new ThemeTextStyle(); |
||||
themeTextStyle.setFontSize(this.fontSizePane.getValue()); |
||||
themeTextStyle.setFontColor(this.fontColorButton.getColor()); |
||||
return themeTextStyle; |
||||
} |
||||
|
||||
public void setFontSizeValue(int fontSize) { |
||||
this.fontSizePane.setValue(fontSize); |
||||
} |
||||
|
||||
public void setFontColorValue(Color fontColor) { |
||||
this.fontColorButton.setColor(fontColor); |
||||
} |
||||
|
||||
public int getFontSizeValue() { |
||||
return this.fontSizePane.getValue(); |
||||
} |
||||
|
||||
public Color getFontColorValue() { |
||||
return this.fontColorButton.getColor(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,40 @@
|
||||
package com.fr.widgettheme.util; |
||||
|
||||
import com.fr.design.gui.frpane.FontSizeComboPane; |
||||
import com.fr.design.gui.ibutton.UIColorButton; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
|
||||
import javax.swing.Box; |
||||
import javax.swing.JPanel; |
||||
import java.awt.Component; |
||||
|
||||
/** |
||||
* 样式设置pane抽象类 |
||||
* |
||||
* @author obo |
||||
* @since 11.0 |
||||
* Created on 2023/12/21 |
||||
*/ |
||||
public class ThemeTextStylePaneCreator { |
||||
private ThemeTextStylePaneCreator() {} |
||||
|
||||
/** |
||||
* 创建主题文本样式配置面板 |
||||
* 包含字体大小下拉框和字体颜色按钮 |
||||
* 可以自适应布局 |
||||
* |
||||
* @param fontSizePane 字体大小配置 |
||||
* @param fontColorButton 字体颜色配置 |
||||
* @return 文本样式面板 |
||||
*/ |
||||
public static JPanel create(FontSizeComboPane fontSizePane, UIColorButton fontColorButton) { |
||||
Component[][] components = {{fontSizePane, Box.createHorizontalStrut(5), fontColorButton}}; |
||||
double f = TableLayout.FILL; |
||||
double p = TableLayout.PREFERRED; |
||||
double[] rowSize = {f}; |
||||
double[] columnSize = {f, p, p}; |
||||
int[][] rowCount = {{1, 1, 1}}; |
||||
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 0, 0); |
||||
} |
||||
} |
Loading…
Reference in new issue