From 172321184131c6c0cdf381dcf0caf0ee2e7c42b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Mon, 2 Nov 2020 16:02:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?CHART-16126=20=E9=A2=84=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E9=A2=84=E8=A7=88=E7=95=8C=E9=9D=A2=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/preview/ChartPreStylePreView.java | 21 +++++-- .../ui/preview/ElementCasePreview.java | 11 ++-- .../preview/PredefinedStylePreviewPane.java | 58 +++++-------------- .../design/mainframe/predefined/previewData | 16 ++--- 4 files changed, 41 insertions(+), 65 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ChartPreStylePreView.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ChartPreStylePreView.java index 31a497d016..fe3275eb66 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ChartPreStylePreView.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ChartPreStylePreView.java @@ -4,15 +4,16 @@ import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartPainter; import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.base.chart.result.WebChartIDInfo; -import com.fr.chart.base.ChartConstants; import com.fr.chart.base.ChartPreStyleProvider; import com.fr.chart.chartattr.ChartCollection; import com.fr.config.predefined.PredefinedStyle; import com.fr.design.gui.chart.MiddleChartComponent; +import com.fr.general.Background; import com.fr.plugin.chart.vanchart.VanChart; import com.fr.script.Calculator; import com.fr.stable.core.PropertyChangeListener; +import javax.swing.BorderFactory; import java.util.List; import java.awt.Dimension; import java.awt.Graphics; @@ -32,6 +33,10 @@ public class ChartPreStylePreView extends MiddleChartComponent { private CallbackEvent callbackEvent; + private static final int BOUNDS = 10; + + private Background componentBackground; + public ChartPreStylePreView() { } @@ -42,6 +47,7 @@ public class ChartPreStylePreView extends MiddleChartComponent { public ChartPreStylePreView(ChartCollection cc, double scaleX, double scaleY) { this.scaleX = scaleX; this.scaleY = scaleY; + this.setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10)); populate(cc); } @@ -51,18 +57,22 @@ public class ChartPreStylePreView extends MiddleChartComponent { public void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; - g2d.translate(ChartConstants.PREGAP4BOUNDS / 2, ChartConstants.PREGAP4BOUNDS / 2); + g2d.translate(BOUNDS, BOUNDS); g2d.scale(scaleX, scaleY); super.paintComponent(g); drawChart(g2d); g2d.scale(1 / scaleX, 1 / scaleY); - g2d.translate(-ChartConstants.PREGAP4BOUNDS / 2, -ChartConstants.PREGAP4BOUNDS / 2); + g2d.translate(-BOUNDS, -BOUNDS); } private void drawChart(Graphics2D g2d) { Dimension d = getBounds().getSize(); - int chartWidth = (int) (d.width / scaleX) - ChartConstants.PREGAP4BOUNDS; - int chartHeight = (int) (d.height / scaleX) - ChartConstants.PREGAP4BOUNDS; + int chartWidth = (int) (d.width / scaleX) - BOUNDS * 2; + int chartHeight = (int) (d.height / scaleX) - BOUNDS * 2; + if (componentBackground != null) { + Graphics clipg = g2d.create(0, 0, chartWidth, chartHeight); + componentBackground.paint(clipg, clipg.getClipBounds()); + } BaseChartPainter painter = chartCollection.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(), WebChartIDInfo.createEmptyDesignerInfo(), chartWidth, chartHeight); painter.paint(g2d, chartWidth, chartHeight, 0, null, callbackEvent); @@ -74,6 +84,7 @@ public class ChartPreStylePreView extends MiddleChartComponent { for (ChartPreStyleProvider chartPreStyleProvider : chartPreStyleProviders) { chartPreStyleProvider.updatePreDefinedStyle(style); } + componentBackground = style.getComponentStyle().getBorderStyle().getBackground(); vanChart.attrChange(); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ElementCasePreview.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ElementCasePreview.java index 18408ec530..1e25c01d02 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ElementCasePreview.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ElementCasePreview.java @@ -7,15 +7,15 @@ import com.fr.log.FineLoggerFactory; import javax.swing.JPanel; import javax.swing.JSeparator; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; /** * Created by kerry on 2020-09-04 @@ -51,8 +51,9 @@ public class ElementCasePreview extends ComponentPreviewPane { jPanel.setOpaque(false); jPanel.setBackground(null); FRFont font = FRFont.getInstance(); - FRFont titleFont = font.applySize(11).applyForeground(Color.decode("#63B2EE")); - FRFont endFont = font.applyForeground(Color.decode("#1B97FF")); + font = font.applySize(11); + FRFont titleFont = font.applySize(14).applyForeground(Color.decode("#63B2EE")); + FRFont endFont = font.applySize(11).applyForeground(Color.decode("#1B97FF")); for (int i = 0; i < PREVIEW_DATA_LIST.size(); i++) { FRFont frFont = font; if (i == 0) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/PredefinedStylePreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/PredefinedStylePreviewPane.java index 836cd32205..b876d723f9 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/PredefinedStylePreviewPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/PredefinedStylePreviewPane.java @@ -12,13 +12,10 @@ import com.fr.design.utils.ComponentUtils; import com.fr.general.Background; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.attr.axis.VanChartAxis; -import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.AttrLabel; import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.column.VanChartColumnPlot; -import com.fr.plugin.chart.line.VanChartLinePlot; import com.fr.plugin.chart.vanchart.VanChart; -import com.fr.stable.Constants; import javax.swing.JComponent; import javax.swing.JPanel; @@ -38,14 +35,9 @@ public class PredefinedStylePreviewPane extends StyleSettingPreviewPane implemen private double scaleX = 1.0; private double scaleY = 1.0; private ChartPreStylePreView columnChartPane; - private ChartPreStylePreView lineChartPane; - private int COLUMN_CHART_WIDTH = 297; - - private int COLUMN_CHART_HEIGHT = 220; - - - public static final double CHART_SCALE = 0.6; + private int COLUMN_CHART_WIDTH = 517; + private int COLUMN_CHART_HEIGHT = 300; public PredefinedStylePreviewPane() { this(1.0, 1.0); @@ -57,21 +49,17 @@ public class PredefinedStylePreviewPane extends StyleSettingPreviewPane implemen this.setBackground(Color.WHITE); this.elementCasePreview = new ElementCasePreview(); this.add(initChartPreViewPane()); - this.elementCasePreview.setPreferredSize(new Dimension(517, 250)); + this.elementCasePreview.setPreferredSize(new Dimension(517, 190)); this.add(this.elementCasePreview); } private JPanel initChartPreViewPane() { - columnChartPane = new ChartPreStylePreView(initVanColumnChart(), CHART_SCALE, CHART_SCALE); + columnChartPane = new ChartPreStylePreView(initVanColumnChart()); columnChartPane.setPreferredSize(new Dimension(COLUMN_CHART_WIDTH, COLUMN_CHART_HEIGHT)); columnChartPane.setCallbackEvent(this); - lineChartPane = new ChartPreStylePreView(initVanLineChart(), CHART_SCALE, CHART_SCALE); - lineChartPane.setPreferredSize(new Dimension(220, 220)); - lineChartPane.setCallbackEvent(this); JPanel panel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); panel.add(columnChartPane); - panel.add(lineChartPane); return panel; } @@ -79,12 +67,11 @@ public class PredefinedStylePreviewPane extends StyleSettingPreviewPane implemen private ChartCollection initVanColumnChart() { try { VanChart chart = (VanChart) ChartTypeManager.getInstance().getCharts(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID)[0].clone(); - chart.getTitle().setPosition(Constants.LEFT); VanChartTools vanChartTools = chart.getVanChartTools(); vanChartTools.setSort(false); vanChartTools.setExport(false); vanChartTools.setFullScreen(false); - VanChartPlot plot = chart.getPlot(); + VanChartColumnPlot plot = chart.getPlot(); AttrLabel defaultAttrLabel = plot.getDefaultAttrLabel(); defaultAttrLabel.setEnable(true); defaultAttrLabel.getAttrLabelDetail().getBorder().setBorderStyle(0); @@ -92,30 +79,14 @@ public class PredefinedStylePreviewPane extends StyleSettingPreviewPane implemen plot.getConditionCollection().getDefaultAttr().addDataSeriesCondition(defaultAttrLabel); plot.getLegend().setLegendVisible(false); plot.getDataSheet().setVisible(true); - ChartCollection chartCollection = new ChartCollection(chart); - return chartCollection; - } catch (Exception ex) { - FineLoggerFactory.getLogger().error(ex.getMessage(), ex); - } - return null; - } - //折线图 - private ChartCollection initVanLineChart() { - try { - VanChart chart = (VanChart) ChartTypeManager.getInstance().getCharts(VanChartLinePlot.VAN_CHART_LINE_PLOT)[0].clone(); - chart.getTitle().setPosition(Constants.LEFT); - VanChartTools vanChartTools = chart.getVanChartTools(); - vanChartTools.setSort(false); - vanChartTools.setExport(false); - vanChartTools.setFullScreen(false); - VanChartLinePlot plot = chart.getPlot(); - plot.getLegend().setPosition(Constants.TOP); - VanChartAxis defaultXAxis = plot.getDefaultXAxis(); + VanChartAxis defaultYAxis = plot.getDefaultYAxis(); Title title = new Title(); - title.setTextObject(Toolkit.i18nText("Fine-Design_Chart_Category")); - defaultXAxis.setTitle(title); - defaultXAxis.setShowAxisTitle(true); + title.setTextObject(Toolkit.i18nText("Fine-Design_Chart_Axis_Title")); + title.getTextAttr().setRotation(-90); + defaultYAxis.setTitle(title); + defaultYAxis.setShowAxisTitle(true); + ChartCollection chartCollection = new ChartCollection(chart); return chartCollection; } catch (Exception ex) { @@ -142,11 +113,9 @@ public class PredefinedStylePreviewPane extends StyleSettingPreviewPane implemen background.paint(g, new Rectangle2D.Double(0, 0, 517, 500)); this.columnChartPane.paintComponent(g); - g.translate(COLUMN_CHART_WIDTH, 0); - this.lineChartPane.paintComponent(g); - g.translate(-COLUMN_CHART_WIDTH, COLUMN_CHART_HEIGHT + 10); + g.translate(0, COLUMN_CHART_HEIGHT); this.elementCasePreview.paintContent(g); - g.translate(0, -COLUMN_CHART_HEIGHT - 10); + g.translate(0, -COLUMN_CHART_HEIGHT); // 恢复双缓冲 ComponentUtils.resetBuffer(dbcomponents); @@ -167,7 +136,6 @@ public class PredefinedStylePreviewPane extends StyleSettingPreviewPane implemen public void refresh(PredefinedStyle style, boolean displayFormBackground) { elementCasePreview.refresh(style); columnChartPane.refresh(style); - lineChartPane.refresh(style); background = displayFormBackground ? style.getFormBackground().getBackground() : style.getReportBackground(); this.repaint(); } diff --git a/designer-base/src/main/resources/com/fr/design/mainframe/predefined/previewData b/designer-base/src/main/resources/com/fr/design/mainframe/predefined/previewData index 444c5e314b..33402e3971 100644 --- a/designer-base/src/main/resources/com/fr/design/mainframe/predefined/previewData +++ b/designer-base/src/main/resources/com/fr/design/mainframe/predefined/previewData @@ -1,11 +1,7 @@ 城市 当月目标 当月实际完成 月度完成率 -南通市 324,646 324,646 105% -合肥市 248,938 348,938 103% -邵阳市 248,938 348,938 103% -九江市 248,938 348,938 103% -武汉市 248,938 348,938 103% -郑州市 248,938 348,938 103% -无锡市 248,938 348,938 103% -南京市 248,938 348,938 103% -苏州市 248,938 348,938 103% -合计 3200,425 2900,300 95% +南通市 324,646 324,646 100% +合肥市 248,938 348,938 140% +邵阳市 248,938 348,938 140% +苏州市 248,938 348,938 140% +合计 1,071,460 1,371,460 128% + From 9bd8c96e8020223838411d685eff511f7e4cafc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Mon, 2 Nov 2020 16:05:17 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E7=A9=BA=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/com/fr/design/mainframe/predefined/previewData | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/designer-base/src/main/resources/com/fr/design/mainframe/predefined/previewData b/designer-base/src/main/resources/com/fr/design/mainframe/predefined/previewData index 33402e3971..263e85a73d 100644 --- a/designer-base/src/main/resources/com/fr/design/mainframe/predefined/previewData +++ b/designer-base/src/main/resources/com/fr/design/mainframe/predefined/previewData @@ -3,5 +3,4 @@ 合肥市 248,938 348,938 140% 邵阳市 248,938 348,938 140% 苏州市 248,938 348,938 140% -合计 1,071,460 1,371,460 128% - +合计 1,071,460 1,371,460 128% \ No newline at end of file