Browse Source

CHART-16126 预定义样式预览界面修改

feature/big-screen
白岳 4 years ago
parent
commit
1723211841
  1. 21
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ChartPreStylePreView.java
  2. 11
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ElementCasePreview.java
  3. 58
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/PredefinedStylePreviewPane.java
  4. 16
      designer-base/src/main/resources/com/fr/design/mainframe/predefined/previewData

21
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.BaseChartPainter;
import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.base.chart.result.WebChartIDInfo; import com.fr.base.chart.result.WebChartIDInfo;
import com.fr.chart.base.ChartConstants;
import com.fr.chart.base.ChartPreStyleProvider; import com.fr.chart.base.ChartPreStyleProvider;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.config.predefined.PredefinedStyle; import com.fr.config.predefined.PredefinedStyle;
import com.fr.design.gui.chart.MiddleChartComponent; import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.general.Background;
import com.fr.plugin.chart.vanchart.VanChart; import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.core.PropertyChangeListener; import com.fr.stable.core.PropertyChangeListener;
import javax.swing.BorderFactory;
import java.util.List; import java.util.List;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
@ -32,6 +33,10 @@ public class ChartPreStylePreView extends MiddleChartComponent {
private CallbackEvent callbackEvent; private CallbackEvent callbackEvent;
private static final int BOUNDS = 10;
private Background componentBackground;
public ChartPreStylePreView() { public ChartPreStylePreView() {
} }
@ -42,6 +47,7 @@ public class ChartPreStylePreView extends MiddleChartComponent {
public ChartPreStylePreView(ChartCollection cc, double scaleX, double scaleY) { public ChartPreStylePreView(ChartCollection cc, double scaleX, double scaleY) {
this.scaleX = scaleX; this.scaleX = scaleX;
this.scaleY = scaleY; this.scaleY = scaleY;
this.setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10));
populate(cc); populate(cc);
} }
@ -51,18 +57,22 @@ public class ChartPreStylePreView extends MiddleChartComponent {
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
g2d.translate(ChartConstants.PREGAP4BOUNDS / 2, ChartConstants.PREGAP4BOUNDS / 2); g2d.translate(BOUNDS, BOUNDS);
g2d.scale(scaleX, scaleY); g2d.scale(scaleX, scaleY);
super.paintComponent(g); super.paintComponent(g);
drawChart(g2d); drawChart(g2d);
g2d.scale(1 / scaleX, 1 / scaleY); g2d.scale(1 / scaleX, 1 / scaleY);
g2d.translate(-ChartConstants.PREGAP4BOUNDS / 2, -ChartConstants.PREGAP4BOUNDS / 2); g2d.translate(-BOUNDS, -BOUNDS);
} }
private void drawChart(Graphics2D g2d) { private void drawChart(Graphics2D g2d) {
Dimension d = getBounds().getSize(); Dimension d = getBounds().getSize();
int chartWidth = (int) (d.width / scaleX) - ChartConstants.PREGAP4BOUNDS; int chartWidth = (int) (d.width / scaleX) - BOUNDS * 2;
int chartHeight = (int) (d.height / scaleX) - ChartConstants.PREGAP4BOUNDS; 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(), BaseChartPainter painter = chartCollection.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(),
WebChartIDInfo.createEmptyDesignerInfo(), chartWidth, chartHeight); WebChartIDInfo.createEmptyDesignerInfo(), chartWidth, chartHeight);
painter.paint(g2d, chartWidth, chartHeight, 0, null, callbackEvent); painter.paint(g2d, chartWidth, chartHeight, 0, null, callbackEvent);
@ -74,6 +84,7 @@ public class ChartPreStylePreView extends MiddleChartComponent {
for (ChartPreStyleProvider chartPreStyleProvider : chartPreStyleProviders) { for (ChartPreStyleProvider chartPreStyleProvider : chartPreStyleProviders) {
chartPreStyleProvider.updatePreDefinedStyle(style); chartPreStyleProvider.updatePreDefinedStyle(style);
} }
componentBackground = style.getComponentStyle().getBorderStyle().getBackground();
vanChart.attrChange(); vanChart.attrChange();
} }

