Browse Source

Pull request #5700: REPORT-58586 & REPORT-58389 & REPORT-58800 & REPORT-58503

Merge in DESIGN/design from ~STARRYI/design:release/11.0 to release/11.0

* commit 'e2534d993323efe587a1bba7f64483ff820c0ec5':
  REPORT-58503 【主题切换】预览区ui改版
  REPORT-58800 【主题切换】优化主题选择界面 应用主题的交互
  REPORT-58389 【FR11二轮回归】设计器-frm模板撤销/切换主题,设计画布都会变小
  REPORT-58586 FR11-二轮回归-单元格属性-样式-切换成跟随主题后,鼠标无法上滑至顶部
persist/11.0
starryi 3 years ago
parent
commit
7db6d154a5
  1. 82
      designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java
  2. 2
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  3. 20
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java
  4. 65
      designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java
  5. 53
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java
  6. BIN
      designer-base/src/main/resources/com/fr/design/images/transparent_background.png
  7. 15
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  8. 4
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java
  9. 4
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java
  10. 46
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java
  11. 42
      designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java

82
designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java

@ -0,0 +1,82 @@
package com.fr.design.cell;
import com.fr.base.NameStyle;
import com.fr.base.ScreenResolution;
import com.fr.base.Style;
import com.fr.design.mainframe.theme.TemplateThemeBlock;
import com.fr.general.IOUtils;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Toolkit;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/9/3
*/
public class CellStylePreviewPane extends JPanel {
private static final Image transparentBackgroundImage = Toolkit.getDefaultToolkit().createImage(CellStylePreviewPane.class.getResource("/com/fr/design/images/transparent_background.png"));
private final float transparentBackgroundWidth;
private final float transparentBackgroundHeight;
private final float transparentBackgroundAspect;
private String paintText = "Report";
private Style style = Style.DEFAULT_STYLE;
public CellStylePreviewPane() {
transparentBackgroundWidth = transparentBackgroundImage.getWidth(null);
transparentBackgroundHeight = transparentBackgroundImage.getHeight(null);
transparentBackgroundAspect = 1.0F * transparentBackgroundImage.getWidth(null) / transparentBackgroundImage.getHeight(null);
}
public void setStyle(Style style) {
this.style = style;
if (style instanceof NameStyle) {
paintText = ((NameStyle) style).getName();
}
repaint();
}
@Override
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
int resolution = ScreenResolution.getScreenResolution();
int width = getWidth();
int height = getHeight();
float scaleWidth = 1.0F * getWidth() / transparentBackgroundWidth;
float scaleHeight = 1.0F * getHeight() / transparentBackgroundHeight;
float maxScale = Math.max(scaleWidth, scaleHeight);
if (maxScale <= 1) {
scaleWidth = scaleHeight = 1;
} else {
scaleHeight = scaleWidth = maxScale;
}
g2d.drawImage(transparentBackgroundImage, 0, 0, (int) (transparentBackgroundWidth * scaleWidth), (int) (transparentBackgroundHeight * scaleHeight), null);
if (style == Style.DEFAULT_STYLE) {
// 如果是默认的style,就只写"Report"上去
Style.paintContent(g2d, paintText, style, width, height, resolution);
return;
}
Style.paintBackground(g2d, style, width, height);
Style.paintContent(g2d, paintText, style, width, height, resolution);
Style.paintBorder(g2d, style, getWidth() - 3, getHeight() - 3);
}
@Override
public Dimension getMinimumSize() {
return getPreferredSize();
}
}

2
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -625,8 +625,6 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
*/ */
public void redo() { public void redo() {
this.getUndoManager().redo(); this.getUndoManager().redo();
// 重做前模版使用主题可能已经被删除或修改,需要重置模版样式
checkAndResetTheme();
fireSuperTargetModified(); fireSuperTargetModified();
} }

20
designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java

