Browse Source

REPORT-72354 导出图片优化二期

feature/x
pengda 2 years ago
parent
commit
fa538f3d78
  1. 74
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  2. 119
      designer-realize/src/main/java/com/fr/design/report/ImageExportPane.java
  3. 9
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

74
designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java

@ -14,6 +14,7 @@ import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIColorButton; import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UINoThemeColorButton; import com.fr.design.gui.ibutton.UINoThemeColorButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIDictionaryComboBox; import com.fr.design.gui.icombobox.UIDictionaryComboBox;
@ -26,6 +27,7 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iprogressbar.UIProgressBarUI; import com.fr.design.gui.iprogressbar.UIProgressBarUI;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.jdk.JdkVersion; import com.fr.design.jdk.JdkVersion;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
@ -42,8 +44,10 @@ import com.fr.general.FRFont;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.log.Log4jConfig; import com.fr.general.log.Log4jConfig;
import com.fr.io.attr.ImageExportAttr;
import com.fr.locale.InterProviderFactory; import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.report.ReportConfigManager;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.os.OperatingSystem; import com.fr.stable.os.OperatingSystem;
import com.fr.third.apache.logging.log4j.Level; import com.fr.third.apache.logging.log4j.Level;
@ -55,6 +59,8 @@ import com.fr.workspace.server.vcs.git.config.GcConfig;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JComponent;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
@ -190,6 +196,14 @@ public class PreferencePane extends BasicPane {
private Timer gcProgressTimer; private Timer gcProgressTimer;
private UIButton gcOkButton = new UIButton(i18nText("Fine-Design_Report_OK")); private UIButton gcOkButton = new UIButton(i18nText("Fine-Design_Report_OK"));
private UIRadioButton previewResolutionBtnS;
private UIRadioButton previewResolutionBtnM;
private UIRadioButton previewRenderSpeed;
private UIRadioButton previewRenderQuality;
private static final int DPI_SCALE_S = 1;
private static final int DPI_SCALE_M = 2;
public PreferencePane() { public PreferencePane() {
this.initComponents(); this.initComponents();
} }
@ -274,6 +288,7 @@ public class PreferencePane extends BasicPane {
JPanel imageCompressPanel = FRGUIPaneFactory.createVerticalTitledBorderPane(i18nText("Fine-Design_Template_Preview_Performance")); JPanel imageCompressPanel = FRGUIPaneFactory.createVerticalTitledBorderPane(i18nText("Fine-Design_Template_Preview_Performance"));
imageCompressPanelCheckBox = new UICheckBox(i18nText("Fine-Design_Image_Compress")); imageCompressPanelCheckBox = new UICheckBox(i18nText("Fine-Design_Image_Compress"));
imageCompressPanel.add(imageCompressPanelCheckBox); imageCompressPanel.add(imageCompressPanelCheckBox);
imageCompressPanel.add(createImageExportSettingPane());
advancePane.add(imageCompressPanel); advancePane.add(imageCompressPanel);
JPanel designerStartupOption = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Startup_Option")); JPanel designerStartupOption = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Startup_Option"));
@ -282,6 +297,34 @@ public class PreferencePane extends BasicPane {
advancePane.add(designerStartupOption); advancePane.add(designerStartupOption);
} }
private JPanel createImageExportSettingPane() {
previewResolutionBtnS = new UIRadioButton(i18nText("Fine-Design_Image_Export_SD"), true);
previewResolutionBtnM = new UIRadioButton(i18nText("Fine-Design_Image_Export_HD"));
ButtonGroup previewResolutionBtnGroup = new ButtonGroup();
previewResolutionBtnGroup.add(previewResolutionBtnS);
previewResolutionBtnGroup.add(previewResolutionBtnM);
previewRenderSpeed = new UIRadioButton(Toolkit.i18nText("Fine-Design_Image_Export_Speed_Priority"));
previewRenderQuality = new UIRadioButton(Toolkit.i18nText("Fine-Design_Image_Export_Quality_First"));
ButtonGroup previewRenderGroup = new ButtonGroup();
previewRenderGroup.add(previewRenderQuality);
previewRenderGroup.add(previewRenderSpeed);
JPanel imageExportSettingPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JComponent[][] templateComps = {
{new UILabel(Toolkit.i18nText("Fine-Design_Report_Engine_Enlarge_Or_Reduce") + ":"), this.previewResolutionBtnS, this.previewResolutionBtnM},
{new UILabel(Toolkit.i18nText("Fine-Design_Image_Export_Rendering_Quality") + ":"), this.previewRenderQuality, this.previewRenderSpeed},
};
imageExportSettingPane.add(
TableLayoutHelper.createGapTableLayoutPane(
templateComps,
new double[]{TableLayout.FILL, TableLayout.FILL},
new double[]{TableLayout.FILL, TableLayout.FILL, TableLayout.FILL},
20, 0),
BorderLayout.CENTER);
imageExportSettingPane.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0));
return imageExportSettingPane;
}
private void createVcsSettingPane(JPanel generalPane) { private void createVcsSettingPane(JPanel generalPane) {
JPanel vcsPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(i18nText("Fine-Design_Vcs_Title")); JPanel vcsPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(i18nText("Fine-Design_Vcs_Title"));
generalPane.add(vcsPane); generalPane.add(vcsPane);
@ -757,6 +800,25 @@ public class PreferencePane extends BasicPane {
this.startWithEmptyFile.setSelected(designerEnvManager.isStartWithEmptyFile()); this.startWithEmptyFile.setSelected(designerEnvManager.isStartWithEmptyFile());
this.imageCompressPanelCheckBox.setSelected(designerEnvManager.isImageCompress()); this.imageCompressPanelCheckBox.setSelected(designerEnvManager.isImageCompress());
ImageExportAttr attr = ReportConfigManager.getProviderInstance().getImageExportAttr();
if (attr.getPreviewRenderQuality() == ImageExportAttr.RENDER_SPEED) {
previewRenderSpeed.setSelected(true);
} else {
previewRenderQuality.setSelected(true);
}
if (attr.getPreviewResolutionScale() == DPI_SCALE_S) {
previewResolutionBtnS.setSelected(true);
} else {
previewResolutionBtnM.setSelected(true);
}
boolean enabled = WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot();
previewRenderSpeed.setEnabled(enabled);
previewRenderQuality.setEnabled(enabled);
previewResolutionBtnS.setEnabled(enabled);
previewResolutionBtnM.setEnabled(enabled);
this.cloudAnalyticsDelayCheckBox.setSelected(designerEnvManager.isCloudAnalyticsDelay()); this.cloudAnalyticsDelayCheckBox.setSelected(designerEnvManager.isCloudAnalyticsDelay());
} }
@ -883,6 +945,18 @@ public class PreferencePane extends BasicPane {
} }
}); });
ImageExportAttr attr = ReportConfigManager.getProviderInstance().getImageExportAttr();
if (previewRenderSpeed.isSelected()) {
attr.setPreviewRenderQuality(ImageExportAttr.RENDER_SPEED);
} else {
attr.setPreviewRenderQuality(ImageExportAttr.RENDER_QUALITY);
}
if (previewResolutionBtnS.isSelected()) {
attr.setPreviewResolutionScale(DPI_SCALE_S);
} else {
attr.setPreviewResolutionScale(DPI_SCALE_M);
}
} }
// 如果语言设置改变了,则显示重启对话框 // 如果语言设置改变了,则显示重启对话框

