|
|
|
package com.fr.widgettheme.theme.panel;
|
|
|
|
|
|
|
|
import com.fr.base.background.ColorBackground;
|
|
|
|
import com.fr.base.theme.FormTheme;
|
|
|
|
import com.fr.chart.chartattr.ChartCollection;
|
|
|
|
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.mainframe.theme.TemplateThemePreviewPane;
|
|
|
|
import com.fr.design.mainframe.theme.preview.ChartComponentPreviewPane;
|
|
|
|
import com.fr.design.mainframe.theme.preview.UINoOpaquePanel;
|
|
|
|
import com.fr.general.Background;
|
|
|
|
import com.fr.log.FineLoggerFactory;
|
|
|
|
import com.fr.plugin.chart.PiePlot4VanChart;
|
|
|
|
import com.fr.plugin.chart.attr.VanChartLegend;
|
|
|
|
import com.fr.plugin.chart.base.VanChartTools;
|
|
|
|
import com.fr.plugin.chart.column.VanChartColumnPlot;
|
|
|
|
import com.fr.plugin.chart.type.GradientType;
|
|
|
|
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 com.fr.widgettheme.ThemePreviewTerminal;
|
|
|
|
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
import java.awt.AlphaComposite;
|
|
|
|
import java.awt.BorderLayout;
|
|
|
|
import java.awt.Color;
|
|
|
|
import java.awt.Composite;
|
|
|
|
import java.awt.Dimension;
|
|
|
|
import java.awt.Graphics2D;
|
|
|
|
import java.awt.geom.Rectangle2D;
|
|
|
|
|
|
|
|
import static com.fr.design.i18n.Toolkit.i18nText;
|
|
|
|
import static com.fr.widgettheme.util.ThemePreviewPaneInitHelper.initColumnPlot;
|
|
|
|
import static com.fr.widgettheme.util.ThemePreviewPaneInitHelper.initVanChartYAxis;
|
|
|
|
import static com.fr.widgettheme.util.ThemePreviewPaneInitHelper.initVanChartsTools;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 主题界面预览控frm界面,就是主jar里的那个界面,做了简单的修改
|
|
|
|
*
|
|
|
|
* @author John.Ying
|
|
|
|
* @since 11.0
|
|
|
|
* Created on 2023/3/18
|
|
|
|
*/
|
|
|
|
public class WidgetDisplayFormThemePreviewPane extends TemplateThemePreviewPane<FormTheme> {
|
|
|
|
private WidgetThemeECComponentPreviewPane elementCasePane;
|
|
|
|
private Background background;
|
|
|
|
private ChartComponentPreviewPane columnChartPreviewPane;
|
|
|
|
private ChartComponentPreviewPane pieChartPreviewPane;
|
|
|
|
private ControlPreviewPane controlPreviewPane;
|
|
|
|
private float alpha = 1.0F;
|
|
|
|
|
|
|
|
public WidgetDisplayFormThemePreviewPane() {
|
|
|
|
setLayout(FRGUIPaneFactory.createBorderLayout());
|
|
|
|
controlPreviewPane = new ControlPreviewPane();
|
|
|
|
controlPreviewPane.setLayout(FRGUIPaneFactory.createLabelFlowLayout());
|
|
|
|
controlPreviewPane.setPreferredSize(new Dimension(615, 40));
|
|
|
|
controlPreviewPane.initControlPreviewPane();
|
|
|
|
JPanel content = new UINoOpaquePanel();
|
|
|
|
content.setLayout(new BorderLayout());
|
|
|
|
add(controlPreviewPane, BorderLayout.NORTH);
|
|
|
|
JPanel chartContent = createChartContent();
|
|
|
|
content.add(chartContent, BorderLayout.CENTER);
|
|
|
|
content.add(elementCasePane = new WidgetThemeECComponentPreviewPane(), BorderLayout.SOUTH);
|
|
|
|
add(content, BorderLayout.CENTER);
|
|
|
|
}
|
|
|
|
|
|
|
|
private JPanel createChartContent() {
|
|
|
|
JPanel chartContent = new UINoOpaquePanel();
|
|
|
|
chartContent.setLayout(new BorderLayout());
|
|
|
|
JPanel columnChartPanel = new UINoOpaquePanel() {
|
|
|
|
public Dimension getPreferredSize() {
|
|
|
|
return new Dimension(379, 314);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
columnChartPanel.setLayout(new BorderLayout());
|
|
|
|
columnChartPreviewPane = createChartPreviewPane(initColumnChart(), i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_Comp_Title1"));
|
|
|
|
columnChartPanel.add(columnChartPreviewPane, BorderLayout.CENTER);
|
|
|
|
|
|
|
|
JPanel pieChartPanel = new UINoOpaquePanel() {
|
|
|
|
public Dimension getPreferredSize() {
|
|
|
|
return new Dimension(236, 314);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
pieChartPanel.setLayout(new BorderLayout());
|
|
|
|
pieChartPreviewPane = createChartPreviewPane(initPieChart(), i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_Comp_Title2"));
|
|
|
|
pieChartPanel.add(pieChartPreviewPane, BorderLayout.CENTER);
|
|
|
|
chartContent.add(columnChartPanel, BorderLayout.CENTER);
|
|
|
|
chartContent.add(pieChartPanel, BorderLayout.EAST);
|
|
|
|
return chartContent;
|
|
|
|
}
|
|
|
|
|
|
|
|
private ChartComponentPreviewPane createChartPreviewPane(ChartCollection chartCollection, String title) {
|
|
|
|
ChartComponentPreviewPane chartComponentPreviewPane = new ChartComponentPreviewPane(title);
|
|
|
|
chartComponentPreviewPane.getContentPane().populate(chartCollection);
|
|
|
|
chartComponentPreviewPane.getContentPane().setCallbackEvent(this);
|
|
|
|
return chartComponentPreviewPane;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void refresh(FormTheme theme) {
|
|
|
|
refresh(theme, ThemePreviewTerminal.PC);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void refresh(FormTheme theme, ThemePreviewTerminal themeStyleType) {
|
|
|
|
background = theme.getBodyStyle().getStyle().getBackground();
|
|
|
|
alpha = theme.getBodyStyle().getStyle().getAlpha();
|
|
|
|
elementCasePane.refresh(theme);
|
|
|
|
columnChartPreviewPane.refresh(theme);
|
|
|
|
pieChartPreviewPane.refresh(theme);
|
|
|
|
controlPreviewPane.refresh(theme, themeStyleType);
|
|
|
|
repaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected void paintBackground(Graphics2D g2d) {
|
|
|
|
if (background == null) {
|
|
|
|
background = ColorBackground.getInstance(Color.WHITE);
|
|
|
|
}
|
|
|
|
Composite oldComposite = g2d.getComposite();
|
|
|
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
|
|
|
|
background.paint(g2d, new Rectangle2D.Double(0, 0, PREVIEW_WIDTH, PREVIEW_HEIGHT));
|
|
|
|
g2d.setComposite(oldComposite);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 初始化柱形图
|
|
|
|
*
|
|
|
|
* @return 存放图表
|
|
|
|
*/
|
|
|
|
private ChartCollection initColumnChart() {
|
|
|
|
try {
|
|
|
|
VanChart chart = (VanChart) ChartTypeManager.getInstance().getCharts(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID)[0].clone();
|
|
|
|
initColumnChartDetail(chart);
|
|
|
|
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 void initColumnChartDetail(VanChart chart) {
|
|
|
|
chart.getTitle().setTitleVisible(false);
|
|
|
|
initVanChartsTools(chart.getVanChartTools());
|
|
|
|
VanChartColumnPlot plot = chart.getPlot();
|
|
|
|
//Form中独有的setPosition,和Report中不同,先单独放在这里,不写在initPlot中
|
|
|
|
plot.getLegend().setPosition(Constants.TOP);
|
|
|
|
initColumnPlot(plot);
|
|
|
|
initVanChartYAxis(plot.getDefaultYAxis());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 初始化饼图
|
|
|
|
*
|
|
|
|
* @return chartCollection
|
|
|
|
*/
|
|
|
|
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();
|
|
|
|
VanChartLegend legend = (VanChartLegend) plot.getLegend();
|
|
|
|
legend.setPosition(Constants.BOTTOM);
|
|
|
|
legend.setCustomSize(true);
|
|
|
|
legend.setMaxHeight(28);
|
|
|
|
plot.getGradientStyle().setGradientType(GradientType.NONE);
|
|
|
|
plot.setInnerRadiusPercent(75);
|
|
|
|
plot.getRadius().setRadiusType(RadiusType.FIXED);
|
|
|
|
plot.getRadius().setRadius(70);
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|