@ -126,15 +126,17 @@ public class TemplateThemeListPane<T extends TemplateTheme> extends BasicPane {
} }
private void setSelectedBlock(TemplateThemeBlock<T> block) { private void setSelectedBlock(TemplateThemeBlock<T> block) {
if (selectedBlock != null) { if (selectedBlock != block) {
selectedBlock.setSelected(false); if (selectedBlock != null) {
} selectedBlock.setSelected(false);
selectedBlock = block; }
if (selectedBlock != null) { selectedBlock = block;
selectedBlock.setSelected(true); if (selectedBlock != null) {
} selectedBlock.setSelected(true);
if (changeListener != null) { }
changeListener.fireChanged(new ChangeEvent(this)); if (changeListener != null) {
changeListener.fireChanged(new ChangeEvent(this));
}
} }
} }

65
designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java

@ -1,9 +1,8 @@
package com.fr.design.mainframe.theme.dialog; package com.fr.design.mainframe.theme.dialog;
import com.fr.base.theme.ThemedTemplate;
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.design.base.mode.DesignModeContext; import com.fr.base.theme.ThemedTemplate;
import com.fr.design.event.ChangeEvent; import com.fr.design.event.ChangeEvent;
import com.fr.design.event.ChangeListener; import com.fr.design.event.ChangeListener;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
@ -11,7 +10,6 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.theme.TemplateThemeListPane; import com.fr.design.mainframe.theme.TemplateThemeListPane;
import com.fr.design.mainframe.theme.ui.BorderUtils; import com.fr.design.mainframe.theme.ui.BorderUtils;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -43,56 +41,27 @@ TemplateThemeUsingDialog<T extends TemplateTheme> extends TemplateThemeDialog {
JPanel content = createContent(); JPanel content = createContent();
UIButton openThemeManagerButton = createOpenThemeManagerButton(); UIButton openThemeManagerButton = createOpenThemeManagerButton();
UIButton usingCurrentThemeButton = createUsingCurrentThemeButton();
UIButton completeButton = createCompleteButton(); UIButton completeButton = createCompleteButton();
setContentPane(createDialogContentPane(content, setContentPane(createDialogContentPane(content,
new UIButton[]{ openThemeManagerButton }, new UIButton[]{ openThemeManagerButton },
new UIButton[]{ usingCurrentThemeButton, completeButton } new UIButton[]{ completeButton }
)); ));
themeListPane.startListenThemeConfig(); themeListPane.startListenThemeConfig();
resetEnableCurrentThemeButton(themeListPane.getSelectedTheme(), usingCurrentThemeButton);
themeListPane.setSelectedChangeListener(new ChangeListener() { themeListPane.setSelectedChangeListener(new ChangeListener() {
@Override @Override
public void fireChanged(ChangeEvent event) { public void fireChanged(ChangeEvent event) {
resetEnableCurrentThemeButton(themeListPane.getSelectedTheme(), usingCurrentThemeButton); TemplateTheme theme = themeListPane.getSelectedTheme();
if (theme != null) {
currentTemplate.setTemplateTheme(theme);
themeListPane.repaint();
}
} }
}); });
} }
private void resetEnableCurrentThemeButton(T selectedTheme, UIButton usingCurrentThemeButton) {
if (selectedTheme == null) {
usingCurrentThemeButton.setEnabled(false);
return;
}
String selectedThemeName = selectedTheme.getName();
if (StringUtils.isEmpty(selectedThemeName)) {
usingCurrentThemeButton.setEnabled(false);
return;
}
if (currentTemplate == null) {
usingCurrentThemeButton.setEnabled(false);
return;
}
TemplateTheme templateUsingTheme = currentTemplate.getTemplateTheme();
if (templateUsingTheme == null) {
usingCurrentThemeButton.setEnabled(true);
return;
}
String templateUsingThemeName = templateUsingTheme.getName();
if (StringUtils.isEmpty(templateUsingThemeName)) {
usingCurrentThemeButton.setEnabled(true);
return;
}
usingCurrentThemeButton.setEnabled(!StringUtils.equals(templateUsingThemeName, selectedTheme.getName()));
}
private JPanel createContent() { private JPanel createContent() {
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
container.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); container.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
@ -123,17 +92,6 @@ TemplateThemeUsingDialog<T extends TemplateTheme> extends TemplateThemeDialog {
return null; return null;
} }
private UIButton createUsingCurrentThemeButton() {
UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Using_Dialog_Use"));
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
apply2CurrentTemplate(button);
}
});
return button;
}
private UIButton createCompleteButton() { private UIButton createCompleteButton() {
UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Using_Dialog_Complete")); UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Using_Dialog_Complete"));
button.addActionListener(new ActionListener() { button.addActionListener(new ActionListener() {
@ -150,13 +108,4 @@ TemplateThemeUsingDialog<T extends TemplateTheme> extends TemplateThemeDialog {
themeListPane.stopAsyncFetchTheme(); themeListPane.stopAsyncFetchTheme();
super.exit(); super.exit();
} }
private void apply2CurrentTemplate(UIButton usingCurrentThemeButton) {
TemplateTheme theme = themeListPane.getSelectedTheme();
if (theme != null) {
currentTemplate.setTemplateTheme(theme);
themeListPane.repaint();
usingCurrentThemeButton.setEnabled(false);
}
}
} }

53
designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java

@ -1,8 +1,7 @@
package com.fr.design.mainframe.theme.edit.cell; package com.fr.design.mainframe.theme.edit.cell;
import com.fr.base.ScreenResolution;
import com.fr.base.Style;
import com.fr.base.theme.settings.ThemedCellStyle; import com.fr.base.theme.settings.ThemedCellStyle;
import com.fr.design.cell.CellStylePreviewPane;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.AttrScrollPane; import com.fr.design.dialog.AttrScrollPane;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
@ -18,12 +17,9 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.theme.ui.BorderUtils; import com.fr.design.mainframe.theme.ui.BorderUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout; import java.awt.GridLayout;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -39,7 +35,7 @@ import static com.fr.design.i18n.Toolkit.i18nText;
*/ */
public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> { public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> {
private ThemedCellStyle cellStyle; private ThemedCellStyle cellStyle;
private PreviewArea previewArea; private CellStylePreviewPane previewArea;
private boolean populating; private boolean populating;
private AttributeChangeListener attributeChangeListener; private AttributeChangeListener attributeChangeListener;
@ -78,7 +74,7 @@ public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> {
for (BasicPane basicPane : paneList) { for (BasicPane basicPane : paneList) {
((AbstractBasicStylePane) basicPane).populateBean(ob.getStyle()); ((AbstractBasicStylePane) basicPane).populateBean(ob.getStyle());
previewArea.preview(ob.getStyle()); previewArea.setStyle(ob.getStyle());
} }
this.populating = false; this.populating = false;
} }
@ -112,7 +108,8 @@ public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> {
jPanel.setLayout(new BorderLayout(0, 4)); jPanel.setLayout(new BorderLayout(0, 4));
JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
previewArea = new PreviewArea(); previewArea = new CellStylePreviewPane();
previewArea.setPreferredSize(new Dimension(223, 30));
previewPane.setBorder(BorderUtils.createTitleBorder(i18nText("Fine-Design_Basic_Preview"))); previewPane.setBorder(BorderUtils.createTitleBorder(i18nText("Fine-Design_Basic_Preview")));
previewPane.add(previewArea, BorderLayout.CENTER); previewPane.add(previewArea, BorderLayout.CENTER);
@ -138,7 +135,7 @@ public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> {
} }
ThemedCellStyle cellStyle = updateBean(); ThemedCellStyle cellStyle = updateBean();
if (cellStyle != null) { if (cellStyle != null) {
previewArea.preview(cellStyle.getStyle()); previewArea.setStyle(cellStyle.getStyle());
} }
fireAttrChangeListener(); fireAttrChangeListener();
} }
@ -157,42 +154,4 @@ public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> {
@Override @Override
public void updateBean(ThemedCellStyle ob) {} public void updateBean(ThemedCellStyle ob) {}
private static class PreviewArea extends JComponent {
private static final String paintText = "Report";
private Style style = Style.DEFAULT_STYLE;
public PreviewArea() {
setPreferredSize(new Dimension(223, 30));
}
public void preview(Style style) {
this.style = style;
repaint();
}
@Override
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
int resolution = ScreenResolution.getScreenResolution();
if (style == Style.DEFAULT_STYLE) {
// 如果是默认的style,就只写"Report"上去
Style.paintContent(g2d, paintText, style, getWidth() - 3, getHeight() - 3, resolution);
return;
}
Style.paintBackground(g2d, style, getWidth() - 3, getHeight() - 3);
Style.paintContent(g2d, paintText, style, getWidth() - 3, getHeight() - 3, resolution);
Style.paintBorder(g2d, style, getWidth() - 3, getHeight() - 3);
}
@Override
public Dimension getMinimumSize() {
return getPreferredSize();
}
}
} }

