|
|
|
@ -1,21 +1,26 @@
|
|
|
|
|
package com.fr.design.mainframe.predefined.ui.preview; |
|
|
|
|
|
|
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
|
import com.fr.base.ScreenResolution; |
|
|
|
|
import com.fr.base.Style; |
|
|
|
|
import com.fr.config.predefined.PredefinedCellStyle; |
|
|
|
|
import com.fr.config.predefined.PredefinedCellStyleConfig; |
|
|
|
|
import com.fr.config.predefined.PredefinedStyle; |
|
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
|
import com.fr.general.FRFont; |
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
|
|
|
|
|
import com.fr.third.javax.annotation.Nonnull; |
|
|
|
|
import javax.swing.JComponent; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import javax.swing.JSeparator; |
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
import java.awt.Dimension; |
|
|
|
|
import java.awt.Graphics; |
|
|
|
|
import java.awt.Graphics2D; |
|
|
|
|
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 |
|
|
|
@ -23,6 +28,7 @@ import java.awt.Dimension;
|
|
|
|
|
public class ElementCasePreview extends ComponentPreviewPane { |
|
|
|
|
private static final List<String[]> PREVIEW_DATA_LIST = new ArrayList<>(); |
|
|
|
|
private static final String BLANK_CHAR = " "; |
|
|
|
|
private List<GridRowPane> gridRowPanes; |
|
|
|
|
|
|
|
|
|
static { |
|
|
|
|
readPreviewData(); |
|
|
|
@ -44,56 +50,122 @@ public class ElementCasePreview extends ComponentPreviewPane {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected JPanel createContentPane() { |
|
|
|
|
|
|
|
|
|
gridRowPanes = new ArrayList<>(); |
|
|
|
|
JPanel jPanel = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); |
|
|
|
|
jPanel.setOpaque(false); |
|
|
|
|
jPanel.setBackground(null); |
|
|
|
|
FRFont font = FRFont.getInstance(); |
|
|
|
|
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; |
|
|
|
|
GridRowPane gridRowPane = new GridRowPane(PREVIEW_DATA_LIST.get(i), Style.DEFAULT_STYLE); |
|
|
|
|
gridRowPanes.add(gridRowPane); |
|
|
|
|
jPanel.add(gridRowPane); |
|
|
|
|
} |
|
|
|
|
return jPanel; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void refresh(PredefinedStyle style) { |
|
|
|
|
super.refresh(style); |
|
|
|
|
PredefinedCellStyleConfig cellStyleConfig = style.getCellStyleConfig(); |
|
|
|
|
for (int i = 0; i < gridRowPanes.size(); i++) { |
|
|
|
|
Style renderStyle = getMainContentStyle(cellStyleConfig); |
|
|
|
|
if (i == 0) { |
|
|
|
|
frFont = titleFont; |
|
|
|
|
renderStyle = getReportHeaderStyle(cellStyleConfig); |
|
|
|
|
} |
|
|
|
|
if (i == PREVIEW_DATA_LIST.size() - 1) { |
|
|
|
|
frFont = endFont; |
|
|
|
|
renderStyle = getHighLightStyle(cellStyleConfig); |
|
|
|
|
} |
|
|
|
|
jPanel.add(new GridRowPane(frFont, PREVIEW_DATA_LIST.get(i))); |
|
|
|
|
|
|
|
|
|
gridRowPanes.get(i).preview(renderStyle); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return jPanel; |
|
|
|
|
|
|
|
|
|
private Style getReportHeaderStyle(PredefinedCellStyleConfig config) { |
|
|
|
|
return getCellStyle(config, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Style getMainContentStyle(PredefinedCellStyleConfig config) { |
|
|
|
|
return getCellStyle(config, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Main_Text")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Style getHighLightStyle(PredefinedCellStyleConfig config) { |
|
|
|
|
return getCellStyle(config, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Highlight_Text")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Nonnull |
|
|
|
|
private Style getCellStyle(PredefinedCellStyleConfig config, String styleName) { |
|
|
|
|
PredefinedCellStyle cellStyle = config.getStyle(styleName); |
|
|
|
|
if (cellStyle == null) { |
|
|
|
|
return Style.DEFAULT_STYLE; |
|
|
|
|
} |
|
|
|
|
return cellStyle.getStyle(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GridRowPane extends JPanel { |
|
|
|
|
public GridRowPane(FRFont frFont, String[] data) { |
|
|
|
|
private List<GridPreview> gridPreviews = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
public GridRowPane(String[] data, Style style) { |
|
|
|
|
this.setOpaque(false); |
|
|
|
|
this.setBackground(null); |
|
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
|
JPanel panel = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(4, 20, 10); |
|
|
|
|
JPanel panel = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(4, 0, 0); |
|
|
|
|
panel.setOpaque(false); |
|
|
|
|
panel.setBackground(null); |
|
|
|
|
for (String text : data) { |
|
|
|
|
panel.add(createLabel(text, frFont)); |
|
|
|
|
GridPreview gridPreview = new GridPreview(text); |
|
|
|
|
gridPreviews.add(gridPreview); |
|
|
|
|
panel.add(gridPreview); |
|
|
|
|
} |
|
|
|
|
this.add(panel, BorderLayout.CENTER); |
|
|
|
|
JSeparator jSeparator = new JSeparator(); |
|
|
|
|
jSeparator.setPreferredSize(new Dimension(246, 2)); |
|
|
|
|
this.add(jSeparator, BorderLayout.SOUTH); |
|
|
|
|
preview(style); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private UILabel createLabel(String text, FRFont frFont) { |
|
|
|
|
UILabel label = new UILabel(text); |
|
|
|
|
label.setFont(frFont); |
|
|
|
|
label.setForeground(frFont.getForeground()); |
|
|
|
|
label.setBackground(null); |
|
|
|
|
return label; |
|
|
|
|
public void preview(Style style) { |
|
|
|
|
for (GridPreview grid : gridPreviews) { |
|
|
|
|
grid.preview(style); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static class GridPreview extends JComponent { |
|
|
|
|
|
|
|
|
|
private Style style = Style.DEFAULT_STYLE; |
|
|
|
|
private String value; |
|
|
|
|
|
|
|
|
|
public GridPreview(String value) { |
|
|
|
|
this.value = value; |
|
|
|
|
setPreferredSize(new Dimension(125, 30)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void preview(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 getPreferredSize(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|