11
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.JPanel;
import javax.swing.JSeparator; import javax.swing.JSeparator;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
/** /**
* Created by kerry on 2020-09-04 * Created by kerry on 2020-09-04
@ -51,8 +51,9 @@ public class ElementCasePreview extends ComponentPreviewPane {
jPanel.setOpaque(false); jPanel.setOpaque(false);
jPanel.setBackground(null); jPanel.setBackground(null);
FRFont font = FRFont.getInstance(); FRFont font = FRFont.getInstance();
FRFont titleFont = font.applySize(11).applyForeground(Color.decode("#63B2EE")); font = font.applySize(11);
FRFont endFont = font.applyForeground(Color.decode("#1B97FF")); 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++) { for (int i = 0; i < PREVIEW_DATA_LIST.size(); i++) {
FRFont frFont = font; FRFont frFont = font;
if (i == 0) { if (i == 0) {

58
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.general.Background;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.attr.axis.VanChartAxis; 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.AttrLabel;
import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.base.VanChartTools;
import com.fr.plugin.chart.column.VanChartColumnPlot; import com.fr.plugin.chart.column.VanChartColumnPlot;
import com.fr.plugin.chart.line.VanChartLinePlot;
import com.fr.plugin.chart.vanchart.VanChart; import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.stable.Constants;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -38,14 +35,9 @@ public class PredefinedStylePreviewPane extends StyleSettingPreviewPane implemen
private double scaleX = 1.0; private double scaleX = 1.0;
private double scaleY = 1.0; private double scaleY = 1.0;
private ChartPreStylePreView columnChartPane; private ChartPreStylePreView columnChartPane;
private ChartPreStylePreView lineChartPane;
private int COLUMN_CHART_WIDTH = 297; private int COLUMN_CHART_WIDTH = 517;
private int COLUMN_CHART_HEIGHT = 300;
private int COLUMN_CHART_HEIGHT = 220;
public static final double CHART_SCALE = 0.6;
public PredefinedStylePreviewPane() { public PredefinedStylePreviewPane() {
this(1.0, 1.0); this(1.0, 1.0);
@ -57,21 +49,17 @@ public class PredefinedStylePreviewPane extends StyleSettingPreviewPane implemen
this.setBackground(Color.WHITE); this.setBackground(Color.WHITE);
this.elementCasePreview = new ElementCasePreview(); this.elementCasePreview = new ElementCasePreview();
this.add(initChartPreViewPane()); this.add(initChartPreViewPane());
this.elementCasePreview.setPreferredSize(new Dimension(517, 250)); this.elementCasePreview.setPreferredSize(new Dimension(517, 190));
this.add(this.elementCasePreview); this.add(this.elementCasePreview);
} }
private JPanel initChartPreViewPane() { 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.setPreferredSize(new Dimension(COLUMN_CHART_WIDTH, COLUMN_CHART_HEIGHT));
columnChartPane.setCallbackEvent(this); 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(); JPanel panel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
panel.add(columnChartPane); panel.add(columnChartPane);
panel.add(lineChartPane);
return panel; return panel;
} }
@ -79,12 +67,11 @@ public class PredefinedStylePreviewPane extends StyleSettingPreviewPane implemen
private ChartCollection initVanColumnChart() { private ChartCollection initVanColumnChart() {
try { try {
VanChart chart = (VanChart) ChartTypeManager.getInstance().getCharts(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID)[0].clone(); VanChart chart = (VanChart) ChartTypeManager.getInstance().getCharts(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID)[0].clone();
chart.getTitle().setPosition(Constants.LEFT);
VanChartTools vanChartTools = chart.getVanChartTools(); VanChartTools vanChartTools = chart.getVanChartTools();
vanChartTools.setSort(false); vanChartTools.setSort(false);
vanChartTools.setExport(false); vanChartTools.setExport(false);
vanChartTools.setFullScreen(false); vanChartTools.setFullScreen(false);
VanChartPlot plot = chart.getPlot(); VanChartColumnPlot plot = chart.getPlot();
AttrLabel defaultAttrLabel = plot.getDefaultAttrLabel(); AttrLabel defaultAttrLabel = plot.getDefaultAttrLabel();
defaultAttrLabel.setEnable(true); defaultAttrLabel.setEnable(true);
defaultAttrLabel.getAttrLabelDetail().getBorder().setBorderStyle(0); defaultAttrLabel.getAttrLabelDetail().getBorder().setBorderStyle(0);
@ -92,30 +79,14 @@ public class PredefinedStylePreviewPane extends StyleSettingPreviewPane implemen
plot.getConditionCollection().getDefaultAttr().addDataSeriesCondition(defaultAttrLabel); plot.getConditionCollection().getDefaultAttr().addDataSeriesCondition(defaultAttrLabel);
plot.getLegend().setLegendVisible(false); plot.getLegend().setLegendVisible(false);
plot.getDataSheet().setVisible(true); plot.getDataSheet().setVisible(true);
ChartCollection chartCollection = new ChartCollection(chart);
return chartCollection;
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
return null;
}
//折线图 VanChartAxis defaultYAxis = plot.getDefaultYAxis();
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();
Title title = new Title(); Title title = new Title();
title.setTextObject(Toolkit.i18nText("Fine-Design_Chart_Category")); title.setTextObject(Toolkit.i18nText("Fine-Design_Chart_Axis_Title"));
defaultXAxis.setTitle(title); title.getTextAttr().setRotation(-90);
defaultXAxis.setShowAxisTitle(true); defaultYAxis.setTitle(title);
defaultYAxis.setShowAxisTitle(true);
ChartCollection chartCollection = new ChartCollection(chart); ChartCollection chartCollection = new ChartCollection(chart);
return chartCollection; return chartCollection;
} catch (Exception ex) { } catch (Exception ex) {
@ -142,11 +113,9 @@ public class PredefinedStylePreviewPane extends StyleSettingPreviewPane implemen
background.paint(g, new Rectangle2D.Double(0, 0, 517, 500)); background.paint(g, new Rectangle2D.Double(0, 0, 517, 500));
this.columnChartPane.paintComponent(g); this.columnChartPane.paintComponent(g);
g.translate(COLUMN_CHART_WIDTH, 0); g.translate(0, COLUMN_CHART_HEIGHT);
this.lineChartPane.paintComponent(g);
g.translate(-COLUMN_CHART_WIDTH, COLUMN_CHART_HEIGHT + 10);
this.elementCasePreview.paintContent(g); this.elementCasePreview.paintContent(g);
g.translate(0, -COLUMN_CHART_HEIGHT - 10); g.translate(0, -COLUMN_CHART_HEIGHT);
// 恢复双缓冲 // 恢复双缓冲
ComponentUtils.resetBuffer(dbcomponents); ComponentUtils.resetBuffer(dbcomponents);
@ -167,7 +136,6 @@ public class PredefinedStylePreviewPane extends StyleSettingPreviewPane implemen
public void refresh(PredefinedStyle style, boolean displayFormBackground) { public void refresh(PredefinedStyle style, boolean displayFormBackground) {
elementCasePreview.refresh(style); elementCasePreview.refresh(style);
columnChartPane.refresh(style); columnChartPane.refresh(style);
lineChartPane.refresh(style);
background = displayFormBackground ? style.getFormBackground().getBackground() : style.getReportBackground(); background = displayFormBackground ? style.getFormBackground().getBackground() : style.getReportBackground();
this.repaint(); this.repaint();
} }

16
designer-base/src/main/resources/com/fr/design/mainframe/predefined/previewData

@ -1,11 +1,7 @@
城市 当月目标 当月实际完成 月度完成率 城市 当月目标 当月实际完成 月度完成率
南通市 324,646 324,646 105% 南通市 324,646 324,646 100%
合肥市 248,938 348,938 103% 合肥市 248,938 348,938 140%
邵阳市 248,938 348,938 103% 邵阳市 248,938 348,938 140%
九江市 248,938 348,938 103% 苏州市 248,938 348,938 140%
武汉市 248,938 348,938 103% 合计 1,071,460 1,371,460 128%
郑州市 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%

Loading…
Cancel
Save