帆软报表设计器源代码。
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.
 
 
 
 

216 lines
9.3 KiB

package com.fr.design.hyperlink.popup;
import com.fine.theme.utils.FineUIStyle;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.gui.frpane.UINumberDragPane;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.js.MobilePopupHyperlink;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import static com.fine.swing.ui.layout.Layouts.column;
import static com.fine.swing.ui.layout.Layouts.cell;
import static com.fine.swing.ui.layout.Layouts.row;
import static com.fine.swing.ui.layout.Layouts.flex;
public class StyleSettingPane extends BasicBeanPane<MobilePopupHyperlink> {
private double maxNumber = 100;
private double maxBorderRadius = 24;
JPanel typePane;
UILabel popupTypeLabel;
JPanel stylePane;
LineComboBox borderType;
NewColorSelectBox borderColor;
UISpinner borderRadiusSpinner;
NewColorSelectBox bgColor;
//透明度
UINumberDragPane numberDragPane;
MobilePopupRegularPane mobileRegularPane;
MobilePopupRegularPane padRegularPane;
public StyleSettingPane() {
this.initComponent();
}
private void initComponent() {
this.setLayout(new BorderLayout());
typePane = this.createTypePane();
stylePane = this.createStylePane();
this.add(column(10,
cell(typePane),
cell(stylePane)
).getComponent());
}
private JPanel createTypePane() {
JPanel typePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
popupTypeLabel = new UILabel("");
UILabel typeLabel = new UILabel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Type"));
typePane.add(row(cell(typeLabel).weight(1), row(cell(popupTypeLabel), flex()).weight(6)).getComponent());
return typePane;
}
private JPanel createStylePane() {
JPanel stylePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
stylePane.add(column(10,
cell(this.createBorderSettingPane()),
cell(this.createBackgroundSettingPane()),
cell(this.createPopupSizePane())
).getComponent());
return stylePane;
}
private JPanel createBorderSettingPane() {
JPanel borderPane = new JPanel();
borderPane.setLayout(new BorderLayout());
borderType = new LineComboBox(MobilePopupConstants.BORDER_LINE_STYLE_ARRAY);
borderColor = new NewColorSelectBox(100);
borderRadiusSpinner = new UISpinner(0, maxBorderRadius, 1, 20);
UILabel borderLabel = new UILabel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Border"));
borderPane.add(column(LayoutConstants.VERTICAL_GAP,
row(cell(borderLabel).weight(1), cell(new UILabel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Line"), FineUIStyle.LABEL_SECONDARY)).weight(1), cell(borderType).weight(2), flex(3)),
row(flex(1), cell(new UILabel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Colors"), FineUIStyle.LABEL_SECONDARY)).weight(1), cell(borderColor).weight(2), flex(3)),
row(flex(1), cell(new UILabel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Radius"), FineUIStyle.LABEL_SECONDARY)).weight(1), cell(borderRadiusSpinner).weight(2), flex(3))
).getComponent());
return borderPane;
}
private JPanel createBackgroundSettingPane() {
JPanel bgPane = new JPanel();
bgPane.setLayout(new BorderLayout());
bgColor = new NewColorSelectBox(100);
JPanel transparencyPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.numberDragPane = new UINumberDragPane(0, 100);
transparencyPane.add(numberDragPane, BorderLayout.CENTER);
transparencyPane.add(new UILabel(" %"), BorderLayout.EAST);
JLabel bgLabel = new JLabel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Background"));
bgPane.add(column(LayoutConstants.VERTICAL_GAP,
row(cell(bgLabel).weight(1), cell(new UILabel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Colors"), FineUIStyle.LABEL_SECONDARY)).weight(1), cell(bgColor).weight(2), flex(3)),
row(flex(1), cell(new UILabel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Opacity"), FineUIStyle.LABEL_SECONDARY)).weight(1), cell(transparencyPane).weight(3), flex(2))
).getComponent());
return bgPane;
}
private JPanel createPopupSizePane() {
JPanel sizePane = new JPanel(new BorderLayout());
mobileRegularPane = new MobilePopupRegularPane(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Mobile_Rules"));
padRegularPane = new MobilePopupRegularPane(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Pad_Rules"));
JLabel sizeLabel = new JLabel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Size"));
sizePane.add(column(LayoutConstants.VERTICAL_GAP,
row(
column(LayoutConstants.VERTICAL_GAP, cell(sizeLabel), flex()).weight(1),
cell(mobileRegularPane).weight(4), flex(2)
),
row(flex(1), cell(padRegularPane).weight(4), flex(2))
).getComponent());
return sizePane;
}
@Override
protected String title4PopupWindow() {
return StringUtils.EMPTY;
}
public void resetPane(String popupTargetType) {
if (StringUtils.equals(popupTargetType, MobilePopupConstants.Target_Template)) {
popupTypeLabel.setText(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Center"));
mobileRegularPane.resetPane(MobilePopupConstants.Regular_Custom, MobilePopupConstants.Popup_Center_Default_Width, MobilePopupConstants.Popup_Center_Default_Height);
padRegularPane.resetPane(MobilePopupConstants.Regular_Custom, MobilePopupConstants.Popup_Center_Default_Width, MobilePopupConstants.Popup_Center_Default_Height);
} else {
popupTypeLabel.setText(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Follow"));
mobileRegularPane.resetPane(MobilePopupConstants.Regular_Custom, MobilePopupConstants.Popup_Follow_Default_Width, MobilePopupConstants.Popup_Follow_Default_Height);
padRegularPane.resetPane(MobilePopupConstants.Regular_Custom, MobilePopupConstants.Popup_Follow_Default_Width, MobilePopupConstants.Popup_Follow_Default_Height);
}
}
@Override
public void populateBean(MobilePopupHyperlink link) {
this.populateTypeBean(link);
this.populateBorderSettingBean(link);
this.populateBackgroundSettingBean(link);
this.populatePopupSizeBean(link);
}
@Override
public MobilePopupHyperlink updateBean() {
return null;
}
@Override
public void updateBean(MobilePopupHyperlink link) {
this.updateBorderSettingBean(link);
this.updateBackgroundSettingBean(link);
this.updatePopupSizeBean(link);
}
private void populateTypeBean(MobilePopupHyperlink link) {
if (StringUtils.equals(link.getPopupTarget(), MobilePopupConstants.Target_Text)) {
popupTypeLabel.setText(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Follow"));
} else {
popupTypeLabel.setText(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Center"));
}
}
private void populateBorderSettingBean(MobilePopupHyperlink link) {
borderType.setSelectedLineStyle(link.getBorderType());
borderColor.setSelectObject(link.getBorderColor());
borderRadiusSpinner.setValue(link.getBorderRadius());
}
private void updateBorderSettingBean(MobilePopupHyperlink link) {
link.setBorderType(borderType.getSelectedLineStyle());
link.setBorderColor(borderColor.getSelectObject());
link.setBorderRadius(borderRadiusSpinner.getValue());
}
private void populateBackgroundSettingBean(MobilePopupHyperlink link) {
bgColor.setSelectObject(link.getBgColor());
numberDragPane.populateBean(link.getBgOpacity() * maxNumber);
}
private void updateBackgroundSettingBean(MobilePopupHyperlink link) {
link.setBgColor(bgColor.getSelectObject());
link.setBgOpacity((float) (numberDragPane.updateBean() / maxNumber));
}
private void populatePopupSizeBean(MobilePopupHyperlink link) {
mobileRegularPane.setRegularType(link.getMobileRegularType());
mobileRegularPane.setWidthSpinnerValue(link.getMobileWidth());
mobileRegularPane.setHeightSpinnerValue(link.getMobileHeight());
padRegularPane.setRegularType(link.getPadRegularType());
padRegularPane.setWidthSpinnerValue(link.getPadWidth());
padRegularPane.setHeightSpinnerValue(link.getPadHeight());
}
private void updatePopupSizeBean(MobilePopupHyperlink link) {
link.setMobileRegularType(mobileRegularPane.getRegularType());
link.setMobileWidth(mobileRegularPane.getWidthSpinnerValue());
link.setMobileHeight(mobileRegularPane.getHeightSpinnerValue());
link.setPadRegularType(padRegularPane.getRegularType());
link.setPadWidth(padRegularPane.getWidthSpinnerValue());
link.setPadHeight(padRegularPane.getHeightSpinnerValue());
}
}