BIN
designer-base/src/main/resources/com/fr/design/images/transparent_background.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

15
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -664,9 +664,11 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
@Override @Override
protected void applyUndoState(FormUndoState u) { protected void applyUndoState(FormUndoState u) {
try { try {
Form undoForm = (Form) u.getForm().clone();
undoForm.checkAndResetTheme();
if (this.index == FORM_TAB) { if (this.index == FORM_TAB) {
//JForm的target重置 //JForm的target重置
this.setTarget((Form) u.getForm().clone()); this.setTarget(undoForm);
JForm.this.refreshRoot(); JForm.this.refreshRoot();
this.formDesign.getArea().setAreaSize(u.getAreaSize(), u.getHorizontalValue(), u.getVerticalValue(), u.getWidthValue(), u.getHeightValue(), u.getSlideValue()); this.formDesign.getArea().setAreaSize(u.getAreaSize(), u.getHorizontalValue(), u.getVerticalValue(), u.getWidthValue(), u.getHeightValue(), u.getSlideValue());
//撤销的时候要重新选择的body布局 //撤销的时候要重新选择的body布局
@ -685,7 +687,6 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
} else { } else {
// 只在报表块里撤销是不需要修改外部form对象的, 因为编辑的是当前报表块. // 只在报表块里撤销是不需要修改外部form对象的, 因为编辑的是当前报表块.
// 修改了JForm的Target需要同步修改formDesign的Target. // 修改了JForm的Target需要同步修改formDesign的Target.
Form undoForm = (Form) u.getForm().clone();
String widgetName = this.formDesign.getElementCaseContainerName(); String widgetName = this.formDesign.getElementCaseContainerName();
//这儿太坑了,u.getForm() 与 getTarget内容不一样 //这儿太坑了,u.getForm() 与 getTarget内容不一样
FormElementCaseProvider dataTable = undoForm.getElementCaseByName(widgetName); FormElementCaseProvider dataTable = undoForm.getElementCaseByName(widgetName);
@ -1188,10 +1189,20 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
FormTheme oldTheme = getTarget().getTemplateTheme(); FormTheme oldTheme = getTarget().getTemplateTheme();
boolean shouldCreateUndoState = compatible == TemplateThemeCompatible.NONE && !StringUtils.equals(oldTheme.getName(), newTheme.getName()); boolean shouldCreateUndoState = compatible == TemplateThemeCompatible.NONE && !StringUtils.equals(oldTheme.getName(), newTheme.getName());
FormArea formArea = formDesign.getArea();
int horizontalValue = formArea.getHorizontalValue();
int verticalValue= formArea.getVerticalValue();
Dimension areaSize = formArea.getAreaSize();
double widthValue = formArea.getWidthPaneValue();
double heightValue = formArea.getHeightPaneValue();
double slideValue = formArea.getSlideValue();
getTarget().setTemplateTheme(newTheme, compatible); getTarget().setTemplateTheme(newTheme, compatible);
fireTargetModified(shouldCreateUndoState); fireTargetModified(shouldCreateUndoState);
formDesign.refreshRoot(); formDesign.refreshRoot();
// 刷新界面后恢复原来的尺寸
formDesign.getArea().setAreaSize(areaSize, horizontalValue, verticalValue, widthValue, heightValue, slideValue);
FormHierarchyTreePane.getInstance().refreshRoot(); FormHierarchyTreePane.getInstance().refreshRoot();
if (this.index != FORM_TAB) { if (this.index != FORM_TAB) {
refreshToolArea(); refreshToolArea();

4
designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java

@ -774,7 +774,9 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
@Override @Override
protected void applyUndoState(WorkBookUndoState u) { protected void applyUndoState(WorkBookUndoState u) {
try { try {
this.setTarget((WorkBook) u.getWorkBook().clone()); WorkBook undoWorkBook = (WorkBook) u.getWorkBook().clone();
undoWorkBook.checkAndResetTheme();
this.setTarget(undoWorkBook);
if (!DesignerMode.isAuthorityEditing()) { if (!DesignerMode.isAuthorityEditing()) {
if (u.getAuthorityType() != BaseUndoState.NORMAL_STATE) { if (u.getAuthorityType() != BaseUndoState.NORMAL_STATE) {
applyAll(u); applyAll(u);

4
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java

@ -7,7 +7,6 @@ import com.fr.design.dialog.BasicPane;
import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener; import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.icontainer.UIScrollPane;
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.layout.TableLayout; import com.fr.design.layout.TableLayout;
@ -132,8 +131,7 @@ public class StylePane extends BasicPane implements UIObserver {
uiLabel.setPreferredSize(new Dimension(uiLabel.getPreferredSize().width, 20)); uiLabel.setPreferredSize(new Dimension(uiLabel.getPreferredSize().width, 20));
container.add(uiLabel, BorderLayout.NORTH); container.add(uiLabel, BorderLayout.NORTH);
themedCellStyleListPane.setBorder(BorderFactory.createEmptyBorder()); themedCellStyleListPane.setBorder(BorderFactory.createEmptyBorder());
UIScrollPane scrollPane = new UIScrollPane(themedCellStyleListPane); container.add(themedCellStyleListPane, BorderLayout.CENTER);
container.add(scrollPane, BorderLayout.CENTER);
return container; return container;
} }

46
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java

@ -1,11 +1,11 @@
package com.fr.design.mainframe.cell.settingpane.style; package com.fr.design.mainframe.cell.settingpane.style;
import com.fr.base.NameStyle; import com.fr.base.NameStyle;
import com.fr.base.ScreenResolution;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.settings.ThemedCellStyle; import com.fr.base.theme.settings.ThemedCellStyle;
import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.cell.CellStylePreviewPane;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
@ -17,7 +17,6 @@ import com.fr.general.ComparatorUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.DefaultListModel; import javax.swing.DefaultListModel;
import javax.swing.JComponent;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.ListCellRenderer; import javax.swing.ListCellRenderer;
@ -26,8 +25,6 @@ import javax.swing.event.ChangeListener;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.io.Serializable; import java.io.Serializable;
@ -142,7 +139,7 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane<NameStyle> imp
private static class RadioButtonListCellRenderer extends JPanel implements ListCellRenderer<Object>, Serializable { private static class RadioButtonListCellRenderer extends JPanel implements ListCellRenderer<Object>, Serializable {
private final UIRadioButton button; private final UIRadioButton button;
private final PreviewArea previewArea; private final CellStylePreviewPane previewArea;
public RadioButtonListCellRenderer() { public RadioButtonListCellRenderer() {
super(); super();
@ -150,7 +147,7 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane<NameStyle> imp
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
setPreferredSize(new Dimension(getPreferredSize().width, 40)); setPreferredSize(new Dimension(getPreferredSize().width, 40));
button = new UIRadioButton(); button = new UIRadioButton();
previewArea = new PreviewArea(); previewArea = new CellStylePreviewPane();
add(button, BorderLayout.WEST); add(button, BorderLayout.WEST);
add(previewArea, BorderLayout.CENTER); add(previewArea, BorderLayout.CENTER);
} }
@ -162,41 +159,4 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane<NameStyle> imp
return this; return this;
} }
} }
private static class PreviewArea extends JComponent {
private String paintText = "Report";
private Style style = Style.DEFAULT_STYLE;
public void setStyle(Style style) {
this.style = style;
if (style instanceof NameStyle) {
paintText = ((NameStyle) style).getName();
}
repaint();
}
@Override
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
int resolution = ScreenResolution.getScreenResolution();
if (style == Style.DEFAULT_STYLE) {
// 如果是默认的style,就只写"Report"上去
Style.paintContent(g2d, paintText, style, getWidth() - 3, getHeight() - 3, resolution);
return;
}
Style.paintBackground(g2d, style, getWidth() - 3, getHeight() - 3);
Style.paintContent(g2d, paintText, style, getWidth() - 3, getHeight() - 3, resolution);
Style.paintBorder(g2d, style, getWidth() - 3, getHeight() - 3);
}
@Override
public Dimension getMinimumSize() {
return getPreferredSize();
}
}
} }

42
designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java

@ -1,9 +1,9 @@
package com.fr.design.report; package com.fr.design.report;
import com.fr.base.NameStyle; import com.fr.base.NameStyle;
import com.fr.base.ScreenResolution;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.design.border.UIRoundedBorder; import com.fr.design.border.UIRoundedBorder;
import com.fr.design.cell.CellStylePreviewPane;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
@ -52,8 +52,6 @@ import java.awt.CardLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.ArrayList; import java.util.ArrayList;
@ -66,7 +64,7 @@ public class ReportStylePane extends BasicPane {
}; };
public static final int DEFAULT_SELECTED_INDEX = 0; public static final int DEFAULT_SELECTED_INDEX = 0;
private final PreviewArea previewArea; private final CellStylePreviewPane previewArea;
private final UIButtonGroup<String> followingThemeButtonGroup; private final UIButtonGroup<String> followingThemeButtonGroup;
private final CustomFloatStyleSettingPane customStylePane; private final CustomFloatStyleSettingPane customStylePane;
private final ThemedCellStyleListPane themedCellStyleListPane; private final ThemedCellStyleListPane themedCellStyleListPane;
@ -78,7 +76,7 @@ public class ReportStylePane extends BasicPane {
setLayout(FRGUIPaneFactory.createBorderLayout()); setLayout(FRGUIPaneFactory.createBorderLayout());
setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
previewArea = new PreviewArea(); previewArea = new CellStylePreviewPane();
followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS); followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS);
customStylePane = new CustomFloatStyleSettingPane(); customStylePane = new CustomFloatStyleSettingPane();
themedCellStyleListPane = new ThemedCellStyleListPane(); themedCellStyleListPane = new ThemedCellStyleListPane();
@ -333,40 +331,6 @@ public class ReportStylePane extends BasicPane {
previewArea.setStyle(updateBean()); previewArea.setStyle(updateBean());
} }
private static class PreviewArea extends JComponent {
private static final String paintText = "Report";
private Style style = Style.DEFAULT_STYLE;
public void setStyle(Style style) {
this.style = style;
repaint();
}
@Override
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
int resolution = ScreenResolution.getScreenResolution();
if (style == Style.DEFAULT_STYLE) {
// 如果是默认的style,就只写"Report"上去
Style.paintContent(g2d, paintText, style, getWidth() - 3, getHeight() - 3, resolution);
return;
}
Style.paintBackground(g2d, style, getWidth() - 3, getHeight() - 3);
Style.paintContent(g2d, paintText, style, getWidth() - 3, getHeight() - 3, resolution);
Style.paintBorder(g2d, style, getWidth() - 3, getHeight() - 3);
}
@Override
public Dimension getMinimumSize() {
return getPreferredSize();
}
}
private static class CustomFloatStyleSettingPane extends BasicPane implements ChangeListener { private static class CustomFloatStyleSettingPane extends BasicPane implements ChangeListener {
private static final int ALIGNMENT_INDEX = 1; private static final int ALIGNMENT_INDEX = 1;
private static final int FONT_INDEX = 2; private static final int FONT_INDEX = 2;

Loading…
Cancel
Save