Browse Source

Pull request #5476: CHART-20117 主题配色界面图表部分预览

Merge in DESIGN/design from ~BJORN/design:feature/x to feature/x

* commit '3d604e95cd058c5935619173669075278e373797':
  处理frm下的新建图表的主题
  CHART-20117 主题配色界面图表部分预览
research/11.0
Bjorn 3 years ago
parent
commit
c69a9da571
  1. 14
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java
  2. 3
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartSeriesStylePane.java
  3. 8
      designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ChartComponentPreviewPane.java
  4. 47
      designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ChartPreviewPane.java
  5. 157
      designer-base/src/main/java/com/fr/design/mainframe/theme/preview/FormThemePreviewPane.java
  6. 87
      designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ReportThemePreviewPane.java
  7. 2
      designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java

14
designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java

@ -1,13 +1,11 @@
package com.fr.design.mainframe.theme; package com.fr.design.mainframe.theme;
import com.fr.base.Style;
import com.fr.base.background.ColorBackground;
import com.fr.base.theme.FineColorManager; import com.fr.base.theme.FineColorManager;
import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeConfig; import com.fr.base.theme.TemplateThemeConfig;
import com.fr.base.theme.settings.ThemeThumbnail; import com.fr.base.theme.settings.ThemeThumbnail;
import com.fr.base.theme.settings.ThemedCellStyle;
import com.fr.base.theme.settings.ThemedCellStyleList; import com.fr.base.theme.settings.ThemedCellStyleList;
import com.fr.base.theme.settings.ThemedChartStyle;
import com.fr.base.theme.settings.ThemedColorScheme; import com.fr.base.theme.settings.ThemedColorScheme;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.frpane.AttributeChangeListener;
@ -15,7 +13,6 @@ 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.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.Theme;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
@ -28,7 +25,6 @@ import com.fr.design.mainframe.theme.edit.ui.ColorListPane;
import com.fr.design.mainframe.theme.edit.ui.LabelUtils; import com.fr.design.mainframe.theme.edit.ui.LabelUtils;
import com.fr.design.mainframe.theme.ui.BorderUtils; import com.fr.design.mainframe.theme.ui.BorderUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRFont;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -40,6 +36,7 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import java.util.List;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
@ -52,7 +49,6 @@ import java.awt.event.FocusEvent;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.List;
/** /**
* @author Starryi * @author Starryi
@ -304,9 +300,13 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
public void onColorSchemeChanged(List<Color> colors) { public void onColorSchemeChanged(List<Color> colors) {
colorListExtendedPane.populate(colors); colorListExtendedPane.populate(colors);
FineColorManager.FineColorReplaceByColorScheme replaceByColorScheme = new FineColorManager.FineColorReplaceByColorScheme(colors);
ThemedCellStyleList cellStyle = cellStyleSettingPane.updateBean(); ThemedCellStyleList cellStyle = cellStyleSettingPane.updateBean();
FineColorManager.traverse(cellStyle, new FineColorManager.FineColorReplaceByColorScheme(colors)); FineColorManager.traverse(cellStyle, replaceByColorScheme);
ThemedChartStyle themedChartStyle = chartStyleSettingPane.updateBean();
FineColorManager.traverse(themedChartStyle, replaceByColorScheme);
chartStyleSettingPane.populateBean(themedChartStyle);
chartStyleSettingPane.populateGradientBar(colors); chartStyleSettingPane.populateGradientBar(colors);
} }

3
designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartSeriesStylePane.java

@ -4,6 +4,7 @@ import com.fr.base.theme.settings.ThemedChartStyle;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.theme.dialog.TemplateThemeProfileDialog;
import com.fr.design.style.background.gradient.FixedGradientBarWithPopMenu; import com.fr.design.style.background.gradient.FixedGradientBarWithPopMenu;
import java.util.List; import java.util.List;
@ -63,7 +64,9 @@ public class ChartSeriesStylePane extends AbstractChartStylePane {
public void populate(ThemedChartStyle chartStyle) { public void populate(ThemedChartStyle chartStyle) {
if (chartStyle.getThemedChartSeriesColor().isCombineColor()) { if (chartStyle.getThemedChartSeriesColor().isCombineColor()) {
List<Color> editingColorScheme = TemplateThemeProfileDialog.getEditingColorScheme();
colorTypeButton.setSelectedIndex(0); colorTypeButton.setSelectedIndex(0);
gradientBar.updateColor(editingColorScheme.get(0), editingColorScheme.get(1));
} else { } else {
colorTypeButton.setSelectedIndex(1); colorTypeButton.setSelectedIndex(1);
gradientBar.updateColor(chartStyle.getThemedChartSeriesColor().getBeginColor(), chartStyle.getThemedChartSeriesColor().getEndColor()); gradientBar.updateColor(chartStyle.getThemedChartSeriesColor().getBeginColor(), chartStyle.getThemedChartSeriesColor().getEndColor());

8
designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ChartComponentPreviewPane.java

@ -12,6 +12,10 @@ import java.awt.Component;
public class ChartComponentPreviewPane extends ComponentPreviewPane implements ThemePreviewed<FormTheme> { public class ChartComponentPreviewPane extends ComponentPreviewPane implements ThemePreviewed<FormTheme> {
private ChartPreviewPane contentPane; private ChartPreviewPane contentPane;
public ChartComponentPreviewPane(boolean showTitle) {
super(showTitle);
}
@Override @Override
protected Component createContentPane() { protected Component createContentPane() {
contentPane = new ChartPreviewPane(); contentPane = new ChartPreviewPane();
@ -23,4 +27,8 @@ public class ChartComponentPreviewPane extends ComponentPreviewPane implements T
super.refresh(theme); super.refresh(theme);
contentPane.refresh(theme); contentPane.refresh(theme);
} }
public ChartPreviewPane getContentPane() {
return contentPane;
}
} }

47
designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ChartPreviewPane.java

@ -1,10 +1,21 @@
package com.fr.design.mainframe.theme.preview; package com.fr.design.mainframe.theme.preview;
import com.fr.base.chart.BaseChartCollection; 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.base.theme.TemplateTheme; import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeCompatible;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.gui.chart.MiddleChartComponent; import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.script.Calculator;
import com.fr.stable.core.PropertyChangeListener; import com.fr.stable.core.PropertyChangeListener;
import javax.swing.BorderFactory;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
/** /**
* @author Starryi * @author Starryi
* @version 1.0 * @version 1.0
@ -12,14 +23,44 @@ import com.fr.stable.core.PropertyChangeListener;
*/ */
public class ChartPreviewPane extends MiddleChartComponent implements ThemePreviewed<TemplateTheme> { public class ChartPreviewPane extends MiddleChartComponent implements ThemePreviewed<TemplateTheme> {
private ChartCollection chartCollection;
private CallbackEvent callbackEvent;
public ChartPreviewPane() {
this.setBorder(BorderFactory.createEmptyBorder(0, 1, 2, 1));
}
public void setCallbackEvent(CallbackEvent callbackEvent) {
this.callbackEvent = callbackEvent;
}
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
super.paintComponent(g);
if (chartCollection != null) {
drawChart(g2d);
}
drawChart(g2d);
}
private void drawChart(Graphics2D g2d) {
Dimension d = getBounds().getSize();
int chartWidth = d.width;
int chartHeight = d.height;
BaseChartPainter painter = chartCollection.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(),
WebChartIDInfo.createEmptyDesignerInfo(), chartWidth, chartHeight);
painter.paint(g2d, chartWidth, chartHeight, 0, null, callbackEvent);
}
@Override @Override
public void populate(BaseChartCollection cc) { public void populate(BaseChartCollection cc) {
this.chartCollection = (ChartCollection) cc;
} }
@Override @Override
public BaseChartCollection update() { public BaseChartCollection update() {
return null; return this.chartCollection;
} }
@Override @Override
@ -34,6 +75,6 @@ public class ChartPreviewPane extends MiddleChartComponent implements ThemePrevi
@Override @Override
public void refresh(TemplateTheme style) { public void refresh(TemplateTheme style) {
chartCollection.onTemplateUsingThemeChange(style, TemplateThemeCompatible.NONE);
} }
} }

