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.
206 lines
7.7 KiB
206 lines
7.7 KiB
package com.fr.design.report; |
|
|
|
import com.fr.base.extension.FileExtension; |
|
import com.fr.design.gui.ibutton.UIRadioButton; |
|
import com.fr.design.gui.ilable.UILabel; |
|
import com.fr.design.i18n.DesignSizeI18nManager; |
|
import com.fr.design.i18n.Toolkit; |
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
import com.fr.design.layout.TableLayout; |
|
import com.fr.design.layout.TableLayoutHelper; |
|
import com.fr.io.attr.ImageExportAttr; |
|
import com.fr.io.attr.ReportExportAttr; |
|
|
|
import javax.swing.AbstractButton; |
|
import javax.swing.BorderFactory; |
|
import javax.swing.ButtonGroup; |
|
import javax.swing.JComponent; |
|
import javax.swing.JPanel; |
|
import java.awt.BorderLayout; |
|
import java.awt.Color; |
|
import java.awt.Dimension; |
|
|
|
/** |
|
* 导出图片配置 |
|
* |
|
* @author vito |
|
* @date 2015/7/6 0006 |
|
*/ |
|
public class ImageExportPane extends AbstractExportPane { |
|
|
|
private UIRadioButton globalResolutionBtnS; |
|
private UIRadioButton globalResolutionBtnM; |
|
private UIRadioButton globalResolutionBtnL; |
|
|
|
private UIRadioButton globalRenderSpeed; |
|
private UIRadioButton globalRenderQuality; |
|
|
|
private UIRadioButton globalFormatJpg; |
|
private UIRadioButton globalFormatPng; |
|
|
|
private UIRadioButton templateThumbnail; |
|
private UIRadioButton templatePaging; |
|
|
|
private static final int RESOLUTION_S = 96; |
|
private static final int RESOLUTION_M = 192; |
|
private static final int RESOLUTION_L = 300; |
|
|
|
private static final int GAP = 6; |
|
|
|
public static final String GLOBAL_CONF = Toolkit.i18nText("Fine-Design_Image_Export_Setting"); |
|
|
|
public ImageExportPane() { |
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
|
JPanel globalTitlePane = FRGUIPaneFactory.createTitledBorderPane(GLOBAL_CONF); |
|
JPanel outNorthPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Export_Setting")); |
|
outNorthPane.setPreferredSize(DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.report.ImageExportPane.outNorthPane")); |
|
UILabel tipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Image_Export_Tips")); |
|
tipLabel.setForeground(Color.GRAY); |
|
JPanel tipsTitlePane = new JPanel(); |
|
tipsTitlePane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); |
|
tipsTitlePane.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
tipsTitlePane.add(tipLabel); |
|
this.add(globalTitlePane); |
|
globalTitlePane.add(outNorthPane); |
|
initGlobalSettings(); |
|
|
|
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
JComponent[][] comps = { |
|
{new UILabel(Toolkit.i18nText("Fine-Design_Image_Export_Resolution") + ":"), this.globalResolutionBtnS, this.globalResolutionBtnM, this.globalResolutionBtnL}, |
|
{new UILabel(Toolkit.i18nText("Fine-Design_Report_Format") + ":"), this.globalFormatJpg, null, this.globalFormatPng}, |
|
{new UILabel(Toolkit.i18nText("Fine-Design_Image_Export_Rendering_Quality") + ":"), this.globalRenderQuality, null, this.globalRenderSpeed}, |
|
{new UILabel(Toolkit.i18nText("Fine-Design_Image_Export_Typesetting") + ":"), this.templateThumbnail, null, this.templatePaging} |
|
}; |
|
centerPane.add( |
|
TableLayoutHelper.createCommonTableLayoutPane( |
|
comps, |
|
new double[]{TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL}, |
|
new double[]{TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL}, |
|
GAP), |
|
BorderLayout.CENTER); |
|
centerPane.add(tipsTitlePane,BorderLayout.SOUTH); |
|
outNorthPane.add(centerPane, BorderLayout.CENTER); |
|
} |
|
|
|
|
|
private void initGlobalSettings() { |
|
globalResolutionBtnS = new UIRadioButton("96dpi"); |
|
globalResolutionBtnM = new UIRadioButton("192dpi", true); |
|
globalResolutionBtnL = new UIRadioButton("300dpi"); |
|
wrapButtonsInButtonGroup(globalResolutionBtnS, globalResolutionBtnM, globalResolutionBtnL); |
|
|
|
globalFormatJpg = new UIRadioButton("jpg"); |
|
globalFormatPng = new UIRadioButton("png", true); |
|
wrapButtonsInButtonGroup(globalFormatJpg, globalFormatPng); |
|
|
|
globalRenderQuality = new UIRadioButton(Toolkit.i18nText("Fine-Design_Image_Export_Quality_First")); |
|
globalRenderSpeed = new UIRadioButton(Toolkit.i18nText(("Fine-Design_Image_Export_Speed_Priority")), true); |
|
wrapButtonsInButtonGroup(globalRenderQuality, globalRenderSpeed); |
|
|
|
templateThumbnail = new UIRadioButton(Toolkit.i18nText("Fine-Design_Image_Export_Thumbnail"), true); |
|
templatePaging = new UIRadioButton(Toolkit.i18nText("Fine-Design_Image_Export_Paging")); |
|
wrapButtonsInButtonGroup(templateThumbnail, templatePaging); |
|
} |
|
|
|
private void wrapButtonsInButtonGroup(AbstractButton... buttons) { |
|
if (buttons != null) { |
|
ButtonGroup buttonGroup = new ButtonGroup(); |
|
for (AbstractButton button : buttons) { |
|
buttonGroup.add(button); |
|
} |
|
} |
|
} |
|
|
|
/** |
|
* 展示界面 |
|
*/ |
|
@Override |
|
public void populate(Object exportAttr) { |
|
populateBean(exportAttr); |
|
} |
|
|
|
/** |
|
* 提交数据 |
|
* |
|
* @return 界面上的更新数据 |
|
*/ |
|
@Override |
|
public void update(Object exportAttr) { |
|
updateBean(); |
|
} |
|
|
|
/** |
|
* 标题 |
|
* |
|
* @return 标题 |
|
*/ |
|
@Override |
|
protected String title4PopupWindow() { |
|
return Toolkit.i18nText("Fine-Design_Image_Export_Export_Image_Setting"); |
|
} |
|
|
|
@Override |
|
public void populateBean(Object exportAttr) { |
|
ReportExportAttr reportExportAttr = (ReportExportAttr) exportAttr; |
|
ImageExportAttr attr = reportExportAttr.getImageExportAttr(); |
|
if (attr == null) { |
|
attr = new ImageExportAttr(); |
|
} |
|
switch (attr.getResolution()) { |
|
case 192: |
|
globalResolutionBtnM.setSelected(true); |
|
break; |
|
case 300: |
|
globalResolutionBtnL.setSelected(true); |
|
break; |
|
default: |
|
globalResolutionBtnS.setSelected(true); |
|
} |
|
if (FileExtension.PNG.getExtension().equals(attr.getFormat())) { |
|
globalFormatPng.setSelected(true); |
|
} else { |
|
globalFormatJpg.setSelected(true); |
|
} |
|
if (attr.getRenderQuality() == ImageExportAttr.RENDER_SPEED) { |
|
globalRenderSpeed.setSelected(true); |
|
} else { |
|
globalRenderQuality.setSelected(true); |
|
} |
|
if (attr.isPaging()) { |
|
templatePaging.setSelected(true); |
|
} else { |
|
templateThumbnail.setSelected(true); |
|
} |
|
} |
|
|
|
@Override |
|
public void updateBean(Object exportAttr) { |
|
ReportExportAttr reportExportAttr = (ReportExportAttr) exportAttr; |
|
ImageExportAttr attr = new ImageExportAttr(); |
|
if (globalResolutionBtnS.isSelected()) { |
|
attr.setResolution(RESOLUTION_S); |
|
} else if (globalResolutionBtnM.isSelected()) { |
|
attr.setResolution(RESOLUTION_M); |
|
} else { |
|
attr.setResolution(RESOLUTION_L); |
|
} |
|
if (globalFormatPng.isSelected()) { |
|
attr.setFormat(FileExtension.PNG.getExtension()); |
|
} else { |
|
attr.setFormat(FileExtension.JPG.getExtension()); |
|
} |
|
if (globalRenderSpeed.isSelected()) { |
|
attr.setRenderQuality(ImageExportAttr.RENDER_SPEED); |
|
} else { |
|
attr.setRenderQuality(ImageExportAttr.RENDER_QUALITY); |
|
} |
|
attr.setPaging(templatePaging.isSelected()); |
|
reportExportAttr.setImageExportAttr(attr); |
|
} |
|
|
|
@Override |
|
public String getTitle() { |
|
return "Image"; |
|
} |
|
} |