kerry
3 years ago
17 changed files with 520 additions and 233 deletions
@ -1,160 +0,0 @@ |
|||||||
package com.fr.design.mainframe.theme.preview; |
|
||||||
|
|
||||||
import com.fr.base.ScreenResolution; |
|
||||||
import com.fr.base.Style; |
|
||||||
import com.fr.base.theme.TemplateTheme; |
|
||||||
import com.fr.base.theme.settings.ThemedCellStyle; |
|
||||||
import com.fr.base.theme.settings.ThemedCellStyleList; |
|
||||||
import com.fr.design.i18n.Toolkit; |
|
||||||
import com.fr.log.FineLoggerFactory; |
|
||||||
|
|
||||||
import javax.swing.JComponent; |
|
||||||
import javax.swing.JPanel; |
|
||||||
import java.awt.Dimension; |
|
||||||
import java.awt.Graphics; |
|
||||||
import java.awt.Graphics2D; |
|
||||||
import java.awt.GridBagConstraints; |
|
||||||
import java.awt.GridBagLayout; |
|
||||||
import java.io.BufferedReader; |
|
||||||
import java.io.StringReader; |
|
||||||
import java.util.ArrayList; |
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author Starryi |
|
||||||
* @version 1.0 |
|
||||||
* Created by Starryi on 2021/8/13 |
|
||||||
*/ |
|
||||||
public class ECPreviewPane extends JPanel implements ThemePreviewed<TemplateTheme> { |
|
||||||
|
|
||||||
private static final List<String[]> DATA_LIST = createDataList(); |
|
||||||
private static final String BLANK_CHAR = " "; |
|
||||||
private final List<List<Cell>> grid = new ArrayList<>(); |
|
||||||
|
|
||||||
private static List<String[]> createDataList() { |
|
||||||
String csv = |
|
||||||
"城市 当月目标 当月实际完成 月度完成率\n" + |
|
||||||
"南通市 324,646 324,646 100%\n" + |
|
||||||
"合肥市 248,938 348,938 140%\n" + |
|
||||||
"邵阳市 248,938 348,938 140%\n" + |
|
||||||
"合计 1,071,460 1,371,460 128%"; |
|
||||||
|
|
||||||
List<String[]> data = new ArrayList<>(); |
|
||||||
try(BufferedReader reader = new BufferedReader(new StringReader(csv))) { |
|
||||||
String textLine; |
|
||||||
while ((textLine = reader.readLine()) != null) { |
|
||||||
String[] texts = textLine.split(BLANK_CHAR); |
|
||||||
data.add(texts); |
|
||||||
} |
|
||||||
} catch (Exception e) { |
|
||||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
||||||
} |
|
||||||
return data; |
|
||||||
} |
|
||||||
|
|
||||||
public ECPreviewPane() { |
|
||||||
setOpaque(false); |
|
||||||
setBackground(null); |
|
||||||
|
|
||||||
GridBagLayout gridBagLayout = new GridBagLayout(); |
|
||||||
setLayout(gridBagLayout); |
|
||||||
GridBagConstraints constraints = new GridBagConstraints(); |
|
||||||
constraints.fill = GridBagConstraints.BOTH; |
|
||||||
for (int i = 0; i < DATA_LIST.size(); i++) { |
|
||||||
String[] textLine = DATA_LIST.get(i); |
|
||||||
List<Cell> row = new ArrayList<>(); |
|
||||||
for (int j = 0; j < textLine.length ; j++) { |
|
||||||
String text = textLine[j]; |
|
||||||
|
|
||||||
constraints.gridx = j; |
|
||||||
constraints.gridy = i; |
|
||||||
constraints.gridwidth = 1; |
|
||||||
constraints.gridheight = 1; |
|
||||||
constraints.weightx = 1.0; |
|
||||||
constraints.weighty = 1.0; |
|
||||||
Cell cell = new Cell(text); |
|
||||||
cell.setPreferredSize(new Dimension(50, 20)); |
|
||||||
gridBagLayout.setConstraints(cell, constraints); |
|
||||||
add(cell); |
|
||||||
|
|
||||||
row.add(cell); |
|
||||||
} |
|
||||||
grid.add(row); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void refresh(TemplateTheme theme) { |
|
||||||
ThemedCellStyleList cellStyleConfig = theme.getCellStyleList(); |
|
||||||
for (int i = 0; i < grid.size(); i++) { |
|
||||||
Style style = getMainContentStyle(cellStyleConfig); |
|
||||||
if (i == 0) { |
|
||||||
style = getReportHeaderStyle(cellStyleConfig); |
|
||||||
} |
|
||||||
if (i == DATA_LIST.size() - 1) { |
|
||||||
style = getHighLightStyle(cellStyleConfig); |
|
||||||
} |
|
||||||
|
|
||||||
List<Cell> row = grid.get(i); |
|
||||||
for (Cell cell : row) { |
|
||||||
cell.refresh(style); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
private Style getReportHeaderStyle(ThemedCellStyleList cellStyleList) { |
|
||||||
return getCellStyle(cellStyleList, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header")); |
|
||||||
} |
|
||||||
|
|
||||||
private Style getMainContentStyle(ThemedCellStyleList cellStyleList) { |
|
||||||
return getCellStyle(cellStyleList, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Main_Text")); |
|
||||||
} |
|
||||||
|
|
||||||
private Style getHighLightStyle(ThemedCellStyleList cellStyleList) { |
|
||||||
return getCellStyle(cellStyleList, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Highlight_Text")); |
|
||||||
} |
|
||||||
|
|
||||||
private Style getCellStyle(ThemedCellStyleList cellStyleList, String styleName) { |
|
||||||
ThemedCellStyle cellStyle = cellStyleList.find(styleName); |
|
||||||
if (cellStyle == null) { |
|
||||||
return Style.DEFAULT_STYLE; |
|
||||||
} |
|
||||||
return cellStyle.getStyle(); |
|
||||||
} |
|
||||||
|
|
||||||
private static class Cell extends JComponent { |
|
||||||
|
|
||||||
private Style style = Style.DEFAULT_STYLE; |
|
||||||
private final String value; |
|
||||||
|
|
||||||
public Cell(String value) { |
|
||||||
this.value = value; |
|
||||||
} |
|
||||||
|
|
||||||
public void refresh(Style style) { |
|
||||||
this.style = style; |
|
||||||
} |
|
||||||
|
|
||||||
public void paint(Graphics g) { |
|
||||||
Graphics2D g2d = (Graphics2D) g; |
|
||||||
int resolution = ScreenResolution.getScreenResolution(); |
|
||||||
|
|
||||||
if (style == Style.DEFAULT_STYLE) { |
|
||||||
Style.paintContent(g2d, value, style, getWidth() - 3, getHeight() - 3, resolution); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
Style.paintBackground(g2d, style, getWidth(), getHeight()); |
|
||||||
|
|
||||||
Style.paintContent(g2d, value, style, getWidth() - 3, getHeight() - 3, resolution); |
|
||||||
|
|
||||||
Style.paintBorder(g2d, style, getWidth() , getHeight() ); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public Dimension getMinimumSize() { |
|
||||||
return new Dimension(125, 30); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,19 @@ |
|||||||
|
package com.fr.design.mainframe.theme.preview; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.LayoutManager; |
||||||
|
|
||||||
|
public class UINoOpaquePanel extends JPanel { |
||||||
|
|
||||||
|
public UINoOpaquePanel(){ |
||||||
|
super(); |
||||||
|
this.setOpaque(false); |
||||||
|
this.setBackground(null); |
||||||
|
} |
||||||
|
|
||||||
|
public UINoOpaquePanel(LayoutManager layout) { |
||||||
|
super(layout, true); |
||||||
|
this.setOpaque(false); |
||||||
|
this.setBackground(null); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
package com.fr.design.mainframe.theme.preview.ecpreview; |
||||||
|
|
||||||
|
import com.fr.base.Style; |
||||||
|
import com.fr.base.theme.TemplateTheme; |
||||||
|
import com.fr.base.theme.settings.ThemedCellStyle; |
||||||
|
import com.fr.base.theme.settings.ThemedCellStyleList; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.mainframe.theme.preview.ThemePreviewed; |
||||||
|
import com.fr.design.mainframe.theme.preview.UINoOpaquePanel; |
||||||
|
import com.fr.design.mainframe.theme.preview.ecpreview.cell.AbstractPreviewCell; |
||||||
|
import com.fr.design.mainframe.theme.preview.ecpreview.cell.PreviewCell; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
public abstract class AbstractECPreviewPane extends UINoOpaquePanel implements ThemePreviewed<TemplateTheme> { |
||||||
|
protected Style getReportHeaderStyle(ThemedCellStyleList cellStyleList) { |
||||||
|
return getCellStyle(cellStyleList, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header")); |
||||||
|
} |
||||||
|
|
||||||
|
protected Style getMainContentStyle(ThemedCellStyleList cellStyleList) { |
||||||
|
return getCellStyle(cellStyleList, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Main_Text")); |
||||||
|
} |
||||||
|
|
||||||
|
protected Style getHighLightStyle(ThemedCellStyleList cellStyleList) { |
||||||
|
return getCellStyle(cellStyleList, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Highlight_Text")); |
||||||
|
} |
||||||
|
|
||||||
|
protected Style getSmallTitleStyle(ThemedCellStyleList cellStyleList) { |
||||||
|
return getCellStyle(cellStyleList, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Small_Title")); |
||||||
|
} |
||||||
|
|
||||||
|
private Style getCellStyle(ThemedCellStyleList cellStyleList, String styleName) { |
||||||
|
ThemedCellStyle cellStyle = cellStyleList.find(styleName); |
||||||
|
if (cellStyle == null) { |
||||||
|
return Style.DEFAULT_STYLE; |
||||||
|
} |
||||||
|
return cellStyle.getStyle(); |
||||||
|
} |
||||||
|
|
||||||
|
protected void refresh(List<AbstractPreviewCell> list, Style style) { |
||||||
|
for (AbstractPreviewCell cell : list) { |
||||||
|
cell.refresh(style); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -1,6 +1,7 @@ |
|||||||
package com.fr.design.mainframe.theme.preview; |
package com.fr.design.mainframe.theme.preview.ecpreview; |
||||||
|
|
||||||
import com.fr.base.theme.FormTheme; |
import com.fr.base.theme.FormTheme; |
||||||
|
import com.fr.design.mainframe.theme.preview.ComponentPreviewPane; |
||||||
|
|
||||||
import java.awt.Component; |
import java.awt.Component; |
||||||
|
|
@ -0,0 +1,104 @@ |
|||||||
|
package com.fr.design.mainframe.theme.preview.ecpreview; |
||||||
|
|
||||||
|
import com.fr.base.theme.TemplateTheme; |
||||||
|
import com.fr.base.theme.settings.ThemedCellStyleList; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.mainframe.theme.preview.UINoOpaquePanel; |
||||||
|
import com.fr.design.mainframe.theme.preview.ecpreview.cell.AbstractPreviewCell; |
||||||
|
import com.fr.design.mainframe.theme.preview.ecpreview.cell.PreviewCell; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
|
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.JPanel; |
||||||
|
|
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.GridLayout; |
||||||
|
import java.io.BufferedReader; |
||||||
|
import java.io.StringReader; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Starryi |
||||||
|
* @version 1.0 |
||||||
|
* Created by Starryi on 2021/8/13 |
||||||
|
*/ |
||||||
|
public class ECPreviewPane extends AbstractECPreviewPane { |
||||||
|
private static String csv = |
||||||
|
"城市 当月目标 当月实际完成 月度完成率 全年完成率\n" + |
||||||
|
"南通市 324,646 324,646 100% 100%\n" + |
||||||
|
"合肥市 248,938 348,938 140% 140%\n" + |
||||||
|
"邵阳市 248,938 348,938 140% 140%\n" + |
||||||
|
"合计 1,071,460 1,371,460 128% 128%"; |
||||||
|
private final List<String[]> DATA_LIST = createDataList(); |
||||||
|
private static final String BLANK_CHAR = " "; |
||||||
|
private List<AbstractPreviewCell> headerCellList = new ArrayList<>(); |
||||||
|
private List<AbstractPreviewCell> contentCellList = new ArrayList<>(); |
||||||
|
private List<AbstractPreviewCell> hightLightCellList = new ArrayList<>(); |
||||||
|
|
||||||
|
private List<String[]> createDataList() { |
||||||
|
List<String[]> data = new ArrayList<>(); |
||||||
|
try (BufferedReader reader = new BufferedReader(new StringReader(csv))) { |
||||||
|
String textLine; |
||||||
|
while ((textLine = reader.readLine()) != null) { |
||||||
|
String[] texts = textLine.split(BLANK_CHAR); |
||||||
|
data.add(texts); |
||||||
|
} |
||||||
|
} catch (Exception e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
return data; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public ECPreviewPane() { |
||||||
|
this.setPreferredSize(new Dimension(517, 170)); |
||||||
|
this.setBorder(BorderFactory.createEmptyBorder(0, 1, 2, 1)); |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
String[] titleArr = DATA_LIST.get(0); |
||||||
|
String[] endArr = DATA_LIST.get(DATA_LIST.size() - 1); |
||||||
|
JPanel titlePane = new UINoOpaquePanel(new GridLayout()); |
||||||
|
this.add(titlePane, BorderLayout.NORTH); |
||||||
|
for (String title : titleArr) { |
||||||
|
PreviewCell cell = new PreviewCell(title); |
||||||
|
cell.setPreferredSize(new Dimension(103, 36)); |
||||||
|
titlePane.add(cell); |
||||||
|
headerCellList.add(cell); |
||||||
|
} |
||||||
|
|
||||||
|
JPanel contentPane = new UINoOpaquePanel(new GridLayout(3, 5, 0, 0)); |
||||||
|
this.add(contentPane, BorderLayout.CENTER); |
||||||
|
for (int i = 1; i < DATA_LIST.size() - 1; i++) { |
||||||
|
String[] textLine = DATA_LIST.get(i); |
||||||
|
for (int j = 0; j < textLine.length; j++) { |
||||||
|
String text = textLine[j]; |
||||||
|
PreviewCell cell = new PreviewCell(text); |
||||||
|
cell.setPreferredSize(new Dimension(103, 33)); |
||||||
|
contentPane.add(cell); |
||||||
|
contentCellList.add(cell); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
JPanel endPane = new UINoOpaquePanel(new GridLayout()); |
||||||
|
this.add(endPane, BorderLayout.SOUTH); |
||||||
|
for (String text : endArr) { |
||||||
|
PreviewCell cell = new PreviewCell(text); |
||||||
|
cell.setPreferredSize(new Dimension(103, 33)); |
||||||
|
endPane.add(cell); |
||||||
|
hightLightCellList.add(cell); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void refresh(TemplateTheme theme) { |
||||||
|
ThemedCellStyleList cellStyleConfig = theme.getCellStyleList(); |
||||||
|
refresh(headerCellList, getReportHeaderStyle(cellStyleConfig)); |
||||||
|
refresh(contentCellList, getMainContentStyle(cellStyleConfig)); |
||||||
|
refresh(hightLightCellList, getHighLightStyle(cellStyleConfig)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,126 @@ |
|||||||
|
package com.fr.design.mainframe.theme.preview.ecpreview; |
||||||
|
|
||||||
|
import com.fr.base.theme.ReportTheme; |
||||||
|
import com.fr.base.theme.TemplateTheme; |
||||||
|
import com.fr.base.theme.settings.ThemedCellStyleList; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.mainframe.theme.preview.ThemePreviewed; |
||||||
|
import com.fr.design.mainframe.theme.preview.UINoOpaquePanel; |
||||||
|
import com.fr.design.mainframe.theme.preview.ecpreview.cell.AbstractPreviewCell; |
||||||
|
import com.fr.design.mainframe.theme.preview.ecpreview.cell.CornerPreviewCell; |
||||||
|
import com.fr.design.mainframe.theme.preview.ecpreview.cell.PreviewCell; |
||||||
|
|
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.GridLayout; |
||||||
|
import java.awt.Point; |
||||||
|
import java.awt.geom.Point2D; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
public class ECReportPreviewPane extends UINoOpaquePanel implements ThemePreviewed<ReportTheme> { |
||||||
|
private List<AbstractPreviewCell> headerCellList = new ArrayList<>(); |
||||||
|
private List<AbstractPreviewCell> titleCellList = new ArrayList<>(); |
||||||
|
private List<AbstractPreviewCell> contentCellList = new ArrayList<>(); |
||||||
|
private List<AbstractPreviewCell> highLightCellList = new ArrayList<>(); |
||||||
|
|
||||||
|
private PreviewPane previewPane; |
||||||
|
|
||||||
|
public ECReportPreviewPane() { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
previewPane = new PreviewPane(); |
||||||
|
this.add(previewPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void refresh(ReportTheme theme) { |
||||||
|
previewPane.refresh(theme); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
class PreviewPane extends AbstractECPreviewPane { |
||||||
|
|
||||||
|
|
||||||
|
public PreviewPane() { |
||||||
|
this.setPreferredSize(new Dimension(517, 270)); |
||||||
|
this.setBorder(BorderFactory.createEmptyBorder(7, 10, 5, 10)); |
||||||
|
|
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
JPanel northPane = createNorthPane(); |
||||||
|
JPanel centerPane = createCenterPane(); |
||||||
|
this.add(northPane, BorderLayout.NORTH); |
||||||
|
this.add(centerPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createNorthPane() { |
||||||
|
JPanel northPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane(); |
||||||
|
CornerPreviewCell cornerCell = new CornerPreviewCell(new String[]{"产品", "数据", "统计维度"}, new Point2D[]{new Point(132, 75), new Point(189, 53)}); |
||||||
|
cornerCell.setPreferredSize(new Dimension(189, 75)); |
||||||
|
headerCellList.add(cornerCell); |
||||||
|
northPane.add(cornerCell, BorderLayout.WEST); |
||||||
|
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane(); |
||||||
|
northPane.add(centerPane, BorderLayout.CENTER); |
||||||
|
PreviewCell cell = new PreviewCell("按地区统计"); |
||||||
|
titleCellList.add(cell); |
||||||
|
cell.setPreferredSize(new Dimension(308, 38)); |
||||||
|
centerPane.add(cell, BorderLayout.NORTH); |
||||||
|
JPanel eastSouthPane = new UINoOpaquePanel(new GridLayout()); |
||||||
|
PreviewCell cell1 = new PreviewCell("华东"); |
||||||
|
PreviewCell cell2 = new PreviewCell("华南"); |
||||||
|
PreviewCell cell3 = new PreviewCell("小计"); |
||||||
|
headerCellList.add(cell1); |
||||||
|
headerCellList.add(cell2); |
||||||
|
headerCellList.add(cell3); |
||||||
|
eastSouthPane.add(cell1); |
||||||
|
eastSouthPane.add(cell2); |
||||||
|
eastSouthPane.add(cell3); |
||||||
|
centerPane.add(eastSouthPane, BorderLayout.CENTER); |
||||||
|
return northPane; |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createCenterPane() { |
||||||
|
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane(); |
||||||
|
JPanel westPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane(); |
||||||
|
centerPane.add(westPane, BorderLayout.WEST); |
||||||
|
PreviewCell cell1 = new PreviewCell("饮料"); |
||||||
|
titleCellList.add(cell1); |
||||||
|
cell1.setPreferredSize(new Dimension(94, 183)); |
||||||
|
westPane.add(cell1, BorderLayout.WEST); |
||||||
|
JPanel gridPane = new UINoOpaquePanel(new GridLayout(6, 1)); |
||||||
|
for (int i = 0; i < 6; i++) { |
||||||
|
PreviewCell cell = new PreviewCell("苹果汁"); |
||||||
|
cell.setPreferredSize(new Dimension(95, 31)); |
||||||
|
headerCellList.add(cell); |
||||||
|
gridPane.add(cell); |
||||||
|
} |
||||||
|
westPane.add(gridPane, BorderLayout.CENTER); |
||||||
|
|
||||||
|
JPanel innerCenterPane = new UINoOpaquePanel(new GridLayout(6, 3)); |
||||||
|
centerPane.add(innerCenterPane, BorderLayout.CENTER); |
||||||
|
for (int i = 0; i < 18; i++) { |
||||||
|
PreviewCell cell = new PreviewCell("35600"); |
||||||
|
cell.setPreferredSize(new Dimension(102, 31)); |
||||||
|
if ((i + 1) % 3 == 0) { |
||||||
|
highLightCellList.add(cell); |
||||||
|
} else { |
||||||
|
contentCellList.add(cell); |
||||||
|
} |
||||||
|
innerCenterPane.add(cell); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
return centerPane; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void refresh(TemplateTheme theme) { |
||||||
|
ThemedCellStyleList cellStyleConfig = theme.getCellStyleList(); |
||||||
|
refresh(headerCellList, getReportHeaderStyle(cellStyleConfig)); |
||||||
|
refresh(contentCellList, getMainContentStyle(cellStyleConfig)); |
||||||
|
refresh(titleCellList, getSmallTitleStyle(cellStyleConfig)); |
||||||
|
refresh(highLightCellList, getHighLightStyle(cellStyleConfig)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,32 @@ |
|||||||
|
package com.fr.design.mainframe.theme.preview.ecpreview.cell; |
||||||
|
|
||||||
|
import com.fr.base.ScreenResolution; |
||||||
|
import com.fr.base.Style; |
||||||
|
|
||||||
|
import javax.swing.JComponent; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.Graphics; |
||||||
|
import java.awt.Graphics2D; |
||||||
|
|
||||||
|
public abstract class AbstractPreviewCell extends JComponent { |
||||||
|
protected Style style = Style.DEFAULT_STYLE; |
||||||
|
|
||||||
|
public void refresh(Style style) { |
||||||
|
this.style = style; |
||||||
|
} |
||||||
|
|
||||||
|
public void paint(Graphics g) { |
||||||
|
Graphics2D g2d = (Graphics2D) g; |
||||||
|
int resolution = ScreenResolution.getScreenResolution(); |
||||||
|
Style.paintBackground(g2d, style, getWidth(), getHeight()); |
||||||
|
paintContent(g2d, resolution); |
||||||
|
Style.paintBorder(g2d, style, getWidth(), getHeight()); |
||||||
|
} |
||||||
|
|
||||||
|
protected abstract void paintContent(Graphics2D g2d, int resolution); |
||||||
|
|
||||||
|
@Override |
||||||
|
public Dimension getMinimumSize() { |
||||||
|
return new Dimension(125, 30); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
package com.fr.design.mainframe.theme.preview.ecpreview.cell; |
||||||
|
|
||||||
|
import com.fr.general.FRFont; |
||||||
|
import com.fr.stable.GraphDrawHelper; |
||||||
|
|
||||||
|
import java.awt.Graphics2D; |
||||||
|
import java.awt.geom.Line2D; |
||||||
|
import java.awt.geom.Point2D; |
||||||
|
|
||||||
|
public class CornerPreviewCell extends AbstractPreviewCell { |
||||||
|
private final String[] values; |
||||||
|
private final Point2D[] point2DS; |
||||||
|
|
||||||
|
public CornerPreviewCell(String[] values, Point2D[] point2DS) { |
||||||
|
this.values = values; |
||||||
|
this.point2DS = point2DS; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void paintContent(Graphics2D g2d, int resolution) { |
||||||
|
FRFont frFont = style.getFRFont(); |
||||||
|
g2d.setPaint(frFont.getForeground()); |
||||||
|
g2d.drawString(values[0], 23, 53); |
||||||
|
GraphDrawHelper.drawRotatedString(g2d, values[1], 104, 50, 30); |
||||||
|
g2d.drawString(values[2], 128, 23); |
||||||
|
//画分割线
|
||||||
|
for (int i = 0; i < point2DS.length; i++) { |
||||||
|
g2d.draw(new Line2D.Double(0, 0, point2DS[i].getX(), point2DS[i].getY())); //画线
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
package com.fr.design.mainframe.theme.preview.ecpreview.cell; |
||||||
|
|
||||||
|
import com.fr.base.Style; |
||||||
|
|
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.Graphics2D; |
||||||
|
|
||||||
|
public class PreviewCell extends AbstractPreviewCell { |
||||||
|
|
||||||
|
private final String value; |
||||||
|
|
||||||
|
public PreviewCell(String value) { |
||||||
|
this.value = value; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void paintContent(Graphics2D g2d, int resolution) { |
||||||
|
Style.paintContent(g2d, value, style, getWidth() - 3, getHeight() - 3, resolution); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Dimension getMinimumSize() { |
||||||
|
return new Dimension(125, 30); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue