From c1b0d6e9b678e90353456a3b8c6248b1eea5533f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Mon, 3 Aug 2020 10:01:53 +0800 Subject: [PATCH 1/3] =?UTF-8?q?CHART-9760=20=20=E7=B3=BB=E5=88=97=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/gui/data/table/SeriesNameUseFieldValuePane.java | 1 + 1 file changed, 1 insertion(+) diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldValuePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldValuePane.java index 0fb700f345..8511430b34 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldValuePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldValuePane.java @@ -40,6 +40,7 @@ public class SeriesNameUseFieldValuePane extends FurtherBasicBeanPane Date: Mon, 3 Aug 2020 10:04:44 +0800 Subject: [PATCH 2/3] =?UTF-8?q?CHART-11708=20=E6=8F=92=E5=85=A5=E5=9B=BE?= =?UTF-8?q?=E8=A1=A8=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/chart/AutoChartIcon.java | 66 ++------------ .../java/com/fr/design/chart/ChartIcon.java | 89 ++++++++++++------- .../com/fr/design/chart/ChartTypePane.java | 22 +++-- 3 files changed, 78 insertions(+), 99 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java b/designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java index 6e347d34b0..a9dbb0b132 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java +++ b/designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java @@ -1,85 +1,29 @@ package com.fr.design.chart; import com.fr.base.chart.BaseChartPainter; -import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.base.chart.result.WebChartIDInfo; -import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; -import com.fr.design.ChartTypeInterfaceManager; -import com.fr.design.file.HistoryTemplateListCache; import com.fr.script.Calculator; -import javax.swing.Icon; -import java.awt.Color; -import java.awt.Component; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Paint; - /** * @author Bjorn * @version 10.0 * Created by Bjorn on 2020-05-29 */ -public class AutoChartIcon implements Icon { +public class AutoChartIcon extends ChartIcon { private static final int WIDTH = 500; private static final int HEIGHT = 281; - private ChartCollection chartCollection; - private CallbackEvent callbackEvent; - - private String chartName; - public AutoChartIcon(ChartCollection chartCollection) { - this.chartCollection = chartCollection; - initChartName(); - } - - public ChartCollection getChartCollection() { - return chartCollection; + super(chartCollection); } - public String getChartName() { - return chartName; - } - - private void initChartName() { - Chart chart = chartCollection.getSelectedChart(Chart.class); - String[] subName = ChartTypeInterfaceManager.getInstance().getSubName(chart.getPlot().getPlotID()); - chartName = subName[0]; - } - - public void registerCallBackEvent(CallbackEvent callbackEvent) { - this.callbackEvent = callbackEvent; - } - - /** - * 画出缩略图Icon - * - * @param g 图形的上下文 - * @param c 所在的Component - * @param x 缩略图的起始坐标x - * @param y 缩略图的起始坐标y - */ @Override - public void paintIcon(Component c, Graphics g, int x, int y) { - - BaseChartPainter painter = chartCollection.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(), + protected BaseChartPainter getChartPainter() { + BaseChartPainter painter = getChartCollection().createResultChartPainterWithOutDealFormula(Calculator.createCalculator(), WebChartIDInfo.createAutoTypeInfo(), getIconWidth(), getIconHeight()); - - int resolution = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getJTemplateResolution(); - - Graphics2D g2d = (Graphics2D) g; - Paint oldPaint = g2d.getPaint(); - g.translate(x, y); - g2d.setPaint(Color.white); - g2d.fillRect(0, 0, getIconWidth(), getIconHeight()); - - painter.paint(g2d, getIconWidth(), getIconHeight(), resolution, null, callbackEvent); - - g.translate(-x, -y); - g2d.setPaint(oldPaint); + return painter; } /** diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartIcon.java b/designer-chart/src/main/java/com/fr/design/chart/ChartIcon.java index 854505d630..4d4a6ed434 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartIcon.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartIcon.java @@ -1,8 +1,13 @@ package com.fr.design.chart; -import com.fr.base.GraphHelper; -import com.fr.general.IOUtils; -import com.fr.stable.Constants; +import com.fr.base.chart.BaseChartPainter; +import com.fr.base.chart.chartdata.CallbackEvent; +import com.fr.base.chart.result.WebChartIDInfo; +import com.fr.chart.chartattr.Chart; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.design.ChartTypeInterfaceManager; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.script.Calculator; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLable; import com.fr.stable.xml.XMLableReader; @@ -13,7 +18,6 @@ import java.awt.Component; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Paint; -import java.awt.image.BufferedImage; /** * 图表的缩略图Icon, 在选择图表类型界面 用到. @@ -21,21 +25,47 @@ import java.awt.image.BufferedImage; public class ChartIcon implements Icon, XMLable { private static final int WIDTH = 400; private static final int HEIGHT = 225; - /** - * 缩略图中的图片路径 - */ - private String imagePath; + + + private ChartCollection chartCollection; + private CallbackEvent callbackEvent; private String chartName; /** * 构造Chart的缩略图Icon */ - public ChartIcon(String imagePath, String chartName) { - this.imagePath = imagePath; + public ChartIcon(ChartCollection chartCollection) { + this.chartCollection = chartCollection; + initChartName(); + } + + public ChartCollection getChartCollection() { + return chartCollection; + } + + public String getChartName() { + return chartName; + } + + public void setChartCollection(ChartCollection chartCollection) { + this.chartCollection = chartCollection; + } + + public void setChartName(String chartName) { this.chartName = chartName; } + private void initChartName() { + Chart chart = chartCollection.getSelectedChart(Chart.class); + String[] subName = ChartTypeInterfaceManager.getInstance().getSubName(chart.getPlot().getPlotID()); + chartName = subName[0]; + } + + public void registerCallBackEvent(CallbackEvent callbackEvent) { + this.callbackEvent = callbackEvent; + } + /** * 画出缩略图Icon * @@ -47,21 +77,29 @@ public class ChartIcon implements Icon, XMLable { @Override public void paintIcon(Component c, Graphics g, int x, int y) { - Graphics2D g2d = (Graphics2D) g; + BaseChartPainter chartPainter = getChartPainter(); - Paint oldPaint = g2d.getPaint(); + int resolution = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getJTemplateResolution(); + Graphics2D g2d = (Graphics2D) g; + Paint oldPaint = g2d.getPaint(); g.translate(x, y); g2d.setPaint(Color.white); - g2d.fillRect(0, 0, getIconWidth(), getIconHeight()); - BufferedImage demoImage = IOUtils.readImageWithCache(imagePath); - GraphHelper.paintImage(g, getIconWidth(), getIconHeight(), demoImage, Constants.IMAGE_ADJUST, Constants.NULL, Constants.NULL, -1, -1); + + chartPainter.paint(g2d, getIconWidth(), getIconHeight(), resolution, null, callbackEvent); g.translate(-x, -y); g2d.setPaint(oldPaint); } + protected BaseChartPainter getChartPainter() { + BaseChartPainter painter = chartCollection.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(), + WebChartIDInfo.createEmptyDesignerInfo(), getIconWidth(), getIconHeight()); + return painter; + } + + /** * 返回缩略图的宽度 * @@ -83,20 +121,6 @@ public class ChartIcon implements Icon, XMLable { } - /** - * 返回缩略图中的图片路径 - * - * @return 缩略图中的图片路径 - */ - public String getImagePath() { - return imagePath; - } - - public String getChartName() { - return chartName; - } - - @Override public void readXML(XMLableReader reader) { //do nothing @@ -114,8 +138,11 @@ public class ChartIcon implements Icon, XMLable { @Override public Object clone() throws CloneNotSupportedException { ChartIcon cloned = (ChartIcon) super.clone(); - cloned.imagePath = this.imagePath; - cloned.chartName = this.chartName; + if (getChartCollection() != null) { + cloned.setChartCollection(this.getChartCollection()); + } + cloned.setChartName(this.getChartName()); + ; return cloned; } diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java index 2bb9a99f22..aab17780e2 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java @@ -3,6 +3,7 @@ package com.fr.design.chart; * the Pane of the Chart */ +import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.chartx.attr.ChartProvider; @@ -12,7 +13,6 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.log.FineLoggerFactory; -import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.DefaultListCellRenderer; @@ -26,7 +26,7 @@ import javax.swing.event.ListSelectionListener; import java.awt.Color; import java.awt.Component; -public class ChartTypePane extends ChartCommonWizardPane { +public class ChartTypePane extends ChartCommonWizardPane implements CallbackEvent { private static final long serialVersionUID = -1175602484968520546L; private String[] chartIDs = ChartTypeManager.getInstanceWithCheck().getAllChartIDs(); @@ -96,14 +96,17 @@ public class ChartTypePane extends ChartCommonWizardPane { int main_index = mainTypeList.getSelectedIndex(); String id = ChartTypePane.this.chartIDs[main_index]; - String[] demoImagePath = ChartTypeInterfaceManager.getInstance().getDemoImagePath(id); + ChartProvider[] charts = ChartTypeManager.getInstance().getCharts(id); String[] subName = ChartTypeInterfaceManager.getInstance().getSubName(id); ChartTypePane.this.iconListModel.clear(); - for (int i = 0, len = subName.length; i < len; i++) { - String ImagePath = demoImagePath.length > i ? demoImagePath[i] : StringUtils.EMPTY; - String chartName = subName[i]; - ChartTypePane.this.iconListModel.addElement(new ChartIcon(ImagePath, chartName)); + for (int i = 0, len = charts.length; i < len; i++) { + ChartProvider chart = charts[i]; + ChartCollection chartCollection = new ChartCollection(chart); + ChartIcon chartIcon = new ChartIcon(chartCollection); + chartIcon.setChartName(subName[i]); + chartIcon.registerCallBackEvent(ChartTypePane.this); + ChartTypePane.this.iconListModel.addElement(chartIcon); } iconViewList.setSelectedIndex(0); } @@ -144,4 +147,9 @@ public class ChartTypePane extends ChartCommonWizardPane { update(chart4Update); } + + @Override + public void callback() { + this.repaint(); + } } \ No newline at end of file From 957d89eed51dea2b993f25cb93c8ea087a519eb8 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Mon, 3 Aug 2020 11:06:25 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-35569=20=E5=8F=82=E6=95=B0=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=EF=BC=8C=E6=B7=BB=E5=8A=A0=E4=B8=80=E4=B8=AA=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=8E=A7=E4=BB=B6=EF=BC=8C=E6=92=A4=E9=94=80=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E5=86=8D=E6=AC=A1=E6=B7=BB=E5=8A=A0=E7=9A=84?= =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E4=BC=9A=E7=A9=BA=E4=B8=80=E4=B8=AA=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/parameter/FormParaDesigner.java | 39 ++++--------------- .../parameter/ParameterDefinitePane.java | 10 +++-- 2 files changed, 15 insertions(+), 34 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java index a91342d4af..c72aa45128 100644 --- a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java +++ b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java @@ -83,7 +83,6 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP private static final int SUBMIT_BUTTON_H_LOCATION = 270; private static final int PARA_IMAGE_SHIFT_X = -4; private static final int FORM_AREA_PADDING_LEFT = 13; - private int addableRegionY; private static Image paraImage = BaseUtils.readImage("/com/fr/design/images/form/parameter.png"); @@ -413,30 +412,10 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP if (layoutContainer == null) { layoutContainer = new XWParameterLayout(); } - refreshAddableRegion(layoutContainer); layoutContainer.setSize(LARGE_PREFERRED_SIZE); setRootComponent(layoutContainer); } - /** - * @param layoutContainer - * @Description: 为了不覆盖以前的组件,所以要计算可以添加组件的区域 - * @return: - * @Author: Henry.Wang - * @date: 2020/7/15 15:12 - */ - public void refreshAddableRegion(XLayoutContainer layoutContainer) { - addableRegionY = 0; - for (int i = 0; i < layoutContainer.getComponentCount(); i++) { - Rectangle rectangle = layoutContainer.getComponent(i).getBounds(); - if (addableRegionY < rectangle.y + rectangle.height) { - addableRegionY = rectangle.y + rectangle.height; - } - } - int vGap = V_COMPONENT_GAP - (int) XCreator.SMALL_PREFERRED_SIZE.getHeight(); - addableRegionY = Math.max(0, addableRegionY - FIRST_V_LOCATION + (int) (XCreator.SMALL_PREFERRED_SIZE.getHeight() / 2) + vGap); - } - /** * 是否是报表的参数面板 * @@ -604,15 +583,14 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP label.setWidgetName("Label" + name); label.setWidgetValue(new WidgetValue(name + ":")); XCreator xCreator = XCreatorUtils.createXCreator(label); - int x = H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + FIRST_H_LOCATION; - int y = addableRegionY + FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE); - if (!(this.autoAddComponent(xCreator, x, y))) { + if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + + FIRST_H_LOCATION, FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { return false; } EditorHolder editor = new EditorHolder(parameter); xCreator = XCreatorUtils.createXCreator(editor); - x = H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + SECOND_H_LOCATION; - if (!(this.autoAddComponent(xCreator, x, y))) { + if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + + SECOND_H_LOCATION, FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { return false; } return true; @@ -668,17 +646,16 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP label.setWidgetValue(new WidgetValue(parameterArray[i].getName() + ":")); XCreator xCreator = XCreatorUtils.createXCreator(label); - int x = H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + FIRST_H_LOCATION; - int y = addableRegionY + FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE); - if (!(this.autoAddComponent(xCreator, x, y))) { + if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + + FIRST_H_LOCATION, FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { break; } // 每行显示5组 EditorHolder editor = new EditorHolder(parameterArray[i]); editor.setWidgetName(parameterArray[i].getName()); xCreator = XCreatorUtils.createXCreator(editor); - x = H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + SECOND_H_LOCATION; - if (!(this.autoAddComponent(xCreator, x, y))) { + if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + + SECOND_H_LOCATION, FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { break; } currentIndex++; diff --git a/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java b/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java index ea78f568f5..13d53b5b25 100644 --- a/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java +++ b/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java @@ -212,12 +212,13 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus return parameterArray; } - public int getToolBarHeight(){ + public int getToolBarHeight() { return TOOLBARPANEDIMHEIGHT; } /** * 导出菜单项,用于图表设计器 + * * @return 菜单项 */ public ShortCut[] shortcut4ExportMenu() { @@ -267,6 +268,8 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus bridge.setBackground(reportParameterAttr.getBackground()); bridge.setUseParamsTemplate(reportParameterAttr.isUseParamsTemplate()); } + + currentIndex = reportParameterAttr.getCurrentIndex(); } @@ -376,8 +379,9 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus } //这里不用 parameterUI 的原因是考虑到没有控件的时候设置宽度有效果但不保存,只有含有控件才保存属性 paraDesignEditor.getParaTarget().setDesignSize(new Dimension(bridge.getDesignWidth(), - (int)paraDesignEditor.getParaTarget().getDesignSize().getHeight())); + (int) paraDesignEditor.getParaTarget().getDesignSize().getHeight())); reportParameterAttr.setParameterUI(parameterUI); + reportParameterAttr.setCurrentIndex(currentIndex); return reportParameterAttr; } @@ -489,7 +493,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus * @return 模板菜单 */ public MenuDef[] menus4Target() { - MenuDef tplMenu = new MenuDef(KeySetUtils.TEMPLATE.getMenuKeySetName(),KeySetUtils.TEMPLATE.getMnemonic()); + MenuDef tplMenu = new MenuDef(KeySetUtils.TEMPLATE.getMenuKeySetName(), KeySetUtils.TEMPLATE.getMnemonic()); if (!DesignerMode.isAuthorityEditing()) { tplMenu.addShortCut(new NameSeparator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_WorkBook"))); tplMenu.addShortCut(new ReportParameterAction(workBook));