157
designer-base/src/main/java/com/fr/design/mainframe/theme/preview/FormThemePreviewPane.java

@ -1,21 +1,38 @@
package com.fr.design.mainframe.theme.preview; package com.fr.design.mainframe.theme.preview;
import com.fr.base.BaseFormula;
import com.fr.base.background.ColorBackground; import com.fr.base.background.ColorBackground;
import com.fr.base.theme.FormTheme; import com.fr.base.theme.FormTheme;
import com.fr.chart.base.ChartConstants;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.Title;
import com.fr.chart.chartdata.NormalChartData;
import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.theme.TemplateThemePreviewPane; import com.fr.design.mainframe.theme.TemplateThemePreviewPane;
import com.fr.design.mainframe.theme.preview.ecpreview.ECComponentPreviewPane; import com.fr.design.mainframe.theme.preview.ecpreview.ECComponentPreviewPane;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.general.Background; import com.fr.general.Background;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.PiePlot4VanChart;
import com.fr.plugin.chart.attr.axis.VanChartAxis;
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.type.RadiusType;
import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.stable.Constants;
import com.fr.stable.StringUtils;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.util.ArrayList;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
/** /**
* @author Starryi * @author Starryi
@ -23,33 +40,58 @@ import java.util.ArrayList;
* Created by Starryi on 2021/8/13 * Created by Starryi on 2021/8/13
*/ */
public class FormThemePreviewPane extends TemplateThemePreviewPane<FormTheme> { public class FormThemePreviewPane extends TemplateThemePreviewPane<FormTheme> {
private ECComponentPreviewPane elementCasePane; private ECComponentPreviewPane elementCasePane;
private Background background; private Background background;
private ComponentPreviewPane testPreviewPane; private ChartComponentPreviewPane columnChartPreviewPane;
private ChartComponentPreviewPane pieChartPreviewPane;
public FormThemePreviewPane() { public FormThemePreviewPane() {
setLayout(FRGUIPaneFactory.createBorderLayout()); setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel content = new UINoOpaquePanel(); JPanel content = new UINoOpaquePanel();
content.setLayout(new BorderLayout()); content.setLayout(new BorderLayout());
content.add(createChartContent(), BorderLayout.CENTER);
content.add(elementCasePane = new ECComponentPreviewPane(), BorderLayout.SOUTH); content.add(elementCasePane = new ECComponentPreviewPane(), BorderLayout.SOUTH);
JPanel northPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane(); add(content, BorderLayout.CENTER);
}
northPane.add(testPreviewPane = new ComponentPreviewPane(true) { private JPanel createChartContent() {
@Override JPanel chartContent = new UINoOpaquePanel();
protected Component createContentPane() { chartContent.setLayout(new BorderLayout());
return new UINoOpaquePanel(); JPanel columnChartPanel = new UINoOpaquePanel() {
public Dimension getPreferredSize() {
return new Dimension(300, 368);
} }
}, BorderLayout.CENTER); };
content.add(northPane, BorderLayout.CENTER); columnChartPanel.setLayout(new BorderLayout());
columnChartPreviewPane = createChartPreviewPane(initColumnChart(), 300, 368);
columnChartPanel.add(columnChartPreviewPane, BorderLayout.CENTER);
add(content, BorderLayout.CENTER); JPanel pieChartPanel = new UINoOpaquePanel() {
public Dimension getPreferredSize() {
return new Dimension(217, 368);
}
};
pieChartPanel.setLayout(new BorderLayout());
pieChartPreviewPane = createChartPreviewPane(initPieChart(), 300, 368);
pieChartPanel.add(pieChartPreviewPane, BorderLayout.CENTER);
chartContent.add(columnChartPanel, BorderLayout.WEST);
chartContent.add(pieChartPanel, BorderLayout.EAST);
return chartContent;
}
private ChartComponentPreviewPane createChartPreviewPane(ChartCollection chartCollection, int width, int height) {
ChartComponentPreviewPane chartComponentPreviewPane = new ChartComponentPreviewPane(true);
chartComponentPreviewPane.getContentPane().populate(chartCollection);
chartComponentPreviewPane.getContentPane().setCallbackEvent(this);
return chartComponentPreviewPane;
} }
@Override @Override
public void refresh(FormTheme theme) { public void refresh(FormTheme theme) {
background = theme.getBodyStyle().getStyle().getBackground(); background = theme.getBodyStyle().getStyle().getBackground();
elementCasePane.refresh(theme); elementCasePane.refresh(theme);
testPreviewPane.refresh(theme); columnChartPreviewPane.refresh(theme);
pieChartPreviewPane.refresh(theme);
repaint(); repaint();
} }
@ -68,4 +110,93 @@ public class FormThemePreviewPane extends TemplateThemePreviewPane<FormTheme> {
} }
//柱形图
private ChartCollection initColumnChart() {
try {
VanChart chart = (VanChart) ChartTypeManager.getInstance().getCharts(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID)[0].clone();
chart.getTitle().setTitleVisible(false);
VanChartTools vanChartTools = chart.getVanChartTools();
vanChartTools.setSort(false);
vanChartTools.setExport(false);
vanChartTools.setFullScreen(false);
VanChartColumnPlot plot = chart.getPlot();
AttrLabel defaultAttrLabel = plot.getDefaultAttrLabel();
defaultAttrLabel.setEnable(true);
defaultAttrLabel.getAttrLabelDetail().getBorder().setBorderStyle(0);
defaultAttrLabel.getAttrLabelDetail().getBackground().setBackground(null);
plot.getConditionCollection().getDefaultAttr().addDataSeriesCondition(defaultAttrLabel);
plot.getLegend().setPosition(Constants.TOP);
plot.setPlotStyle(ChartConstants.STYLE_NONE);
plot.setSeriesOverlapPercent(30);
plot.setCategoryIntervalPercent(30);
VanChartAxis defaultYAxis = plot.getDefaultYAxis();
Title title = new Title();
title.setTextObject(Toolkit.i18nText("Fine-Design_Chart_Axis_Title"));
title.getTextAttr().setRotation(-90);
title.getTextAttr().setThemed(true);
defaultYAxis.setTitle(title);
defaultYAxis.setShowAxisTitle(true);
defaultYAxis.setCustomMaxValue(true);
defaultYAxis.setCustomMinValue(true);
defaultYAxis.setCustomMainUnit(true);
defaultYAxis.setMaxValue(BaseFormula.createFormulaBuilder().build("=600"));
defaultYAxis.setMinValue(BaseFormula.createFormulaBuilder().build("=0"));
defaultYAxis.setMainUnit(BaseFormula.createFormulaBuilder().build("=200"));
Object[] category = {
Toolkit.i18nText("Fine-Design_Chart_Category") + "1",
Toolkit.i18nText("Fine-Design_Chart_Category") + "2",
Toolkit.i18nText("Fine-Design_Chart_Category") + "3",
Toolkit.i18nText("Fine-Design_Chart_Category") + "4"
};
Object[] series = {
Toolkit.i18nText("Fine-Design_Chart_Series") + "1",
Toolkit.i18nText("Fine-Design_Chart_Series") + "2"
};
Object[][] value = {
{"250", "540", "300", "410"},
{"180", "190", "170", "100"},
};
NormalChartData normalChartData = new NormalChartData(category, series, value);
chart.setPreViewChartData(normalChartData);
ChartCollection chartCollection = new ChartCollection(chart);
return chartCollection;
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
return null;
}
//饼图
private ChartCollection initPieChart() {
try {
VanChart chart = (VanChart) ChartTypeManager.getInstance().getCharts(PiePlot4VanChart.VAN_CHART_PIE_PLOT)[0].clone();
chart.getTitle().setTitleVisible(false);
VanChartTools vanChartTools = chart.getVanChartTools();
vanChartTools.setSort(false);
vanChartTools.setExport(false);
vanChartTools.setFullScreen(false);
PiePlot4VanChart plot = chart.getPlot();
plot.getLegend().setPosition(Constants.BOTTOM);
plot.setPlotStyle(ChartConstants.STYLE_NONE);
plot.setInnerRadiusPercent(75);
plot.getRadius().setRadiusType(RadiusType.FIXED);
plot.getRadius().setRadius(80);
Object[] category = {StringUtils.EMPTY};
Object[] series = {"A1", "B1", "C1", "D1", "E1", "F1", "G1", "H1"};
Object[][] value = {{45}, {24}, {12}, {8}, {5}, {3}, {2}, {1},};
NormalChartData normalChartData = new NormalChartData(category, series, value);
chart.setPreViewChartData(normalChartData);
ChartCollection chartCollection = new ChartCollection(chart);
return chartCollection;
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
return null;
}
} }

87
designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ReportThemePreviewPane.java

@ -1,21 +1,32 @@
package com.fr.design.mainframe.theme.preview; package com.fr.design.mainframe.theme.preview;
import com.fr.base.BaseFormula;
import com.fr.base.background.ColorBackground; import com.fr.base.background.ColorBackground;
import com.fr.base.theme.ReportTheme; import com.fr.base.theme.ReportTheme;
import com.fr.chart.base.ChartConstants;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.Title;
import com.fr.chart.chartdata.NormalChartData;
import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.theme.TemplateThemePreviewPane; import com.fr.design.mainframe.theme.TemplateThemePreviewPane;
import com.fr.design.mainframe.theme.preview.ecpreview.ECComponentPreviewPane;
import com.fr.design.mainframe.theme.preview.ecpreview.ECReportPreviewPane; import com.fr.design.mainframe.theme.preview.ecpreview.ECReportPreviewPane;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.general.Background; import com.fr.general.Background;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.attr.axis.VanChartAxis;
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.vanchart.VanChart;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import java.util.ArrayList;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
/** /**
* @author Starryi * @author Starryi
@ -26,10 +37,16 @@ public class ReportThemePreviewPane extends TemplateThemePreviewPane<ReportTheme
private Background background; private Background background;
private final ECReportPreviewPane reportPreviewPane; private final ECReportPreviewPane reportPreviewPane;
private final ChartPreviewPane chartPreviewPane;
public ReportThemePreviewPane(){ public ReportThemePreviewPane(){
setLayout(FRGUIPaneFactory.createBorderLayout()); setLayout(FRGUIPaneFactory.createBorderLayout());
chartPreviewPane = new ChartPreviewPane();
chartPreviewPane.populate(initColumnChart());
chartPreviewPane.setCallbackEvent(this);
reportPreviewPane = new ECReportPreviewPane(); reportPreviewPane = new ECReportPreviewPane();
this.add(new UINoOpaquePanel(), BorderLayout.CENTER); this.add(chartPreviewPane, BorderLayout.CENTER);
this.add(reportPreviewPane, BorderLayout.SOUTH); this.add(reportPreviewPane, BorderLayout.SOUTH);
} }
@ -37,6 +54,7 @@ public class ReportThemePreviewPane extends TemplateThemePreviewPane<ReportTheme
public void refresh(ReportTheme theme) { public void refresh(ReportTheme theme) {
background = theme.getBodyStyle().getBackground(); background = theme.getBodyStyle().getBackground();
reportPreviewPane.refresh(theme); reportPreviewPane.refresh(theme);
chartPreviewPane.refresh(theme);
repaint(); repaint();
} }
@ -53,4 +71,65 @@ public class ReportThemePreviewPane extends TemplateThemePreviewPane<ReportTheme
ComponentUtils.resetBuffer(dbcomponents); ComponentUtils.resetBuffer(dbcomponents);
} }
//柱形图
private ChartCollection initColumnChart() {
try {
VanChart chart = (VanChart) ChartTypeManager.getInstance().getCharts(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID)[0].clone();
VanChartTools vanChartTools = chart.getVanChartTools();
vanChartTools.setSort(false);
vanChartTools.setExport(false);
vanChartTools.setFullScreen(false);
VanChartColumnPlot plot = chart.getPlot();
AttrLabel defaultAttrLabel = plot.getDefaultAttrLabel();
defaultAttrLabel.setEnable(true);
defaultAttrLabel.getAttrLabelDetail().getBorder().setBorderStyle(0);
defaultAttrLabel.getAttrLabelDetail().getBackground().setBackground(null);
plot.getConditionCollection().getDefaultAttr().addDataSeriesCondition(defaultAttrLabel);
plot.setPlotStyle(ChartConstants.STYLE_NONE);
plot.setSeriesOverlapPercent(30);
plot.setCategoryIntervalPercent(30);
VanChartAxis defaultYAxis = plot.getDefaultYAxis();
Title title = new Title();
title.setTextObject(Toolkit.i18nText("Fine-Design_Chart_Axis_Title"));
title.getTextAttr().setRotation(-90);
title.getTextAttr().setThemed(true);
defaultYAxis.setTitle(title);
defaultYAxis.setShowAxisTitle(true);
defaultYAxis.setCustomMaxValue(true);
defaultYAxis.setCustomMinValue(true);
defaultYAxis.setCustomMainUnit(true);
defaultYAxis.setMaxValue(BaseFormula.createFormulaBuilder().build("=600"));
defaultYAxis.setMinValue(BaseFormula.createFormulaBuilder().build("=0"));
defaultYAxis.setMainUnit(BaseFormula.createFormulaBuilder().build("=200"));
Object[] category = {
Toolkit.i18nText("Fine-Design_Chart_Category") + "1",
Toolkit.i18nText("Fine-Design_Chart_Category") + "2",
Toolkit.i18nText("Fine-Design_Chart_Category") + "3",
Toolkit.i18nText("Fine-Design_Chart_Category") + "4"
};
Object[] series = {
Toolkit.i18nText("Fine-Design_Chart_Series") + "1",
Toolkit.i18nText("Fine-Design_Chart_Series") + "2",
Toolkit.i18nText("Fine-Design_Chart_Series") + "3"
};
Object[][] value = {
{"340", "510", "300", "250"},
{"180", "360", "170", "100"},
{"210", "205", "405", "190"}
};
NormalChartData normalChartData = new NormalChartData(category, series, value);
chart.setPreViewChartData(normalChartData);
ChartCollection chartCollection = new ChartCollection(chart);
return chartCollection;
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
return null;
}
} }

2
designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java

@ -2,6 +2,7 @@ package com.fr.design.chart.gui;
import com.fr.base.chart.BaseChartGetter; import com.fr.base.chart.BaseChartGetter;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.core.WidgetOption;
import com.fr.form.ui.ChartEditor; import com.fr.form.ui.ChartEditor;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
@ -40,6 +41,7 @@ public class ChartWidgetOption extends WidgetOption {
try { try {
ChartEditor widget = clz.newInstance(); ChartEditor widget = clz.newInstance();
ChartCollection chartCollection = (ChartCollection) BaseChartGetter.createChartCollection(this.chartID); ChartCollection chartCollection = (ChartCollection) BaseChartGetter.createChartCollection(this.chartID);
chartCollection.setThemeStyle(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplateTheme());
VanChart vanChart = chartCollection.getSelectedChartProvider(VanChart.class); VanChart vanChart = chartCollection.getSelectedChartProvider(VanChart.class);
if (vanChart !=null) { if (vanChart !=null) {
vanChart.resetAttrInForm(); vanChart.resetAttrInForm();

Loading…
Cancel
Save