|
|
@ -1,21 +1,26 @@ |
|
|
|
package com.fr.design.mainframe.predefined.ui.preview; |
|
|
|
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.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.general.FRFont; |
|
|
|
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
|
|
|
import com.fr.third.javax.annotation.Nonnull; |
|
|
|
|
|
|
|
import javax.swing.JComponent; |
|
|
|
import javax.swing.JPanel; |
|
|
|
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.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 |
|
|
@ -23,6 +28,7 @@ import java.awt.Dimension; |
|
|
|
public class ElementCasePreview extends ComponentPreviewPane { |
|
|
|
public class ElementCasePreview extends ComponentPreviewPane { |
|
|
|
private static final List<String[]> PREVIEW_DATA_LIST = new ArrayList<>(); |
|
|
|
private static final List<String[]> PREVIEW_DATA_LIST = new ArrayList<>(); |
|
|
|
private static final String BLANK_CHAR = " "; |
|
|
|
private static final String BLANK_CHAR = " "; |
|
|
|
|
|
|
|
private List<GridRowPane> gridRowPanes; |
|
|
|
|
|
|
|
|
|
|
|
static { |
|
|
|
static { |
|
|
|
readPreviewData(); |
|
|
|
readPreviewData(); |
|
|
@ -44,56 +50,122 @@ public class ElementCasePreview extends ComponentPreviewPane { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected JPanel createContentPane() { |
|
|
|
protected JPanel createContentPane() { |
|
|
|
|
|
|
|
gridRowPanes = new ArrayList<>(); |
|
|
|
JPanel jPanel = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); |
|
|
|
JPanel jPanel = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); |
|
|
|
jPanel.setOpaque(false); |
|
|
|
jPanel.setOpaque(false); |
|
|
|
jPanel.setBackground(null); |
|
|
|
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++) { |
|
|
|
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) { |
|
|
|
if (i == 0) { |
|
|
|
frFont = titleFont; |
|
|
|
renderStyle = getReportHeaderStyle(cellStyleConfig); |
|
|
|
} |
|
|
|
} |
|
|
|
if (i == PREVIEW_DATA_LIST.size() - 1) { |
|
|
|
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 { |
|
|
|
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.setOpaque(false); |
|
|
|
this.setBackground(null); |
|
|
|
this.setBackground(null); |
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
JPanel panel = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(4, 20, 10); |
|
|
|
JPanel panel = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(4, 0, 0); |
|
|
|
panel.setOpaque(false); |
|
|
|
panel.setOpaque(false); |
|
|
|
panel.setBackground(null); |
|
|
|
panel.setBackground(null); |
|
|
|
for (String text : data) { |
|
|
|
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); |
|
|
|
this.add(panel, BorderLayout.CENTER); |
|
|
|
JSeparator jSeparator = new JSeparator(); |
|
|
|
preview(style); |
|
|
|
jSeparator.setPreferredSize(new Dimension(246, 2)); |
|
|
|
|
|
|
|
this.add(jSeparator, BorderLayout.SOUTH); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private UILabel createLabel(String text, FRFont frFont) { |
|
|
|
public void preview(Style style) { |
|
|
|
UILabel label = new UILabel(text); |
|
|
|
for (GridPreview grid : gridPreviews) { |
|
|
|
label.setFont(frFont); |
|
|
|
grid.preview(style); |
|
|
|
label.setForeground(frFont.getForeground()); |
|
|
|
} |
|
|
|
label.setBackground(null); |
|
|
|
|
|
|
|
return label; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|