119
designer-realize/src/main/java/com/fr/design/report/ImageExportPane.java

@ -9,8 +9,9 @@ import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.io.attr.ImageExportAttr; import com.fr.io.attr.ImageExportAttr;
import com.fr.io.attr.ReportExportAttr; import com.fr.io.attr.ReportExportAttr;
import com.fr.report.ReportConfigManager;
import java.awt.Color;
import javax.swing.AbstractButton;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.ButtonGroup; import javax.swing.ButtonGroup;
import javax.swing.JComponent; import javax.swing.JComponent;
@ -35,33 +36,26 @@ public class ImageExportPane extends AbstractExportPane {
private UIRadioButton globalFormatJpg; private UIRadioButton globalFormatJpg;
private UIRadioButton globalFormatPng; private UIRadioButton globalFormatPng;
private UIRadioButton previewResolutionBtnS; private UIRadioButton templateThumbnail;
private UIRadioButton previewResolutionBtnM; private UIRadioButton templatePaging;
private UIRadioButton previewRenderSpeed;
private UIRadioButton previewRenderQuality;
private static final int RESOLUTION_S = 96; private static final int RESOLUTION_S = 96;
private static final int RESOLUTION_M = 192; private static final int RESOLUTION_M = 192;
private static final int RESOLUTION_L = 300; private static final int RESOLUTION_L = 300;
private static final int DPI_SCALE_S = 1;
private static final int DPI_SCALE_M = 2;
private static final int GAP = 20; private static final int GAP = 20;
public static final String GLOBAL_CONF = Toolkit.i18nText("Fine-Design_Image_Export_Global_Configuration"); public static final String GLOBAL_CONF = Toolkit.i18nText("Fine-Design_Image_Export_Setting");
private ReportExportAttr reportExportAttr;
public ImageExportPane() { public ImageExportPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
JPanel globalTitlePane = FRGUIPaneFactory.createTitledBorderPane(GLOBAL_CONF); JPanel globalTitlePane = FRGUIPaneFactory.createTitledBorderPane(GLOBAL_CONF);
JPanel previewSetting = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Basic_Preview")); JPanel tipsTitlePane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Advice"));
UILabel tipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Image_Export_Tips"));
tipLabel.setForeground(Color.RED);
tipsTitlePane.add(tipLabel);
this.add(globalTitlePane, BorderLayout.NORTH); this.add(globalTitlePane, BorderLayout.NORTH);
this.add(previewSetting, BorderLayout.CENTER);
initGlobalSettings(); initGlobalSettings();
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
@ -69,6 +63,7 @@ public class ImageExportPane extends AbstractExportPane {
{new UILabel(Toolkit.i18nText("Fine-Design_Image_Export_Resolution") + ":"), this.globalResolutionBtnS, this.globalResolutionBtnM, this.globalResolutionBtnL}, {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_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_Rendering_Quality") + ":"), this.globalRenderQuality, null, this.globalRenderSpeed},
{new UILabel(Toolkit.i18nText("Fine-Design_Image_Export_Typesetting") + ":"), this.templateThumbnail, null, this.templatePaging}
}; };
centerPane.add( centerPane.add(
TableLayoutHelper.createCommonTableLayoutPane( TableLayoutHelper.createCommonTableLayoutPane(
@ -77,23 +72,8 @@ public class ImageExportPane extends AbstractExportPane {
new double[]{TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL}, new double[]{TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL},
GAP), GAP),
BorderLayout.CENTER); BorderLayout.CENTER);
centerPane.add(tipsTitlePane,BorderLayout.SOUTH);
globalTitlePane.add(centerPane, BorderLayout.CENTER); globalTitlePane.add(centerPane, BorderLayout.CENTER);
JPanel templateCenterPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JComponent[][] templateComps = {
{new UILabel(Toolkit.i18nText("Fine-Design_Report_Engine_Enlarge_Or_Reduce") + ":"), this.previewResolutionBtnS, this.previewResolutionBtnM},
{new UILabel(Toolkit.i18nText("Fine-Design_Image_Export_Rendering_Quality") + ":"), this.previewRenderQuality, this.previewRenderSpeed},
};
templateCenterPane.add(
TableLayoutHelper.createCommonTableLayoutPane(
templateComps,
new double[]{TableLayout.FILL, TableLayout.FILL, TableLayout.FILL},
new double[]{TableLayout.FILL, TableLayout.FILL, TableLayout.FILL},
GAP),
BorderLayout.CENTER);
previewSetting.add(templateCenterPane, BorderLayout.CENTER);
} }
@ -101,36 +81,29 @@ public class ImageExportPane extends AbstractExportPane {
globalResolutionBtnS = new UIRadioButton("96dpi", true); globalResolutionBtnS = new UIRadioButton("96dpi", true);
globalResolutionBtnM = new UIRadioButton("192dpi"); globalResolutionBtnM = new UIRadioButton("192dpi");
globalResolutionBtnL = new UIRadioButton("300dpi"); globalResolutionBtnL = new UIRadioButton("300dpi");
ButtonGroup globalResolutionBtnGroup = new ButtonGroup(); wrapButtonsInButtonGroup(globalResolutionBtnS, globalResolutionBtnM, globalResolutionBtnL);
globalResolutionBtnGroup.add(globalResolutionBtnS);
globalResolutionBtnGroup.add(globalResolutionBtnM);
globalResolutionBtnGroup.add(globalResolutionBtnL);
globalFormatJpg = new UIRadioButton("jpg", true); globalFormatJpg = new UIRadioButton("jpg", true);
globalFormatPng = new UIRadioButton("png"); globalFormatPng = new UIRadioButton("png");
ButtonGroup globalFormatGroup = new ButtonGroup(); wrapButtonsInButtonGroup(globalFormatJpg, globalFormatPng);
globalFormatGroup.add(globalFormatJpg);
globalFormatGroup.add(globalFormatPng);
globalRenderQuality = new UIRadioButton(Toolkit.i18nText("Fine-Design_Image_Export_Quality_First"), true); globalRenderQuality = new UIRadioButton(Toolkit.i18nText("Fine-Design_Image_Export_Quality_First"), true);
globalRenderSpeed = new UIRadioButton(Toolkit.i18nText(("Fine-Design_Image_Export_Speed_Priority"))); globalRenderSpeed = new UIRadioButton(Toolkit.i18nText(("Fine-Design_Image_Export_Speed_Priority")));
ButtonGroup globalRenderGroup = new ButtonGroup(); wrapButtonsInButtonGroup(globalRenderQuality, globalRenderSpeed);
globalRenderGroup.add(globalRenderQuality);
globalRenderGroup.add(globalRenderSpeed); templateThumbnail = new UIRadioButton(Toolkit.i18nText("Fine-Design_Image_Export_Thumbnail"));
templatePaging = new UIRadioButton(Toolkit.i18nText("Fine-Design_Image_Export_Paging"));
previewResolutionBtnS = new UIRadioButton("100%", true); wrapButtonsInButtonGroup(templateThumbnail, templatePaging);
previewResolutionBtnM = new UIRadioButton("200%");
ButtonGroup previewResolutionBtnGroup = new ButtonGroup();
previewResolutionBtnGroup.add(previewResolutionBtnS);
previewResolutionBtnGroup.add(previewResolutionBtnM);
previewRenderSpeed = new UIRadioButton(Toolkit.i18nText("Fine-Design_Image_Export_Speed_Priority"));
previewRenderQuality = new UIRadioButton(Toolkit.i18nText("Fine-Design_Image_Export_Quality_First"));
ButtonGroup previewRenderGroup = new ButtonGroup();
previewRenderGroup.add(previewRenderQuality);
previewRenderGroup.add(previewRenderSpeed);
} }
private void wrapButtonsInButtonGroup(AbstractButton... buttons) {
if (buttons != null) {
ButtonGroup buttonGroup = new ButtonGroup();
for (AbstractButton button : buttons) {
buttonGroup.add(button);
}
}
}
/** /**
* 展示界面 * 展示界面
@ -150,10 +123,6 @@ public class ImageExportPane extends AbstractExportPane {
updateBean(); updateBean();
} }
private ImageExportAttr getGlobalImageExportAttr() {
return ReportConfigManager.getProviderInstance().getImageExportAttr();
}
/** /**
* 标题 * 标题
* *
@ -166,7 +135,11 @@ public class ImageExportPane extends AbstractExportPane {
@Override @Override
public void populateBean(Object exportAttr) { public void populateBean(Object exportAttr) {
ImageExportAttr attr = getGlobalImageExportAttr(); ReportExportAttr reportExportAttr = (ReportExportAttr) exportAttr;
ImageExportAttr attr = reportExportAttr.getImageExportAttr();
if (attr == null) {
attr = new ImageExportAttr();
}
switch (attr.getResolution()) { switch (attr.getResolution()) {
case 192: case 192:
globalResolutionBtnM.setSelected(true); globalResolutionBtnM.setSelected(true);
@ -187,24 +160,17 @@ public class ImageExportPane extends AbstractExportPane {
} else { } else {
globalRenderQuality.setSelected(true); globalRenderQuality.setSelected(true);
} }
if (attr.isPaging()) {
if (attr.getPreviewRenderQuality() == ImageExportAttr.RENDER_SPEED) { templatePaging.setSelected(true);
previewRenderSpeed.setSelected(true);
} else {
previewRenderQuality.setSelected(true);
}
if (attr.getPreviewResolutionScale() == DPI_SCALE_S) {
previewResolutionBtnS.setSelected(true);
} else { } else {
previewResolutionBtnM.setSelected(true); templateThumbnail.setSelected(true);
} }
} }
@Override @Override
public void updateBean(Object exportAttr) { public void updateBean(Object exportAttr) {
ImageExportAttr attr = getGlobalImageExportAttr(); ReportExportAttr reportExportAttr = (ReportExportAttr) exportAttr;
ImageExportAttr attr = new ImageExportAttr();
if (globalResolutionBtnS.isSelected()) { if (globalResolutionBtnS.isSelected()) {
attr.setResolution(RESOLUTION_S); attr.setResolution(RESOLUTION_S);
} else if (globalResolutionBtnM.isSelected()) { } else if (globalResolutionBtnM.isSelected()) {
@ -222,17 +188,8 @@ public class ImageExportPane extends AbstractExportPane {
} else { } else {
attr.setRenderQuality(ImageExportAttr.RENDER_QUALITY); attr.setRenderQuality(ImageExportAttr.RENDER_QUALITY);
} }
attr.setPaging(templatePaging.isSelected());
if (previewRenderSpeed.isSelected()) { reportExportAttr.setImageExportAttr(attr);
attr.setPreviewRenderQuality(ImageExportAttr.RENDER_SPEED);
} else {
attr.setPreviewRenderQuality(ImageExportAttr.RENDER_QUALITY);
}
if (previewResolutionBtnS.isSelected()) {
attr.setPreviewResolutionScale(DPI_SCALE_S);
} else {
attr.setPreviewResolutionScale(DPI_SCALE_M);
}
} }
@Override @Override

9
designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

@ -102,6 +102,8 @@ import com.fr.log.FineLoggerFactory;
import com.fr.log.LogHandler; import com.fr.log.LogHandler;
import com.fr.module.Activator; import com.fr.module.Activator;
import com.fr.module.extension.Prepare; import com.fr.module.extension.Prepare;
import com.fr.plugin.beforeload.embed.DefaultPluginEmbedInfo;
import com.fr.plugin.beforeload.embed.PluginEmbedInfo;
import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginContext;
import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.manage.PluginFilter;
@ -154,7 +156,7 @@ import javax.swing.SwingWorker;
public class DesignerActivator extends Activator implements Prepare { public class DesignerActivator extends Activator implements Prepare {
private LogHandler<DesignerLogAppender> logHandler = null; private LogHandler<DesignerLogAppender> logHandler = null;
private static final String PLUGIN_EXPORT_IMAGE_SETTING = "com.fr.plugin.exportimagesettings.v11";
private final Once pushUpdateTask = new Once(new Runnable() { private final Once pushUpdateTask = new Once(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -521,6 +523,11 @@ public class DesignerActivator extends Activator implements Prepare {
}.execute(); }.execute();
} }
}); });
prepareDefaultEmbedPluginInfo();
}
private void prepareDefaultEmbedPluginInfo() {
addMutable(PluginEmbedInfo.KEY, DefaultPluginEmbedInfo.create(PLUGIN_EXPORT_IMAGE_SETTING));
} }
private void startLoginAuthServer() { private void startLoginAuthServer() {

Loading…
Cancel
Save