帆软报表设计器源代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

139 lines
5.1 KiB

package com.fr.widgettheme.theme.panel;
import com.fr.base.background.ColorBackground;
import com.fr.base.theme.TemplateTheme;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.theme.preview.ThemePreviewed;
import com.fr.general.Background;
import com.fr.widgettheme.ThemePreviewTerminal;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.List;
/**
* 主题界面页面中的参数界面
*
* @author John.Ying
* @since 11.0
* Created on 2023/3/18
*/
public class ControlPreviewPane extends JPanel implements ThemePreviewed<TemplateTheme> {
public static final int PREVIEW_WIDTH = 615;
public static final int PREVIEW_HEIGHT = 62;
/**
* 参数界面中放置的所有cell,用于监听主题样式变更
*/
public final List<ControlPreviewCell> list = new ArrayList<>();
private Background background;
private static final String DATE_ICON_URL = "/com/fr/web/images/form/resources/date_16.png";
private static final String COMBOBOX_ICON_URL = "/com/fr/widgettheme/combobox.png";
@Override
public void refresh(TemplateTheme style) {
refresh(style, ThemePreviewTerminal.PC);
}
@Override
public void refresh(TemplateTheme style, ThemePreviewTerminal type) {
this.background = style.getParamContainerStyle().getBackground();
for (ControlPreviewCell controlPreviewCell : list) {
controlPreviewCell.refresh(style, type);
}
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
paintBackground((Graphics2D) g);
}
protected void paintBackground(Graphics2D g2d) {
if (background == null) {
background = ColorBackground.getInstance(Color.WHITE);
}
background.paint(g2d, new Rectangle2D.Double(0, 0, PREVIEW_WIDTH, PREVIEW_HEIGHT));
}
/**
* 初始化参数界面,往里面添加各种cell
*/
public void initControlPreviewPane() {
initDateControlPane();
initComboboxControlPane();
initRadioButtonControlPane();
initNormalButtonControlPane();
}
/**
* 初始化日期控件包括文字跟控件
*/
private void initDateControlPane() {
TextPreviewCell dateTextCell = new TextPreviewCell(Toolkit.i18nText("Fine-Design_Theme_Control_Date_Text"));
dateTextCell.setPreferredSize(new Dimension(80, 30));
ControlPreviewCellWithIcon dateEditorCell = new ControlPreviewCellWithIcon(Toolkit.i18nText("Fine-Design_Theme_Control_Date_Editor_Text"));
dateEditorCell.drawIcon(DATE_ICON_URL);
dateEditorCell.setTextColor(ControlPreviewCell.DEFAULT_COLOR);
this.add(dateTextCell);
this.add(dateEditorCell);
this.list.add(dateTextCell);
this.list.add(dateEditorCell);
}
/**
* 初始化下拉框控件包括文件跟控件
*/
private void initComboboxControlPane() {
TextPreviewCell comboBoxTextCell = new TextPreviewCell(Toolkit.i18nText("Fine-Design_Theme_Control_ComboBox_Text"));
comboBoxTextCell.setPreferredSize(new Dimension(60, 30));
ControlPreviewCellWithIcon comboBoxControlPreviewCell = new ControlPreviewCellWithIcon(Toolkit.i18nText("Fine-Design_Theme_Control_ComboBox_Editor_Text"));
comboBoxControlPreviewCell.drawIcon(COMBOBOX_ICON_URL);
comboBoxControlPreviewCell.setTextColor(ControlPreviewCell.DEFAULT_COLOR);
this.add(comboBoxTextCell);
this.add(comboBoxControlPreviewCell);
this.list.add(comboBoxControlPreviewCell);
this.list.add(comboBoxTextCell);
}
/**
* 初始化单选按钮组控件
*/
private void initRadioButtonControlPane() {
RingControlPreviewCell ringControlPreviewCell = new RingControlPreviewCell();
RoundControlPreviewCell roundControlPreviewCell = new RoundControlPreviewCell();
TextPreviewCell yearTextFieldCell = new TextPreviewCell(Toolkit.i18nText("Fine-Design_Theme_Control_Radio_Year"));
yearTextFieldCell.setPreferredSize(new Dimension(38, 30));
TextPreviewCell monthTextFieldCell = new TextPreviewCell(Toolkit.i18nText("Fine-Design_Theme_Control_Radio_Month"));
monthTextFieldCell.setPreferredSize(new Dimension(38, 30));
this.add(ringControlPreviewCell);
this.add(yearTextFieldCell);
this.add(roundControlPreviewCell);
this.add(monthTextFieldCell);
this.list.add(ringControlPreviewCell);
this.list.add(roundControlPreviewCell);
this.list.add(yearTextFieldCell);
this.list.add(monthTextFieldCell);
}
/**
* 初始化按钮预览格子
*/
private void initNormalButtonControlPane() {
NormalButtonPreviewCell normalButton = new NormalButtonPreviewCell(FRGUIPaneFactory.createCenterFlowLayout(), ControlPreviewCell.DEFAULT_MESSAGE);
this.add(normalButton);
this.list.add(normalButton);
}
}