diff --git a/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java b/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java index dd3ddab3b9..8f2021c696 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java +++ b/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java @@ -116,11 +116,6 @@ public abstract class UIDialog extends JDialog { doCancel(); } }); - - applyEnterAction(); - } - - protected void applyEnterAction() { JPanel defaultPane = (JPanel) this.getContentPane(); InputMap inputMapAncestor = defaultPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); ActionMap actionMap = defaultPane.getActionMap(); diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/ColorSchemeComboBox.java similarity index 85% rename from designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java rename to designer-base/src/main/java/com/fr/design/gui/icombobox/ColorSchemeComboBox.java index e09362cb64..044bb65188 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/ColorSchemeComboBox.java @@ -1,11 +1,9 @@ -package com.fr.design.chartx.component.combobox; +package com.fr.design.gui.icombobox; import com.fr.base.ChartColorMatching; import com.fr.base.ChartPreStyleConfig; import com.fr.cert.token.lang.Collections; import com.fr.chart.base.ChartConstants; -import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.i18n.Toolkit; import com.fr.general.GeneralUtils; @@ -36,11 +34,18 @@ public class ColorSchemeComboBox extends UIComboBox { private Map colorSchemes; + private boolean preDefined; + public ColorSchemeComboBox() { - this(null); + this(null, false); } public ColorSchemeComboBox(Map colorSchemes) { + this(colorSchemes, false); + } + + public ColorSchemeComboBox(Map colorSchemes, boolean preDefined) { + this.preDefined = preDefined; //通过配色方案的集合初始化下拉控件,如果参数为null,从配置中读取配色方案。 if (colorSchemes == null) { colorSchemes = getColorSchemesFromConfig(); @@ -59,22 +64,26 @@ public class ColorSchemeComboBox extends UIComboBox { //所有的样式名称 Iterator names = config.names(); - //添加默认的方案和第一个方案 - String defaultName = config.getCurrentStyle(); - ChartColorMatching defaultStyle = (ChartColorMatching) config.getPreStyle(defaultName); - if (names.hasNext()) { - Object firstName = names.next(); - ChartColorMatching firstStyle = (ChartColorMatching) config.getPreStyle(firstName); - if (defaultStyle == null) { - defaultStyle = firstStyle; - } - colorSchemes.put(Toolkit.i18nText("Fine-Design_Report_Default"), colorMatchingToColorInfo(defaultStyle)); - colorSchemes.put(firstStyle.getId(), colorMatchingToColorInfo(firstStyle)); + if (preDefined) { + colorSchemes.put(Toolkit.i18nText("Fine-Design_Chart_Predefined"), null); } else { - ColorInfo colorInfo = new ColorInfo(); - colorInfo.setGradient(false); - colorInfo.setColors(Collections.arrayToList(ChartConstants.CHART_COLOR_ARRAY)); - colorSchemes.put(Toolkit.i18nText("Fine-Design_Report_Default"), colorInfo); + //添加默认的方案和第一个方案 + String defaultName = config.getCurrentStyle(); + ChartColorMatching defaultStyle = (ChartColorMatching) config.getPreStyle(defaultName); + if (names.hasNext()) { + Object firstName = names.next(); + ChartColorMatching firstStyle = (ChartColorMatching) config.getPreStyle(firstName); + if (defaultStyle == null) { + defaultStyle = firstStyle; + } + colorSchemes.put(Toolkit.i18nText("Fine-Design_Report_Default"), colorMatchingToColorInfo(defaultStyle)); + colorSchemes.put(firstStyle.getId(), colorMatchingToColorInfo(firstStyle)); + } else { + ColorInfo colorInfo = new ColorInfo(); + colorInfo.setGradient(false); + colorInfo.setColors(Collections.arrayToList(ChartConstants.CHART_COLOR_ARRAY)); + colorSchemes.put(Toolkit.i18nText("Fine-Design_Report_Default"), colorInfo); + } } //添加其他的配色方案 diff --git a/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java b/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java index b188cb5aa8..50d6448b8d 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java @@ -55,7 +55,7 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO private static final int ANGEL = 90; private static final int GAP = 23; private static final int VERGAP = 3; - private static final Dimension SPINNER_DIMENSION = new Dimension(75, 20); + private static final Dimension SPINNER_DIMENSION = new Dimension(70, 20); private static final String[] TEXT = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Wrap_Text"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Single_Line"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_StyleAlignment_Single_Line(Adjust_Font)"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_StyleAlignment_Multi_Line(Adjust_Font)")}; diff --git a/designer-base/src/main/java/com/fr/design/gui/style/BackgroundNoImagePane.java b/designer-base/src/main/java/com/fr/design/gui/style/BackgroundNoImagePane.java index 54ad9623ef..556b27c21f 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/BackgroundNoImagePane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/BackgroundNoImagePane.java @@ -28,7 +28,7 @@ public class BackgroundNoImagePane extends BackgroundPane{ fireStateChanged(); } }); - GradientBackgroundQuickPane gradientPane = new GradientBackgroundQuickPane(); + GradientBackgroundQuickPane gradientPane = createGradientBackgroundQuickPane(); gradientPane.registerChangeListener(new UIObserverListener() { @Override @@ -42,4 +42,8 @@ public class BackgroundNoImagePane extends BackgroundPane{ gradientPane }; } -} \ No newline at end of file + + protected GradientBackgroundQuickPane createGradientBackgroundQuickPane(){ + return new GradientBackgroundQuickPane(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java b/designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java index 88ee482cb8..407c522ceb 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java @@ -71,7 +71,7 @@ public class BackgroundPane extends AbstractBasicStylePane { double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{null, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Fill") + " ", SwingConstants.LEFT),typeComboBox}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Fill"), SwingConstants.LEFT),typeComboBox}, new Component[]{null, centerPane} }; double[] rowSize = {p, p, p}; @@ -89,7 +89,7 @@ public class BackgroundPane extends AbstractBasicStylePane { kinds.add(new TextureBackgroundQuickPane()); kinds.add(new PatternBackgroundQuickPane()); kinds.add(new ImageBackgroundQuickPane()); - kinds.add(new GradientBackgroundQuickPane()); + kinds.add(createGradientBackgroundQuickPane()); Set providers = ExtraDesignClassManager.getInstance().getArray(BackgroundQuickUIProvider.MARK_STRING); for (BackgroundQuickUIProvider provider : providers) { kinds.add(provider.appearanceForBackground()); @@ -98,6 +98,10 @@ public class BackgroundPane extends AbstractBasicStylePane { return kinds.toArray(new BackgroundQuickPane[kinds.size()]); } + protected GradientBackgroundQuickPane createGradientBackgroundQuickPane(){ + return new GradientBackgroundQuickPane(); + } + /** * 事件监听 @@ -172,4 +176,4 @@ public class BackgroundPane extends AbstractBasicStylePane { return style.deriveBackground(this.update()); } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/gui/style/BackgroundSpecialPane.java b/designer-base/src/main/java/com/fr/design/gui/style/BackgroundSpecialPane.java index 72aa1b35e7..3713fca7bc 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/BackgroundSpecialPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/BackgroundSpecialPane.java @@ -39,7 +39,7 @@ public class BackgroundSpecialPane extends BackgroundPane{ fireStateChanged(); } }); - GradientBackgroundQuickPane gradientPane = new GradientBackgroundQuickPane(); + GradientBackgroundQuickPane gradientPane = createGradientBackgroundQuickPane(); gradientPane.registerChangeListener(new UIObserverListener() { @Override public void doChange() { @@ -48,12 +48,12 @@ public class BackgroundSpecialPane extends BackgroundPane{ }); //hugh:表单支持背景接口 List kinds = new ArrayList(); - + kinds.add(new NullBackgroundQuickPane()); kinds.add(colorBackgroundPane); kinds.add(imageBackgroundPane); kinds.add(gradientPane); - + Set providers = ExtraDesignClassManager.getInstance().getArray(BackgroundQuickUIProvider.MARK_STRING); for (BackgroundQuickUIProvider provider : providers) { BackgroundQuickPane newTypePane = provider.appearanceForBackground(); @@ -65,7 +65,11 @@ public class BackgroundSpecialPane extends BackgroundPane{ }); kinds.add(newTypePane); } - + return kinds.toArray(new BackgroundQuickPane[kinds.size()]); } -} \ No newline at end of file + + protected GradientBackgroundQuickPane createGradientBackgroundQuickPane(){ + return new GradientBackgroundQuickPane(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java b/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java index f63d8f576c..da0a2131c6 100644 --- a/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java +++ b/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java @@ -152,6 +152,20 @@ public class FRGUIPaneFactory { return jp; } + /** + * 创建一个无间隔带标题边框面板 + * + * @param string 边框标题 + * @return JPanel对象 + */ + public static JPanel createTitledBorderNoGapPane(String string) { + JPanel jp = new JPanel(); + UITitledBorder explainBorder = UITitledBorder.createBorderWithTitle(string); + jp.setBorder(explainBorder); + jp.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + return jp; + } + /** * 创建一个带标题边框面板,垂直居左布局 * @@ -304,6 +318,21 @@ public class FRGUIPaneFactory { return jp; } + /** + * 创建一个靠左的水平流式布局 + * @param firstGap 首元素和边框间距 + * @param hgap 水平间距 + * @param vgap 竖直间距 + * @return JPanel对象 + */ + public static JPanel createBoxFlowInnerContainer_S_Pane(int firstGap, int hgap, int vgap) { + JPanel jp = new JPanel(); + jp.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + jp.setLayout(new FRLeftFlowLayout(firstGap, hgap, vgap)); + return jp; + } + + /** * 创建一个靠左流式布局,流式内嵌,首元素距离左边0 * @@ -315,6 +344,21 @@ public class FRGUIPaneFactory { return jp; } + /** + * 创建一个靠左的水平流式布局 + * @param hgap 水平间距 + * @param vgap 竖直间距 + * @return JPanel对象 + */ + public static JPanel createBoxFlowInnerContainer_S_Pane(int hgap, int vgap) { + JPanel jp = new JPanel(); + jp.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + jp.setLayout(new FlowLayout(FlowLayout.LEFT, hgap, vgap)); + return jp; + } + + + /** * 创建一个靠右面板 * @@ -469,6 +513,8 @@ public class FRGUIPaneFactory { return jp; } + + /** * 创建垂直流布局面板 * diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index f29e22698c..6129f87462 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -6,6 +6,7 @@ import com.fr.base.Parameter; import com.fr.base.ScreenResolution; import com.fr.base.io.BaseBook; import com.fr.base.iofile.attr.DesignBanCopyAttrMark; +import com.fr.base.iofile.attr.PredefinedStyleAttrMark; import com.fr.base.iofile.attr.TemplateIdAttrMark; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignModelAdapter; @@ -38,6 +39,9 @@ import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.chart.info.ChartInfoCollector; +import com.fr.design.mainframe.predefined.info.PredefinedStyleInfoCollector; +import com.fr.design.mainframe.predefined.ui.ReportPredefinedStylePane; +import com.fr.design.mainframe.predefined.ui.dialog.ReportPredefinedStyleDialog; import com.fr.design.mainframe.template.info.TemplateInfoCollector; import com.fr.design.mainframe.template.info.TemplateProcessInfo; import com.fr.design.mainframe.template.info.TimeConsumeTimer; @@ -78,8 +82,13 @@ import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JOptionPane; +import javax.swing.SwingConstants; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.undo.UndoManager; +import java.awt.Dimension; +import java.awt.FontMetrics; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.Arrays; import java.util.Set; @@ -90,6 +99,8 @@ import java.awt.BorderLayout; * 报表设计和表单设计的编辑区域(设计器编辑的IO文件) */ public abstract class JTemplate> extends TargetComponent implements ToolBarMenuDockPlus, DesignerProxy { + + private static final int PREDEFINED_ICON_WIDTH = 27; // TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null private static final int PREFIX_NUM = 3000; private FILE editingFILE = null; @@ -142,8 +153,14 @@ public abstract class JTemplate> consumeTimer.setEnabled(shouldInitForCollectInfo(isNewFile)); initAndStartPlugin(); + + if (this.template.getAttrMark(PredefinedStyleAttrMark.XML_TAG) == null) { + this.template.addAttrMark(new PredefinedStyleAttrMark()); + } } + + private void initAndStartPlugin() { initPluginPane(); startListenPlugin(); @@ -797,6 +814,7 @@ public abstract class JTemplate> return false; } try { + this.getTarget().setPredefinedStyleName(this.getTemplatePredefinedStyle(), false); this.getTarget().export(editingFILE.asOutputStream()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); @@ -1296,10 +1314,57 @@ public abstract class JTemplate> for (DesignerFrameUpButtonProvider provider : providers) { uiButtons = ArrayUtils.addAll(uiButtons, provider.getUpButtons(getMenuState())); } - + UIButton predefinedBtn = createPreDefinedButton(); + if (predefinedBtn != null) { + uiButtons = ArrayUtils.addAll(uiButtons, new UIButton[]{predefinedBtn}); + } return uiButtons; } + private UIButton createPreDefinedButton() { + UIButton preferenceButton = new UIButton(BaseUtils.readIcon("/com/fr/design/icon/icon_predefined_style.png")); + preferenceButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Template_Style")); + preferenceButton.setText(getTemplatePredefinedStyle()); + preferenceButton.setAlignmentX(SwingConstants.LEFT); + setPredefinedButtonSize(preferenceButton); + preferenceButton.set4ToolbarButton(); + preferenceButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); + ReportPredefinedStylePane stylePane = new ReportPredefinedStylePane(JTemplate.this, preferenceButton); + ReportPredefinedStyleDialog dialog = new ReportPredefinedStyleDialog(designerFrame, stylePane); + PredefinedStyleInfoCollector.getInstance().collectClickNumber(); + dialog.setVisible(true); + + } + }); + return preferenceButton; + } + + private void setPredefinedButtonSize(UIButton predefinedBtn) { + String text = predefinedBtn.getText(); + FontMetrics metrics = predefinedBtn.getFontMetrics(predefinedBtn.getFont()); + predefinedBtn.setPreferredSize(new Dimension(Math.min(metrics.stringWidth(text) + PREDEFINED_ICON_WIDTH, 100), 20)); + } + + public void resetPredefinedStyle(String styleName, UIButton predefinedBtn) { + this.getTarget().setPredefinedStyleName(styleName, true); + predefinedBtn.setText(getTemplatePredefinedStyle()); + setPredefinedButtonSize(predefinedBtn); + this.fireTargetModified(); + this.repaint(); + } + + public String getTemplatePredefinedStyle(){ + PredefinedStyleAttrMark attrMark = this.getTarget().getAttrMark(PredefinedStyleAttrMark.XML_TAG); + if (attrMark == null){ + attrMark = new PredefinedStyleAttrMark(); + } + return attrMark.getPreferenceStyleName(); + } + + /** * 由于老版本的模板没有模板ID,当勾选使用参数模板时候,就加一个模板ID attr * diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartGradientPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/VanChartGradientPane.java similarity index 96% rename from designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartGradientPane.java rename to designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/VanChartGradientPane.java index 2cdcf24017..e891bd934a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartGradientPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/VanChartGradientPane.java @@ -1,4 +1,4 @@ -package com.fr.van.chart.designer.component.background; +package com.fr.design.mainframe.backgroundpane; import com.fr.base.background.GradientBackground; import com.fr.design.event.UIObserverListener; @@ -6,11 +6,9 @@ import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.backgroundpane.GradientBackgroundQuickPane; import com.fr.design.style.background.gradient.FixedGradientBar; import com.fr.general.Background; - import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java index 15291211cb..6ac14505a6 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java @@ -3,7 +3,6 @@ package com.fr.design.mainframe.burying.point; import com.fr.base.FRContext; import com.fr.base.io.XMLReadHelper; import com.fr.design.DesignerEnvManager; -import com.fr.design.mainframe.template.info.SendHelper; import com.fr.log.FineLoggerFactory; import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; @@ -20,25 +19,20 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; /** * @author Bjorn * @version 10.0 * Created by Bjorn on 2020-02-21 */ -public abstract class AbstractPointCollector implements BasePointCollector { +public abstract class AbstractPointCollector implements BasePointCollector { + - protected Map pointInfoMap; private static final int MAX_SIZE = 512 * 1024 * 1024; public AbstractPointCollector() { - pointInfoMap = new ConcurrentHashMap<>(); - loadFromFile(); + } /** @@ -48,34 +42,6 @@ public abstract class AbstractPointCollector implem return FileUtils.sizeOf(getInfoFile()) <= MAX_SIZE && DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv(); } - @Override - public void sendPointInfo() { - - addIdleDayCount(); - - List removeList = new ArrayList<>(); - List sendList = new ArrayList<>(); - - for (String key : pointInfoMap.keySet()) { - AbstractPointInfo pointInfo = pointInfoMap.get(key); - pointInfo.selectPoint(removeList, sendList); - } - - // 发送记录 - for (String key : sendList) { - if(SendHelper.sendPointInfo(pointInfoMap.get(key))){ - removeList.add(key); - } - } - - // 清空记录 - for (String key : removeList) { - pointInfoMap.remove(key); - } - - saveInfo(); - } - /** * 从文件中读取埋点信息 */ diff --git a/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractTemplateInfoCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractTemplateInfoCollector.java new file mode 100644 index 0000000000..34dc5ea2a4 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractTemplateInfoCollector.java @@ -0,0 +1,56 @@ +package com.fr.design.mainframe.burying.point; + +import com.fr.design.mainframe.template.info.SendHelper; +import com.fr.design.mainframe.template.info.TemplateProcessInfo; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Created by kerry on 2020-09-04 + */ +public abstract class AbstractTemplateInfoCollector extends AbstractPointCollector { + protected Map pointInfoMap; + + public AbstractTemplateInfoCollector() { + pointInfoMap = new ConcurrentHashMap<>(); + loadFromFile(); + + } + + + /** + * 保存埋点的信息到本地 + */ + public abstract void collectInfo(String templateID, String originID, TemplateProcessInfo processInfo, int timeConsume); + + @Override + public void sendPointInfo() { + + addIdleDayCount(); + + List removeList = new ArrayList<>(); + List sendList = new ArrayList<>(); + + for (String key : pointInfoMap.keySet()) { + BasePointInfo pointInfo = pointInfoMap.get(key); + pointInfo.selectPoint(removeList, sendList); + } + + // 发送记录 + for (String key : sendList) { + if(SendHelper.sendPointInfo(pointInfoMap.get(key))){ + removeList.add(key); + } + } + + // 清空记录 + for (String key : removeList) { + pointInfoMap.remove(key); + } + + saveInfo(); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/burying/point/BasePointCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/BasePointCollector.java index f10f1682e0..e2a3c778c9 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/burying/point/BasePointCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/BasePointCollector.java @@ -1,6 +1,5 @@ package com.fr.design.mainframe.burying.point; -import com.fr.design.mainframe.template.info.TemplateProcessInfo; import com.fr.stable.xml.XMLReadable; import com.fr.stable.xml.XMLWriter; @@ -16,8 +15,4 @@ public interface BasePointCollector extends XMLReadable, XMLWriter { */ public void sendPointInfo(); - /** - * 保存埋点的信息到本地 - */ - public void collectInfo(String templateID, String originID, TemplateProcessInfo processInfo, int timeConsume); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java index cd651fc6b3..428e5625c6 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java @@ -4,7 +4,7 @@ import com.fr.base.io.BaseBook; import com.fr.chartx.attr.ChartProvider; import com.fr.chartx.config.info.AbstractConfig; import com.fr.chartx.config.info.constant.ConfigType; -import com.fr.design.mainframe.burying.point.AbstractPointCollector; +import com.fr.design.mainframe.burying.point.AbstractTemplateInfoCollector; import com.fr.design.mainframe.template.info.TemplateInfo; import com.fr.design.mainframe.template.info.TemplateProcessInfo; import com.fr.general.ComparatorUtils; @@ -21,7 +21,7 @@ import java.util.Map; * @version 10.0 * Created by Bjorn on 2020-02-18 */ -public class ChartInfoCollector extends AbstractPointCollector { +public class ChartInfoCollector extends AbstractTemplateInfoCollector { private static final String XML_TAG = "ChartInfoCollector"; private static final String XML_LAST_EDIT_DAY = "lastEditDay"; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/PatternStyle.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/PatternStyle.java new file mode 100644 index 0000000000..94892f75ec --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/PatternStyle.java @@ -0,0 +1,38 @@ +package com.fr.design.mainframe.predefined; + +import com.fr.config.predefined.PredefinedStyle; +import com.fr.predefined.PredefinedPatternStyleManager; + + +/** + * Created by kerry on 2020-08-31 + */ +public enum PatternStyle { + DARK_STYLE(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Dark_Pattern")) { + @Override + public PredefinedStyle getPredefinedStyle() { + return PredefinedPatternStyleManager.INSTANCE.getDarkMode(); + } + }, + LIGHT_STYLE(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Light_Pattern")) { + @Override + public PredefinedStyle getPredefinedStyle() { + return PredefinedPatternStyleManager.INSTANCE.getLightMode(); + } + }; + + + private String name; + + + PatternStyle(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public abstract PredefinedStyle getPredefinedStyle(); + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/info/PredefinedStyleInfoCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/info/PredefinedStyleInfoCollector.java new file mode 100644 index 0000000000..2827cbee0b --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/info/PredefinedStyleInfoCollector.java @@ -0,0 +1,118 @@ +package com.fr.design.mainframe.predefined.info; + +import com.fr.config.MarketConfig; +import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.burying.point.AbstractPointCollector; +import com.fr.design.mainframe.template.info.SendHelper; +import com.fr.general.CloudCenter; +import com.fr.general.GeneralUtils; +import com.fr.json.JSONObject; +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLableReader; +import com.fr.third.joda.time.DateTime; + +/** + * Created by kerry on 2020-09-04 + */ +public class PredefinedStyleInfoCollector extends AbstractPointCollector { + private static final String SIMPLE_DATE_PATTERN = "yyyy-MM-dd"; + private static final String XML_TAG = "PredefinedStyleInfo"; + private static final String XML_FILE_NAME = "predefinedStyle.info"; + private static final String CLOUD_URL = CloudCenter.getInstance().acquireUrlByKind("predefinedInfo.collector") + "/single"; + + private static final String FUNCTION_NAME = "predefinedStyle"; + private static final String FUNCTION_ID = "FR-F7003"; + + private static final String ATTR_FUNCTION_NAME = "functionName"; + private static final String ATTR_FUNCTION_ID = "functionId"; + private static final String ATTR_UUID = "uuid"; + private static final String ATTR_UID = "uid"; + private static final String ATTR_JAR_TIME = "jatTime"; + private static final String ATTR_CLICK_NUMBER = "clickNumber"; + private static final String ATTR_USE_NUMBER = "useNumber"; + private static final String ATTR_TIME = "time"; + + private int clickNumber = 0; + + private int useNumber = 0; + + public int getClickNumber() { + return clickNumber; + } + + public int getUseNumber() { + return useNumber; + } + + private static class Holder { + private static PredefinedStyleInfoCollector collector = new PredefinedStyleInfoCollector(); + } + + private PredefinedStyleInfoCollector() { + loadFromFile(); + } + + public static PredefinedStyleInfoCollector getInstance() { + return Holder.collector; + } + + public void collectClickNumber() { + clickNumber++; + saveInfo(); + } + + public void collectUseNumber() { + useNumber++; + saveInfo(); + } + + @Override + protected String getInfoFilePath() { + return XML_FILE_NAME; + } + + @Override + protected void addIdleDayCount() { + + } + + @Override + public void sendPointInfo() { + String content = generateTotalInfo(); + + SendHelper.sendSinglePointInfo(CLOUD_URL, content); + } + + public String generateTotalInfo() { + + JSONObject jo = JSONObject.create(); + jo.put(ATTR_FUNCTION_NAME, FUNCTION_NAME); + jo.put(ATTR_FUNCTION_ID, FUNCTION_ID); + jo.put(ATTR_UUID, DesignerEnvManager.getEnvManager().getUUID()); + jo.put(ATTR_UID, MarketConfig.getInstance().getBBSAttr().getBbsUid()); + jo.put(ATTR_JAR_TIME, GeneralUtils.readFullVersionNO()); + jo.put(ATTR_CLICK_NUMBER, this.clickNumber); + jo.put(ATTR_USE_NUMBER, this.useNumber); + jo.put(ATTR_TIME, DateTime.now().toString(SIMPLE_DATE_PATTERN)); + return jo.toString(); + } + + + @Override + public void readXML(XMLableReader reader) { + if (reader.isAttr()) { + String name = reader.getTagName(); + if (XML_TAG.equals(name)) { + this.clickNumber = reader.getAttrAsInt(ATTR_CLICK_NUMBER, 0); + this.useNumber = reader.getAttrAsInt(ATTR_USE_NUMBER, 0); + } + } + } + + @Override + public void writeXML(XMLPrintWriter writer) { + writer.startTAG(XML_TAG); + writer.attr(ATTR_CLICK_NUMBER, this.clickNumber).attr(ATTR_USE_NUMBER, this.useNumber); + writer.end(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleBlock.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleBlock.java new file mode 100644 index 0000000000..c4cb09a029 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleBlock.java @@ -0,0 +1,142 @@ +package com.fr.design.mainframe.predefined.ui; + +import com.fr.base.BaseUtils; +import com.fr.base.GraphHelper; +import com.fr.config.predefined.PredefinedStyle; +import com.fr.design.mainframe.predefined.ui.dialog.PredefinedStyleEditDialog; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.predefined.ui.preview.PredefinedStylePreviewPane; +import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; +import com.fr.stable.Constants; + +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +/** + * Created by kerry on 2020-08-25 + */ +public class PredefinedStyleBlock extends JPanel { + private PredefinedStyle previewObject; + private PredefinedStyleSelectPane parentPane; + private Icon markedMode = IOUtils.readIcon("/com/fr/design/form/images/marked.png"); + private static final Color BORDER_COLOR = new Color(141, 194, 249); + + private boolean mouseOver = false; + + private MouseListener mouseListener = new MouseListener() { + @Override + public void mouseClicked(MouseEvent e) { + setSelect(); + } + + @Override + public void mousePressed(MouseEvent e) { + + } + + @Override + public void mouseReleased(MouseEvent e) { + + } + + @Override + public void mouseEntered(MouseEvent e) { + mouseOver = true; + PredefinedStyleBlock.this.repaint(); + } + + @Override + public void mouseExited(MouseEvent e) { + mouseOver = false; + PredefinedStyleBlock.this.repaint(); + } + }; + + + public PredefinedStyleBlock(PredefinedStyle previewObject, PredefinedStyleSelectPane selectPane, boolean supportEdit) { + this.previewObject = previewObject; + this.parentPane = selectPane; + initPane(supportEdit); + this.addMouseListener(mouseListener); + } + + private void setSelect() { + this.parentPane.setSelectedPreviewPane(this); + } + + @Override + public void paint(Graphics g) { + super.paint(g); + boolean isSelected = ComparatorUtils.equals(this, this.parentPane.getSelectedPreviewPane()); + if (ComparatorUtils.equals(this.parentPane.getCurrentApplicateStyle(), this.previewObject.getStyleName())) { + markedMode.paintIcon(this, g, 176, 0); + } + if (isSelected || this.mouseOver) { + g.setColor(BORDER_COLOR); + Rectangle rectangle = new Rectangle(1, 1, this.getWidth() - 2, this.getHeight() - 2); + GraphHelper.draw(g, rectangle, Constants.LINE_MEDIUM); + } + } + + + private void initPane(boolean supportEdit) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + PredefinedStylePreviewPane content = new PredefinedStylePreviewPane(0.387, 0.384); + content.setPreferredSize(new Dimension(200, 125)); + UILabel label = new UILabel(previewObject.getStyleName()); + label.setToolTipText(previewObject.getStyleName()); + label.setPreferredSize(new Dimension(167, 25)); + + + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + panel.setBorder(BorderFactory.createEmptyBorder(0,9,2,5)); + panel.add(label, BorderLayout.WEST); + if (supportEdit) { + addEditButton(panel); + } + + this.add(content, BorderLayout.CENTER); + this.add(panel, BorderLayout.SOUTH); + this.setPreferredSize(new Dimension(200, 150)); + panel.setBackground(Color.WHITE); + this.setBackground(Color.WHITE); + content.refresh(this.previewObject); + + } + + private void addEditButton(JPanel panel) { + UIButton editButton = new UIButton(BaseUtils.readIcon("/com/fr/design/icon/icon_edit.png")); + editButton.setPreferredSize(new Dimension(24, 24)); + editButton.setBorderPainted(false); + editButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + PredefinedStyleEditPane editPane = PredefinedStyleEditPane.createEditPane(parentPane); + PredefinedStyleEditDialog editDialog = new PredefinedStyleEditDialog( + SwingUtilities.getWindowAncestor(PredefinedStyleBlock.this), editPane, previewObject.isBuiltIn()); + editPane.populate(PredefinedStyleBlock.this.previewObject); + editDialog.setVisible(true); + } + }); + panel.add(editButton, BorderLayout.EAST); + + } + + public PredefinedStyle update() { + return this.previewObject; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java new file mode 100644 index 0000000000..c267082b40 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java @@ -0,0 +1,278 @@ +package com.fr.design.mainframe.predefined.ui; + +import com.fr.config.predefined.PredefinedStyle; +import com.fr.config.predefined.PredefinedStyleConfig; +import com.fr.config.ServerPreferenceConfig; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.gui.frpane.UITabbedPane; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.predefined.ui.detail.ChartStyleSettingPane; +import com.fr.design.mainframe.predefined.ui.detail.ColorFillStylePane; +import com.fr.design.mainframe.predefined.ui.detail.PredefinedBackgroundSettingPane; +import com.fr.design.mainframe.predefined.ui.detail.ComponentStyleSettingPane; +import com.fr.design.mainframe.predefined.ui.detail.CellStyleListControlPane; +import com.fr.design.mainframe.predefined.ui.preview.PredefinedStylePreviewPane; +import com.fr.design.utils.DesignUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Dimension; + +/** + * Created by kerry on 2020-08-26 + */ +public class PredefinedStyleEditPane extends AbstractAttrNoScrollPane { + private PredefinedStylePreviewPane previewPane; + private UITextField styleNameField; + private PredefinedBackgroundSettingPane backgroundSettingPane; + private CellStyleListControlPane cellStyleSettingPane; + private ComponentStyleSettingPane componentStyleSettingPane; + private ChartStyleSettingPane chartStyleSettingPane; + private PredefinedStyleSelectPane selectPane; + private ColorFillStylePane colorFillStylePane; + private boolean isPopulating = false; + private UITabbedPane uiTabbedPane; + + private boolean isLightMode = true; + + @Override + protected JPanel createContentPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + jPanel.add(createLeftPane(), BorderLayout.WEST); + jPanel.add(createRightPane(), BorderLayout.CENTER); + + this.addAttributeChangeListener(new AttributeChangeListener() { + @Override + public void attributeChange() { + if (!isPopulating) { + valueChangeAction(); + } + } + }); + return jPanel; + } + + public void valueChangeAction() { + boolean displayFormBackground = backgroundSettingPane.currentFormBackground() || uiTabbedPane.getSelectedIndex() == 3; + previewPane.refresh(this.update(), displayFormBackground); + } + + @Override + public String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Style_Edit"); + } + + private PredefinedStyleEditPane(PredefinedStyleSelectPane selectPane, boolean newEditPane) { + this.selectPane = selectPane; + this.styleNameField.setEnabled(newEditPane); + } + + public static PredefinedStyleEditPane createEditPane(PredefinedStyleSelectPane selectPane) { + return new PredefinedStyleEditPane(selectPane, false); + } + + public static PredefinedStyleEditPane createNewEditPane(PredefinedStyleSelectPane selectPane) { + return new PredefinedStyleEditPane(selectPane, true); + } + + + private JPanel createLeftPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel titlePane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Overall_Preview")); + previewPane = new PredefinedStylePreviewPane(); + previewPane.setPreferredSize(new Dimension(517, 320)); + + titlePane.add(previewPane); + jPanel.add(titlePane, BorderLayout.CENTER); + return jPanel; + } + + private JPanel createRightPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel styleNamePane = createStyleNamePane(); + jPanel.add(styleNamePane, BorderLayout.NORTH); + + JPanel basicSettingPane = createBasicSettingPane(); + jPanel.add(basicSettingPane, BorderLayout.CENTER); + + JPanel customDetailPane = createCustomDetailPane(); + jPanel.add(customDetailPane, BorderLayout.SOUTH); + return jPanel; + } + + private JPanel createStyleNamePane() { + JPanel jPanel = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(5, 26, 8); + jPanel.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Style_Name"))); + this.styleNameField = new UITextField(); + this.styleNameField.setPreferredSize(new Dimension(160, 20)); + jPanel.add(this.styleNameField); + return jPanel; + } + + private JPanel createBasicSettingPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel titlePane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Basic_Setting")); + JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + colorFillStylePane = new ColorFillStylePane(); + contentPane.add(colorFillStylePane); + titlePane.add(contentPane); + jPanel.add(titlePane, BorderLayout.CENTER); + titlePane.setSize(new Dimension(348, 157)); + return jPanel; + } + + private JPanel createCustomDetailPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel titlePane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Custom_Detail")); + titlePane.setLayout(FRGUIPaneFactory.createLeftZeroLayout()); + jPanel.add(titlePane, BorderLayout.CENTER); + uiTabbedPane = new UITabbedPane(); + uiTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Template_Background"), createTemplateBackgroundSettingPane()); + uiTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Cell_Style"), createCellStyleSettingPane()); + uiTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Chart_Style"), createChartStyleSettingPane()); + uiTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Component_Style"), createComponentStyleSettingPane()); + uiTabbedPane.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + valueChangeAction(); + } + }); + titlePane.add(uiTabbedPane); + uiTabbedPane.setPreferredSize(new Dimension(323, 298)); + titlePane.setPreferredSize(new Dimension(333, 320)); + return jPanel; + } + + + private JPanel createTemplateBackgroundSettingPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + jPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5)); + this.backgroundSettingPane = new PredefinedBackgroundSettingPane(); + jPanel.setPreferredSize(new Dimension(309, 248)); + UIScrollPane scrollPane = new UIScrollPane(this.backgroundSettingPane); + scrollPane.setBorder(BorderFactory.createEmptyBorder()); + jPanel.add(new UIScrollPane(this.backgroundSettingPane)); + return jPanel; + } + + private JPanel createCellStyleSettingPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + jPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); + this.cellStyleSettingPane = new CellStyleListControlPane(); + jPanel.add(this.cellStyleSettingPane); + return jPanel; + } + + + private JPanel createChartStyleSettingPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + jPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5)); + this.chartStyleSettingPane = new ChartStyleSettingPane(); + jPanel.add(this.chartStyleSettingPane); + return jPanel; + } + + + private JPanel createComponentStyleSettingPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + jPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5)); + this.componentStyleSettingPane = new ComponentStyleSettingPane(); + jPanel.add(this.componentStyleSettingPane); + return jPanel; + } + + + public void populate(PredefinedStyle previewObject) { + isPopulating = true; + isLightMode = previewObject.isLightMode(); + styleNameField.setText(previewObject.getStyleName()); + this.backgroundSettingPane.populateBean(previewObject.getPredefinedBackground()); + this.cellStyleSettingPane.populateBean(previewObject.getCellStyleConfig()); + this.componentStyleSettingPane.populateBean(previewObject.getComponentStyle()); + this.colorFillStylePane.populateBean(previewObject.getPredefinedColorStyle()); + this.chartStyleSettingPane.populateBean(previewObject.getPredefinedChartStyle()); + previewPane.refresh(previewObject); + isPopulating = false; + } + + public PredefinedStyle update() { + PredefinedStyle predefinedStyle = new PredefinedStyle(); + predefinedStyle.setLightMode(isLightMode); + predefinedStyle.setStyleName(this.styleNameField.getText()); + predefinedStyle.setCellStyleConfig(this.cellStyleSettingPane.updateBean()); + predefinedStyle.setPredefinedBackground(this.backgroundSettingPane.updateBean()); + predefinedStyle.setComponentStyle(this.componentStyleSettingPane.updateBean()); + predefinedStyle.setPredefinedColorStyle(this.colorFillStylePane.update()); + predefinedStyle.setPredefinedChartStyle(this.chartStyleSettingPane.updateBean()); + return predefinedStyle; + } + + public boolean saveStyle() { + PredefinedStyle previewObject; + try { + previewObject = update(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + return false; + } + if (this.styleNameField.isEnabled() && !validateRepeat(previewObject.getStyleName())) { + return false; + } + if (!saveStyle(previewObject)) { + return false; + } + DesignUtils.refreshDesignerFrame(); + return true; + } + + private boolean saveStyle(PredefinedStyle previewObject) { + PredefinedStyleConfig config = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig(); + if (StringUtils.isEmpty(previewObject.getStyleName())) { + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(PredefinedStyleEditPane.this), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Name_Cannot_Empty")); + + return false; + } + config.add(previewObject); + ServerPreferenceConfig.getInstance().setPreferenceStyleConfig(config); + selectPane.refreshPane(); + return true; + } + + public void saveAsNewStyle(String styleName) { + PredefinedStyle previewObject; + try { + previewObject = update(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + return; + } + previewObject.setStyleName(styleName); + if (validateRepeat(styleName)) { + saveStyle(previewObject); + } + } + + private boolean validateRepeat(String styleName) { + PredefinedStyleConfig config = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig(); + if (config.getStyle(styleName) != null) { + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(PredefinedStyleEditPane.this), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_Name_Repeat")); + + return false; + } + return true; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSelectPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSelectPane.java new file mode 100644 index 0000000000..26b92907a9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSelectPane.java @@ -0,0 +1,102 @@ +package com.fr.design.mainframe.predefined.ui; + +import com.fr.config.predefined.PredefinedStyle; +import com.fr.config.ServerPreferenceConfig; +import com.fr.design.dialog.BasicPane; +import com.fr.design.event.ChangeListener; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.layout.FRGUIPaneFactory; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.util.Iterator; + +/** + * Created by kerry on 2020-08-26 + */ +public class PredefinedStyleSelectPane extends BasicPane { + private PredefinedStyleBlock selectedBlock; + private boolean editable; + private JPanel contentPane; + private String currentApplicateStyle; + private ChangeListener changeListener; + + + public PredefinedStyleSelectPane(String currentApplicateStyle, boolean editable) { + this.editable = editable; + this.currentApplicateStyle = currentApplicateStyle; + initPane(); + } + + public void registerChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + + } + + + private void initPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + contentPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(5, 8); + createContentPane(); + UIScrollPane scrollPane = new UIScrollPane(contentPane); + scrollPane.setPreferredSize(new Dimension(630, 480)); + scrollPane.setBorder(BorderFactory.createEmptyBorder()); + this.add(scrollPane, BorderLayout.CENTER); + } + + + public void createContentPane() { + contentPane.removeAll(); + Iterator iterator = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig().getPredefinedStyleIterator(); + int rowCount = (ServerPreferenceConfig.getInstance().getPreferenceStyleConfig().getPredefinedSize() +2)/ 3; + contentPane.setPreferredSize(new Dimension(618, 157 * rowCount)); + while (iterator.hasNext()) { + PredefinedStyle tmpStyle = iterator.next(); + + if (tmpStyle != null) { + PredefinedStyleBlock tmpPanel = + new PredefinedStyleBlock(tmpStyle, this, this.editable); + contentPane.add(tmpPanel); + } + } + } + + + public String getCurrentApplicateStyle() { + return currentApplicateStyle; + } + + public void refreshPane() { + createContentPane(); + this.validate(); + this.repaint(); + } + + @Override + protected String title4PopupWindow() { + return null; + } + + public void setSelectedPreviewPane(PredefinedStyleBlock selectedPreviewPane) { + this.selectedBlock = selectedPreviewPane; + if (changeListener != null) { + changeListener.fireChanged(null); + } + this.repaint(); + } + + public PredefinedStyleBlock getSelectedPreviewPane() { + return selectedBlock; + } + + public PredefinedStyle update() { + if (this.selectedBlock == null){ + return null; + } + return this.selectedBlock.update(); + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSettingPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSettingPane.java new file mode 100644 index 0000000000..758f8e0131 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSettingPane.java @@ -0,0 +1,152 @@ +package com.fr.design.mainframe.predefined.ui; + +import com.fr.config.predefined.PredefinedNameStyleProvider; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.predefined.ui.preview.StyleSettingPreviewPane; + +import javax.swing.ButtonGroup; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * Created by kerry on 2020-09-02 + */ +public abstract class PredefinedStyleSettingPane extends AbstractAttrNoScrollPane { + protected StyleSettingPreviewPane previewPane; + protected UIRadioButton predefinedRadioBtn; + private UIRadioButton customRadioBtn; + private JPanel customDetailPane; + private JPanel predefinedSettingPane; + private CardLayout tabbedPane; + private JPanel center; + private boolean isPopulating = false; + + + public void setPopulating(boolean populating) { + isPopulating = populating; + } + + protected void initContentPane() { + leftContentPane = createContentPane(); + this.add(leftContentPane, BorderLayout.CENTER); + } + + @Override + protected JPanel createContentPane() { + JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + previewPane = createPreviewPane(); + JPanel previewTitlePane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview")); + if (previewPane != null) { + previewTitlePane.setPreferredSize(new Dimension(407, 527)); + previewTitlePane.add(previewPane); + contentPane.add(previewTitlePane, BorderLayout.WEST); + } + + customDetailPane = createCustomDetailPane(); + predefinedSettingPane = createPredefinedSettingPane(); + + JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel jPanel = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(10, 20, 10); + jPanel.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style"))); + predefinedRadioBtn = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Predefined")); + customRadioBtn = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom")); + + tabbedPane = new CardLayout(); + center = new JPanel(tabbedPane); + center.add(predefinedSettingPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Predefined")); + center.add(customDetailPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom")); + predefinedRadioBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + tabbedPane.show(center, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Predefined")); + } + }); + customRadioBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + tabbedPane.show(center, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom")); + } + }); + jPanel.add(predefinedRadioBtn); + jPanel.add(customRadioBtn); + + ButtonGroup layoutBG = new ButtonGroup(); + layoutBG.add(predefinedRadioBtn); + layoutBG.add(customRadioBtn); + centerPane.add(jPanel, BorderLayout.NORTH); + centerPane.add(center, BorderLayout.CENTER); + contentPane.add(centerPane, BorderLayout.CENTER); + this.addAttributeChangeListener(new AttributeChangeListener() { + @Override + public void attributeChange() { + if (isPopulating) { + return; + } + if (previewPane != null) { + previewPane.refresh(); + } + } + }); + return contentPane; + } + + + protected abstract StyleSettingPreviewPane createPreviewPane(); + + protected abstract JPanel createCustomDetailPane(); + + protected JPanel createPredefinedSettingPane() { + return new JPanel(); + } + + protected void populate(PredefinedNameStyleProvider nameStyle) { + this.predefinedRadioBtn.setSelected(nameStyle.usePredefinedStyle()); + this.customRadioBtn.setSelected(!nameStyle.usePredefinedStyle()); + if (nameStyle.usePredefinedStyle()) { + tabbedPane.show(center, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Predefined")); + } else { + tabbedPane.show(center, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom")); + } + + } + + protected String getPredefinedStyleName() { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + return template.getTemplatePredefinedStyle(); + } + + /** + * 展示数据 + * + * @param ob 待展示的对象 + */ + public abstract void populateBean(T ob); + + /** + * 保存数据 + * + * @return 待保存的对象 + */ + public abstract T updateBean(); + + /** + * 保存数据 + * + * @param ob 待保存的对象 + */ + public void updateBean(T ob) { + + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ReportPredefinedStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ReportPredefinedStylePane.java new file mode 100644 index 0000000000..4f2c8b6035 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ReportPredefinedStylePane.java @@ -0,0 +1,53 @@ +package com.fr.design.mainframe.predefined.ui; + +import com.fr.config.predefined.PredefinedStyle; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.JTemplate; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.FlowLayout; + +/** + * Created by kerry on 2020-08-28 + */ +public class ReportPredefinedStylePane extends BasicPane { + private PredefinedStyleSelectPane selectPane; + private JTemplate currentTemplate; + private UIButton preferenceBtn; + + public ReportPredefinedStylePane(JTemplate jTemplate, UIButton preferenceButton) { + this.currentTemplate = jTemplate; + this.preferenceBtn = preferenceButton; + initPane(); + } + + private void initPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel jPanel = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Style_Select")); + jPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + JPanel subPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.selectPane = new PredefinedStyleSelectPane(currentTemplate.getTemplatePredefinedStyle(), false); + subPanel.add(this.selectPane, BorderLayout.CENTER); + jPanel.add(subPanel, BorderLayout.CENTER); + this.add(jPanel, BorderLayout.CENTER); + } + + public void update() { + PredefinedStyle style = selectPane.update(); + if (style != null) { + currentTemplate.resetPredefinedStyle(style.getStyleName(), preferenceBtn); + } + } + + public void refresh() { + this.selectPane.refreshPane(); + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Template_Style"); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ServerPredefinedStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ServerPredefinedStylePane.java new file mode 100644 index 0000000000..90b013e0e9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ServerPredefinedStylePane.java @@ -0,0 +1,206 @@ +package com.fr.design.mainframe.predefined.ui; + + +import com.fr.base.BaseUtils; +import com.fr.config.predefined.PredefinedStyle; +import com.fr.config.predefined.PredefinedStyleConfig; +import com.fr.config.ServerPreferenceConfig; +import com.fr.design.actions.UpdateAction; +import com.fr.design.event.ChangeEvent; +import com.fr.design.event.ChangeListener; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.mainframe.predefined.PatternStyle; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.i18n.Toolkit; +import com.fr.design.icon.IconPathConstants; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.predefined.ui.dialog.PredefinedStyleEditDialog; +import com.fr.design.menu.MenuDef; +import com.fr.design.menu.ToolBarDef; +import com.fr.design.utils.DesignUtils; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JSeparator; +import javax.swing.SwingUtilities; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +/** + * Created by kerry on 2020-08-25 + */ +public class ServerPredefinedStylePane extends BasicPane { + + private static final Color TIP_COLOR = Color.decode("#8F8F92"); + private RemoveAction removeAction; + + private PredefinedStyleSelectPane selectPane; + + + public ServerPredefinedStylePane() { + initPane(); + } + + private void initPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel jPanel = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Style_Manager")); + jPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + jPanel.setLayout(FRGUIPaneFactory.createLeftZeroLayout()); + JPanel subPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + subPanel.add(createControlPane(), BorderLayout.NORTH); + PredefinedStyle style = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig().getDefaultPredefinedStyle(); + + this.selectPane = new PredefinedStyleSelectPane(style == null ? StringUtils.EMPTY : style.getStyleName(), true); + this.selectPane.registerChangeListener(new ChangeListener() { + @Override + public void fireChanged(ChangeEvent event) { + PredefinedStyle selectStyle = selectPane.getSelectedPreviewPane().update(); + removeAction.setEnabled(!selectStyle.isBuiltIn()); + } + }); + this.selectPane.addMouseListener(new MouseListener() { + @Override + public void mouseClicked(MouseEvent e) { + if (selectPane.getSelectedPreviewPane() != null) { + removeAction.setEnabled(true); + } + } + + @Override + public void mousePressed(MouseEvent e) { + + } + + @Override + public void mouseReleased(MouseEvent e) { + + } + + @Override + public void mouseEntered(MouseEvent e) { + + } + + @Override + public void mouseExited(MouseEvent e) { + + } + }); + JSeparator jSeparator = new JSeparator(); + subPanel.add(jSeparator, BorderLayout.CENTER); + subPanel.add(this.selectPane, BorderLayout.SOUTH); + jPanel.add(subPanel); + this.add(jPanel, BorderLayout.CENTER); + this.repaint(); + } + + + private JPanel createControlPane() { + MenuDef addMenuDef = new MenuDef(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Action_Add")); + addMenuDef.setIconPath(IconPathConstants.ADD_POPMENU_ICON_PATH); + createAddMenuDef(addMenuDef); + ToolBarDef toolbarDef = new ToolBarDef(); + removeAction = new RemoveAction(); + removeAction.setEnabled(false); + toolbarDef.addShortCut(addMenuDef, removeAction); + UIToolbar toolBar = ToolBarDef.createJToolBar(); + toolBar.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); + toolbarDef.updateToolBar(toolBar); + JPanel toolbarPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + toolbarPane.add(toolBar, BorderLayout.CENTER); + UILabel tipLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Style_Manager_Tip")); + tipLabel.setForeground(TIP_COLOR); + tipLabel.setHorizontalTextPosition(UILabel.RIGHT); + toolbarPane.add(tipLabel, BorderLayout.EAST); + toolbarPane.setPreferredSize(new Dimension(620, 30)); + return toolbarPane; + } + + private void createAddMenuDef(MenuDef addMenuDef) { + addMenuDef.setRePaint(true); + addMenuDef.addShortCut(new CreateStyleAction(PatternStyle.DARK_STYLE)); + addMenuDef.addShortCut(new CreateStyleAction(PatternStyle.LIGHT_STYLE)); + + } + + + public void update() { + PredefinedStyle style = selectPane.update(); + if (style != null) { + PredefinedStyleConfig config = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig(); + config.setDefaultPredefinedStyle(style.getStyleName()); + ServerPreferenceConfig.getInstance().setPreferenceStyleConfig(config); + DesignUtils.refreshDesignerFrame(); + } + + } + + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Server_Style"); + } + + private class RemoveAction extends UpdateAction { + + public RemoveAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove")); + this.setMnemonic('R'); + this.setSmallIcon(BaseUtils.readIcon(IconPathConstants.TD_REMOVE_ICON_PATH)); + } + + @Override + public void actionPerformed(ActionEvent e) { + PredefinedStyle previewObject = ServerPredefinedStylePane.this.selectPane.update(); + int selVal = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(ServerPredefinedStylePane.this), + Toolkit.i18nText("Fine-Design_Predefined_Remove_Style_Confirm", previewObject.getStyleName()), + Toolkit.i18nText("Fine-Design_Basic_Delete"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); + if (selVal == JOptionPane.YES_OPTION) { + removeStyle(previewObject.getStyleName()); + ServerPredefinedStylePane.this.selectPane.refreshPane(); + } + } + } + + + private class CreateStyleAction extends UpdateAction { + private PatternStyle style; + + public CreateStyleAction(PatternStyle style) { + this.style = style; + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Create_Parttern_Style") + style.getName()); + this.setMnemonic('R'); + } + + @Override + public void actionPerformed(ActionEvent e) { + createNewPatternStylePane(); + } + + private void createNewPatternStylePane() { + PredefinedStyleEditPane editPane = PredefinedStyleEditPane.createNewEditPane(selectPane); + PredefinedStyleEditDialog editDialog = new PredefinedStyleEditDialog( + SwingUtilities.getWindowAncestor(ServerPredefinedStylePane.this), editPane); + editPane.populate(style.getPredefinedStyle()); + editDialog.setVisible(true); + } + } + + + private void removeStyle(String name) { + PredefinedStyleConfig config = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig(); + config.removeStyle(name); + ServerPreferenceConfig.getInstance().setPreferenceStyleConfig(config); + DesignUtils.refreshDesignerFrame(); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleListControlPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleListControlPane.java new file mode 100644 index 0000000000..e81de14a0e --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleListControlPane.java @@ -0,0 +1,225 @@ +package com.fr.design.mainframe.predefined.ui.detail; + +import com.fr.base.BaseUtils; +import com.fr.base.Style; +import com.fr.config.predefined.PredefinedCellStyle; +import com.fr.config.predefined.PredefinedCellStyleConfig; +import com.fr.design.actions.UpdateAction; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.gui.NameInspector; +import com.fr.design.gui.controlpane.JListControlPane; +import com.fr.design.gui.controlpane.NameObjectCreator; +import com.fr.design.gui.controlpane.NameableCreator; +import com.fr.design.gui.controlpane.ShortCut4JControlPane; +import com.fr.design.gui.controlpane.UnrepeatedNameHelper; +import com.fr.design.gui.ilist.ListModelElement; +import com.fr.design.gui.ilist.ModNameActionListener; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.predefined.ui.detail.cell.CustomPredefinedStylePane; +import com.fr.design.menu.ShortCut; +import com.fr.general.ComparatorUtils; +import com.fr.general.NameObject; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.Nameable; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JSeparator; +import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +/** + * Created by kerry on 2020-09-27 + */ +public class CellStyleListControlPane extends JListControlPane { + private boolean namePermitted = true; + + public CellStyleListControlPane() { + super(); + this.addModNameActionListener(new ModNameActionListener() { + public void nameModed(int index, String oldName, String newName) { + if (ComparatorUtils.equals(oldName, newName) || ComparatorUtils.equals(newName, NameInspector.ILLEGAL_NAME_HOLDER)) { + return; + } + namePermitted = true; + String[] allNames = nameableList.getAllNames(); + allNames[index] = StringUtils.EMPTY; + if (StringUtils.isEmpty(newName)) { + showTipDialogAndReset(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Empty_Name"), index); + return; + } + if (isNameRepeated(new List[]{Arrays.asList(allNames)}, newName)) { + showTipDialogAndReset(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Duplicate_Name", newName), index); + return; + } + populateSelectedValue(); + } + }); + } + + private void showTipDialogAndReset(String content, int index) { + nameableList.stopEditing(); + + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(CellStyleListControlPane.this), + content, + Toolkit.i18nText("Fine-Design_Basic_Alert"), + JOptionPane.WARNING_MESSAGE); + setIllegalIndex(index); + namePermitted = false; + } + + @Override + public NameableCreator[] createNameableCreators() { + return new NameableCreator[]{new CellStyleNameObjectCreator("新样式", PredefinedCellStyle.class, + CustomPredefinedStylePane.class)}; + } + + @Override + protected String title4PopupWindow() { + return "单元格样式设置面板"; + } + + protected void initComponentPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setCreators(this.createNameableCreators()); + initCardPane(); + JPanel leftPane = getLeftPane(); + JSeparator jSeparator = new JSeparator(SwingConstants.VERTICAL); + leftPane.setPreferredSize(new Dimension(70, 0)); + jSeparator.setPreferredSize(new Dimension(2, 0)); + cardPane.setPreferredSize(new Dimension(238, 0)); + cardPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); + JPanel mainSplitPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + mainSplitPane.add(leftPane, BorderLayout.WEST); + mainSplitPane.add(jSeparator, BorderLayout.CENTER); + mainSplitPane.add(cardPane, BorderLayout.EAST); + + this.add(mainSplitPane, BorderLayout.CENTER); + this.checkButtonEnabled(); + } + + protected ShortCut4JControlPane[] createShortcuts() { + return new ShortCut4JControlPane[]{ + shortCutFactory.addItemShortCut(), + new RemoveItemShortCut4JControlPane(new RemoveItemAction()) + }; + } + + + public class RemoveItemShortCut4JControlPane extends ShortCut4JControlPane { + RemoveItemShortCut4JControlPane(ShortCut shortCut) { + this.shortCut = shortCut; + } + + @Override + public void checkEnable() { + ListModelElement selectModel = CellStyleListControlPane.this.getSelectedValue(); + if (selectModel != null) { + NameObject selectNameObject = (NameObject) selectModel.wrapper; + PredefinedCellStyle cellStyle = (PredefinedCellStyle) (selectNameObject.getObject()); + this.shortCut.setEnabled(!cellStyle.isBuiltIn() && !cellStyle.isDefaultStyle()); + } else { + this.shortCut.setEnabled(false); + } + + } + } + + + private class RemoveItemAction extends UpdateAction { + RemoveItemAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText(("Fine-Design_Basic_Action_Remove"))); + this.setMnemonic('R'); + this.setSmallIcon(BaseUtils + .readIcon("/com/fr/base/images/cell/control/remove.png")); + } + + @Override + public void actionPerformed(ActionEvent evt) { + CellStyleListControlPane.this.onRemoveItem(); + } + } + + + class CellStyleNameObjectCreator extends NameObjectCreator { + public CellStyleNameObjectCreator(String menuName, Class clazz, Class updatePane) { + super(menuName, clazz, updatePane); + } + + public Nameable createNameable(UnrepeatedNameHelper helper) { + Constructor constructor = null; + try { + constructor = clazzOfInitCase.getConstructor(); + PredefinedCellStyle cellStyle = constructor.newInstance(); + + cellStyle.setName(menuName); + cellStyle.setStyle(Style.getInstance()); + return new NameObject(helper.createUnrepeatedName(this.menuName()), cellStyle); + + } catch (NoSuchMethodException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } catch (IllegalAccessException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } catch (InstantiationException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } catch (InvocationTargetException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return null; + } + } + + + /** + * Populate + */ + public void populateBean(PredefinedCellStyleConfig ob) { + if (ob == null) { + return; + } + + List nameStyleList = new ArrayList(); + + Iterator styleNameIterator = ob.getStyleNameIterator(); + while (styleNameIterator.hasNext()) { + String name = (String) styleNameIterator.next(); + PredefinedCellStyle tmpStyle = ob.getStyle(name); + + if (tmpStyle != null) { + nameStyleList.add(new NameObject(name, tmpStyle)); + } + } + + NameObject[] nameObjects = new NameObject[nameStyleList.size()]; + nameStyleList.toArray(nameObjects); + + populate(nameObjects); + } + + + public PredefinedCellStyleConfig updateBean() { + Nameable[] nameables = this.update(); + PredefinedCellStyleConfig styleConfig = new PredefinedCellStyleConfig(); + for (int i = 0; i < nameables.length; i++) { + PredefinedCellStyle tmpStyle = (PredefinedCellStyle) ((NameObject) nameables[i]).getObject(); + tmpStyle.setName(nameables[i].getName()); + styleConfig.addStyle(tmpStyle); + } + return styleConfig; + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ChartStyleSettingPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ChartStyleSettingPane.java new file mode 100644 index 0000000000..6eb155eb6d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ChartStyleSettingPane.java @@ -0,0 +1,94 @@ +package com.fr.design.mainframe.predefined.ui.detail; + +import com.fr.config.predefined.PredefinedChartStyle; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.MultiTabPane; +import com.fr.design.mainframe.predefined.ui.detail.chart.ChartAxisStylePane; +import com.fr.design.mainframe.predefined.ui.detail.chart.ChartBackgroundStylePane; +import com.fr.design.mainframe.predefined.ui.detail.chart.ChartDataSheetStylePane; +import com.fr.design.mainframe.predefined.ui.detail.chart.ChartLabelStylePane; +import com.fr.design.mainframe.predefined.ui.detail.chart.ChartLegendStylePane; +import com.fr.design.mainframe.predefined.ui.detail.chart.ChartTitleStylePane; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-16 + */ +public class ChartStyleSettingPane extends MultiTabPane { + + private ChartTitleStylePane chartTitleStylePane; + private ChartLegendStylePane chartLegendStylePane; + private ChartLabelStylePane chartLabelPane; + private ChartAxisStylePane chartAxisStylePane; + private ChartDataSheetStylePane chartDataSheetStylePane; + private ChartBackgroundStylePane chartBackgroundStylePane; + + public ChartStyleSettingPane() { + } + + @Override + protected void initLayout() { + super.initLayout(); + } + + @Override + protected List initPaneList() { + this.chartTitleStylePane = new ChartTitleStylePane(); + this.chartLegendStylePane = new ChartLegendStylePane(); + this.chartLabelPane = new ChartLabelStylePane(); + this.chartAxisStylePane = new ChartAxisStylePane(); + this.chartDataSheetStylePane = new ChartDataSheetStylePane(); + this.chartBackgroundStylePane = new ChartBackgroundStylePane(); + paneList = new ArrayList<>(); + paneList.add(this.chartTitleStylePane); + paneList.add(this.chartLegendStylePane); + paneList.add(this.chartLabelPane); + paneList.add(this.chartAxisStylePane); + paneList.add(this.chartDataSheetStylePane); + paneList.add(this.chartBackgroundStylePane); + return paneList; + } + + @Override + public void populateBean(PredefinedChartStyle ob) { + chartTitleStylePane.populate(ob); + chartLegendStylePane.populate(ob); + chartLabelPane.populate(ob); + chartAxisStylePane.populate(ob); + chartDataSheetStylePane.populate(ob); + chartBackgroundStylePane.populate(ob); + } + + @Override + public void updateBean(PredefinedChartStyle ob) { + + } + + + @Override + public PredefinedChartStyle updateBean() { + PredefinedChartStyle chartStyle = new PredefinedChartStyle(); + chartTitleStylePane.update(chartStyle); + chartLegendStylePane.update(chartStyle); + chartLabelPane.update(chartStyle); + chartAxisStylePane.update(chartStyle); + chartDataSheetStylePane.update(chartStyle); + chartBackgroundStylePane.update(chartStyle); + return chartStyle; + } + + + @Override + public boolean accept(Object ob) { + return false; + } + + @Override + public void reset() { + + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ColorFillStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ColorFillStylePane.java new file mode 100644 index 0000000000..9e2a0d5efd --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ColorFillStylePane.java @@ -0,0 +1,292 @@ +package com.fr.design.mainframe.predefined.ui.detail; + +import com.fr.base.ChartColorMatching; +import com.fr.base.ChartPreStyleConfig; +import com.fr.base.Utils; +import com.fr.chart.base.ChartConstants; +import com.fr.config.predefined.ColorFillStyle; +import com.fr.config.predefined.PredefinedColorStyle; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.icombobox.ColorSchemeComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.style.background.gradient.FixedGradientBar; +import com.fr.design.style.color.ColorAdjustPane; +import com.fr.stable.StringUtils; + +import javax.swing.JPanel; +import java.util.Arrays; +import java.util.List; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-15 + */ +public class ColorFillStylePane extends BasicBeanPane { + + private ColorSchemeComboBox styleSelectBox; + private JPanel customPane; + private JPanel changeColorSetPane; + private FixedGradientBar colorGradient; + + private CardLayout cardLayout; + + private ColorAdjustPane colorAdjustPane; + + private Color[] gradientColors; + private Color[] accColors; + + private boolean gradientSelect = false; + + public ColorFillStylePane() { + this.setLayout(new BorderLayout()); + + styleSelectBox = createColorSchemeComboBox(); + customPane = new JPanel(FRGUIPaneFactory.createBorderLayout()) { + @Override + public Dimension getPreferredSize() { + if (!customPane.isVisible()) { + return new Dimension(0, 0); + } + if (!gradientSelect) { + return colorAdjustPane.getPreferredSize(); + } + return colorGradient.getPreferredSize(); + } + }; + + changeColorSetPane = new JPanel(cardLayout = new CardLayout()); + changeColorSetPane.add(colorGradient = new FixedGradientBar(4, 130), "gradient"); + gradientColors = new Color[]{Color.WHITE, FixedGradientBar.NEW_CHARACTER}; + changeColorSetPane.add(colorAdjustPane = new ColorAdjustPane(), "acc"); + accColors = ColorAdjustPane.DEFAULT_COLORS; + cardLayout.show(changeColorSetPane, "acc"); + customPane.add(changeColorSetPane, BorderLayout.CENTER); + initListener(); + initLayout(); + + } + + public ColorSchemeComboBox getStyleSelectBox() { + return styleSelectBox; + } + + public JPanel getCustomPane() { + return customPane; + } + + protected ColorSchemeComboBox createColorSchemeComboBox() { + return new ColorSchemeComboBox(); + } + + private void initListener() { + colorAdjustPane.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + accColors = colorAdjustPane.getColors(); + if (styleSelectBox.getSelectType() != ColorSchemeComboBox.SelectType.COMBINATION_COLOR) { + styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.COMBINATION_COLOR); + } + ColorFillStylePane.this.revalidate(); + } + }); + colorGradient.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + gradientColors[0] = colorGradient.getSelectColorPointBtnP1().getColorInner(); + gradientColors[1] = colorGradient.getSelectColorPointBtnP2().getColorInner(); + if (styleSelectBox.getSelectType() != ColorSchemeComboBox.SelectType.GRADATION_COLOR) { + styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.GRADATION_COLOR); + } + } + }); + styleSelectBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + styleSelectBoxChange(); + } + }); + } + + protected void styleSelectBoxChange() { + switch (styleSelectBox.getSelectType()) { + case COMBINATION_COLOR: + colorAdjustPane.updateColor(accColors); + cardLayout.show(changeColorSetPane, "acc"); + gradientSelect = false; + break; + case GRADATION_COLOR: + colorGradient.updateColor(gradientColors[0], gradientColors[1]); + cardLayout.show(changeColorSetPane, "gradient"); + gradientSelect = true; + break; + default: + ColorSchemeComboBox.ColorInfo selectColorInfo = styleSelectBox.getSelectColorInfo(); + if (selectColorInfo == null) { + return; + } + if (selectColorInfo.isGradient()) { + colorGradient.updateColor(selectColorInfo.getColors().get(0), selectColorInfo.getColors().get(1)); + cardLayout.show(changeColorSetPane, "gradient"); + gradientSelect = true; + } else { + colorAdjustPane.updateColor(selectColorInfo.getColors().toArray(new Color[]{})); + cardLayout.show(changeColorSetPane, "acc"); + gradientSelect = false; + } + break; + } + ColorFillStylePane.this.revalidate(); + } + + protected void initLayout() { + this.setLayout(new BorderLayout()); + this.add(getContentPane(), BorderLayout.CENTER); + } + + protected JPanel getContentPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double e = 155; + double[] columnSize = {f, e}; + double[] rowSize = {p, p, p}; + + JPanel panel = TableLayoutHelper.createGapTableLayoutPane(contentPaneComponents(), rowSize, columnSize, 12, LayoutConstants.VGAP_LARGE); + return panel; + } + + protected Component[][] contentPaneComponents() { + return new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Template_Color")), styleSelectBox}, + new Component[]{null, customPane}, + + }; + } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Color"); + } + + public void populateBean(PredefinedColorStyle predefinedColorStyle) { + populateBean(predefinedColorStyle.getColorFillStyle()); + } + + @Override + public void populateBean(ColorFillStyle colorFillStyle) { + String fillStyleName = colorFillStyle == null ? "" : colorFillStyle.getFillStyleName(); + if (StringUtils.isBlank(fillStyleName) || !styleSelectBox.getItems().contains(fillStyleName)) { + if (colorFillStyle == null || colorFillStyle.getColorStyle() == ChartConstants.COLOR_DEFAULT) { + styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.DEFAULT);//默认 + } else { + int colorStyle = colorFillStyle.getColorStyle(); + if (colorStyle == ChartConstants.COLOR_GRADIENT) { + gradientColors[0] = colorFillStyle.getColorList().get(0); + gradientColors[1] = colorFillStyle.getColorList().get(1); + styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.GRADATION_COLOR); + } else { + int colorSize = colorFillStyle.getColorList().size(); + accColors = new Color[colorSize]; + for (int i = 0; i < colorSize; i++) { + accColors[i] = colorFillStyle.getColorList().get(i); + } + styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.COMBINATION_COLOR); + } + } + } else { + styleSelectBox.setSelectedItem(fillStyleName); + } + } + + public PredefinedColorStyle update() { + PredefinedColorStyle predefinedColorStyle = new PredefinedColorStyle(); + predefinedColorStyle.setColorFillStyle(updateBean()); + return predefinedColorStyle; + } + + @Override + public ColorFillStyle updateBean() { + switch (styleSelectBox.getSelectType()) { + case COMBINATION_COLOR: + return updateCombinationColor(); + case GRADATION_COLOR: + return updateGradationColor(); + case DEFAULT: + return updateDefaultColor(); + default: + return updateNormalColor(); + } + } + + private ColorFillStyle updateCombinationColor() { + ColorFillStyle colorFillStyle = new ColorFillStyle(); + List colorList = colorFillStyle.getColorList(); + colorFillStyle.setColorStyle(ChartConstants.COLOR_ACC); + for (int i = 0, length = accColors.length; i < length; i++) { + colorList.add(accColors[i]); + } + colorFillStyle.setCustomFillStyle(true); + return colorFillStyle; + } + + private ColorFillStyle updateGradationColor() { + ColorFillStyle colorFillStyle = new ColorFillStyle(); + List colorList = colorFillStyle.getColorList(); + colorFillStyle.setColorStyle(ChartConstants.COLOR_GRADIENT); + Color start = gradientColors[0]; + Color end = gradientColors[1]; + colorList.add(start); + colorList.add(end); + colorFillStyle.setCustomFillStyle(true); + return colorFillStyle; + } + + private ColorFillStyle updateDefaultColor() { + ColorFillStyle colorFillStyle = new ColorFillStyle(); + colorFillStyle.setColorStyle(ChartConstants.COLOR_DEFAULT); + return colorFillStyle; + } + + private ColorFillStyle updateNormalColor() { + ChartPreStyleConfig manager = ChartPreStyleConfig.getInstance(); + Object preStyle = manager.getPreStyle(styleSelectBox.getSelectedItem()); + if (preStyle instanceof ChartColorMatching) { + ColorFillStyle colorFillStyle = new ColorFillStyle(); + ChartColorMatching chartColorMatching = (ChartColorMatching) preStyle; + colorFillStyle.setColorStyle(chartColorMatching.getGradient() ? ChartConstants.COLOR_GRADIENT : ChartConstants.COLOR_ACC); + List colorList = chartColorMatching.getColorList(); + if (colorList == null || colorList.size() == 0) { + colorList = Arrays.asList(ChartConstants.CHART_COLOR_ARRAY); + } + colorFillStyle.setColorList(colorList); + colorFillStyle.setFillStyleName(Utils.objectToString(styleSelectBox.getSelectedItem())); + return colorFillStyle; + } else { + return updateModifyColor(); + } + } + + private ColorFillStyle updateModifyColor() { + ColorFillStyle colorFillStyle = new ColorFillStyle(); + ColorSchemeComboBox.ColorInfo selectColorInfo = styleSelectBox.getSelectColorInfo(); + boolean isGradient = selectColorInfo.isGradient(); + List colors = selectColorInfo.getColors(); + colorFillStyle.setColorList(colors); + colorFillStyle.setCustomFillStyle(true); + colorFillStyle.setColorStyle(isGradient ? ChartConstants.COLOR_GRADIENT : ChartConstants.COLOR_ACC); + return colorFillStyle; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ComponentStyleSettingPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ComponentStyleSettingPane.java new file mode 100644 index 0000000000..5a7ea8502d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ComponentStyleSettingPane.java @@ -0,0 +1,69 @@ +package com.fr.design.mainframe.predefined.ui.detail; + +import com.fr.config.predefined.PredefinedComponentStyle; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.MultiTabPane; +import com.fr.design.mainframe.predefined.ui.detail.component.ComponentFrameStylePane; +import com.fr.design.mainframe.predefined.ui.detail.component.ComponentMarginStylePane; +import com.fr.design.mainframe.predefined.ui.detail.component.ComponentTitleStylePane; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by kerry on 2020-09-01 + */ +public class ComponentStyleSettingPane extends MultiTabPane { + private ComponentFrameStylePane frameStylePane; + private ComponentTitleStylePane titleStylePane; + private ComponentMarginStylePane marginStylePane; + + public ComponentStyleSettingPane() { + } + + + @Override + protected List initPaneList() { + this.frameStylePane = new ComponentFrameStylePane(); + this.titleStylePane = ComponentTitleStylePane.createPredefinedSettingPane(); + this.marginStylePane = new ComponentMarginStylePane(); + paneList = new ArrayList(); + paneList.add(this.frameStylePane); + paneList.add(this.titleStylePane); + paneList.add(this.marginStylePane); + return paneList; + } + + @Override + public void populateBean(PredefinedComponentStyle ob) { + this.frameStylePane.populate(ob); + this.titleStylePane.populate(ob); + this.marginStylePane.populate(ob); + } + + @Override + public void updateBean(PredefinedComponentStyle ob) { + + } + + + @Override + public PredefinedComponentStyle updateBean() { + PredefinedComponentStyle componentStyle = new PredefinedComponentStyle(); + this.frameStylePane.update(componentStyle); + this.titleStylePane.update(componentStyle); + this.marginStylePane.update(componentStyle); + return componentStyle; + } + + + @Override + public boolean accept(Object ob) { + return false; + } + + @Override + public void reset() { + + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/PredefinedBackgroundSettingPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/PredefinedBackgroundSettingPane.java new file mode 100644 index 0000000000..05b02a5645 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/PredefinedBackgroundSettingPane.java @@ -0,0 +1,81 @@ +package com.fr.design.mainframe.predefined.ui.detail; + +import com.fr.config.predefined.PredefinedBackground; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.predefined.ui.detail.background.BackgroundSettingPane; +import com.fr.design.mainframe.predefined.ui.detail.background.BackgroundWithAlphaSettingPane; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * Created by kerry on 2020-08-31 + */ +public class PredefinedBackgroundSettingPane extends BasicBeanPane { + private UIButtonGroup buttonGroup; + private BackgroundSettingPane reportBackgroundSettingPane; + private BackgroundWithAlphaSettingPane formBackgroundSettingPane; + + + public PredefinedBackgroundSettingPane() { + initPane(); + } + + private void initPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + reportBackgroundSettingPane = new BackgroundSettingPane(); + formBackgroundSettingPane = new BackgroundWithAlphaSettingPane(); + CardLayout tabbedPane = new CardLayout(); + JPanel center = new JPanel(tabbedPane); + center.add(reportBackgroundSettingPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plain_Report")); + center.add(formBackgroundSettingPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Decision_Report")); + this.buttonGroup = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plain_Report"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Decision_Report")}); + buttonGroup.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (buttonGroup.getSelectedIndex() == 0) { + tabbedPane.show(center, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plain_Report")); + } else { + tabbedPane.show(center, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Decision_Report")); + } + } + }); + + + this.add(buttonGroup, BorderLayout.NORTH); + + this.add(center, BorderLayout.CENTER); + this.buttonGroup.setSelectedIndex(0); + } + + public boolean currentFormBackground() { + return buttonGroup.getSelectedIndex() == 1; + } + + @Override + public void populateBean(PredefinedBackground predefinedBackground) { + reportBackgroundSettingPane.populateBean(predefinedBackground.getReportBackground()); + formBackgroundSettingPane.populateBean(predefinedBackground.getFormBackground()); + } + + @Override + public PredefinedBackground updateBean() { + PredefinedBackground predefinedBackground = new PredefinedBackground(); + predefinedBackground.setReportBackground(reportBackgroundSettingPane.updateBean()); + predefinedBackground.setFormBackground(formBackgroundSettingPane.updateBean()); + return predefinedBackground; + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_Background_Setting"); + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/AbstractBackgroundDetailPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/AbstractBackgroundDetailPane.java new file mode 100644 index 0000000000..7cc1629bfa --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/AbstractBackgroundDetailPane.java @@ -0,0 +1,51 @@ +package com.fr.design.mainframe.predefined.ui.detail.background; + +import com.fr.design.event.UIObserverListener; +import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane; +import com.fr.general.Background; + +import javax.swing.event.ChangeListener; + +/** + * Created by kerry on 2020-09-14 + */ +public abstract class AbstractBackgroundDetailPane extends BackgroundQuickPane { + @Override + public boolean accept(Background background) { + return false; + } + + @Override + public void populateBean(Background background) { + this.populate((T) background); + } + + @Override + public Background updateBean() { + return this.update(); + } + + @Override + public String title4PopupWindow() { + return null; + } + + @Override + public void reset() { + + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + + } + + public abstract void populate(T background); + + public abstract T update(); + + public void addChangeListener(ChangeListener changeListener) { + + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundSettingPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundSettingPane.java new file mode 100644 index 0000000000..3efd0b447e --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundSettingPane.java @@ -0,0 +1,135 @@ +package com.fr.design.mainframe.predefined.ui.detail.background; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane; +import com.fr.general.Background; +import com.fr.log.FineLoggerFactory; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; + +/** + * Created by kerry on 2020-09-02 + */ +public class BackgroundSettingPane extends BasicBeanPane { + private ChangeListener changeListener = null; + private UIComboBox headCombobox; + private BackgroundQuickPane[] paneList; + + public BackgroundSettingPane() { + init(); + } + + private void init() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.add(createComboHeadPane(), BorderLayout.NORTH); + CardLayout cardlayout = new CardLayout(); + paneList = supportKindsOfBackgroundUI(); + final JPanel centerPane = new JPanel(cardlayout) { + @Override + public Dimension getPreferredSize() {// AUGUST:使用当前面板的的高度 + int index = headCombobox.getSelectedIndex(); + return new Dimension(super.getPreferredSize().width, paneList[index].getPreferredSize().height); + } + }; + centerPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); + for (BackgroundQuickPane pane : paneList) { + headCombobox.addItem(pane.title4PopupWindow()); + centerPane.add(pane, pane.title4PopupWindow()); + } + headCombobox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + cardlayout.show(centerPane, (String) headCombobox.getSelectedItem()); + } + }); + this.add(centerPane, BorderLayout.CENTER); + } + + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + } + + + private JPanel createComboHeadPane() { + headCombobox = new UIComboBox(); + + JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Fill")), headCombobox}}, + TableLayoutHelper.FILL_NONE, 33, 5); + headCombobox.setPreferredSize(new Dimension(160, 20)); + jPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); + return jPanel; + } + + protected BackgroundQuickPane[] supportKindsOfBackgroundUI() { + java.util.List kinds = new ArrayList<>(); + kinds.add(new EmptyBackgroundPane()); + kinds.add(new ColorDetailPane()); + kinds.add(new TextureDetailObservePane()); + kinds.add(new PatternDetailPane()); + kinds.add(createImageSelectPane()); + kinds.add(new GradientDetailPane()); + return kinds.toArray(new BackgroundQuickPane[kinds.size()]); + } + + protected ImageDetailPane createImageSelectPane() { + ImageDetailPane imageDetailPane = new ImageDetailPane(); + imageDetailPane.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + fireChangeListener(); + } + }); + return imageDetailPane; + } + + protected void fireChangeListener() { + if (changeListener != null) { + changeListener.stateChanged(null); + } + } + + + @Override + public void populateBean(Background background) { + for (int i = 0; i < paneList.length; i++) { + BackgroundQuickPane pane = paneList[i]; + if (pane.accept(background)) { + pane.populateBean(background); + headCombobox.setSelectedIndex(i); + return; + } + } + } + + @Override + public Background updateBean() { + int selectIndex = this.headCombobox.getSelectedIndex(); + try { + return paneList[selectIndex].updateBean(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return null; + } + + @Override + protected String title4PopupWindow() { + return null; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundWithAlphaSettingPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundWithAlphaSettingPane.java new file mode 100644 index 0000000000..dba0dce230 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundWithAlphaSettingPane.java @@ -0,0 +1,76 @@ +package com.fr.design.mainframe.predefined.ui.detail.background; + +import com.fr.config.predefined.BackgroundWithAlpha; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.gui.frpane.UINumberDragPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; + +/** + * Created by kerry on 2020-09-04 + */ +public class BackgroundWithAlphaSettingPane extends BasicBeanPane { + private BackgroundSettingPane backgroundSettingPane; + //透明度 + private UINumberDragPane numberDragPane; + + private double maxNumber = 100; + + + public BackgroundWithAlphaSettingPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + backgroundSettingPane = new FormBackgroundSettingPane(); + + JPanel eastpane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(2, 0); + this.numberDragPane = new UINumberDragPane(0, 100); + this.numberDragPane.setPreferredSize(new Dimension(148, 20)); + eastpane.add(numberDragPane); + eastpane.add(new UILabel("%")); + JPanel transparencyPane = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Alpha")), + eastpane}}, TableLayoutHelper.FILL_LASTCOLUMN, 18, 5); + transparencyPane.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); + + + Component[][] components = new Component[][]{ + new Component[]{backgroundSettingPane}, + new Component[]{transparencyPane}}; + + JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_NONE, IntervalConstants.INTERVAL_W2, IntervalConstants.INTERVAL_L1); + this.add(panel, BorderLayout.CENTER); + } + + + public void addChangeListener(ChangeListener changeListener) { + this.backgroundSettingPane.addChangeListener(changeListener); + } + + + @Override + public void populateBean(BackgroundWithAlpha ob) { + backgroundSettingPane.populateBean(ob.getBackground()); + numberDragPane.populateBean(ob.getAlpha() * maxNumber); + } + + @Override + public BackgroundWithAlpha updateBean() { + BackgroundWithAlpha backgroundWithAlpha = new BackgroundWithAlpha(); + backgroundWithAlpha.setBackground(backgroundSettingPane.updateBean()); + backgroundWithAlpha.setAlpha((float) (numberDragPane.updateBean() / maxNumber)); + return backgroundWithAlpha; + } + + @Override + protected String title4PopupWindow() { + return null; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ColorDetailPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ColorDetailPane.java new file mode 100644 index 0000000000..ce4f923cbc --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ColorDetailPane.java @@ -0,0 +1,103 @@ +package com.fr.design.mainframe.predefined.ui.detail.background; + +import com.fr.base.background.ColorBackground; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.style.color.ColorSelectPane; +import com.fr.general.Background; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; + +/** + * Created by kerry on 2020-08-31 + */ +public class ColorDetailPane extends AbstractBackgroundDetailPane { + private ColorBackgroundSelectPane selectPane; + + + public ColorDetailPane() { + this.selectPane = new ColorBackgroundSelectPane(); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.add(this.selectPane, BorderLayout.CENTER); + } + + @Override + public void populate(ColorBackground background) { + this.selectPane.setColor(background.getColor()); + } + + @Override + public ColorBackground update() { + return ColorBackground.getInstance(selectPane.getColor()); + } + + public String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Color"); + } + + @Override + public boolean accept(Background background) { + return background instanceof ColorBackground; + } + + class ColorBackgroundSelectPane extends ColorSelectPane implements UIObserver { + protected UIObserverListener uiObserverListener; + + protected void initialCompents(boolean isSupportTransparent) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder()); + if (isSupportTransparent) { + this.add(createNorthPane(), BorderLayout.NORTH); + } + JPanel centerPane = createCenterPane(); + this.add(centerPane, BorderLayout.CENTER); + this.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (uiObserverListener != null) { + uiObserverListener.doChange(); + } + } + }); + } + + private JPanel createNorthPane() { + UIButton transpanrentBtn = createTranspanrentButton(); + transpanrentBtn.setPreferredSize(new Dimension(160, 20)); + JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Color")), + transpanrentBtn}}, TableLayoutHelper.FILL_NONE, 33, 5); + jPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 10)); + return jPanel; + } + + protected JPanel createCenterPane() { + JPanel centerPane = super.createCenterPane(); + + JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{new UILabel(" "), centerPane}}, TableLayoutHelper.FILL_NONE, 33, 5); + jPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 10)); + return jPanel; + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.uiObserverListener = listener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/EmptyBackgroundPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/EmptyBackgroundPane.java new file mode 100644 index 0000000000..569db10231 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/EmptyBackgroundPane.java @@ -0,0 +1,34 @@ +package com.fr.design.mainframe.predefined.ui.detail.background; + +import com.fr.general.Background; + +/** + * Created by kerry on 2020-09-01 + */ +public class EmptyBackgroundPane extends AbstractBackgroundDetailPane { + + @Override + public void populate(Background background) { + + } + + @Override + public Background update() { + return null; + } + + /** + * 名称 + * + * @return 名称 + */ + public String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Null"); + } + + public boolean accept(Background background) { + return background == null; + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/FormBackgroundSettingPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/FormBackgroundSettingPane.java new file mode 100644 index 0000000000..1a683df5cc --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/FormBackgroundSettingPane.java @@ -0,0 +1,48 @@ +package com.fr.design.mainframe.predefined.ui.detail.background; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.event.UIObserverListener; +import com.fr.design.fun.BackgroundQuickUIProvider; +import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * Created by kerry on 2020-09-14 + */ +public class FormBackgroundSettingPane extends BackgroundSettingPane { + + public FormBackgroundSettingPane() { + super(); + } + + @Override + protected BackgroundQuickPane[] supportKindsOfBackgroundUI() { + ColorDetailPane colorDetailPane = new ColorDetailPane(); + ImageDetailPane imageDetailPane = createImageSelectPane(); + GradientDetailPane gradientPane = new GradientDetailPane(); + //hugh:表单支持背景接口 + List kinds = new ArrayList(); + + kinds.add(new EmptyBackgroundPane()); + kinds.add(colorDetailPane); + kinds.add(imageDetailPane); + kinds.add(gradientPane); + + Set providers = ExtraDesignClassManager.getInstance().getArray(BackgroundQuickUIProvider.MARK_STRING); + for (BackgroundQuickUIProvider provider : providers) { + BackgroundQuickPane newTypePane = provider.appearanceForBackground(); + newTypePane.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + fireChangeListener(); + } + }); + kinds.add(newTypePane); + } + + return kinds.toArray(new BackgroundQuickPane[kinds.size()]); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/GradientDetailPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/GradientDetailPane.java new file mode 100644 index 0000000000..0f4fc225e1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/GradientDetailPane.java @@ -0,0 +1,159 @@ +package com.fr.design.mainframe.predefined.ui.detail.background; + +import com.fr.base.background.GradientBackground; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.style.background.gradient.GradientBar; +import com.fr.general.Background; + +import javax.swing.ButtonGroup; +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * 渐变色的面板,不是很pp,面板应用显得繁琐,有写可以写成控件类型,比如色彩选择的。。,可以做得花哨点 + * + * @author ben + */ +public class GradientDetailPane extends AbstractBackgroundDetailPane implements UIObserver { + private static final long serialVersionUID = -6854603990673031897L; + private UIObserverListener listener; + private UIRadioButton left2right, top2bottom; + private GradientBar gradientBar; + private ChangeListener changeListener = null; + + public GradientDetailPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + + JPanel gradientPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel blankJp = new JPanel(); + gradientBar = new GradientBar(4, 145); + blankJp.add(gradientBar); + + gradientPanel.add(gradientBar, BorderLayout.SOUTH); + + JPanel jp = new JPanel(new GridLayout(2, 1, 15, 10)); + + + left2right = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Page_Setup_Horizontal")); + jp.add(left2right); + left2right.setSelected(true); + left2right.addActionListener(reviewListener); + + top2bottom = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Page_Setup_Vertical")); + jp.add(top2bottom); + top2bottom.addActionListener(reviewListener); + + ButtonGroup toggle = new ButtonGroup(); + toggle.add(left2right); + toggle.add(top2bottom); + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Gradient_Setting")), gradientPanel}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Gradient_Color")), jp} + }; + JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, + IntervalConstants.INTERVAL_W4, IntervalConstants.INTERVAL_L1); + this.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (listener != null) { + listener.doChange(); + } + } + }); + + + this.add(contentPane); + } + + @Override + public boolean accept(Background background) { + return background instanceof GradientBackground; + } + + + + public void populate(GradientBackground bg) { + this.gradientBar.getSelectColorPointBtnP1().setColorInner(bg.getStartColor()); + this.gradientBar.getSelectColorPointBtnP2().setColorInner(bg.getEndColor()); + if (bg.getDirection() == GradientBackground.LEFT2RIGHT) { + left2right.setSelected(true); + } else { + top2bottom.setSelected(true); + } + if (bg.isUseCell()) { + return; + } + double startValue = (double) bg.getBeginPlace(); + double endValue = (double) bg.getFinishPlace(); + gradientBar.setStartValue(startValue); + gradientBar.setEndValue(endValue); + this.gradientBar.repaint(); + } + + public GradientBackground update() { + GradientBackground gb = new GradientBackground( + gradientBar.getSelectColorPointBtnP1().getColorInner(), + gradientBar.getSelectColorPointBtnP2().getColorInner()); + if (left2right.isSelected()) { + gb.setDirection(GradientBackground.LEFT2RIGHT); + } else { + gb.setDirection(GradientBackground.TOP2BOTTOM); + } + if (gradientBar.isOriginalPlace()) { + gb.setUseCell(true); + } else { + gb.setUseCell(false); + gb.setBeginPlace((float) gradientBar.getStartValue()); + gb.setFinishPlace((float) gradientBar.getEndValue()); + } + return gb; + } + + + ActionListener reviewListener = new ActionListener() { + public void actionPerformed(ActionEvent e) { + fireChagneListener(); + } + }; + + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + gradientBar.addChangeListener(changeListener); + } + + public void fireChagneListener() { + if (this.changeListener != null) { + ChangeEvent evt = new ChangeEvent(this); + this.changeListener.stateChanged(evt); + } + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.listener = listener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + + @Override + public String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Gradient_Color"); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ImageDetailPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ImageDetailPane.java new file mode 100644 index 0000000000..a369000213 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ImageDetailPane.java @@ -0,0 +1,218 @@ +package com.fr.design.mainframe.predefined.ui.detail.background; + +import com.fr.base.Style; +import com.fr.base.background.ImageBackground; +import com.fr.base.background.ImageFileBackground; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.frpane.ImgChooseWrapper; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.style.background.image.ImageFileChooser; +import com.fr.design.style.background.image.ImagePreviewPane; +import com.fr.general.Background; +import com.fr.stable.Constants; + +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * Image background pane. + */ +public class ImageDetailPane extends AbstractBackgroundDetailPane implements UIObserver { + private UIObserverListener listener; + protected ImagePreviewPane previewPane = null; + private Style imageStyle = null; + private ChangeListener changeListener = null; + private ImageFileChooser imageFileChooser = null; + + private UIRadioButton defaultRadioButton = null; + private UIRadioButton tiledRadioButton = null; + private UIRadioButton extendRadioButton = null; + private UIRadioButton adjustRadioButton = null; + + + public ImageDetailPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.add(initSelectFilePane(), BorderLayout.CENTER); + imageFileChooser = new ImageFileChooser(); + imageFileChooser.setMultiSelectionEnabled(false); + previewPane = new ImagePreviewPane(); + this.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (listener != null) { + listener.doChange(); + } + } + }); + } + + public JPanel initSelectFilePane() { + JPanel selectFilePane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + selectFilePane.setBorder(BorderFactory.createEmptyBorder()); + UIButton selectPictureButton = new UIButton( + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Image_Select")); + selectPictureButton.setMnemonic('S'); + selectPictureButton.addActionListener(selectPictureActionListener); + selectPictureButton.setPreferredSize(new Dimension(160, 20)); + //布局 + defaultRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Layout_Default")); + tiledRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Layout_Image_Titled")); + extendRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Layout_Image_Extend")); + adjustRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Layout_Image_Adjust")); + + defaultRadioButton.addActionListener(layoutActionListener); + tiledRadioButton.addActionListener(layoutActionListener); + extendRadioButton.addActionListener(layoutActionListener); + adjustRadioButton.addActionListener(layoutActionListener); + + JPanel jp = new JPanel(new GridLayout(4, 1, 15, 10)); + for (UIRadioButton button : imageLayoutButtons()) { + jp.add(button); + } + + ButtonGroup layoutBG = new ButtonGroup(); + layoutBG.add(defaultRadioButton); + layoutBG.add(tiledRadioButton); + layoutBG.add(extendRadioButton); + layoutBG.add(adjustRadioButton); + + defaultRadioButton.setSelected(true); + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Image")), selectPictureButton}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Fill_Mode")), jp} + }; + JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_NONE, + IntervalConstants.INTERVAL_W4, IntervalConstants.INTERVAL_L1); + selectFilePane.add(centerPane, BorderLayout.CENTER); + return selectFilePane; + } + + protected UIRadioButton[] imageLayoutButtons() { + return new UIRadioButton[]{ + defaultRadioButton, + tiledRadioButton, + extendRadioButton, + adjustRadioButton + }; + } + + @Override + public boolean accept(Background background) { + return background instanceof ImageBackground; + } + + + /** + * Select picture. + */ + ActionListener selectPictureActionListener = new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + int returnVal = imageFileChooser.showOpenDialog(ImageDetailPane.this); + setImageStyle(); + ImgChooseWrapper.getInstance(previewPane, imageFileChooser, imageStyle, changeListener).dealWithImageFile(returnVal); + } + }; + + protected void setImageStyle() { + if (tiledRadioButton.isSelected()) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED); + } else if (adjustRadioButton.isSelected()) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_ADJUST); + } else if (extendRadioButton.isSelected()) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_EXTEND); + } else { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER); + } + } + + ActionListener layoutActionListener = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent evt) { + setImageStyle(); + changeImageStyle(); + } + + private void changeImageStyle() { + previewPane.setImageStyle(ImageDetailPane.this.imageStyle); + previewPane.repaint(); + } + }; + + @Override + public void populate(ImageBackground imageBackground) { + if (imageBackground.getLayout() == Constants.IMAGE_CENTER) { + defaultRadioButton.setSelected(true); + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER); + } else if (imageBackground.getLayout() == Constants.IMAGE_EXTEND) { + extendRadioButton.setSelected(true); + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_EXTEND); + } else if (imageBackground.getLayout() == Constants.IMAGE_ADJUST) { + adjustRadioButton.setSelected(true); + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_ADJUST); + } else { + tiledRadioButton.setSelected(true); + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED); + } + previewPane.setImageStyle(ImageDetailPane.this.imageStyle); + if (imageBackground.getImage() != null) { + previewPane.setImageWithSuffix(imageBackground.getImageWithSuffix()); + } + + if (imageBackground.getImage() != null) { + previewPane.setImage(imageBackground.getImage()); + } + + fireChagneListener(); + } + + @Override + public ImageBackground update() { + ImageBackground imageBackground = new ImageFileBackground(previewPane.getImageWithSuffix()); + setImageStyle(); + imageBackground.setLayout(imageStyle.getImageLayout()); + return imageBackground; + } + + @Override + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + } + + private void fireChagneListener() { + if (this.changeListener != null) { + ChangeEvent evt = new ChangeEvent(this); + this.changeListener.stateChanged(evt); + } + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.listener = listener; + } + + + @Override + public String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Image"); + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/PatternDetailPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/PatternDetailPane.java new file mode 100644 index 0000000000..5fa3b6ac25 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/PatternDetailPane.java @@ -0,0 +1,127 @@ +package com.fr.design.mainframe.predefined.ui.detail.background; + +import com.fr.base.background.PatternBackground; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.dialog.AttrScrollPane; +import com.fr.design.dialog.BasicScrollPane; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.style.background.impl.PatternBackgroundPane; +import com.fr.design.style.color.ColorSelectBox; +import com.fr.general.Background; +import com.fr.log.FineLoggerFactory; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.GridLayout; +import java.awt.LayoutManager; + +/** + * Created by kerry on 2020-08-31 + */ +public class PatternDetailPane extends AbstractBackgroundDetailPane implements UIObserver { + + private UIObserverListener listener; + private PatternNewBackgroundPane patternNewBackgroundPane; + + public PatternDetailPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + patternNewBackgroundPane = new PatternNewBackgroundPane(6); + this.add(patternNewBackgroundPane, BorderLayout.CENTER); + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.listener = listener; + } + + @Override + public void populate(PatternBackground background) { + this.patternNewBackgroundPane.populate(background); + } + + @Override + public PatternBackground update() { + try { + return (PatternBackground) this.patternNewBackgroundPane.update(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return null; + } + @Override + public String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Pattern"); + } + + + @Override + public boolean accept(Background background) { + return background instanceof PatternBackground; + } + + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + + class PatternNewBackgroundPane extends PatternBackgroundPane { + private PatternNewBackgroundPane(int nColumn) { + super(nColumn); + } + + protected LayoutManager layoutOfTypePane(int nColumn) { + return new GridLayout(0, nColumn, 2, 2); + } + + protected void initComponents(int nColumn) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder()); + JPanel jPanel = new JPanel(); + jPanel.setLayout(layoutOfTypePane(nColumn)); + setChildrenOfTypePane(jPanel); + + foregroundColorPane = new ColorSelectBox(80); + backgroundColorPane = new ColorSelectBox(80); + foregroundColorPane.setSelectObject(Color.lightGray); + backgroundColorPane.setSelectObject(Color.black); + UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Pattern")); + label.setVerticalAlignment(SwingConstants.TOP); + Component[][] components = new Component[][]{ + new Component[]{label, jPanel}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_ForeBackground_Color")), foregroundColorPane}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Pattern_Color")), backgroundColorPane} + }; + JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, + IntervalConstants.INTERVAL_W4, IntervalConstants.INTERVAL_L1); + JPanel jPanel1 = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + jPanel1.add(centerPane); + BasicScrollPane basicScrollPane = new AttrScrollPane() { + @Override + protected JPanel createContentPane() { + return jPanel1; + } + }; + jPanel1.setBorder(BorderFactory.createEmptyBorder()); + this.add(basicScrollPane, BorderLayout.NORTH); + this.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (listener != null) { + listener.doChange(); + } + } + }); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/TextureDetailObservePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/TextureDetailObservePane.java new file mode 100644 index 0000000000..189b811d99 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/TextureDetailObservePane.java @@ -0,0 +1,97 @@ +package com.fr.design.mainframe.predefined.ui.detail.background; + +import com.fr.base.background.TextureBackground; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.style.background.texture.TextureDetailPane; +import com.fr.general.Background; +import com.fr.log.FineLoggerFactory; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; + +/** + * Created by kerry on 2020-09-02 + */ +public class TextureDetailObservePane extends AbstractBackgroundDetailPane implements UIObserver { + private TextureDetailPane detailPane; + + private UIObserverListener listener; + + public TextureDetailObservePane() { + + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + detailPane = TextureDetailPane.createMiniTextureDetailPane(6); + + detailPane.setPreferredSize(new Dimension(160, 108)); + UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture")); + label.setPreferredSize(new Dimension(24, 108)); + label.setVerticalAlignment(SwingConstants.TOP); + JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{label, detailPane}}, TableLayoutHelper.FILL_LASTCOLUMN, 33, 5); + jPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 10)); + + + detailPane.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (listener != null) { + listener.doChange(); + } + } + }); + this.add(jPanel, BorderLayout.CENTER); + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.listener = listener; + + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + + @Override + public void populate(TextureBackground background) { + this.detailPane.populate(background); + } + + @Override + public TextureBackground update() { + try { + return (TextureBackground) this.detailPane.update(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return null; + } + + + @Override + public String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture"); + } + + @Override + public boolean accept(Background background) { + return background instanceof TextureBackground; + } + + + @Override + public void addChangeListener(ChangeListener changeListener) { + + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/cell/CustomPredefinedStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/cell/CustomPredefinedStylePane.java new file mode 100644 index 0000000000..e3e19f5871 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/cell/CustomPredefinedStylePane.java @@ -0,0 +1,228 @@ +package com.fr.design.mainframe.predefined.ui.detail.cell; + +import com.fr.base.ScreenResolution; +import com.fr.base.Style; +import com.fr.config.predefined.PredefinedCellStyle; +import com.fr.design.constants.UIConstants; +import com.fr.design.dialog.AttrScrollPane; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.BasicScrollPane; +import com.fr.design.dialog.MultiTabPane; +import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.gui.style.AbstractBasicStylePane; +import com.fr.design.gui.style.AlignmentPane; +import com.fr.design.gui.style.BorderPane; +import com.fr.design.gui.style.FormatPane; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GridLayout; +import java.util.ArrayList; +import java.util.List; + + +/** + * 哎,复杂的原型图导致复杂的画法。非我所愿也 + * + * @author zhou + * @since 2012-5-24上午10:36:10 + */ +public class CustomPredefinedStylePane extends MultiTabPane { + private PredefinedCellStyle cellStyle; + private PreviewArea previewArea; + private boolean populating; + + + public CustomPredefinedStylePane() { + super(); + tabPane.setOneLineTab(true); + tabPane.setDrawLine(false); + tabPane.setBorder(BorderFactory.createLineBorder(UIConstants.SHADOW_GREY)); + tabPane.setLayout(new GridLayout(1, 3, 0, 0)); + } + + public static CustomPredefinedStylePane createPredefinedStylePane() { + return new CustomPredefinedStylePane(); + } + + public static CustomPredefinedStylePane createDefaultPredefinedStylePane() { + return new CustomPredefinedStylePaneNoBorder(); + } + + /** + * @return + */ + public String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Custom_Style"); + } + + + /** + * + */ + public void reset() { + populateBean(null); + } + + @Override + /** + * + */ + public void populateBean(PredefinedCellStyle ob) { + this.populating = true; + this.cellStyle = ob; + for (int i = 0; i < paneList.size(); i++) { + ((AbstractBasicStylePane) paneList.get(i)).populateBean(ob.getStyle()); + previewArea.preview(ob.getStyle()); + } + this.populating = false; + } + + @Override + /** + * + */ + public PredefinedCellStyle updateBean() { + AbstractBasicStylePane basicStylePane = (AbstractBasicStylePane) paneList.get(tabPane.getSelectedIndex()); + this.cellStyle.setStyle(basicStylePane.update(this.cellStyle.getStyle())); + return this.cellStyle; + } + + + /** + * @param ob + * @return + */ + public boolean accept(Object ob) { + return ob instanceof PredefinedCellStyle; + } + + @Override + protected List initPaneList() { + paneList = new ArrayList(); + paneList.add(new FormatPane()); + paneList.add(new BorderPane()); + paneList.add(new AlignmentPane()); + return paneList; + } + + protected void initLayout() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + + JPanel jPanel = new JPanel(); + jPanel.setLayout(new BorderLayout(0, 4)); + + JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + previewArea = new PreviewArea(); + previewPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"), null)); + previewPane.add(previewArea, BorderLayout.CENTER); + + this.add(previewPane, BorderLayout.NORTH); + + this.add(jPanel, BorderLayout.CENTER); + jPanel.add(tabPane, BorderLayout.NORTH); + JPanel attrListenerPane = new AbstractAttrNoScrollPane() { + + @Override + protected void initContentPane() { + leftContentPane = createContentPane(); + this.add(leftContentPane, BorderLayout.CENTER); + } + + @Override + protected JPanel createContentPane() { + this.addAttributeChangeListener(new AttributeChangeListener() { + @Override + public void attributeChange() { + if (populating) { + return; + } + PredefinedCellStyle cellStyle = updateBean(); + if (cellStyle != null) { + previewArea.preview(cellStyle.getStyle()); + } + } + }); + BasicScrollPane basicScrollPane = new AttrScrollPane() { + @Override + protected JPanel createContentPane() { + return centerPane; + } + }; + return basicScrollPane; + } + }; + jPanel.add(attrListenerPane, BorderLayout.CENTER); + } + + @Override + /** + * + */ + public void updateBean(PredefinedCellStyle ob) { + return; + } + + + private static class CustomPredefinedStylePaneNoBorder extends CustomPredefinedStylePane { + @Override + protected List initPaneList() { + paneList = new ArrayList(); + paneList.add(new FormatPane()); + paneList.add(new AlignmentPane()); + return paneList; + } + + } + + /** + * 预览Style的面板 + * + * @author richer + */ + private static class PreviewArea extends JComponent { + + private String paintText = "Report"; + private Style style = Style.DEFAULT_STYLE; + + public PreviewArea() { + setPreferredSize(new Dimension(40, 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(); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/AbstractChartStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/AbstractChartStylePane.java new file mode 100644 index 0000000000..2fd47d6b29 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/AbstractChartStylePane.java @@ -0,0 +1,49 @@ +package com.fr.design.mainframe.predefined.ui.detail.chart; + +import com.fr.config.predefined.PredefinedChartStyle; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-17 + */ +public abstract class AbstractChartStylePane extends BasicPane { + + public AbstractChartStylePane() { + initComponents(); + initPane(); + } + + protected abstract void initComponents(); + + protected void initPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + double e = 155; + double p = TableLayout.PREFERRED; + double[] columnSize = {p, e}; + JPanel gapTableLayoutPane = TableLayoutHelper.createGapTableLayoutPane(getComponent(), getRows(p), columnSize, 20, LayoutConstants.VGAP_LARGE); + gapTableLayoutPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); + UIScrollPane rightTopPane = new UIScrollPane(gapTableLayoutPane); + rightTopPane.setBorder(BorderFactory.createEmptyBorder()); + this.add(rightTopPane, BorderLayout.CENTER); + } + + protected abstract Component[][] getComponent(); + + protected abstract double[] getRows(double p); + + public abstract void populate(PredefinedChartStyle chartStyle); + + public abstract void update(PredefinedChartStyle chartStyle); +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartAxisStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartAxisStylePane.java new file mode 100644 index 0000000000..4c6fc16ddc --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartAxisStylePane.java @@ -0,0 +1,69 @@ +package com.fr.design.mainframe.predefined.ui.detail.chart; + +import com.fr.config.predefined.PredefinedChartStyle; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.style.color.ColorSelectBox; + +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-16 + */ +public class ChartAxisStylePane extends AbstractChartStylePane { + + //轴标题字体样式 + private ChartFontPane titleFontPane; + + //轴标签字体样式 + private ChartFontPane labelFontPane; + + //轴线颜色 + private ColorSelectBox axisLineColor; + + protected void initComponents() { + titleFontPane = new ChartFontPane() { + public String getUILabelText() { + return Toolkit.i18nText("Fine-Design_Chart_Axis_Title_Character"); + } + }; + labelFontPane = new ChartFontPane() { + public String getUILabelText() { + return Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Character"); + } + }; + axisLineColor = new ColorSelectBox(100); + } + + protected Component[][] getComponent() { + return new Component[][]{ + new Component[]{titleFontPane, null}, + new Component[]{labelFontPane, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Axis_Line_Color")), axisLineColor} + }; + } + + protected double[] getRows(double p) { + return new double[]{p, p, p}; + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis"); + } + + public void populate(PredefinedChartStyle chartStyle) { + titleFontPane.populate(chartStyle.getAxisTitleFont()); + labelFontPane.populate(chartStyle.getAxisLabelFont()); + axisLineColor.setSelectObject(chartStyle.getAxisLineColor()); + } + + + public void update(PredefinedChartStyle chartStyle) { + chartStyle.setAxisTitleFont(titleFontPane.update()); + chartStyle.setAxisLabelFont(labelFontPane.update()); + chartStyle.setAxisLineColor(axisLineColor.getSelectObject()); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartBackgroundStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartBackgroundStylePane.java new file mode 100644 index 0000000000..0cb602eeaa --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartBackgroundStylePane.java @@ -0,0 +1,113 @@ +package com.fr.design.mainframe.predefined.ui.detail.chart; + +import com.fr.base.background.ImageBackground; +import com.fr.config.predefined.PredefinedChartStyle; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.ImageBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.NullBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.VanChartGradientPane; +import com.fr.design.style.color.ColorSelectBox; +import com.fr.general.Background; +import com.fr.stable.Constants; + +import javax.swing.JPanel; +import java.util.ArrayList; +import java.util.List; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-17 + */ +public class ChartBackgroundStylePane extends AbstractChartStylePane { + + private UIComboBox typeComboBox; + private List paneList; + private JPanel centerPane; + //网格线颜色 + private ColorSelectBox mainGridColor; + + protected void initComponents() { + mainGridColor = new ColorSelectBox(100); + + typeComboBox = new UIComboBox(); + final CardLayout cardlayout = new CardLayout(); + initList(); + + centerPane = new JPanel(cardlayout) { + @Override + public Dimension getPreferredSize() {// AUGUST:使用当前面板的的高度 + int index = typeComboBox.getSelectedIndex(); + return new Dimension(super.getPreferredSize().width, paneList.get(index).getPreferredSize().height); + } + }; + for (int i = 0; i < paneList.size(); i++) { + BackgroundQuickPane pane = paneList.get(i); + typeComboBox.addItem(pane.title4PopupWindow()); + centerPane.add(pane, pane.title4PopupWindow()); + } + + typeComboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + cardlayout.show(centerPane, (String) typeComboBox.getSelectedItem()); + } + }); + } + + protected Component[][] getComponent() { + return new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Area_Background_Color")), typeComboBox}, + new Component[]{null, centerPane}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Grid_Line_Color")), mainGridColor} + }; + } + + protected double[] getRows(double p) { + return new double[]{p, p, p, p}; + } + + private void initList() { + paneList = new ArrayList<>(); + paneList.add(new NullBackgroundQuickPane()); + paneList.add(new ColorBackgroundQuickPane()); + paneList.add(new ImageBackgroundQuickPane(false)); + paneList.add(new VanChartGradientPane()); + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Background"); + } + + public void populate(PredefinedChartStyle chartStyle) { + Background background = chartStyle.getChartBackground(); + for (int i = 0; i < paneList.size(); i++) { + BackgroundQuickPane pane = paneList.get(i); + if (pane.accept(background)) { + pane.populateBean(background); + typeComboBox.setSelectedIndex(i); + break; + } + } + mainGridColor.setSelectObject(chartStyle.getGridMainLineColor()); + } + + public void update(PredefinedChartStyle chartStyle) { + chartStyle.setChartBackground(paneList.get(typeComboBox.getSelectedIndex()).updateBean()); + if (chartStyle.getChartBackground() instanceof ImageBackground) { + ((ImageBackground) chartStyle.getChartBackground()).setLayout(Constants.IMAGE_EXTEND); + } + chartStyle.setGridMainLineColor(mainGridColor.getSelectObject()); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartDataSheetStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartDataSheetStylePane.java new file mode 100644 index 0000000000..2da8ee35f3 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartDataSheetStylePane.java @@ -0,0 +1,58 @@ +package com.fr.design.mainframe.predefined.ui.detail.chart; + +import com.fr.config.predefined.PredefinedChartStyle; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.style.color.ColorSelectBox; + +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-17 + */ +public class ChartDataSheetStylePane extends AbstractChartStylePane { + + //字体样式 + private ChartFontPane fontPane; + + //边框颜色 + private ColorSelectBox borderColor; + + protected void initComponents() { + fontPane = new ChartFontPane() { + public String getUILabelText() { + return Toolkit.i18nText("Fine-Design_Chart_DataSheet_Character"); + } + }; + borderColor = new ColorSelectBox(100); + } + + protected Component[][] getComponent() { + return new Component[][]{ + new Component[]{fontPane, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Border_Color")), borderColor} + }; + } + + protected double[] getRows(double p) { + return new double[]{p, p, p}; + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Sheet"); + } + + public void populate(PredefinedChartStyle chartStyle) { + fontPane.populate(chartStyle.getDataSheetFont()); + borderColor.setSelectObject(chartStyle.getDataSheetBorderColor()); + } + + + public void update(PredefinedChartStyle chartStyle) { + chartStyle.setDataSheetFont(fontPane.update()); + chartStyle.setDataSheetBorderColor(borderColor.getSelectObject()); + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartFontPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartFontPane.java new file mode 100644 index 0000000000..93c0f8a6b6 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartFontPane.java @@ -0,0 +1,160 @@ +package com.fr.design.mainframe.predefined.ui.detail.chart; + +import com.fr.base.BaseUtils; +import com.fr.base.FRContext; +import com.fr.base.Utils; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.dialog.BasicPane; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.ibutton.UIToggleButton; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.FRFont; +import com.fr.general.GeneralUtils; + +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; +import java.awt.Font; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-16 + */ +public class ChartFontPane extends BasicPane { + + public static final int FONT_START = 6; + public static final int FONT_END = 72; + private UIComboBox fontNameComboBox; + private UIComboBox fontSizeComboBox; + private UIToggleButton bold; + private UIToggleButton italic; + private UIColorButton fontColor; + private static Integer[] FONT_SIZES = new Integer[FONT_END - FONT_START + 1]; + + static { + for (int i = FONT_START; i <= FONT_END; i++) { + FONT_SIZES[i - FONT_START] = i; + } + } + + public ChartFontPane() { + initState(); + initComponents(); + } + + private void initState() { + fontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); + fontSizeComboBox = new UIComboBox(FONT_SIZES); + bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); + italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); + fontColor = new UIColorButton(); + } + + protected void initComponents() { + Component[] components = new Component[]{ + fontColor, italic, bold + }; + JPanel buttonPane = new JPanel(new BorderLayout()); + buttonPane.add(fontSizeComboBox, BorderLayout.CENTER); + buttonPane.add(GUICoreUtils.createFlowPane(components, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE), BorderLayout.EAST); + + this.setLayout(new BorderLayout()); + this.add(getContentPane(buttonPane), BorderLayout.CENTER); + + populate(FRContext.getDefaultValues().getFRFont()); + } + + protected JPanel getContentPane(JPanel buttonPane) { + double e = 155; + double p = TableLayout.PREFERRED; + double[] rows = {p, p, p}; + double[] columnSize = {p, e}; + UILabel text = new UILabel(getUILabelText(), SwingConstants.LEFT); + Component[][] components = { + new Component[]{null, null}, + new Component[]{text, fontNameComboBox}, + new Component[]{null, buttonPane} + }; + + return TableLayoutHelper.createGapTableLayoutPane(components, rows, columnSize, 20, LayoutConstants.VGAP_LARGE); + } + + public String getUILabelText() { + return Toolkit.i18nText("Fine-Design_Chart_Character"); + } + + public String title4PopupWindow() { + return null; + } + + public void populate(FRFont frFont) { + UIObserverListener listener = fontNameComboBox == null ? null : fontNameComboBox.getUiObserverListener(); + removeAllComboBoxListener(); + + if (frFont != null) { + fontNameComboBox.setSelectedItem(frFont.getFamily()); + bold.setSelected(frFont.isBold()); + italic.setSelected(frFont.isItalic()); + populateFontSize(frFont); + if (fontColor != null) { + fontColor.setColor(frFont.getForeground()); + } + } + + //更新结束后,注册监听器 + registerAllComboBoxListener(listener); + } + + private void populateFontSize(FRFont frFont) { + if (fontSizeComboBox != null) { + fontSizeComboBox.setSelectedItem(frFont.getSize()); + } + } + + private void removeAllComboBoxListener() { + fontNameComboBox.removeChangeListener(); + fontSizeComboBox.removeChangeListener(); + } + + private void registerAllComboBoxListener(UIObserverListener listener) { + fontNameComboBox.registerChangeListener(listener); + fontSizeComboBox.registerChangeListener(listener); + } + + /** + * 更新字 + * + * @return 更新字 + */ + public FRFont update() { + String name = GeneralUtils.objectToString(fontNameComboBox.getSelectedItem()); + + return FRFont.getInstance(name, updateFontStyle(), updateFontSize(), fontColor.getColor()); + } + + private int updateFontStyle() { + int style = Font.PLAIN; + if (bold.isSelected() && !italic.isSelected()) { + style = Font.BOLD; + } else if (!bold.isSelected() && italic.isSelected()) { + style = Font.ITALIC; + } else if (bold.isSelected() && italic.isSelected()) { + style = 3; + } + + return style; + } + + private float updateFontSize() { + return Float.parseFloat(GeneralUtils.objectToString(fontSizeComboBox.getSelectedItem())); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartLabelStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartLabelStylePane.java new file mode 100644 index 0000000000..b51535b82a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartLabelStylePane.java @@ -0,0 +1,78 @@ +package com.fr.design.mainframe.predefined.ui.detail.chart; + +import com.fr.config.predefined.PredefinedChartStyle; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-16 + */ +public class ChartLabelStylePane extends AbstractChartStylePane { + + private UIButtonGroup autoButton; + //字体样式 + private ChartFontPane chartFontPane; + + protected void initComponents() { + autoButton = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Auto"), + Toolkit.i18nText("Fine-Design_Chart_Custom")}); + chartFontPane = new ChartFontPane() { + public String getUILabelText() { + return Toolkit.i18nText("Fine-Design_Chart_Label_Character"); + } + }; + initListener(); + } + + protected Component[][] getComponent() { + return new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Style_Setting")), autoButton}, + new Component[]{chartFontPane, null} + }; + } + + protected double[] getRows(double p) { + return new double[]{p, p, p}; + } + + private void initListener() { + autoButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkPreButton(); + } + }); + } + + private void checkPreButton() { + chartFontPane.setVisible(autoButton.getSelectedIndex() == 1); + chartFontPane.setPreferredSize(autoButton.getSelectedIndex() == 1 ? new Dimension(0, 60) : new Dimension(0, 0)); + } + + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Label"); + } + + public void populate(PredefinedChartStyle chartStyle) { + autoButton.setSelectedIndex(chartStyle.isAutoLabelFont() ? 0 : 1); + chartFontPane.populate(chartStyle.getLabelFont()); + checkPreButton(); + } + + + public void update(PredefinedChartStyle chartStyle) { + chartStyle.setAutoLabelFont(autoButton.getSelectedIndex() == 0); + chartStyle.setLabelFont(chartFontPane.update()); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartLegendStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartLegendStylePane.java new file mode 100644 index 0000000000..c956dfcfd9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartLegendStylePane.java @@ -0,0 +1,49 @@ +package com.fr.design.mainframe.predefined.ui.detail.chart; + +import com.fr.config.predefined.PredefinedChartStyle; +import com.fr.design.i18n.Toolkit; + +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-16 + */ +public class ChartLegendStylePane extends AbstractChartStylePane { + + //字体样式 + private ChartFontPane chartFontPane; + + protected void initComponents() { + chartFontPane = new ChartFontPane() { + public String getUILabelText() { + return Toolkit.i18nText("Fine-Design_Chart_Legend_Character"); + } + }; + } + + protected Component[][] getComponent() { + return new Component[][]{ + new Component[]{chartFontPane, null} + }; + } + + protected double[] getRows(double p) { + return new double[]{p}; + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Legend"); + } + + public void populate(PredefinedChartStyle chartStyle) { + chartFontPane.populate(chartStyle.getLegendFont()); + } + + + public void update(PredefinedChartStyle chartStyle) { + chartStyle.setLegendFont(chartFontPane.update()); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartTitleStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartTitleStylePane.java new file mode 100644 index 0000000000..d5bc56cd9e --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartTitleStylePane.java @@ -0,0 +1,49 @@ +package com.fr.design.mainframe.predefined.ui.detail.chart; + +import com.fr.config.predefined.PredefinedChartStyle; +import com.fr.design.i18n.Toolkit; + +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-16 + */ +public class ChartTitleStylePane extends AbstractChartStylePane { + + //字体样式 + private ChartFontPane chartFontPane; + + protected void initComponents() { + chartFontPane = new ChartFontPane() { + public String getUILabelText() { + return Toolkit.i18nText("Fine-Design_Chart_Title_Character"); + } + }; + } + + protected Component[][] getComponent() { + return new Component[][]{ + new Component[]{chartFontPane, null} + }; + } + + protected double[] getRows(double p) { + return new double[]{p}; + } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Report_Title"); + } + + public void populate(PredefinedChartStyle chartStyle) { + chartFontPane.populate(chartStyle.getTitleFont()); + } + + + public void update(PredefinedChartStyle chartStyle) { + chartStyle.setTitleFont(chartFontPane.update()); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentFrameStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentFrameStylePane.java new file mode 100644 index 0000000000..e5d411b301 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentFrameStylePane.java @@ -0,0 +1,153 @@ +package com.fr.design.mainframe.predefined.ui.detail.component; + +import com.fr.base.GraphHelper; +import com.fr.base.Utils; +import com.fr.config.predefined.PredefinedComponentStyle; +import com.fr.design.gui.frpane.UINumberDragPane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIButtonUI; +import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.icombobox.LineComboBox; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.gui.style.BackgroundSpecialPane; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.backgroundpane.GradientBackgroundQuickPane; +import com.fr.general.act.BorderPacker; +import com.fr.stable.Constants; + +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.geom.RoundRectangle2D; + +/** + * Created by kerry on 2020-09-01 + */ +public class ComponentFrameStylePane extends ComponentStylePane { + private final static String[] BORDER_STYLE = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Common"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Shadow")}; + private static final double ALPHA_MAX_NUMBER = 100; + private final static int[] BORDER_LINE_STYLE_ARRAY = new int[]{ + Constants.LINE_NONE, + Constants.LINE_THIN, //1px + Constants.LINE_MEDIUM, //2px + Constants.LINE_THICK, //3px + }; + + //渲染风格 + private UIComboBox borderStyleCombo; + //边框粗细 + private LineComboBox currentLineCombo; + //边框圆角 + private UISpinner borderCornerSpinner; + //边框颜色 + private UIColorButton currentLineColorPane; + //主体背景 + private BackgroundSpecialPane backgroundPane; + //透明度 + private UINumberDragPane numberDragPane; + + public ComponentFrameStylePane() { + initPane(); + } + + protected void initPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder(6, 0, 0, 0)); + this.borderStyleCombo = new UIComboBox(BORDER_STYLE); + this.currentLineCombo = new LineComboBox(BORDER_LINE_STYLE_ARRAY); + this.currentLineColorPane = new UIColorButton(null); + this.borderCornerSpinner = new UISpinner(0, 1000, 1, 0); + currentLineColorPane.setUI(getButtonUI(currentLineColorPane)); + currentLineColorPane.set4ToolbarButton(); + currentLineColorPane.setPreferredSize(new Dimension(20, 20)); + JPanel buttonPane = new JPanel(new BorderLayout()); + buttonPane.add(currentLineColorPane, BorderLayout.WEST); + backgroundPane = new BackgroundSpecialPane(){ + @Override + protected GradientBackgroundQuickPane createGradientBackgroundQuickPane(){ + return new GradientBackgroundQuickPane(119); + } + }; + JPanel transparencyPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.numberDragPane = new UINumberDragPane(0, 100); + transparencyPane.add(numberDragPane, BorderLayout.CENTER); + transparencyPane.add(new UILabel(" %"), BorderLayout.EAST); + + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p, p, p, p, p, p, p}; + double[] columnSize = {p, 157}; + JPanel rightTopContentPane = TableLayoutHelper.createCommonTableLayoutPane(new JComponent[][]{ + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Render_Style")), borderStyleCombo}, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Border_Line")), currentLineCombo}, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Border_Color")), buttonPane}, + getBorderCornerSpinnerComp(), + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Background")), backgroundPane}, + {new UILabel(""), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Alpha"))}, + {new UILabel(""), transparencyPane}, + }, rowSize, columnSize, 10); + UIScrollPane rightTopPane = new UIScrollPane(rightTopContentPane); + rightTopPane.setBorder(BorderFactory.createEmptyBorder()); + this.add(rightTopPane, BorderLayout.CENTER); + } + + + private JComponent[] getBorderCornerSpinnerComp() { + return new JComponent[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius") + ":"), borderCornerSpinner}; + } + + + protected UIButtonUI getButtonUI(final UIColorButton uiColorButton) { + return new UIButtonUI() { + + public void paint(Graphics g, JComponent c) { + UIButton b = (UIButton) c; + g.setColor(Color.black); + GraphHelper.draw(g, new RoundRectangle2D.Double(1, 1, b.getWidth() - 2, b.getHeight() - 2, 0, 0), 1); + + if (b.getModel().isEnabled()) { + g.setColor(uiColorButton.getColor()); + } else { + g.setColor(new Color(Utils.filterRGB(uiColorButton.getColor().getRGB(), 50))); + } + g.fillRect(2, 2, b.getWidth() - 3, b.getHeight() - 3); + } + }; + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Frame"); + } + + + @Override + public void populate(PredefinedComponentStyle componentStyle) { + BorderPacker borderStyle = componentStyle.getBorderStyle(); + this.borderStyleCombo.setSelectedIndex(borderStyle.getBorderStyle()); + this.borderCornerSpinner.setValue(borderStyle.getBorderRadius()); + this.currentLineCombo.setSelectedLineStyle(borderStyle.getBorder()); + this.currentLineColorPane.setColor(borderStyle.getColor()); + this.backgroundPane.populateBean(borderStyle.getBackground()); + numberDragPane.populateBean(borderStyle.getAlpha() * ALPHA_MAX_NUMBER); + } + + @Override + public void update(PredefinedComponentStyle componentStyle) { + BorderPacker style = componentStyle.getBorderStyle(); + style.setBorderStyle(borderStyleCombo.getSelectedIndex()); + style.setBorderRadius((int) borderCornerSpinner.getValue()); + style.setBorder(currentLineCombo.getSelectedLineStyle()); + style.setColor(currentLineColorPane.getColor()); + style.setBackground(backgroundPane.update()); + style.setAlpha((float) (numberDragPane.updateBean() / ALPHA_MAX_NUMBER)); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentMarginStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentMarginStylePane.java new file mode 100644 index 0000000000..b36702fb71 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentMarginStylePane.java @@ -0,0 +1,93 @@ +package com.fr.design.mainframe.predefined.ui.detail.component; + +import com.fr.config.predefined.PredefinedComponentStyle; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; + +/** + * Created by kerry on 2020-09-01 + */ +public class ComponentMarginStylePane extends ComponentStylePane { + protected UISpinner top; + protected UISpinner bottom; + protected UISpinner left; + protected UISpinner right; + + public ComponentMarginStylePane() { + initBoundPane(0, 0, 0, 0); + } + + public void initBoundPane(int t, int b, int l, int r) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + top = new UISpinner(0, Integer.MAX_VALUE, 1, t); + bottom = new UISpinner(0, Integer.MAX_VALUE, 1, b); + left = new UISpinner(0, Integer.MAX_VALUE, 1, l); + right = new UISpinner(0, Integer.MAX_VALUE, 1, r); + top.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate")); + bottom.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate")); + left.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate")); + right.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate")); + UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate")); + label.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0)); + label.setVerticalAlignment(SwingConstants.TOP); + JPanel panel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ + new Component[]{label, createRightPane()}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W2, IntervalConstants.INTERVAL_L1); + this.add(panel); + } + + + public JPanel createRightPane() { + double f = TableLayout.FILL; + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p}; + double[] columnSize = {f, f}; + int[][] rowCount = {{1, 1}, {1, 1}}; + Component[][] components1 = new Component[][]{ + new Component[]{top, bottom}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Top"), SwingConstants.CENTER), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bottom"), SwingConstants.CENTER)} + }; + Component[][] components2 = new Component[][]{ + new Component[]{left, right}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Left"), SwingConstants.CENTER), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Right"), SwingConstants.CENTER)} + }; + JPanel northPanel = TableLayoutHelper.createGapTableLayoutPane(components1, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_L6, IntervalConstants.INTERVAL_L6); + northPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, IntervalConstants.INTERVAL_L1, 0)); + JPanel centerPanel = TableLayoutHelper.createGapTableLayoutPane(components2, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_L6, IntervalConstants.INTERVAL_L6); + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + panel.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0)); + panel.add(northPanel, BorderLayout.NORTH); + panel.add(centerPanel, BorderLayout.CENTER); + return panel; + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Base_Margin"); + } + + @Override + public void populate(PredefinedComponentStyle componentStyle) { + this.top.setValue(componentStyle.getTop()); + this.bottom.setValue(componentStyle.getBottom()); + this.left.setValue(componentStyle.getLeft()); + this.right.setValue(componentStyle.getRight()); + } + + @Override + public void update(PredefinedComponentStyle componentStyle) { + componentStyle.setTop((int) this.top.getValue()); + componentStyle.setBottom((int) this.bottom.getValue()); + componentStyle.setLeft((int) this.left.getValue()); + componentStyle.setRight((int) this.right.getValue()); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentStylePane.java new file mode 100644 index 0000000000..9d858cfea0 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentStylePane.java @@ -0,0 +1,15 @@ +package com.fr.design.mainframe.predefined.ui.detail.component; + +import com.fr.config.predefined.PredefinedComponentStyle; +import com.fr.design.dialog.BasicPane; + + +/** + * Created by kerry on 2020-09-01 + */ +public abstract class ComponentStylePane extends BasicPane { + + public abstract void populate(PredefinedComponentStyle componentStyle); + + public abstract void update(PredefinedComponentStyle componentStyle); +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentTitleStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentTitleStylePane.java new file mode 100644 index 0000000000..2d0e7746e9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentTitleStylePane.java @@ -0,0 +1,258 @@ +package com.fr.design.mainframe.predefined.ui.detail.component; + +import com.fr.base.BaseUtils; +import com.fr.base.Utils; +import com.fr.config.predefined.PredefinedComponentStyle; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.constants.UIConstants; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.ibutton.UIToggleButton; +import com.fr.design.gui.icombobox.LineComboBox; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.style.BackgroundNoImagePane; +import com.fr.design.gui.style.FRFontPane; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.backgroundpane.GradientBackgroundQuickPane; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.form.ui.LayoutBorderStyle; +import com.fr.form.ui.WidgetTitle; +import com.fr.general.FRFont; +import com.fr.general.act.BorderPacker; +import com.fr.general.act.TitlePacker; +import com.fr.stable.ArrayUtils; +import com.fr.stable.Constants; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; + +/** + * Created by kerry on 2020-09-01 + */ +public class ComponentTitleStylePane extends ComponentStylePane { + private final static Dimension BUTTON_SIZE = new Dimension(24, 20); + //标题内容 + private TinyFormulaPane formulaPane; + //标题格式 + private UIComboBox fontNameComboBox; + private UIComboBox fontSizeComboBox; + private UIColorButton colorSelectPane; + private UIToggleButton bold; + private UIToggleButton italic; + private UIToggleButton underline; + private LineComboBox underlineCombo; + //对齐方式 + private UIButtonGroup hAlignmentPane; + //标题背景 + private BackgroundNoImagePane titleBackgroundPane; + + public static ComponentTitleStylePane createPredefinedSettingPane(){ + return new ComponentTitleStylePane(true); + } + + public static ComponentTitleStylePane createStyleSettingPane(){ + return new ComponentTitleStylePane(false); + } + + private ComponentTitleStylePane(boolean isPredefined) { + initPane(isPredefined); + } + + protected void initPane(boolean isPredefined) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder(6, 0,0,0)); + formulaPane = new TinyFormulaPane(); + fontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES); + fontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); + fontNameComboBox.setPreferredSize(new Dimension(105 , 20)); + JPanel fontSizeTypePane = new JPanel(new BorderLayout(3, 0)); + fontSizeTypePane.add(fontSizeComboBox, BorderLayout.CENTER); + fontSizeTypePane.add(fontNameComboBox, BorderLayout.EAST); + + Icon[] hAlignmentIconArray = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), + BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"), + BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png"),}; + Integer[] hAlignment = new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT}; + hAlignmentPane = new UIButtonGroup(hAlignmentIconArray, hAlignment); + hAlignmentPane.setAllToolTips(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Left") + , com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Center"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Right")}); + JPanel hPaneContainer = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); + hPaneContainer.add(hAlignmentPane); + + titleBackgroundPane = new BackgroundNoImagePane(){ + @Override + protected GradientBackgroundQuickPane createGradientBackgroundQuickPane(){ + return new GradientBackgroundQuickPane(119); + } + }; + + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p, p, p, p, p, p, p}; + double[] columnSize = {p, 157}; + JComponent[][] jComponents = new JComponent[][]{ + {new UILabel(com.fr.design.i18n.Toolkit.i18nText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Char"))), fontSizeTypePane}, + {new UILabel(""), initFontButtonPane()}, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Alignment-Style")), hAlignmentPane}, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Background")), titleBackgroundPane}}; + + JComponent[][] displayComponents = createDisplayComponentArray(isPredefined, jComponents); + JPanel rightBottomContentPane = TableLayoutHelper.createCommonTableLayoutPane(displayComponents, rowSize, columnSize, 10); + + UIScrollPane jPanel = new UIScrollPane(rightBottomContentPane); + jPanel.setBorder(BorderFactory.createEmptyBorder()); + this.add(jPanel, BorderLayout.CENTER); + } + + private JComponent[][] createDisplayComponentArray(boolean isPredefined, JComponent[][] baseComponents) { + if (isPredefined) { + return baseComponents; + } + JComponent[][] titleComponent = new JComponent[][]{{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Content")), formulaPane}}; + return ArrayUtils.addAll(titleComponent, baseComponents); + + } + + protected JPanel initFontButtonPane() { + colorSelectPane = new UIColorButton(); + bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); + italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); + underline = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png")); + bold.setPreferredSize(BUTTON_SIZE); + italic.setPreferredSize(BUTTON_SIZE); + underline.setPreferredSize(BUTTON_SIZE); + underline.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + underlineCombo.setVisible(underline.isSelected()); + } + }); + underlineCombo = new LineComboBox(UIConstants.BORDER_LINE_STYLE_ARRAY); + Component[] components_font = new Component[]{ + colorSelectPane, italic, bold, underline + }; + JPanel buttonPane = new JPanel(new BorderLayout()); + buttonPane.add(GUICoreUtils.createFlowPane(components_font, FlowLayout.LEFT, LayoutConstants.HGAP_SMALL)); + JPanel combinePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + combinePane.add(buttonPane, BorderLayout.WEST); + combinePane.add(underlineCombo, BorderLayout.CENTER); + initAllNames(); + setToolTips(); + return combinePane; + + } + + protected void initAllNames() { + fontNameComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Family")); + fontSizeComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Size")); + colorSelectPane.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Foreground")); + italic.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Italic")); + bold.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Bold")); + underline.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Underline")); + underlineCombo.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Line_Style")); + } + + protected void setToolTips() { + colorSelectPane.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Foreground")); + italic.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Italic")); + bold.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Bold")); + underline.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Underline")); + } + + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Title"); + } + + @Override + public void populate(PredefinedComponentStyle componentStyle) { + BorderPacker borderStyle = componentStyle.getBorderStyle(); + TitlePacker widgetTitle = borderStyle == null ? new WidgetTitle() : borderStyle.getTitle(); + widgetTitle = widgetTitle == null ? new WidgetTitle() : widgetTitle; + + populateFormula(widgetTitle); + populateFont(widgetTitle); + + hAlignmentPane.setSelectedItem(widgetTitle.getPosition()); + + titleBackgroundPane.populateBean(widgetTitle.getBackground()); + } + + private void populateFormula(TitlePacker widgetTitle) { + this.formulaPane.populateBean(widgetTitle.getTextObject().toString()); + } + + protected void populateFont(TitlePacker widgetTitle) { + FRFont frFont = widgetTitle.getFrFont(); + this.fontSizeComboBox.setSelectedItem(frFont.getSize()); + this.fontNameComboBox.setSelectedItem(frFont.getFamily()); + this.colorSelectPane.setColor(frFont.getForeground()); + this.colorSelectPane.repaint(); + bold.setSelected(frFont.isBold()); + italic.setSelected(frFont.isItalic()); + int line = frFont.getUnderline(); + if (line == Constants.LINE_NONE) { + underline.setSelected(false); + underlineCombo.setVisible(false); + } else { + underline.setSelected(true); + underlineCombo.setVisible(true); + this.underlineCombo.setSelectedLineStyle(line); + } + } + + @Override + public void update(PredefinedComponentStyle componentStyle) { + BorderPacker style = componentStyle.getBorderStyle(); + TitlePacker title = style.getTitle() == null ? new WidgetTitle() : style.getTitle(); + String titleText = formulaPane.updateBean(); + title.setTextObject(titleText); + style.setType(StringUtils.isEmpty(titleText) ? LayoutBorderStyle.STANDARD : LayoutBorderStyle.TITLE); + FRFont frFont = title.getFrFont(); + frFont = frFont.applySize((Integer) fontSizeComboBox.getSelectedItem()); + frFont = frFont.applyName(fontNameComboBox.getSelectedItem().toString()); + frFont = frFont.applyForeground(colorSelectPane.getColor()); + frFont = updateItalicBold(frFont); + int line = underline.isSelected() ? this.underlineCombo.getSelectedLineStyle() : Constants.LINE_NONE; + frFont = frFont.applyUnderline(line); + title.setFrFont(frFont); + title.setPosition((Integer) hAlignmentPane.getSelectedItem()); + title.setBackground(titleBackgroundPane.update()); + style.setTitle(title); + } + + private FRFont updateItalicBold(FRFont frFont) { + int italic_bold = frFont.getStyle(); + boolean isItalic = italic_bold == Font.ITALIC || italic_bold == (Font.BOLD + Font.ITALIC); + boolean isBold = italic_bold == Font.BOLD || italic_bold == (Font.BOLD + Font.ITALIC); + if (italic.isSelected() && !isItalic) { + italic_bold += Font.ITALIC; + } else if (!italic.isSelected() && isItalic) { + italic_bold -= Font.ITALIC; + } + frFont = frFont.applyStyle(italic_bold); + if (bold.isSelected() && !isBold) { + italic_bold += Font.BOLD; + } else if (!bold.isSelected() && isBold) { + italic_bold -= Font.BOLD; + } + frFont = frFont.applyStyle(italic_bold); + return frFont; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/PredefinedStyleEditDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/PredefinedStyleEditDialog.java new file mode 100644 index 0000000000..3fe434fd08 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/PredefinedStyleEditDialog.java @@ -0,0 +1,193 @@ +package com.fr.design.mainframe.predefined.ui.dialog; + +import com.fr.config.ServerPreferenceConfig; +import com.fr.config.predefined.PredefinedStyleConfig; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.mainframe.predefined.ui.PredefinedStyleEditPane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.JDialog; + +import javax.swing.JPanel; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +/** + * Created by kerry on 2020-08-26 + */ +public class PredefinedStyleEditDialog extends JDialog { + + public PredefinedStyleEditDialog(Window parent, PredefinedStyleEditPane contentPane) { + this(parent, contentPane, false); + } + + + public PredefinedStyleEditDialog(Window parent, PredefinedStyleEditPane contentPane, boolean isBuiltIn) { + super(parent, ModalityType.APPLICATION_MODAL); + + this.setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Style_Edit")); + this.setResizable(false); + JPanel defaultPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + this.setContentPane(defaultPane); + + UIButton saveBtn = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Save")); + saveBtn.setEnabled(!isBuiltIn); + saveBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if(contentPane.saveStyle()){ + dialogExit(); + } + } + }); + UIButton saveAsBtn = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_Save_As_New")); + saveAsBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + SaveAsNewStyleDialog saveAsNewStyleDialog = new SaveAsNewStyleDialog(PredefinedStyleEditDialog.this, contentPane); + saveAsNewStyleDialog.setVisible(true); + + } + }); + UIButton cancelBtn = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cancel")); + cancelBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dialogExit(); + } + }); + JPanel buttonPanel = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); + buttonPanel.add(saveBtn); + buttonPanel.add(saveAsBtn); + buttonPanel.add(cancelBtn); + + defaultPane.add(contentPane, BorderLayout.CENTER); + defaultPane.add(buttonPanel, BorderLayout.SOUTH); + + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dialogExit(); + } + }); + + + this.setSize(new Dimension(900, 600)); + GUICoreUtils.centerWindow(this); + } + + public void dialogExit() { + this.dispose(); + } + + class SaveAsNewStyleDialog extends JDialog { + private UITextField textField; + private UILabel tipLabel; + + public SaveAsNewStyleDialog(Window parent, PredefinedStyleEditPane editPane) { + super(parent, ModalityType.APPLICATION_MODAL); + + this.setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_Save_As_New")); + this.setResizable(false); + UIButton confirm = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm")); + confirm.setEnabled(false); + confirm.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String name = textField.getText(); + if (valid(name)) { + editPane.saveAsNewStyle(name); + dialogExit(); + PredefinedStyleEditDialog.this.dialogExit(); + } else { + tipLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_Name_Repeat")); + } + } + }); + UIButton cancle = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cancel")); + cancle.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dialogExit(); + } + }); + JPanel defaultPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + JPanel buttonPanel = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); + buttonPanel.add(confirm); + buttonPanel.add(cancle); + + JPanel panel = createSaveAsPane(confirm); + + + defaultPane.add(panel, BorderLayout.CENTER); + defaultPane.add(buttonPanel, BorderLayout.SOUTH); + + this.setContentPane(defaultPane); + + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dialogExit(); + } + }); + + + this.setSize(new Dimension(300, 130)); + GUICoreUtils.centerWindow(this); + } + + private JPanel createSaveAsPane(UIButton confirm) { + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel centerPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(20, 5); + centerPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Style_Name"))); + textField = new UITextField(); + textField.getDocument().addDocumentListener(new DocumentListener() { + @Override + public void insertUpdate(DocumentEvent e) { + confirm.setEnabled(StringUtils.isNotEmpty(textField.getText())); + } + + @Override + public void removeUpdate(DocumentEvent e) { + + } + + @Override + public void changedUpdate(DocumentEvent e) { + + } + }); + textField.setPreferredSize(new Dimension(180, 20)); + centerPane.add(textField); + panel.add(centerPane, BorderLayout.CENTER); + tipLabel = new UILabel(); + tipLabel.setBorder(BorderFactory.createEmptyBorder(10, 20, 0, 0)); + tipLabel.setForeground(Color.RED); + panel.add(tipLabel, BorderLayout.SOUTH); + return panel; + + + } + + + public void dialogExit() { + this.dispose(); + } + + private boolean valid(String name) { + PredefinedStyleConfig config = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig(); + return !config.containStyle(name); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/ReportPredefinedStyleDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/ReportPredefinedStyleDialog.java new file mode 100644 index 0000000000..8c9daf0b09 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/ReportPredefinedStyleDialog.java @@ -0,0 +1,93 @@ +package com.fr.design.mainframe.predefined.ui.dialog; + +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.predefined.ui.ReportPredefinedStylePane; +import com.fr.design.mainframe.predefined.ui.ServerPredefinedStylePane; +import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.JDialog; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +/** + * Created by kerry on 2020-08-26 + */ +public class ReportPredefinedStyleDialog extends JDialog { + + + public ReportPredefinedStyleDialog(Window parent, ReportPredefinedStylePane contentPane) { + super(parent, ModalityType.APPLICATION_MODAL); + + this.setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Template_Style")); + this.setResizable(false); + JPanel defaultPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + this.setContentPane(defaultPane); + UIButton managerBtn = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Style_Manager")); + managerBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + ServerPredefinedStylePane predefinedStylePane = new ServerPredefinedStylePane(); + ServerPredefinedStyleDialog dialog = new ServerPredefinedStyleDialog(ReportPredefinedStyleDialog.this, predefinedStylePane); + dialog.setVisible(true); + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosed(WindowEvent e) { + contentPane.refresh(); + } + }); + } + }); + + + UIButton settingBtn = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_Applicate_Style")); + settingBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + contentPane.update(); + dialogExit(); + } + }); + + UIButton cancelBtn = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cancel")); + cancelBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dialogExit(); + } + }); + JPanel southPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel buttonPanel1 = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + buttonPanel1.add(managerBtn); + southPane.add(buttonPanel1, BorderLayout.CENTER); + + JPanel buttonPanel2 = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); + buttonPanel2.add(settingBtn); + buttonPanel2.add(cancelBtn); + + southPane.add(buttonPanel2, BorderLayout.EAST); + + defaultPane.add(contentPane, BorderLayout.CENTER); + defaultPane.add(southPane, BorderLayout.SOUTH); + + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dialogExit(); + } + }); + + + this.setSize(new Dimension(660, 600)); + GUICoreUtils.centerWindow(this); + } + + public void dialogExit() { + this.dispose(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/ServerPredefinedStyleDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/ServerPredefinedStyleDialog.java new file mode 100644 index 0000000000..439bb3ec28 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/ServerPredefinedStyleDialog.java @@ -0,0 +1,68 @@ +package com.fr.design.mainframe.predefined.ui.dialog; + +import com.fr.design.mainframe.predefined.ui.ServerPredefinedStylePane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.JDialog; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +/** + * Created by kerry on 2020-08-26 + */ +public class ServerPredefinedStyleDialog extends JDialog { + + + public ServerPredefinedStyleDialog(Window parent, ServerPredefinedStylePane contentPane) { + super(parent, ModalityType.APPLICATION_MODAL); + this.setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Server_Style")); + this.setResizable(false); + JPanel defaultPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + this.setContentPane(defaultPane); + + UIButton settingBtn = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_Set_Default")); + settingBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + contentPane.update(); + dialogExit(); + } + }); + + UIButton cancelBtn = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cancel")); + cancelBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dialogExit(); + } + }); + JPanel buttonPanel = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); + buttonPanel.add(settingBtn); + buttonPanel.add(cancelBtn); + + defaultPane.add(contentPane, BorderLayout.CENTER); + defaultPane.add(buttonPanel, BorderLayout.SOUTH); + + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dialogExit(); + } + }); + + + this.setSize(new Dimension(660, 600)); + GUICoreUtils.centerWindow(this); + } + + public void dialogExit(){ + this.dispose(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ComponentPreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ComponentPreviewPane.java new file mode 100644 index 0000000000..0fffe2ff4f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ComponentPreviewPane.java @@ -0,0 +1,146 @@ +package com.fr.design.mainframe.predefined.ui.preview; + +import com.fr.base.FRContext; +import com.fr.base.GraphHelper; +import com.fr.config.predefined.PredefinedStyle; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.general.Background; +import com.fr.general.FRFont; +import com.fr.general.act.BorderPacker; +import com.fr.general.act.TitlePacker; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; + +/** + * Created by kerry on 2020-09-04 + */ +public abstract class ComponentPreviewPane extends StyleSettingPreviewPane { + private PredefinedStyle style = new PredefinedStyle(); + private static final int SMALL_GAP = 5; + private static final int GAP = 10; + private JPanel contentPane; + private TitlePreviewPane titlePane; + + + public ComponentPreviewPane() { + this.setBackground(null); + this.setOpaque(false); + this.contentPane = createContentPane(); + this.titlePane = new TitlePreviewPane(); + this.titlePane.setPreferredSize(new Dimension(484, 35)); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10)); + + this.add(titlePane, BorderLayout.NORTH); + this.add(contentPane, BorderLayout.CENTER); + } + + protected abstract JPanel createContentPane(); + + public void refresh() { + this.repaint(); + } + + public void refresh(PredefinedStyle style) { + this.style = style; + } + + + @Override + public void paint(Graphics g) { + paintContent(g); + + + } + + public void paintContent(Graphics g) { + BorderPacker borderStyle = style.getComponentStyle().getBorderStyle(); + + updateBorders(g, borderStyle); + + paintTitle(g, borderStyle.getTitle()); + + paintContentPane(g,borderStyle); + + } + + private void paintContentPane(Graphics g, BorderPacker borderStyle) { + + Graphics clipg; + clipg = g.create(10, 40, this.contentPane.getWidth(), this.contentPane.getHeight()); + if (borderStyle.getBackground() != null) { + borderStyle.getBackground().paint(clipg, clipg.getClipBounds()); + } + this.contentPane.paint(clipg); + clipg.dispose(); + + } + + private void paintTitle(Graphics g, TitlePacker titlePacker) { + FRFont font = titlePacker.getFrFont(); + Background background = titlePacker.getBackground(); + if (background != null) { + background.paint(g, new Rectangle2D.Double(10, 5, this.titlePane.getWidth(), this.titlePane.getHeight())); + } + titlePane.setFontObject(font); + titlePane.paintComponent(g); + } + + private void updateBorders(Graphics g, BorderPacker borderStyle) { + if (borderStyle != null) { + borderStyle.paint(g, new Rectangle2D.Double(SMALL_GAP, SMALL_GAP, getWidth() - GAP, getHeight() - SMALL_GAP - GAP)); + } + } + + + private class TitlePreviewPane extends JPanel { + private FRFont frFont = null; + + public TitlePreviewPane() { + this.setBackground(null); + this.setOpaque(false); + frFont = FRContext.getDefaultValues().getFRFont(); + } + + @Override + public void paint(Graphics g) { + + } + + public void paintComponent(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + Dimension d = getSize(); + if (frFont == null) { + return; + } + FontMetrics fm = getFontMetrics(frFont); + if (this.isEnabled()) { + g2d.setColor(frFont.getForeground()); + } else { + g2d.setColor(new Color(237, 237, 237)); + } + g2d.setFont(frFont.applySize(14).applyResolutionNP(96)); + int startY = 0; + startY = (d.height + fm.getHeight()) / 2; + drawTabBack(g2d, startY); + } + + private void drawTabBack(Graphics2D g2d, int startY) { + String paintText = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_Preview_Title_Text"); + GraphHelper.drawString(g2d, paintText, GAP, 32); + } + + public void setFontObject(FRFont font) { + this.frFont = font; + } + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ElementCasePreview.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ElementCasePreview.java new file mode 100644 index 0000000000..18408ec530 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ElementCasePreview.java @@ -0,0 +1,98 @@ +package com.fr.design.mainframe.predefined.ui.preview; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.general.FRFont; +import com.fr.log.FineLoggerFactory; + +import javax.swing.JPanel; +import javax.swing.JSeparator; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +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; + +/** + * Created by kerry on 2020-09-04 + */ +public class ElementCasePreview extends ComponentPreviewPane { + private static final List PREVIEW_DATA_LIST = new ArrayList<>(); + private static final String BLANK_CHAR = " "; + + static { + readPreviewData(); + } + + private static void readPreviewData() { + try { + InputStream inputStream = ElementCasePreview.class.getResourceAsStream("/com/fr/design/mainframe/predefined/previewData"); + BufferedReader br = new BufferedReader(new InputStreamReader(inputStream, + StandardCharsets.UTF_8)); + String lineTxt = null; + while ((lineTxt = br.readLine()) != null) { + String[] data = lineTxt.split(BLANK_CHAR); + PREVIEW_DATA_LIST.add(data); + } + br.close(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + + @Override + protected JPanel createContentPane() { + + JPanel jPanel = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); + jPanel.setOpaque(false); + jPanel.setBackground(null); + FRFont font = FRFont.getInstance(); + FRFont titleFont = font.applySize(11).applyForeground(Color.decode("#63B2EE")); + FRFont endFont = font.applyForeground(Color.decode("#1B97FF")); + for (int i = 0; i < PREVIEW_DATA_LIST.size(); i++) { + FRFont frFont = font; + if (i == 0) { + frFont = titleFont; + } + if (i == PREVIEW_DATA_LIST.size() - 1) { + frFont = endFont; + } + jPanel.add(new GridRowPane(frFont, PREVIEW_DATA_LIST.get(i))); + + } + + return jPanel; + } + + class GridRowPane extends JPanel { + public GridRowPane(FRFont frFont, String[] data) { + this.setOpaque(false); + this.setBackground(null); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel panel = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(4, 20, 10); + panel.setOpaque(false); + panel.setBackground(null); + for (String text : data) { + panel.add(createLabel(text, frFont)); + } + this.add(panel, BorderLayout.CENTER); + JSeparator jSeparator = new JSeparator(); + jSeparator.setPreferredSize(new Dimension(246, 2)); + this.add(jSeparator, BorderLayout.SOUTH); + } + + private UILabel createLabel(String text, FRFont frFont) { + UILabel label = new UILabel(text); + label.setFont(frFont); + label.setForeground(frFont.getForeground()); + label.setBackground(null); + return label; + } + + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/PredefinedStylePreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/PredefinedStylePreviewPane.java new file mode 100644 index 0000000000..d7ca347ed0 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/PredefinedStylePreviewPane.java @@ -0,0 +1,80 @@ +package com.fr.design.mainframe.predefined.ui.preview; + +import com.fr.base.background.ColorBackground; +import com.fr.config.predefined.PredefinedStyle; +import com.fr.design.utils.ComponentUtils; +import com.fr.general.Background; + +import javax.swing.JComponent; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.util.ArrayList; + +/** + * Created by kerry on 2020-09-06 + */ +public class PredefinedStylePreviewPane extends StyleSettingPreviewPane { + private ElementCasePreview elementCasePreview; + private Background background; + private double scaleX = 1.0; + private double scaleY = 1.0; + + public PredefinedStylePreviewPane() { + this(1.0, 1.0); + } + + public PredefinedStylePreviewPane(double scaleX, double scaleY) { + this.scaleX = scaleX; + this.scaleY = scaleY; + this.setBackground(Color.WHITE); + this.elementCasePreview = new ElementCasePreview(); + this.elementCasePreview.setPreferredSize(new Dimension(517, 320)); + this.add(this.elementCasePreview); + } + + @Override + public void refresh() { + + } + + @Override + public void paint(Graphics g) { + ((Graphics2D) g).scale(scaleX, scaleY); + // 禁止双缓冲 + ArrayList dbcomponents = new ArrayList(); + ComponentUtils.disableBuffer(this.elementCasePreview, dbcomponents); + + if (background == null) { + background = ColorBackground.getInstance(Color.WHITE); + } + background.paint(g, new Rectangle2D.Double(0, 0, 517, 320)); + + this.elementCasePreview.paintContent(g); + + // 恢复双缓冲 + ComponentUtils.resetBuffer(dbcomponents); + + } + + @Override + public void paintComponents(Graphics g) { + super.paintComponents(g); + if (background != null) { + background.paint(g, new Rectangle2D.Double(0, 0, this.getWidth(), this.getHeight())); + } + } + + public void refresh(PredefinedStyle style) { + refresh(style, false); + } + + public void refresh(PredefinedStyle style, boolean displayFormBackground) { + elementCasePreview.refresh(style); + background = displayFormBackground ? style.getFormBackground().getBackground() : style.getReportBackground(); + this.repaint(); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/StyleSettingPreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/StyleSettingPreviewPane.java new file mode 100644 index 0000000000..4fff5841e8 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/StyleSettingPreviewPane.java @@ -0,0 +1,17 @@ +package com.fr.design.mainframe.predefined.ui.preview; + +import javax.swing.JPanel; + +/** + * Created by kerry on 2020-08-31 + */ +public abstract class StyleSettingPreviewPane extends JPanel { + public StyleSettingPreviewPane() { + + } + + + public abstract void refresh(); + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java b/designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java index 694389f30a..931e756663 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java @@ -27,7 +27,7 @@ public class SendHelper { return success; } - private static boolean sendSinglePointInfo(String url, String content) { + public static boolean sendSinglePointInfo(String url, String content) { Map para = new HashMap<>(); para.put("token", SiteCenterToken.generateToken()); para.put("content", content); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java index 23c07ea3a5..e41759d24a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe.template.info; -import com.fr.design.mainframe.burying.point.AbstractPointCollector; import com.fr.design.mainframe.burying.point.AbstractPointInfo; +import com.fr.design.mainframe.burying.point.AbstractTemplateInfoCollector; import com.fr.json.JSON; import com.fr.json.JSONFactory; import com.fr.json.JSONObject; @@ -18,7 +18,7 @@ import java.util.concurrent.ConcurrentHashMap; * 做模板的过程和耗时收集,辅助类 * Created by plough on 2017/2/21. */ -public class TemplateInfoCollector extends AbstractPointCollector { +public class TemplateInfoCollector extends AbstractTemplateInfoCollector { private static final String XML_TAG = "TplInfo"; private static final String XML_TEMPLATE_INFO_LIST = "TemplateInfoList"; private static final String XML_FILE_NAME = "tpl.info"; diff --git a/designer-base/src/main/java/com/fr/design/notification/SnapChatAllTypes.java b/designer-base/src/main/java/com/fr/design/notification/SnapChatAllTypes.java index 6aeb384df5..34e73d9834 100644 --- a/designer-base/src/main/java/com/fr/design/notification/SnapChatAllTypes.java +++ b/designer-base/src/main/java/com/fr/design/notification/SnapChatAllTypes.java @@ -6,33 +6,61 @@ import com.fr.stable.CommonUtils; * created by Harrison on 2020/03/16 **/ public abstract class SnapChatAllTypes { - + public enum Menu implements SnapChatKey { - + /** * 社区按钮 */ BBS("BBS"); - + private static final String SIGN = "0001"; - + private String key; - + Menu(String key) { this.key = key; } - + + public String getKey() { + return key; + } + + @Override + public String calc() { + + return CommonUtils.join( + new String[]{SIGN, getKey()}, "-" + ); + } + } + + public enum UpdateAction implements SnapChatKey { + + /** + * 服务器预定义样式 + */ + PREDEFINED_STYLE("PREDEFINED_STYLE"); + + private static final String SIGN = "0002"; + + private String key; + + UpdateAction(String key) { + this.key = key; + } + public String getKey() { return key; } - + @Override public String calc() { - + return CommonUtils.join( new String[]{SIGN, getKey()}, "-" ); } } - + } diff --git a/designer-base/src/main/java/com/fr/design/style/background/impl/BPane.java b/designer-base/src/main/java/com/fr/design/style/background/impl/BPane.java index 9a9805a5cd..8f91686764 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/impl/BPane.java +++ b/designer-base/src/main/java/com/fr/design/style/background/impl/BPane.java @@ -15,7 +15,7 @@ public abstract class BPane extends BackgroundDetailPane { this.initComponents(nColumn); } - private void initComponents(int nColumn) { + protected void initComponents(int nColumn) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); diff --git a/designer-base/src/main/java/com/fr/design/style/background/impl/TextureBackgroundPane.java b/designer-base/src/main/java/com/fr/design/style/background/impl/TextureBackgroundPane.java index 3dd59bd5b4..9d1cb168c6 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/impl/TextureBackgroundPane.java +++ b/designer-base/src/main/java/com/fr/design/style/background/impl/TextureBackgroundPane.java @@ -1,197 +1,59 @@ package com.fr.design.style.background.impl; -import com.fr.base.GraphHelper; -import com.fr.base.background.TextureBackground; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.style.background.BackgroundDetailPane; +import com.fr.design.style.background.texture.TextureDetailPane; import com.fr.general.Background; -import com.fr.general.ComparatorUtils; -import javax.swing.*; -import javax.swing.event.ChangeEvent; +import javax.swing.BorderFactory; +import javax.swing.JPanel; import javax.swing.event.ChangeListener; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.geom.Rectangle2D; +import java.awt.BorderLayout; /** * Texture background pane. TODO kunsnat: 拆出去. 真特么的长.. */ -public class TextureBackgroundPane extends BPane { - - private static final TexturePaint[] EMBED_TEXTURE_PAINT_ARRAY = new TexturePaint[]{ - TextureBackground.NEWSPRINT_TEXTURE_PAINT, - TextureBackground.RECYCLED_PAPER_TEXTURE_PAINT, - TextureBackground.PARCHMENT_TEXTURE_PAINT, - TextureBackground.STATIONERY_TEXTURE_PAINT, - TextureBackground.GREEN_MARBLE_TEXTURE_PAINT, - TextureBackground.WHITE_MARBLE_TEXTURE_PAINT, - TextureBackground.BROWN_MARBLE_TEXTURE_PAINT, - TextureBackground.GRANITE_TEXTURE_PAINT, - TextureBackground.BLUE_TISSUE_PAPER_TEXTURE_PAINT, - TextureBackground.PINK_TISSUE_PAPER_TEXTURE_PAINT, - TextureBackground.PURPLE_MESH_TEXTURE_PAINT, - TextureBackground.BOUQUET_TEXTURE_PAINT, - TextureBackground.PAPYRUS_TEXTURE_PAINT, - TextureBackground.CANVAS_TEXTURE_PAINT, - TextureBackground.DENIM_TEXTURE_PAINT, - TextureBackground.WOVEN_MAT_TEXTURE_PAINT, - TextureBackground.WATER_DROPLETS_TEXTURE_PAINT, - TextureBackground.PAPER_BAG_TEXTURE_PAINT, - TextureBackground.FISH_FOSSIL_TEXTURE_PAINT, - TextureBackground.SAND_TEXTURE_PAINT, - TextureBackground.CORK_TEXTURE_PAINT, - TextureBackground.WALNUT_TEXTURE_PAINT, - TextureBackground.OAK_TEXTURE_PAINT, - TextureBackground.MEDIUM_WOOD_TEXTURE_PAINT}; - - private static final String[] EMBED_TEXTURE_PAINT_DES_ARRAY = new String[]{ - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Newsprint"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Recycled_Paper"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Parchment"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Stationery"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Green_Marble"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_White_Marble"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Brown_Marble"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Granite"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Blue_Tissue_Paper"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Pink_Tissue_Paper"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Purple_Mesh"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Bouquet"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Papyrus"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Canvas"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Denim"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Woven_Mat"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Water_Droplets"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_PaperBag"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_FishFossil"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Sand"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Cork"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Walnut"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Oak"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Medium_Wood") - }; - - private TexturePaint texturePaint; - private TextureButton[] textureButtonArray; +public class TextureBackgroundPane extends BackgroundDetailPane { + + + private TextureDetailPane detailPane; public TextureBackgroundPane() { - super(8);// 默认的. + this(8);// 默认的. } - public TextureBackgroundPane(int colum) { - super(colum);// 自定义的. - } + public TextureBackgroundPane(int column) { + this.detailPane = TextureDetailPane.createNormalTextureDetailPane(column); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); - protected LayoutManager layoutOfTypePane(int nColumn) { - return FRGUIPaneFactory.createNColumnGridLayout(nColumn); + JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); + this.add(contentPane, BorderLayout.NORTH); + + JPanel typePane = FRGUIPaneFactory.createTitledBorderPane(titleOfTypePane()); + contentPane.add(typePane); + typePane.add(this.detailPane); } + + protected String titleOfTypePane() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture"); } - protected void setChildrenOfTypePane(JPanel typePane2) { - ButtonGroup patternButtonGroup = new ButtonGroup(); - textureButtonArray = new TextureButton[EMBED_TEXTURE_PAINT_ARRAY.length]; - for (int i = 0; i < EMBED_TEXTURE_PAINT_ARRAY.length; i++) { - textureButtonArray[i] = new TextureButton( - EMBED_TEXTURE_PAINT_ARRAY[i], EMBED_TEXTURE_PAINT_DES_ARRAY[i]); - patternButtonGroup.add(textureButtonArray[i]); - typePane2.add(textureButtonArray[i]); - } - } + public void populate(Background background) { - if (background instanceof TextureBackground) { - TextureBackground textureBackground = (TextureBackground) background; - - this.texturePaint = textureBackground.getTexturePaint(); - - for (int i = 0; i < textureButtonArray.length; i++) { - if (ComparatorUtils.equals(textureButtonArray[i].getTexturePaint(), this.texturePaint)) { - textureButtonArray[i].setSelected(true); - break; - } - } - } else { - this.textureButtonArray[0].setSelected(true); - this.texturePaint = textureButtonArray[0].getTexturePaint(); - } + this.detailPane.populate(background); } public Background update() throws Exception { - return new TextureBackground(this.texturePaint); + return this.detailPane.update(); } + @Override public void addChangeListener(ChangeListener changeListener) { - for (int i = 0; i < this.textureButtonArray.length; i++) { - this.textureButtonArray[i].addChangeListener(changeListener); - } + this.detailPane.addChangeListener(changeListener); } - /** - * Texture type button. - */ - class TextureButton extends JToggleButton implements ActionListener { - - private TexturePaint buttonTexturePaint; - - public TextureButton(TexturePaint buttonTexturePaint, String tooltip) { - this.buttonTexturePaint = buttonTexturePaint; - this.setToolTipText(tooltip); - - this.setCursor(new Cursor(Cursor.HAND_CURSOR)); - this.addActionListener(this); - this.setBorder(null); - } - - public void paintComponent(Graphics g) { - Graphics2D g2d = (Graphics2D) g; - - Dimension d = getSize(); - - g2d.setPaint(this.buttonTexturePaint); - GraphHelper.fill(g2d, new Rectangle2D.Double(0, 0, d.width - 1d, - d.height - 1d)); - - if (ComparatorUtils.equals(texturePaint, this.buttonTexturePaint)) {// it's - // selected. - g2d.setPaint(Color.black); - } else { - g2d.setPaint(Color.gray); - } - GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1d, - d.height - 1d)); - } - - public Dimension getPreferredSize() { - return new Dimension(36, 32); - } - - public TexturePaint getTexturePaint() { - return this.buttonTexturePaint; - } - - /** - * set Pattern setIndex. - */ - public void actionPerformed(ActionEvent evt) { - TextureBackgroundPane.this.texturePaint = this.getTexturePaint(); - - fireChagneListener(); - TextureBackgroundPane.this.repaint(); // repaint. - } - - public void addChangeListener(ChangeListener changeListener) { - this.changeListener = changeListener; - } - - private void fireChagneListener() { - if (this.changeListener != null) { - ChangeEvent evt = new ChangeEvent(this); - this.changeListener.stateChanged(evt); - } - } - } } diff --git a/designer-base/src/main/java/com/fr/design/style/background/texture/TextureDetailPane.java b/designer-base/src/main/java/com/fr/design/style/background/texture/TextureDetailPane.java new file mode 100644 index 0000000000..fd6fe7f2c8 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/style/background/texture/TextureDetailPane.java @@ -0,0 +1,208 @@ +package com.fr.design.style.background.texture; + +import com.fr.base.GraphHelper; +import com.fr.base.background.TextureBackground; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.style.background.BackgroundDetailPane; +import com.fr.general.Background; +import com.fr.general.ComparatorUtils; + +import javax.swing.ButtonGroup; +import javax.swing.JToggleButton; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.Color; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GridLayout; +import java.awt.LayoutManager; +import java.awt.TexturePaint; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.geom.Rectangle2D; + +/** + * Created by kerry on 2020-08-31 + */ +public class TextureDetailPane extends BackgroundDetailPane { + + private static final TexturePaint[] EMBED_TEXTURE_PAINT_ARRAY = new TexturePaint[]{ + TextureBackground.NEWSPRINT_TEXTURE_PAINT, + TextureBackground.RECYCLED_PAPER_TEXTURE_PAINT, + TextureBackground.PARCHMENT_TEXTURE_PAINT, + TextureBackground.STATIONERY_TEXTURE_PAINT, + TextureBackground.GREEN_MARBLE_TEXTURE_PAINT, + TextureBackground.WHITE_MARBLE_TEXTURE_PAINT, + TextureBackground.BROWN_MARBLE_TEXTURE_PAINT, + TextureBackground.GRANITE_TEXTURE_PAINT, + TextureBackground.BLUE_TISSUE_PAPER_TEXTURE_PAINT, + TextureBackground.PINK_TISSUE_PAPER_TEXTURE_PAINT, + TextureBackground.PURPLE_MESH_TEXTURE_PAINT, + TextureBackground.BOUQUET_TEXTURE_PAINT, + TextureBackground.PAPYRUS_TEXTURE_PAINT, + TextureBackground.CANVAS_TEXTURE_PAINT, + TextureBackground.DENIM_TEXTURE_PAINT, + TextureBackground.WOVEN_MAT_TEXTURE_PAINT, + TextureBackground.WATER_DROPLETS_TEXTURE_PAINT, + TextureBackground.PAPER_BAG_TEXTURE_PAINT, + TextureBackground.FISH_FOSSIL_TEXTURE_PAINT, + TextureBackground.SAND_TEXTURE_PAINT, + TextureBackground.CORK_TEXTURE_PAINT, + TextureBackground.WALNUT_TEXTURE_PAINT, + TextureBackground.OAK_TEXTURE_PAINT, + TextureBackground.MEDIUM_WOOD_TEXTURE_PAINT}; + + private static final String[] EMBED_TEXTURE_PAINT_DES_ARRAY = new String[]{ + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Newsprint"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Recycled_Paper"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Parchment"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Stationery"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Green_Marble"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_White_Marble"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Brown_Marble"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Granite"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Blue_Tissue_Paper"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Pink_Tissue_Paper"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Purple_Mesh"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Bouquet"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Papyrus"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Canvas"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Denim"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Woven_Mat"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Water_Droplets"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_PaperBag"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_FishFossil"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Sand"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Cork"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Walnut"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Oak"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Medium_Wood") + }; + + + private TexturePaint texturePaint; + private TextureButton[] textureButtonArray; + + private TextureDetailPane(LayoutManager layoutManager, Dimension perTextureBtnSize) { +// this.setForeground(Color.WHITE); +// this.setBackground(Color.WHITE); + this.setLayout(layoutManager); + this.setChildrenOfTypePane(perTextureBtnSize); + } + + public static TextureDetailPane createNormalTextureDetailPane(int nColumn) { + return new TextureDetailPane(FRGUIPaneFactory.createNColumnGridLayout(nColumn), new Dimension(36, 32)); + } + + public static TextureDetailPane createMiniTextureDetailPane(int nColumn) { + return new TextureDetailPane(new GridLayout(0, nColumn, 2, 2), new Dimension(23, 23)); + } + + + protected void setChildrenOfTypePane(Dimension dimension) { + ButtonGroup patternButtonGroup = new ButtonGroup(); + textureButtonArray = new TextureButton[EMBED_TEXTURE_PAINT_ARRAY.length]; + for (int i = 0; i < EMBED_TEXTURE_PAINT_ARRAY.length; i++) { + textureButtonArray[i] = new TextureButton( + EMBED_TEXTURE_PAINT_ARRAY[i], EMBED_TEXTURE_PAINT_DES_ARRAY[i]); + textureButtonArray[i].setPreferredSize(dimension); + patternButtonGroup.add(textureButtonArray[i]); + this.add(textureButtonArray[i]); + } + } + + public void populate(Background background) { + if (background instanceof TextureBackground) { + TextureBackground textureBackground = (TextureBackground) background; + + this.texturePaint = textureBackground.getTexturePaint(); + + for (int i = 0; i < textureButtonArray.length; i++) { + if (ComparatorUtils.equals(textureButtonArray[i].getTexturePaint(), this.texturePaint)) { + textureButtonArray[i].setSelected(true); + break; + } + } + } else { + this.textureButtonArray[0].setSelected(true); + this.texturePaint = textureButtonArray[0].getTexturePaint(); + } + } + + public Background update() throws Exception { + return new TextureBackground(this.texturePaint); + } + + public void addChangeListener(ChangeListener changeListener) { + for (int i = 0; i < this.textureButtonArray.length; i++) { + this.textureButtonArray[i].addChangeListener(changeListener); + } + } + + /** + * Texture type button. + */ + class TextureButton extends JToggleButton implements ActionListener { + + private TexturePaint buttonTexturePaint; + + public TextureButton(TexturePaint buttonTexturePaint, String tooltip) { + this.buttonTexturePaint = buttonTexturePaint; + this.setToolTipText(tooltip); + + this.setCursor(new Cursor(Cursor.HAND_CURSOR)); + this.addActionListener(this); + this.setBorder(null); + } + + public void paintComponent(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + + Dimension d = getSize(); + + g2d.setPaint(this.buttonTexturePaint); + GraphHelper.fill(g2d, new Rectangle2D.Double(0, 0, d.width - 1d, + d.height - 1d)); + + if (ComparatorUtils.equals(texturePaint, this.buttonTexturePaint)) {// it's + // selected. + g2d.setPaint(Color.black); + } else { + g2d.setPaint(Color.gray); + } + GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1d, + d.height - 1d)); + } + + public Dimension getPreferredSize() { + return new Dimension(36, 32); + } + + public TexturePaint getTexturePaint() { + return this.buttonTexturePaint; + } + + /** + * set Pattern setIndex. + */ + public void actionPerformed(ActionEvent evt) { + TextureDetailPane.this.texturePaint = this.getTexturePaint(); + + fireChagneListener(); + TextureDetailPane.this.repaint(); // repaint. + } + + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + } + + private void fireChagneListener() { + if (this.changeListener != null) { + ChangeEvent evt = new ChangeEvent(this); + this.changeListener.stateChanged(evt); + } + } + } +} diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartColorAdjustPane.java b/designer-base/src/main/java/com/fr/design/style/color/ColorAdjustPane.java similarity index 94% rename from designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartColorAdjustPane.java rename to designer-base/src/main/java/com/fr/design/style/color/ColorAdjustPane.java index b053a5eb9b..909501857a 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartColorAdjustPane.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorAdjustPane.java @@ -1,14 +1,12 @@ -package com.fr.design.mainframe.chart.gui.style; +package com.fr.design.style.color; import com.fr.base.BaseUtils; import com.fr.base.background.ColorBackground; -import com.fr.design.chartx.component.button.ColorButton; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.style.AbstractSelectBox; -import com.fr.design.style.color.ColorSelectPane; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; @@ -32,7 +30,7 @@ import java.awt.image.BufferedImage; * @version 10.0 * Created by Bjorn on 2020-03-25 */ -public class ChartColorAdjustPane extends JPanel implements UIObserver { +public class ColorAdjustPane extends JPanel implements UIObserver { public static final Color[] DEFAULT_COLORS = { new Color(99, 178, 238), @@ -58,11 +56,11 @@ public class ChartColorAdjustPane extends JPanel implements UIObserver { private ChangeListener changeListener; - public ChartColorAdjustPane() { + public ColorAdjustPane() { this(DEFAULT_COLORS); } - public ChartColorAdjustPane(Color[] colors) { + public ColorAdjustPane(Color[] colors) { iniListener(); createColorButton(colors); createContentPane(); @@ -217,7 +215,7 @@ public class ChartColorAdjustPane extends JPanel implements UIObserver { if(colorButtons.size() < MAX_BUTTON) { colorButtons.add(createColorButton(color)); } - ChartColorAdjustPane.this.stateChanged(); + ColorAdjustPane.this.stateChanged(); relayout(); } }); diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/button/ColorButton.java b/designer-base/src/main/java/com/fr/design/style/color/ColorButton.java similarity index 97% rename from designer-chart/src/main/java/com/fr/design/chartx/component/button/ColorButton.java rename to designer-base/src/main/java/com/fr/design/style/color/ColorButton.java index dd908505db..f5f2288ff9 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/button/ColorButton.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorButton.java @@ -1,9 +1,8 @@ -package com.fr.design.chartx.component.button; +package com.fr.design.style.color; import com.fr.base.BaseUtils; import com.fr.base.background.ColorBackground; import com.fr.design.style.AbstractSelectBox; -import com.fr.design.style.color.ColorSelectPane; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java index c82eac0c0d..437b3c8c4e 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java @@ -53,25 +53,19 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable initialCompents(isSupportTransparent); } - private void initialCompents(boolean isSupportTransparent) { + protected void initialCompents(boolean isSupportTransparent) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); if (isSupportTransparent) { - UIButton transpanrentButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ChartF_Transparency")); - this.add(transpanrentButton, BorderLayout.NORTH); - transpanrentButton.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - doTransparent(); - } - }); + this.add(createTranspanrentButton(), BorderLayout.NORTH); } + this.add(createCenterPane(), BorderLayout.CENTER); + } + protected JPanel createCenterPane(){ // center JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); - this.add(centerPane, BorderLayout.CENTER); centerPane.add(getRow1Pane()); @@ -98,6 +92,19 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable centerPane1.setBorder(BorderFactory.createEmptyBorder(2, 8, 8, 8)); centerPane1.add(customButton, BorderLayout.NORTH); centerPane.add(centerPane1); + return centerPane; + } + + protected UIButton createTranspanrentButton(){ + UIButton transpanrentButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ChartF_Transparency")); + transpanrentButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + doTransparent(); + } + }); + return transpanrentButton; } protected JPanel getMenuColorPane() { diff --git a/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java b/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java index ef66fc039a..54f1755b94 100644 --- a/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java +++ b/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java @@ -404,6 +404,7 @@ public class CustomIconPane extends BasicPane { double p = TableLayout.PREFERRED; double[] rowSize = {p, p}; double[] columnSize = {p, p}; + int[][] rowCount = {{1, 1}, {1, 1}}; UIButton browseButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_SelectIcon")); browseButton.setPreferredSize(new Dimension(80, 25)); browseButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Click_this_button")); @@ -442,7 +443,7 @@ public class CustomIconPane extends BasicPane { imagePane.add(browseButton); Component[][] components = {{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Name") + ":"), nameTextField}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Icon") + ":"), imagePane}}; - JPanel centerPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1); this.add(centerPane, BorderLayout.CENTER); } diff --git a/designer-base/src/main/resources/com/fr/design/icon/icon_edit.png b/designer-base/src/main/resources/com/fr/design/icon/icon_edit.png new file mode 100644 index 0000000000..f6de9d0d46 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/icon/icon_edit.png differ diff --git a/designer-base/src/main/resources/com/fr/design/icon/icon_predefined_style.png b/designer-base/src/main/resources/com/fr/design/icon/icon_predefined_style.png new file mode 100644 index 0000000000..af81b6b3b5 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/icon/icon_predefined_style.png differ diff --git a/designer-base/src/main/resources/com/fr/design/mainframe/predefined/previewData b/designer-base/src/main/resources/com/fr/design/mainframe/predefined/previewData new file mode 100644 index 0000000000..444c5e314b --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/mainframe/predefined/previewData @@ -0,0 +1,11 @@ +城市 当月目标 当月实际完成 月度完成率 +南通市 324,646 324,646 105% +合肥市 248,938 348,938 103% +邵阳市 248,938 348,938 103% +九江市 248,938 348,938 103% +武汉市 248,938 348,938 103% +郑州市 248,938 348,938 103% +无锡市 248,938 348,938 103% +南京市 248,938 348,938 103% +苏州市 248,938 348,938 103% +合计 3200,425 2900,300 95% diff --git a/designer-base/src/test/java/com/fr/design/mainframe/predefined/info/PredefinedStyleInfoCollectorTest.java b/designer-base/src/test/java/com/fr/design/mainframe/predefined/info/PredefinedStyleInfoCollectorTest.java new file mode 100644 index 0000000000..34bff89349 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/mainframe/predefined/info/PredefinedStyleInfoCollectorTest.java @@ -0,0 +1,97 @@ +package com.fr.design.mainframe.predefined.info; + +import com.fr.config.BBSAttr; +import com.fr.config.MarketConfig; +import com.fr.design.DesignerEnvManager; +import com.fr.general.GeneralUtils; +import com.fr.json.JSON; +import com.fr.json.JSONFactory; +import com.fr.json.JSONObject; +import com.fr.stable.ProductConstants; +import com.fr.third.org.apache.commons.io.FileUtils; +import org.easymock.EasyMock; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; +import org.powermock.modules.junit4.PowerMockRunner; +import java.io.File; +import java.io.IOException; + +/** + * Created by kerry on 2020-09-05 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({ProductConstants.class, MarketConfig.class, DesignerEnvManager.class, GeneralUtils.class}) +@SuppressStaticInitializationFor({"com.fr.jvm.assist.FineAssist"}) +public class PredefinedStyleInfoCollectorTest { + private String filePath; + private String initialFileContent; + + + @Before + public void setUp() throws IOException { + PowerMock.mockStatic(ProductConstants.class); + + filePath = getClass().getResource("predefinedStyle.info").getPath(); + String dirPath = filePath.substring(0, filePath.indexOf("predefinedStyle.info")); + EasyMock.expect(ProductConstants.getEnvHome()).andReturn(dirPath).anyTimes(); + + EasyMock.replay(); + PowerMock.replayAll(); + initialFileContent = FileUtils.readFileToString(new File(filePath), "utf-8"); + } + + @After + public void tearDown() throws IOException { + FileUtils.writeStringToFile(new File(filePath), initialFileContent, "utf-8"); + } + + @Test + public void testCollectClickNumber() { + PredefinedStyleInfoCollector.getInstance().collectClickNumber(); + Assert.assertEquals(1, PredefinedStyleInfoCollector.getInstance().getClickNumber()); + } + + @Test + public void testCollectUseNumber() { + PredefinedStyleInfoCollector.getInstance().collectUseNumber(); + Assert.assertEquals(1, PredefinedStyleInfoCollector.getInstance().getUseNumber()); + } + + @Test + public void testGenerateTotalInfo() { + PowerMock.mockStatic(DesignerEnvManager.class); + PowerMock.mockStatic(MarketConfig.class); + PowerMock.mockStatic(GeneralUtils.class); + + DesignerEnvManager envManager = EasyMock.mock(DesignerEnvManager.class); + EasyMock.expect(envManager.getUUID()).andReturn("xxxxx-12345-xxxxx").once(); + EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(envManager).once(); + + + MarketConfig marketConfig = EasyMock.mock(MarketConfig.class); + BBSAttr bbsAttr = new BBSAttr(); + bbsAttr.setBbsUid(12345); + EasyMock.expect(marketConfig.getBBSAttr()).andReturn(bbsAttr).once(); + EasyMock.expect(MarketConfig.getInstance()).andReturn(marketConfig).once(); + + EasyMock.expect(GeneralUtils.readFullVersionNO()).andReturn("10.0.9.2020.0817.final"); + + EasyMock.replay(envManager, marketConfig); + + PowerMock.replayAll(); + String content = PredefinedStyleInfoCollector.getInstance().generateTotalInfo(); + JSONObject jsonObject = JSONFactory.createJSON(JSON.OBJECT, content); + Assert.assertEquals("predefinedStyle", jsonObject.getString("functionName")); + Assert.assertEquals("FR-F7003", jsonObject.getString("functionId")); + Assert.assertEquals("xxxxx-12345-xxxxx", jsonObject.getString("uuid")); + Assert.assertEquals(12345, jsonObject.getInt("uid")); + Assert.assertEquals("10.0.9.2020.0817.final", jsonObject.getString("jatTime")); + } + +} diff --git a/designer-base/src/test/resources/com/fr/design/mainframe/predefined/info/predefinedStyle.info b/designer-base/src/test/resources/com/fr/design/mainframe/predefined/info/predefinedStyle.info new file mode 100644 index 0000000000..1d66b61077 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/mainframe/predefined/info/predefinedStyle.info @@ -0,0 +1,2 @@ + + diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithPreStyle.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithPreStyle.java new file mode 100644 index 0000000000..e27ed43e1e --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithPreStyle.java @@ -0,0 +1,97 @@ +package com.fr.design.mainframe.chart.gui.style; + +import com.fr.chart.base.TextAttr; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-03 + */ +public class ChartTextAttrPaneWithPreStyle extends ChartTextAttrPane { + + private static final int PREDEFINED_STYLE = 0; + private static final int CUSTOM = 1; + + private UIButtonGroup preButton; + private JPanel textFontPane; + + public ChartTextAttrPaneWithPreStyle() { + initListener(); + } + + protected JPanel getContentPane(JPanel buttonPane) { + preButton = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Predefined"), + Toolkit.i18nText("Fine-Design_Chart_Custom")}); + double f = TableLayout.FILL; + double e = getEdithAreaWidth(); + double[] columnSize = {f, e}; + double p = TableLayout.PREFERRED; + textFontPane = TableLayout4VanChartHelper.createGapTableLayoutPane(getComponents(buttonPane), getRowSize(), columnSize); + + double[] rowSize = {p, p, p}; + UILabel text = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT); + Component[][] components = { + new Component[]{null, null}, + new Component[]{text, preButton}, + new Component[]{textFontPane, null}, + }; + return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); + } + + protected double getEdithAreaWidth() { + return TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + } + + protected Component[][] getComponents(JPanel buttonPane) { + return new Component[][]{ + new Component[]{null, getFontNameComboBox()}, + new Component[]{null, buttonPane} + }; + } + + private void initListener() { + preButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkPreButton(); + } + }); + } + + private void checkPreButton() { + textFontPane.setVisible(preButton.getSelectedIndex() == CUSTOM); + textFontPane.setPreferredSize(preButton.getSelectedIndex() == CUSTOM ? new Dimension(0, 60) : new Dimension(0, 0)); + } + + public void populate(TextAttr textAttr) { + if (textAttr.isPredefinedStyle()) { + preButton.setSelectedIndex(PREDEFINED_STYLE); + } else { + preButton.setSelectedIndex(CUSTOM); + } + super.populate(textAttr); + checkPreButton(); + } + + public void update(TextAttr textAttr) { + int selectedIndex = preButton.getSelectedIndex(); + if (selectedIndex == PREDEFINED_STYLE) { + textAttr.setPredefinedStyle(true); + } else { + textAttr.setPredefinedStyle(false); + } + super.update(textAttr); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ColorSelectBoxWithPreStyle.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ColorSelectBoxWithPreStyle.java new file mode 100644 index 0000000000..a4a0344fa4 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ColorSelectBoxWithPreStyle.java @@ -0,0 +1,88 @@ +package com.fr.design.mainframe.chart.gui.style; + +import com.fr.chart.base.ColorWithPreStyle; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.style.color.ColorSelectBox; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-07 + */ +public class ColorSelectBoxWithPreStyle extends BasicPane { + + private static final int PREDEFINED_STYLE = 0; + private static final int CUSTOM = 1; + + private UIButtonGroup preButton; + private ColorSelectBox colorSelectBox; + + public ColorSelectBoxWithPreStyle(int preferredWidth) { + preButton = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Predefined"), + Toolkit.i18nText("Fine-Design_Chart_Custom")}); + colorSelectBox = new ColorSelectBox(preferredWidth); + initContent(); + initListener(); + } + + private void initContent() { + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + double[] columnSize = {f, e}; + double p = TableLayout.PREFERRED; + + double[] rowSize = {p, p, p}; + UILabel text = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color"), SwingConstants.LEFT); + Component[][] components = { + new Component[]{text, preButton}, + new Component[]{null, colorSelectBox}, + }; + JPanel gapTableLayoutPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); + this.setLayout(new BorderLayout()); + this.add(gapTableLayoutPane, BorderLayout.CENTER); + } + + private void initListener() { + preButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkPreButton(); + } + }); + } + + private void checkPreButton() { + colorSelectBox.setVisible(preButton.getSelectedIndex() == CUSTOM); + this.setPreferredSize(preButton.getSelectedIndex() == CUSTOM ? new Dimension(0, 55) : new Dimension(0, 23)); + } + + public String title4PopupWindow() { + return null; + } + + public void populate(ColorWithPreStyle colorWithPreStyle) { + preButton.setSelectedIndex(colorWithPreStyle.isPredefinedStyle() ? PREDEFINED_STYLE : CUSTOM); + colorSelectBox.setSelectObject(colorWithPreStyle.getColor()); + checkPreButton(); + } + + public ColorWithPreStyle update() { + ColorWithPreStyle colorWithPreStyle = new ColorWithPreStyle(); + colorWithPreStyle.setPredefinedStyle(preButton.getSelectedIndex() == PREDEFINED_STYLE); + colorWithPreStyle.setColor(colorSelectBox.getSelectObject()); + return colorWithPreStyle; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java b/designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java index 09ba3d3ce6..8091a78eb0 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java @@ -8,7 +8,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.chart.gui.style.ChartColorAdjustPane; +import com.fr.design.style.color.ColorAdjustPane; import com.fr.design.style.background.gradient.FixedGradientBar; import javax.swing.BorderFactory; @@ -38,7 +38,7 @@ public class ChartPreFillStylePane extends BasicBeanPane { private UIButtonGroup groupButton; - private ChartColorAdjustPane colorAdjustPane; + private ColorAdjustPane colorAdjustPane; private FixedGradientBar colorGradient; public ChartPreFillStylePane() { @@ -59,7 +59,7 @@ public class ChartPreFillStylePane extends BasicBeanPane { changeColorSetPane = new JPanel(cardLayout = new CardLayout()); changeColorSetPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); changeColorSetPane.add(colorGradient = new FixedGradientBar(4, 150), "gradient"); - changeColorSetPane.add(colorAdjustPane = new ChartColorAdjustPane(), "acc"); + changeColorSetPane.add(colorAdjustPane = new ColorAdjustPane(), "acc"); cardLayout.show(changeColorSetPane, "acc"); customPane.add(changeColorSetPane, BorderLayout.CENTER); @@ -124,9 +124,9 @@ public class ChartPreFillStylePane extends BasicBeanPane { if (colorList.isEmpty()) { List resultList = new ArrayList<>(); - Collections.addAll(resultList, ChartColorAdjustPane.DEFAULT_COLORS); + Collections.addAll(resultList, ColorAdjustPane.DEFAULT_COLORS); condition.setColorList(resultList); - colorAdjustPane.updateColor(ChartColorAdjustPane.DEFAULT_COLORS); + colorAdjustPane.updateColor(ColorAdjustPane.DEFAULT_COLORS); } else { colorAdjustPane.updateColor(colorList.toArray(new Color[colorList.size()])); } diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleManagerPane.java b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleManagerPane.java index 44b504ef3f..98f3862dcc 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleManagerPane.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleManagerPane.java @@ -2,7 +2,7 @@ package com.fr.design.module; import com.fr.base.ChartColorMatching; import com.fr.base.ChartPreStyleConfig; -import com.fr.design.chartx.component.combobox.ColorSchemeComboBox; +import com.fr.design.gui.icombobox.ColorSchemeComboBox; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java index a5a3238d5c..c92cfd857f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java @@ -69,7 +69,7 @@ public class VanChartColumnSeriesPane extends VanChartAbstractPlotSeriesPane { //边框(有圆角) protected VanChartBorderPane createDiffBorderPane() { - return new VanChartBorderWithRadiusPane(); + return new VanChartBorderWithRadiusPane(true); } private JPanel createSeriesStylePane(double[] row, double[] col) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomSeriesPane.java index d92e35506f..f8a920dbc7 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomSeriesPane.java @@ -1,5 +1,6 @@ package com.fr.van.chart.custom.style; +import com.fr.chart.base.AttrFillStyle; import com.fr.chart.chartattr.Chart; import com.fr.chartx.config.info.constant.ConfigType; import com.fr.design.layout.TableLayout; @@ -90,10 +91,15 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane { VanChartCustomPlot plot = (VanChartCustomPlot) chart.getPlot(); - if (fillStylePane != null){ - plot.setPlotFillStyle(fillStylePane.updateBean()); + if (fillStylePane != null) { + AttrFillStyle plotFillStyle = plot.getPlotFillStyle(); + if(plotFillStyle == null) { + plotFillStyle = new AttrFillStyle(); + plot.setPlotFillStyle(plotFillStyle); + } + fillStylePane.updateBean(plotFillStyle); } - if (seriesPane != null){ + if (seriesPane != null) { plotSeriesPane.updateBean(plot); } //系列埋点 diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java b/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java index 9ea26a5c5b..93d8b02898 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java @@ -29,6 +29,7 @@ import com.fr.van.chart.designer.component.VanChartLabelContentPane; import com.fr.van.chart.designer.component.VanChartRefreshTooltipContentPane; import com.fr.van.chart.designer.component.VanChartTooltipContentPane; import com.fr.van.chart.designer.style.HeatMapRangeLegendPane; +import com.fr.van.chart.designer.style.MapRangeLegendPane; import com.fr.van.chart.designer.style.VanChartPlotLegendPane; import com.fr.van.chart.designer.style.VanChartRangeLegendPane; import com.fr.van.chart.designer.style.VanChartStylePane; @@ -65,12 +66,12 @@ import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; -import java.awt.Component; import java.lang.reflect.Constructor; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.awt.Component; /** * Created by Mitisky on 16/3/1. @@ -128,8 +129,8 @@ public class PlotFactory { legendMap.put(VanChartMultiPiePlot.class, VanLegendPaneWidthOutHighlight.class); legendMap.put(VanChartScatterPlot.class, VanChartRangeLegendPane.class); legendMap.put(VanChartBubblePlot.class, VanChartRangeLegendPane.class); - legendMap.put(VanChartMapPlot.class, VanChartRangeLegendPane.class); - legendMap.put(VanChartDrillMapPlot.class, VanChartRangeLegendPane.class); + legendMap.put(VanChartMapPlot.class, MapRangeLegendPane.class); + legendMap.put(VanChartDrillMapPlot.class, MapRangeLegendPane.class); legendMap.put(VanChartHeatMapPlot.class, HeatMapRangeLegendPane.class); legendMap.put(VanChartWordCloudPlot.class, VanChartRangeLegendPane.class); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java index 8f3f83c5b4..2299c3585e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java @@ -1,159 +1,57 @@ package com.fr.van.chart.designer.component; -import com.fr.base.ChartColorMatching; -import com.fr.base.ChartPreStyleConfig; -import com.fr.base.Utils; import com.fr.chart.base.AttrFillStyle; -import com.fr.chart.base.ChartConstants; -import com.fr.chart.base.ChartUtils; -import com.fr.design.beans.BasicBeanPane; -import com.fr.design.chartx.component.combobox.ColorSchemeComboBox; -import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.icombobox.ColorSchemeComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayout; import com.fr.design.mainframe.DesignerBean; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.chart.gui.style.ChartColorAdjustPane; -import com.fr.design.style.background.gradient.FixedGradientBar; +import com.fr.design.mainframe.predefined.ui.detail.ColorFillStylePane; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.stable.StringUtils; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; import javax.swing.BorderFactory; import javax.swing.JPanel; -import java.util.List; import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Color; import java.awt.Component; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; /** * Created by mengao on 2017/8/17. */ -public class VanChartFillStylePane extends BasicBeanPane implements DesignerBean { +public class VanChartFillStylePane extends ColorFillStylePane implements DesignerBean { public static final String name = "vanChartFillStyle"; - protected ColorSchemeComboBox styleSelectBox; - protected JPanel customPane; - protected JPanel changeColorSetPane; - protected FixedGradientBar colorGradient; - - protected CardLayout cardLayout; - - protected ChartColorAdjustPane colorAdjustPane; - - private Color[] gradientColors; - private Color[] accColors; - - private boolean gradientSelect = false; - public VanChartFillStylePane() { - this.setLayout(new BorderLayout()); - - styleSelectBox = new ColorSchemeComboBox(); - customPane = new JPanel(FRGUIPaneFactory.createBorderLayout()) { - @Override - public Dimension getPreferredSize() { - if (!gradientSelect) { - return colorAdjustPane.getPreferredSize(); - } - return colorGradient.getPreferredSize(); - } - }; - - changeColorSetPane = new JPanel(cardLayout = new CardLayout()); - changeColorSetPane.add(colorGradient = new FixedGradientBar(4, 130), "gradient"); - gradientColors = new Color[]{Color.WHITE, FixedGradientBar.NEW_CHARACTER}; - changeColorSetPane.add(colorAdjustPane = new ChartColorAdjustPane(), "acc"); - accColors = ChartColorAdjustPane.DEFAULT_COLORS; - cardLayout.show(changeColorSetPane, "acc"); - customPane.add(changeColorSetPane, BorderLayout.CENTER); - initListener(); - initLayout(); + super(); DesignerContext.setDesignerBean(name, this); + } + protected void styleSelectBoxChange() { + getCustomPane().setVisible(getStyleSelectBox().getSelectedIndex() != 0); + super.styleSelectBoxChange(); } - private void initListener() { - colorAdjustPane.registerChangeListener(new UIObserverListener() { - @Override - public void doChange() { - accColors = colorAdjustPane.getColors(); - if (styleSelectBox.getSelectType() != ColorSchemeComboBox.SelectType.COMBINATION_COLOR) { - styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.COMBINATION_COLOR); - } - VanChartFillStylePane.this.revalidate(); - } - }); - colorGradient.registerChangeListener(new UIObserverListener() { - @Override - public void doChange() { - gradientColors[0] = colorGradient.getSelectColorPointBtnP1().getColorInner(); - gradientColors[1] = colorGradient.getSelectColorPointBtnP2().getColorInner(); - if (styleSelectBox.getSelectType() != ColorSchemeComboBox.SelectType.GRADATION_COLOR) { - styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.GRADATION_COLOR); - } - } - }); - styleSelectBox.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - switch (styleSelectBox.getSelectType()) { - case COMBINATION_COLOR: - colorAdjustPane.updateColor(accColors); - cardLayout.show(changeColorSetPane, "acc"); - gradientSelect = false; - break; - case GRADATION_COLOR: - colorGradient.updateColor(gradientColors[0], gradientColors[1]); - cardLayout.show(changeColorSetPane, "gradient"); - gradientSelect = true; - break; - default: - ColorSchemeComboBox.ColorInfo selectColorInfo = styleSelectBox.getSelectColorInfo(); - if (selectColorInfo.isGradient()) { - colorGradient.updateColor(selectColorInfo.getColors().get(0), selectColorInfo.getColors().get(1)); - cardLayout.show(changeColorSetPane, "gradient"); - gradientSelect = true; - } else { - colorAdjustPane.updateColor(selectColorInfo.getColors().toArray(new Color[]{})); - cardLayout.show(changeColorSetPane, "acc"); - gradientSelect = false; - } - break; - } - VanChartFillStylePane.this.revalidate(); - } - }); + protected ColorSchemeComboBox createColorSchemeComboBox() { + return new ColorSchemeComboBox(null, true); } protected void initLayout() { - this.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); - this.setLayout(new BorderLayout()); + super.initLayout(); this.add(getContentPane(), BorderLayout.CENTER); } protected JPanel getContentPane() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] columnSize = {f, e}; - double[] rowSize = {p, p, p}; - Component[][] components = new Component[][]{ - new Component[]{null, null}, - new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Match_Color_Scheme")), styleSelectBox}, - new Component[]{null, customPane}, + JPanel contentPane = super.getContentPane(); + contentPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); + return contentPane; + } + protected Component[][] contentPaneComponents() { + return new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Match_Color_Scheme")), getStyleSelectBox()}, + new Component[]{null, getCustomPane()}, }; - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); - panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); - return panel; } @Override @@ -161,107 +59,31 @@ public class VanChartFillStylePane extends BasicBeanPane implemen return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color"); } - @Override public void populateBean(AttrFillStyle condition) { - String fillStyleName = condition == null ? "" : condition.getFillStyleName(); - if (StringUtils.isBlank(fillStyleName) || !styleSelectBox.getItems().contains(fillStyleName)) {//兼容处理 - if (condition == null || condition.getColorStyle() == ChartConstants.COLOR_DEFAULT) { - styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.DEFAULT);//默认 - } else { - int colorStyle = condition.getColorStyle(); - if (colorStyle == ChartConstants.COLOR_GRADIENT) { - gradientColors[0] = condition.getColorIndex(0); - gradientColors[1] = condition.getColorIndex(1); - styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.GRADATION_COLOR); - } else { - int colorSize = condition.getColorSize(); - accColors = new Color[colorSize]; - for (int i = 0; i < colorSize; i++) { - accColors[i] = condition.getColorIndex(i); - } - styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.COMBINATION_COLOR); - } - } - } else { - styleSelectBox.setSelectedItem(fillStyleName); + if (condition.isPredefinedStyle()) { + getStyleSelectBox().setSelectType(ColorSchemeComboBox.SelectType.DEFAULT); + return; } + populateBean(condition.getColorFillStyle()); } - @Override - public AttrFillStyle updateBean() { - switch (styleSelectBox.getSelectType()) { - case COMBINATION_COLOR: - return updateCombinationColor(); - case GRADATION_COLOR: - return updateGradationColor(); - case DEFAULT: - return updateDefaultColor(); - default: - return updateNormalColor(); - } - } - - private AttrFillStyle updateCombinationColor() { - AttrFillStyle condition = new AttrFillStyle(); - condition.clearColors(); - condition.setColorStyle(ChartConstants.COLOR_ACC); - for (int i = 0, length = accColors.length; i < length; i++) { - condition.addFillColor(accColors[i]); + public void updateBean(AttrFillStyle attrFillStyle) { + if (getStyleSelectBox().getSelectedIndex() == 0) { + attrFillStyle.setPredefinedStyle(true); + return; } - condition.setCustomFillStyle(true); - return condition; - } - - private AttrFillStyle updateGradationColor() { - AttrFillStyle condition = new AttrFillStyle(); - condition.clearColors(); - condition.setColorStyle(ChartConstants.COLOR_GRADIENT); - Color start = gradientColors[0]; - Color end = gradientColors[1]; - condition.addFillColor(start); - condition.addFillColor(end); - condition.setCustomFillStyle(true); - return condition; - } - - private AttrFillStyle updateDefaultColor() { - AttrFillStyle condition = new AttrFillStyle(); - condition.clearColors(); - condition.setColorStyle(ChartConstants.COLOR_DEFAULT); - return condition; - } - - private AttrFillStyle updateNormalColor() { - ChartPreStyleConfig manager = ChartPreStyleConfig.getInstance(); - Object preStyle = manager.getPreStyle(styleSelectBox.getSelectedItem()); - if (preStyle instanceof ChartColorMatching) { - AttrFillStyle def = ChartUtils.chartColorMatching2AttrFillStyle((ChartColorMatching) preStyle); - def.setFillStyleName(Utils.objectToString(styleSelectBox.getSelectedItem())); - return def; - } else { - return updateModifyColor(); - } - } - - private AttrFillStyle updateModifyColor() { - AttrFillStyle condition = new AttrFillStyle(); - condition.clearColors(); - ColorSchemeComboBox.ColorInfo selectColorInfo = styleSelectBox.getSelectColorInfo(); - boolean isGradient = selectColorInfo.isGradient(); - List colors = selectColorInfo.getColors(); - condition.setColorList(colors); - condition.setCustomFillStyle(true); - condition.setColorStyle(isGradient ? ChartConstants.COLOR_GRADIENT : ChartConstants.COLOR_ACC); - return condition; + attrFillStyle.setPredefinedStyle(false); + attrFillStyle.setColorFillStyle(updateBean()); } /** * 刷新组件对象 */ public void refreshBeanElement() { - AttrFillStyle attrFillStyle = updateBean(); + AttrFillStyle attrFillStyle = new AttrFillStyle(); + updateBean(attrFillStyle); - styleSelectBox.refresh(); + getStyleSelectBox().refresh(); populateBean(attrFillStyle); GUICoreUtils.repaint(this); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartHtmlLabelPaneWithBackGroundLabel.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartHtmlLabelPaneWithBackGroundLabel.java deleted file mode 100644 index f9c9f7d490..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartHtmlLabelPaneWithBackGroundLabel.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.fr.van.chart.designer.component; - -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; - -import javax.swing.JPanel; -import java.awt.Component; - -public class VanChartHtmlLabelPaneWithBackGroundLabel extends VanChartHtmlLabelPane { - - protected JPanel createWidthAndHeightPane() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; - - JPanel panel = super.createWidthAndHeightPane(); - - Component[][] components = new Component[][]{ - new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Background")), panel}, - }; - - return TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{d, f}); - } -} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPane.java index 7fe05a3600..8586f21067 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPane.java @@ -13,6 +13,6 @@ public class VanChartLabelContentPane extends VanChartTooltipContentPane { } protected VanChartHtmlLabelPane createHtmlLabelPane() { - return new VanChartHtmlLabelPaneWithBackGroundLabel(); + return new VanChartHtmlLabelPane(); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPaneWithoutRichText.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPaneWithoutRichText.java new file mode 100644 index 0000000000..dafaef060c --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPaneWithoutRichText.java @@ -0,0 +1,361 @@ +package com.fr.van.chart.designer.component; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; +import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class VanChartLabelContentPaneWithoutRichText extends BasicBeanPane { + + private UIButtonGroup content; + + private ValueFormatPaneWithCheckBox valueFormatPane; + private PercentFormatPaneWithCheckBox percentFormatPane; + private CategoryNameFormatPaneWithCheckBox categoryNameFormatPane; + private SeriesNameFormatPaneWithCheckBox seriesNameFormatPane; + + //监控刷新时,自动数据点提示使用 + private ChangedValueFormatPaneWithCheckBox changedValueFormatPane; + private ChangedPercentFormatPaneWithCheckBox changedPercentFormatPane; + private UIButtonGroup styleButton; + private ChartTextAttrPane textAttrPane; + private JPanel centerPane; + private JPanel commonPanel; + private JPanel stylePanel; + private VanChartHtmlLabelPane htmlLabelPane; + + private VanChartStylePane parent; + private JPanel showOnPane; + + public VanChartLabelContentPaneWithoutRichText(VanChartStylePane parent, JPanel showOnPane) { + this.parent = parent; + this.showOnPane = showOnPane; + + this.setLayout(new BorderLayout()); + this.add(createLabelContentPane(), BorderLayout.CENTER); + } + + public ValueFormatPaneWithCheckBox getValueFormatPane() { + return valueFormatPane; + } + + public void setValueFormatPane(ValueFormatPaneWithCheckBox valueFormatPane) { + this.valueFormatPane = valueFormatPane; + } + + public PercentFormatPaneWithCheckBox getPercentFormatPane() { + return percentFormatPane; + } + + public void setPercentFormatPane(PercentFormatPaneWithCheckBox percentFormatPane) { + this.percentFormatPane = percentFormatPane; + } + + public CategoryNameFormatPaneWithCheckBox getCategoryNameFormatPane() { + return categoryNameFormatPane; + } + + public void setCategoryNameFormatPane(CategoryNameFormatPaneWithCheckBox categoryNameFormatPane) { + this.categoryNameFormatPane = categoryNameFormatPane; + } + + public SeriesNameFormatPaneWithCheckBox getSeriesNameFormatPane() { + return seriesNameFormatPane; + } + + public void setSeriesNameFormatPane(SeriesNameFormatPaneWithCheckBox seriesNameFormatPane) { + this.seriesNameFormatPane = seriesNameFormatPane; + } + + private JPanel createLabelContentPane() { + content = new UIButtonGroup<>(new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Common"), + Toolkit.i18nText("Fine-Design_Chart_Custom") + }); + + initFormatPane(parent, showOnPane); + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + + commonPanel = createCommonPanel(); + htmlLabelPane = createHtmlLabelPane(); + htmlLabelPane.setParent(parent); + stylePanel = createTextStylePane(); + centerPane = new JPanel(new CardLayout()) { + @Override + public Dimension getPreferredSize() { + if (content.getSelectedIndex() == 0) { + return commonPanel.getPreferredSize(); + } else { + return new Dimension(commonPanel.getPreferredSize().width, htmlLabelPane.getPreferredSize().height); + } + } + }; + centerPane.add(htmlLabelPane, Toolkit.i18nText("Fine-Design_Chart_Custom")); + centerPane.add(commonPanel, Toolkit.i18nText("Fine-Design_Chart_Common")); + + double[] column = {f, e}; + double[] row = {p, p, p}; + Component[][] components = new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(getLabelContentTitle()), content}, + new Component[]{null, centerPane}, + }; + initContentListener(); + JPanel paramsPanel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, column); + + JPanel contentPane = new JPanel(new BorderLayout()); + contentPane.add(paramsPanel, BorderLayout.CENTER); + contentPane.add(stylePanel, BorderLayout.SOUTH); + + return getLabelContentPane(contentPane); + } + + protected boolean hasTextStylePane() { + return true; + } + + private JPanel createTextStylePane() { + styleButton = new UIButtonGroup<>(new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Automatic"), + Toolkit.i18nText("Fine-Design_Chart_Custom") + }); + + textAttrPane = new ChartTextAttrPane() { + protected Component[][] getComponents(JPanel buttonPane) { + return new Component[][]{ + new Component[]{null, null}, + new Component[]{null, getFontNameComboBox()}, + new Component[]{null, buttonPane} + }; + } + }; + + JPanel buttonPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), styleButton); + + JPanel stylePanel = new JPanel(new BorderLayout()); + stylePanel.add(buttonPane, BorderLayout.CENTER); + stylePanel.add(textAttrPane, BorderLayout.SOUTH); + + initStyleButtonListener(); + + return stylePanel; + } + + private void initStyleButtonListener() { + styleButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + checkStylePane(); + } + }); + } + + private void checkStylePane() { + if (hasTextStylePane()) { + stylePanel.setVisible(true); + textAttrPane.setVisible(styleButton.getSelectedIndex() == 1); + } else { + stylePanel.setVisible(false); + } + } + + protected String getLabelContentTitle() { + return Toolkit.i18nText("Fine-Design_Report_Text"); + } + + protected JPanel getLabelContentPane(JPanel contentPane) { + return createTableLayoutPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Content"), contentPane); + } + + protected VanChartHtmlLabelPane createHtmlLabelPane() { + return new VanChartHtmlLabelPane(); + } + + protected JPanel createCommonPanel() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + + double[] columnSize = {f, p}; + double[] rowSize = getRowSize(p); + + return TableLayoutHelper.createTableLayoutPane(getPaneComponents(), rowSize, columnSize); + } + + protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { + categoryNameFormatPane = new CategoryNameFormatPaneWithCheckBox(parent, showOnPane); + seriesNameFormatPane = new SeriesNameFormatPaneWithCheckBox(parent, showOnPane); + valueFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane); + percentFormatPane = new PercentFormatPaneWithCheckBox(parent, showOnPane); + } + + protected JPanel createTableLayoutPaneWithTitle(String title, JPanel panel) { + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(title, panel); + } + + protected double[] getRowSize(double p) { + return new double[]{p, p, p, p}; + } + + protected Component[][] getPaneComponents() { + return new Component[][]{ + new Component[]{categoryNameFormatPane, null}, + new Component[]{seriesNameFormatPane, null}, + new Component[]{valueFormatPane, null}, + new Component[]{percentFormatPane, null}, + }; + } + + private void initContentListener() { + content.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkCardPane(); + } + }); + } + + + private void checkCardPane() { + CardLayout cardLayout = (CardLayout) centerPane.getLayout(); + if (content.getSelectedIndex() == 1) { + cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Custom")); + if (isDirty()) { + setCustomFormatterText(); + setDirty(false); + } + } else { + cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Common")); + } + } + + protected void setCustomFormatterText() { + htmlLabelPane.setCustomFormatterText(updateBean().getFormatterTextFromCommon()); + } + + public boolean isDirty() { + return categoryNameFormatPane.isDirty() || seriesNameFormatPane.isDirty() || valueFormatPane.isDirty() || percentFormatPane.isDirty() + || (changedValueFormatPane != null && changedValueFormatPane.isDirty()) || (changedValueFormatPane != null && changedPercentFormatPane.isDirty()); + } + + public void setDirty(boolean isDirty) { + categoryNameFormatPane.setDirty(isDirty); + seriesNameFormatPane.setDirty(isDirty); + valueFormatPane.setDirty(isDirty); + percentFormatPane.setDirty(isDirty); + + if (changedValueFormatPane != null) { + changedValueFormatPane.setDirty(isDirty); + } + if (changedPercentFormatPane != null) { + changedPercentFormatPane.setDirty(isDirty); + } + } + + @Override + protected String title4PopupWindow() { + return ""; + } + + + @Override + public void populateBean(AttrTooltipContent attrTooltipContent) { + if (attrTooltipContent == null) { + return; + } + + content.setSelectedIndex(attrTooltipContent.isCommon() ? 0 : 1); + + populateFormatPane(attrTooltipContent); + + htmlLabelPane.populate(attrTooltipContent.getHtmlLabel()); + if (!attrTooltipContent.isCommon()) { + setDirty(false); + } + if (hasTextStylePane()) { + this.styleButton.setSelectedIndex(attrTooltipContent.isCustom() ? 1 : 0); + this.textAttrPane.populate(attrTooltipContent.getTextAttr()); + } + checkCardPane(); + checkStylePane(); + } + + protected void populateFormatPane(AttrTooltipContent attrTooltipContent) { + categoryNameFormatPane.populate(attrTooltipContent.getCategoryFormat()); + seriesNameFormatPane.populate(attrTooltipContent.getSeriesFormat()); + valueFormatPane.populate(attrTooltipContent.getValueFormat()); + percentFormatPane.populate(attrTooltipContent.getPercentFormat()); + + if (changedValueFormatPane != null) { + changedValueFormatPane.populate(attrTooltipContent.getChangedValueFormat()); + } + if (changedPercentFormatPane != null) { + changedPercentFormatPane.populate(attrTooltipContent.getChangedPercentFormat()); + } + } + + public AttrTooltipContent updateBean() { + AttrTooltipContent attrTooltipContent = createAttrTooltip(); + + attrTooltipContent.setCommon(content.getSelectedIndex() == 0); + + updateFormatPane(attrTooltipContent); + + updateFormatsWithPaneWidth(attrTooltipContent); + + htmlLabelPane.update(attrTooltipContent.getHtmlLabel()); + + if (hasTextStylePane()) { + attrTooltipContent.setCustom(styleButton.getSelectedIndex() == 1); + attrTooltipContent.setTextAttr(this.textAttrPane.update()); + } + + return attrTooltipContent; + } + + protected AttrTooltipContent createAttrTooltip() { + return new AttrTooltipContent(); + } + + protected void updateFormatPane(AttrTooltipContent attrTooltipContent) { + categoryNameFormatPane.update(attrTooltipContent.getCategoryFormat()); + seriesNameFormatPane.update(attrTooltipContent.getSeriesFormat()); + valueFormatPane.update(attrTooltipContent.getValueFormat()); + percentFormatPane.update(attrTooltipContent.getPercentFormat()); + + if (changedValueFormatPane != null) { + changedValueFormatPane.update(attrTooltipContent.getChangedValueFormat()); + } + if (changedPercentFormatPane != null) { + changedPercentFormatPane.update(attrTooltipContent.getChangedPercentFormat()); + } + } + + private void updateFormatsWithPaneWidth(AttrTooltipContent attrTooltipContent) { + int paneWidth = seriesNameFormatPane.getWidth(); + if (paneWidth == 0) { + attrTooltipContent.getSeriesFormat().setEnable(false); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRefreshTooltipContentPane.java index 7ecb797d6a..09e208cc10 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRefreshTooltipContentPane.java @@ -22,10 +22,6 @@ public class VanChartRefreshTooltipContentPane extends VanChartTooltipContentPan return new double[]{p,p,p,p,p,p}; } - protected boolean supportRichEditor() { - return false; - } - @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { super.initFormatPane(parent, showOnPane); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorDialog.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorDialog.java deleted file mode 100644 index 2cc0463f92..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorDialog.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.fr.van.chart.designer.component; - -import com.fr.design.dialog.BasicDialog; -import com.fr.design.dialog.BasicPane; -import com.fr.design.i18n.Toolkit; -import com.fr.design.utils.gui.GUICoreUtils; - -import java.awt.Dimension; -import java.awt.Frame; - -public class VanChartRichEditorDialog extends BasicDialog { - - public static final Dimension DEFAULT = new Dimension(660, 600); - - public VanChartRichEditorDialog(Frame parent, BasicPane pane) { - super(parent, pane); - - this.setTitle(Toolkit.i18nText("Fine-Design_Report_RichTextEditor")); - this.setBasicDialogSize(DEFAULT); - GUICoreUtils.centerWindow(this); - this.setResizable(false); - } - - protected void applyEnterAction() { - - } - - public void checkValid() { - - } -} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java index b2eab2df5a..8578059a98 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java @@ -51,15 +51,6 @@ public class VanChartTooltipContentPane extends BasicBeanPane content; private CategoryNameFormatPaneWithCheckBox categoryNameFormatPane; @@ -231,19 +222,11 @@ public class VanChartTooltipContentPane extends BasicBeanPane(new String[]{ - Toolkit.i18nText("Fine-Design_Chart_Common"), - Toolkit.i18nText("Fine-Design_Chart_Rich_Text"), - Toolkit.i18nText("Fine-Design_Chart_Custom") - }); - } else { - content = new UIButtonGroup<>(new String[]{ - Toolkit.i18nText("Fine-Design_Chart_Common"), - Toolkit.i18nText("Fine-Design_Chart_Custom") - }); - } + content = new UIButtonGroup<>(new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Common"), + Toolkit.i18nText("Fine-Design_Chart_Rich_Text"), + Toolkit.i18nText("Fine-Design_Chart_Custom") + }); Component[][] components = new Component[][]{ new Component[]{null, null}, @@ -365,13 +318,8 @@ public class VanChartTooltipContentPane extends BasicBeanPane pane = VanChartRichEditorPane.createRichEditorPane(richText); - BasicDialog dialog = new VanChartRichEditorDialog(new JFrame(), pane); + BasicDialog dialog = pane.showWindow(new JFrame()); pane.populate(VanChartRichEditorPane.getRichEditorModel(richText)); @@ -507,46 +455,20 @@ public class VanChartTooltipContentPane extends BasicBeanPane(); + paneList = new ArrayList<>(); initList(); @@ -86,7 +86,7 @@ public class VanChartBackgroundPane extends BasicPane { @Override public void itemStateChanged(ItemEvent e) { - cardlayout.show(centerPane, (String)typeComboBox.getSelectedItem()); + cardlayout.show(centerPane, (String) typeComboBox.getSelectedItem()); fireStateChanged(); } }); @@ -97,7 +97,7 @@ public class VanChartBackgroundPane extends BasicPane { protected Component[][] getPaneComponents() { shadow = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_On"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Off")}, new Boolean[]{true, false}); - return new Component[][]{ + return new Component[][]{ new Component[]{null, null}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Fill")), typeComboBox}, new Component[]{null, centerPane}, @@ -123,13 +123,14 @@ public class VanChartBackgroundPane extends BasicPane { if (e == null) { e = new ChangeEvent(this); } - ((ChangeListener)listeners[i + 1]).stateChanged(e); + ((ChangeListener) listeners[i + 1]).stateChanged(e); } } } /** * 返回标题 + * * @return 标题 */ public String title4PopupWindow() { @@ -137,16 +138,20 @@ public class VanChartBackgroundPane extends BasicPane { } public void populate(GeneralInfo attr) { - if(attr == null) { + if (attr == null) { return; } - Background background = attr.getBackground(); double alpha = attr.getAlpha() * ALPHA_V; transparent.populateBean(alpha); - if(shadow != null){ + if (shadow != null) { shadow.setSelectedIndex(attr.isShadow() == true ? 0 : 1); } - for (int i = 0; i < paneList.size(); i++) { + populateBackground(attr, 0); + } + + public void populateBackground(GeneralInfo attr, int begin) { + Background background = attr.getBackground(); + for (int i = begin; i < paneList.size(); i++) { BackgroundQuickPane pane = paneList.get(i); if (pane.accept(background)) { pane.populateBean(background); @@ -160,13 +165,17 @@ public class VanChartBackgroundPane extends BasicPane { if (attr == null) { attr = new GeneralInfo(); } - attr.setBackground(paneList.get(typeComboBox.getSelectedIndex()).updateBean()); - if(attr.getBackground() instanceof ImageBackground){ - ((ImageBackground) attr.getBackground()).setLayout(Constants.IMAGE_EXTEND); - } + updateBackground(attr); attr.setAlpha((float) (transparent.updateBean() / ALPHA_V)); - if(shadow != null){ + if (shadow != null) { attr.setShadow(shadow.getSelectedIndex() == 0); } } + + public void updateBackground(GeneralInfo attr) { + attr.setBackground(paneList.get(typeComboBox.getSelectedIndex()).updateBean()); + if (attr.getBackground() instanceof ImageBackground) { + ((ImageBackground) attr.getBackground()).setLayout(Constants.IMAGE_EXTEND); + } + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundPaneWithAutoColor.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundPaneWithAutoColor.java new file mode 100644 index 0000000000..cd5d26d4a5 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundPaneWithAutoColor.java @@ -0,0 +1,49 @@ +package com.fr.van.chart.designer.component.background; + +import com.fr.chart.chartglyph.GeneralInfo; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.NullBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.VanChartGradientPane; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-11 + */ +public class VanChartBackgroundPaneWithAutoColor extends VanChartBackgroundPane { + + private static final int AUTO = 0; + + public VanChartBackgroundPaneWithAutoColor() { + super(); + } + + protected void initList() { + paneList.add(new NullBackgroundQuickPane() { + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Automatic"); + } + }); + paneList.add(new NullBackgroundQuickPane()); + paneList.add(new ColorBackgroundQuickPane()); + paneList.add(new VanChartGradientPane()); + } + + public void populateBackground(GeneralInfo attr, int begin) { + if (attr.isAutoBackground()) { + typeComboBox.setSelectedIndex(AUTO); + return; + } + super.populateBackground(attr, begin + 1); + } + + public void updateBackground(GeneralInfo attr) { + if (typeComboBox.getSelectedIndex() == AUTO) { + attr.setAutoBackground(true); + return; + } + attr.setAutoBackground(false); + super.updateBackground(attr); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundPaneWithPreStyle.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundPaneWithPreStyle.java new file mode 100644 index 0000000000..fbb66d2e3f --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundPaneWithPreStyle.java @@ -0,0 +1,51 @@ +package com.fr.van.chart.designer.component.background; + +import com.fr.chart.base.BackgroundWithPreStyle; +import com.fr.chart.chartglyph.GeneralInfo; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.ImageBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.NullBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.VanChartGradientPane; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-08 + */ +public class VanChartBackgroundPaneWithPreStyle extends VanChartBackgroundPane { + + private static final int PREDEFINED_STYLE = 0; + + @Override + protected void initList() { + paneList.add(new NullBackgroundQuickPane() { + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Predefined"); + } + }); + paneList.add(new NullBackgroundQuickPane()); + paneList.add(new ColorBackgroundQuickPane()); + paneList.add(new ImageBackgroundQuickPane(false)); + paneList.add(new VanChartGradientPane()); + } + + public void populateBackground(GeneralInfo attr, int begin) { + BackgroundWithPreStyle backgroundWithPreStyle = attr.getBackgroundWithPreStyle(); + if (backgroundWithPreStyle.isPredefinedStyle()) { + typeComboBox.setSelectedIndex(PREDEFINED_STYLE); + return; + } + super.populateBackground(attr, begin + 1); + } + + public void updateBackground(GeneralInfo attr) { + if (typeComboBox.getSelectedIndex() == PREDEFINED_STYLE) { + attr.getBackgroundWithPreStyle().setPredefinedStyle(true); + return; + } + attr.getBackgroundWithPreStyle().setPredefinedStyle(false); + super.updateBackground(attr); + } + +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundWithOutImagePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundWithOutImagePane.java index e457f8c032..cf95305476 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundWithOutImagePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundWithOutImagePane.java @@ -2,6 +2,7 @@ package com.fr.van.chart.designer.component.background; import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane; import com.fr.design.mainframe.backgroundpane.NullBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.VanChartGradientPane; /** * 图表 属性表.背景设置 界面.(包括 无, 颜色, 渐变)+开启阴影 diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderPane.java index 4514e39b9c..94f66b63a1 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderPane.java @@ -4,6 +4,7 @@ package com.fr.van.chart.designer.component.border; import com.fr.chart.base.AttrBorder; import com.fr.chart.chartglyph.GeneralInfo; import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; @@ -17,47 +18,105 @@ import com.fr.van.chart.designer.TableLayout4VanChartHelper; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; //线型 + 颜色 public class VanChartBorderPane extends BasicPane { private static final long serialVersionUID = -7770029552989609464L; + + private UIButtonGroup autoButton; protected LineComboBox currentLineCombo; protected ColorSelectBox currentLineColorPane; + protected JPanel colorPanel; + public VanChartBorderPane() { + this(false); + } + + public VanChartBorderPane(boolean hasAuto) { + if (hasAuto) { + autoButton = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Automatic"), + Toolkit.i18nText("Fine-Design_Chart_Custom")}); + initListener(); + } initComponents(); + initColorPanel(); + initContent(); } protected void initComponents() { currentLineCombo = new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART); currentLineColorPane = new ColorSelectBox(100); + } + + protected void initContent() { double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double[] columnSize = {f, e}; Component[][] components = getUseComponent(); JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, getRowSize(), columnSize); this.setLayout(new BorderLayout()); - this.add(panel,BorderLayout.CENTER); + this.add(panel, BorderLayout.CENTER); + } + + protected void initColorPanel() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + double[] columnSize = {f, e}; + double[] rowSize; + UILabel colorLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Color")); + Component[][] components; + if (autoButton != null) { + rowSize = new double[]{p, p}; + components = new Component[][]{ + new Component[]{colorLabel, autoButton}, + new Component[]{null, currentLineColorPane} + }; + } else { + rowSize = new double[]{p}; + components = new Component[][]{ + new Component[]{colorLabel, currentLineColorPane} + }; + } + colorPanel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); + } + + protected double[] getRowSize() { + double p = TableLayout.PREFERRED; + return new double[]{p, p, p, p}; } protected Component[][] getUseComponent() { UILabel lineStyleLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")); - UILabel colorLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Color")); return new Component[][]{ - new Component[]{null,null}, + new Component[]{null, null}, new Component[]{lineStyleLabel, UIComponentUtils.wrapWithBorderLayoutPane(currentLineCombo)}, - new Component[]{colorLabel, currentLineColorPane}, + new Component[]{colorPanel, null}, }; } - protected double[] getRowSize() { - double p = TableLayout.PREFERRED; - return new double[]{p, p, p, p}; + private void initListener() { + autoButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkPreButton(); + } + }); + } + + private void checkPreButton() { + currentLineColorPane.setVisible(autoButton.getSelectedIndex() == 1); + currentLineColorPane.setPreferredSize(autoButton.getSelectedIndex() == 1 ? new Dimension(0, 20) : new Dimension(0, 0)); } /** * 标题 + * * @return 标题 */ public String title4PopupWindow() { @@ -65,44 +124,73 @@ public class VanChartBorderPane extends BasicPane { } public void populate(GeneralInfo attr) { - if(attr == null) { + if (attr == null) { return; } - currentLineCombo.setSelectedLineStyle(attr.getBorderStyle()); - currentLineColorPane.setSelectObject(attr.getBorderColor()); + if (currentLineCombo != null) { + currentLineCombo.setSelectedLineStyle(attr.getBorderStyle()); + } + if (currentLineColorPane != null) { + currentLineColorPane.setSelectObject(attr.getBorderColor()); + } } public void update(GeneralInfo attr) { - if(attr == null) { + if (attr == null) { attr = new GeneralInfo(); } - attr.setBorderStyle(currentLineCombo.getSelectedLineStyle()); - attr.setBorderColor(currentLineColorPane.getSelectObject()); + if (currentLineCombo != null) { + attr.setBorderStyle(currentLineCombo.getSelectedLineStyle()); + } + if (currentLineColorPane != null) { + attr.setBorderColor(currentLineColorPane.getSelectObject()); + } } - public void update(AttrBorder attrBorder){ - if(attrBorder == null){ + public void update(AttrBorder attrBorder) { + if (attrBorder == null) { return; } - attrBorder.setBorderStyle(currentLineCombo.getSelectedLineStyle()); - attrBorder.setBorderColor(currentLineColorPane.getSelectObject()); + if (autoButton != null) { + attrBorder.setAutoColor(autoButton.getSelectedIndex() == 0); + } + if (currentLineCombo != null) { + attrBorder.setBorderStyle(currentLineCombo.getSelectedLineStyle()); + } + if (currentLineColorPane != null) { + attrBorder.setBorderColor(currentLineColorPane.getSelectObject()); + } } public void populate(AttrBorder attr) { - if(attr == null) { + if (attr == null) { return; } - currentLineCombo.setSelectedLineStyle(attr.getBorderStyle()); - currentLineColorPane.setSelectObject(attr.getBorderColor()); + if (autoButton != null) { + autoButton.setSelectedIndex(attr.isAutoColor() ? 0 : 1); + checkPreButton(); + } + if (currentLineCombo != null) { + currentLineCombo.setSelectedLineStyle(attr.getBorderStyle()); + } + if (currentLineColorPane != null) { + currentLineColorPane.setSelectObject(attr.getBorderColor()); + } } public AttrBorder update() { AttrBorder attr = new AttrBorder(); - - attr.setBorderStyle(currentLineCombo.getSelectedLineStyle()); - attr.setBorderColor(currentLineColorPane.getSelectObject()); + if (autoButton != null) { + attr.setAutoColor(autoButton.getSelectedIndex() == 0); + } + if (currentLineCombo != null) { + attr.setBorderStyle(currentLineCombo.getSelectedLineStyle()); + } + if (currentLineColorPane != null) { + attr.setBorderColor(currentLineColorPane.getSelectObject()); + } return attr; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderPaneWithPreStyle.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderPaneWithPreStyle.java new file mode 100644 index 0000000000..790082ae42 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderPaneWithPreStyle.java @@ -0,0 +1,57 @@ +package com.fr.van.chart.designer.component.border; + +import com.fr.chart.chartglyph.GeneralInfo; +import com.fr.design.gui.icombobox.LineComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.chart.gui.style.ColorSelectBoxWithPreStyle; +import com.fr.design.utils.gui.UIComponentUtils; +import com.fr.design.widget.FRWidgetFactory; +import com.fr.stable.CoreConstants; + +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-07 + */ +public class VanChartBorderPaneWithPreStyle extends VanChartBorderPane { + + private ColorSelectBoxWithPreStyle colorSelectBoxWithPreStyle; + + public VanChartBorderPaneWithPreStyle() { + super(); + } + + protected void initComponents() { + currentLineCombo = new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART); + colorSelectBoxWithPreStyle = new ColorSelectBoxWithPreStyle(100); + } + + protected Component[][] getUseComponent() { + UILabel lineStyleLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")); + + return new Component[][]{ + new Component[]{null, null}, + new Component[]{lineStyleLabel, UIComponentUtils.wrapWithBorderLayoutPane(currentLineCombo)}, + new Component[]{colorSelectBoxWithPreStyle, null}, + }; + } + + public void populate(GeneralInfo attr) { + super.populate(attr); + if (attr == null) { + return; + } + colorSelectBoxWithPreStyle.populate(attr.getColorWithPreStyle()); + } + + public void update(GeneralInfo attr) { + super.update(attr); + if (attr == null) { + attr = new GeneralInfo(); + } + attr.setColorWithPreStyle(colorSelectBoxWithPreStyle.update()); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithAlphaPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithAlphaPane.java index e2ff67c911..724cefe921 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithAlphaPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithAlphaPane.java @@ -2,7 +2,6 @@ package com.fr.van.chart.designer.component.border; import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.ilable.UILabel; - import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.plugin.chart.VanChartAttrHelper; @@ -19,12 +18,23 @@ import java.awt.Component; public class VanChartBorderWithAlphaPane extends VanChartBorderPane{ private UINumberDragPane transparent; + public VanChartBorderWithAlphaPane() { + super(); + } + + public VanChartBorderWithAlphaPane(boolean hasAuto) { + super(hasAuto); + } + @Override protected void initComponents() { + super.initComponents(); transparent = new UINumberDragPane(0,100); - this.add(new JSeparator(), BorderLayout.SOUTH); + } - super.initComponents(); + protected void initContent() { + this.add(new JSeparator(), BorderLayout.SOUTH); + super.initContent(); } @Override @@ -35,7 +45,7 @@ public class VanChartBorderWithAlphaPane extends VanChartBorderPane{ FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")), UIComponentUtils.wrapWithBorderLayoutPane(currentLineCombo) }, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")),currentLineColorPane}, + new Component[]{colorPanel, null}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alpha")), transparent} }; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithRadiusPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithRadiusPane.java index fabf1e669c..d6fdf9c699 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithRadiusPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithRadiusPane.java @@ -19,15 +19,28 @@ public class VanChartBorderWithRadiusPane extends VanChartBorderPane { private static final long serialVersionUID = -3937853702118283803L; private UISpinner radius; + public VanChartBorderWithRadiusPane() { + super(); + } + + public VanChartBorderWithRadiusPane(boolean hasAuto) { + super(hasAuto); + } + public UISpinner getRadius() { return radius; } @Override protected void initComponents() { + super.initComponents(); radius = new UISpinner(0,1000,1,0); + } + + @Override + protected void initContent() { this.add(new JSeparator(), BorderLayout.SOUTH); - super.initComponents(); + super.initContent(); } @Override @@ -38,7 +51,7 @@ public class VanChartBorderWithRadiusPane extends VanChartBorderPane { FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")), UIComponentUtils.wrapWithBorderLayoutPane(currentLineCombo) }, - new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")),currentLineColorPane}, + new Component[]{colorPanel, null}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Radius")),radius} } ; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/GaugeLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/GaugeLabelContentPane.java index 7369bc5aff..6459ef480b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/GaugeLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/GaugeLabelContentPane.java @@ -2,7 +2,7 @@ package com.fr.van.chart.designer.component.label; import com.fr.design.i18n.Toolkit; -import com.fr.van.chart.designer.component.VanChartTooltipContentPane; +import com.fr.van.chart.designer.component.VanChartLabelContentPaneWithoutRichText; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -10,7 +10,7 @@ import javax.swing.JPanel; /** * Created by mengao on 2017/8/13. */ -public class GaugeLabelContentPane extends VanChartTooltipContentPane { +public class GaugeLabelContentPane extends VanChartLabelContentPaneWithoutRichText { public GaugeLabelContentPane(VanChartStylePane parent, JPanel showOnPane) { super(parent, showOnPane); @@ -24,10 +24,6 @@ public class GaugeLabelContentPane extends VanChartTooltipContentPane { return contentPane; } - protected boolean supportRichEditor() { - return false; - } - protected boolean hasTextStylePane() { return false; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/RefreshTooltipContentPaneWithOutSeries.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/RefreshTooltipContentPaneWithOutSeries.java index ca7479cc05..309bf244a0 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/RefreshTooltipContentPaneWithOutSeries.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/RefreshTooltipContentPaneWithOutSeries.java @@ -17,10 +17,6 @@ public class RefreshTooltipContentPaneWithOutSeries extends TooltipContentPaneWi super(null, showOnPane); } - protected boolean supportRichEditor() { - return false; - } - @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { super.initFormatPane(parent, showOnPane); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartLabelConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartLabelConditionPane.java index 706a9cb75c..deffbcabe6 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartLabelConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartLabelConditionPane.java @@ -3,7 +3,6 @@ package com.fr.van.chart.designer.other.condition.item; import com.fr.chart.base.DataSeriesCondition; import com.fr.chart.chartattr.Plot; import com.fr.design.condition.ConditionAttributesPane; - import com.fr.plugin.chart.base.AttrLabel; import com.fr.van.chart.designer.style.label.VanChartPlotLabelNoCheckPane; import com.fr.van.chart.designer.style.label.VanChartPlotLabelPane; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/HeatMapRangeLegendPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/HeatMapRangeLegendPane.java index cb316dffeb..d77a106a29 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/HeatMapRangeLegendPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/HeatMapRangeLegendPane.java @@ -7,7 +7,7 @@ import javax.swing.JPanel; * 只有渐变色图例和区域段图例. * 没有主题配色 */ -public class HeatMapRangeLegendPane extends VanChartRangeLegendPane { +public class HeatMapRangeLegendPane extends MapRangeLegendPane { public HeatMapRangeLegendPane() { } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/MapRangeLegendPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/MapRangeLegendPane.java new file mode 100644 index 0000000000..7c88c088a2 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/MapRangeLegendPane.java @@ -0,0 +1,25 @@ +package com.fr.van.chart.designer.style; + +import com.fr.van.chart.designer.component.background.VanChartBackgroundPane; +import com.fr.van.chart.designer.component.background.VanChartBackgroundPaneWithAutoColor; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-11 + */ +public class MapRangeLegendPane extends VanChartRangeLegendPane { + + public MapRangeLegendPane() { + super(); + } + + public MapRangeLegendPane(VanChartStylePane parent) { + super(parent); + } + + @Override + protected VanChartBackgroundPane creatBackgroundPane(){ + return new VanChartBackgroundPaneWithAutoColor(); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java index 241a93ea09..ef1e8573a5 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java @@ -14,6 +14,7 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithPreStyle; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.plugin.chart.attr.VanChartLegend; import com.fr.plugin.chart.type.LayoutType; @@ -21,6 +22,7 @@ import com.fr.stable.Constants; import com.fr.van.chart.designer.PlotFactory; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartFloatPositionPane; +import com.fr.van.chart.designer.component.background.VanChartBackgroundPane; import com.fr.van.chart.designer.component.background.VanChartBackgroundWithOutImagePane; import com.fr.van.chart.designer.component.border.VanChartBorderWithRadiusPane; @@ -54,7 +56,7 @@ public class VanChartPlotLegendPane extends BasicPane { private ChartTextAttrPane textAttrPane; private VanChartBorderWithRadiusPane borderPane; - private VanChartBackgroundWithOutImagePane backgroundPane; + private VanChartBackgroundPane backgroundPane; private UIButtonGroup location; private UIToggleButton customFloatPositionButton; private UIButtonGroup layoutButton; @@ -135,7 +137,7 @@ public class VanChartPlotLegendPane extends BasicPane { protected JPanel createLegendPaneWithoutHighlight() { borderPane = new VanChartBorderWithRadiusPane(); - backgroundPane = new VanChartBackgroundWithOutImagePane(); + backgroundPane = creatBackgroundPane(); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; @@ -153,9 +155,13 @@ public class VanChartPlotLegendPane extends BasicPane { return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } + protected VanChartBackgroundPane creatBackgroundPane(){ + return new VanChartBackgroundWithOutImagePane(); + } + protected JPanel createLegendPane() { borderPane = new VanChartBorderWithRadiusPane(); - backgroundPane = new VanChartBackgroundWithOutImagePane(); + backgroundPane = creatBackgroundPane(); highlightPane = createHighlightPane(); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); @@ -281,7 +287,7 @@ public class VanChartPlotLegendPane extends BasicPane { } private JPanel createTitleStylePane() { - textAttrPane = new ChartTextAttrPane(); + textAttrPane = new ChartTextAttrPaneWithPreStyle(); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), textAttrPane); } @@ -382,7 +388,7 @@ public class VanChartPlotLegendPane extends BasicPane { legend = new VanChartLegend(); } legend.setLegendVisible(isLegendVisible.isSelected()); - legend.setFRFont(textAttrPane.updateFRFont()); + textAttrPane.update(legend.getTextAttr()); borderPane.update(legend); backgroundPane.update(legend); @@ -408,7 +414,7 @@ public class VanChartPlotLegendPane extends BasicPane { public void populateBean(VanChartLegend legend) { if (legend != null) { isLegendVisible.setSelected(legend.isLegendVisible()); - textAttrPane.populate(legend.getFRFont()); + textAttrPane.populate(legend.getTextAttr()); borderPane.populate(legend); backgroundPane.populate(legend); if (!legend.isFloating()) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java index 3d5042e6ab..d5dba9df85 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java @@ -15,7 +15,7 @@ import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.PaneTitleConstants; -import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithPreStyle; import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.plugin.chart.attr.VanChartTitle; @@ -54,7 +54,7 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { private JPanel titlePane; private TinyFormulaPane titleContent; - private ChartTextAttrPane textAttrPane; + private ChartTextAttrPaneWithPreStyle textAttrPane; private UIButtonGroup alignmentPane; private VanChartBackgroundWithOutShadowWithRadiusPane backgroundPane; private UIToggleButton useHtml; @@ -171,7 +171,7 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { } private JPanel createTitleStylePane() { - textAttrPane = new ChartTextAttrPane(); + textAttrPane = new ChartTextAttrPaneWithPreStyle(); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), textAttrPane); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java index be2c7d8a5f..3a5904d703 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java @@ -20,7 +20,8 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; -import com.fr.design.style.color.ColorSelectBox; +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithPreStyle; +import com.fr.design.mainframe.chart.gui.style.ColorSelectBoxWithPreStyle; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.plugin.chart.attr.axis.VanChartAxis; @@ -79,7 +80,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { private JPanel labelGapValuePane; protected LineComboBox axisLineStyle; - protected ColorSelectBox axisLineColor; + protected ColorSelectBoxWithPreStyle axisLineColor; protected UIButtonGroup mainTick; protected UIButtonGroup secondTick; @@ -327,24 +328,16 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { } protected ChartTextAttrPane getChartTextAttrPane() { - return new ChartTextAttrPane() { - - @Override - protected JPanel getContentPane(JPanel buttonPane) { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; - double[] columnSize = {f, e}; - double[] rowSize = {p, p, p}; - - return TableLayout4VanChartHelper.createGapTableLayoutPane(getComponents(buttonPane), rowSize, columnSize); + return new ChartTextAttrPaneWithPreStyle() { + protected double getEdithAreaWidth() { + return TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; } }; } protected JPanel createLineStylePane(double[] row, double[] col) { axisLineStyle = createLineComboBox(); - axisLineColor = new ColorSelectBox(100); + axisLineColor = new ColorSelectBoxWithPreStyle(100); String[] strings = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")}; AxisTickLineType[] values = new AxisTickLineType[]{AxisTickLineType.TICK_LINE_OUTSIDE, AxisTickLineType.TICK_LINE_NONE}; mainTick = new UIButtonGroup(strings, values); @@ -362,7 +355,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { return new Component[][]{ new Component[]{null, null}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Type")), axisLineStyle}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")), axisLineColor}, + new Component[]{axisLineColor, null}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Main_Graduation_Line")), mainTick}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Second_Graduation_Line")), secondTick}, }; @@ -656,7 +649,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { axisLineStyle.setSelectedLineStyle(axis.getAxisStyle()); } if (axisLineColor != null) { - axisLineColor.setSelectObject(axis.getAxisColor()); + axisLineColor.populate(axis.getLineColorWithPreStyle()); } if (mainTick != null) { mainTick.setSelectedItem(axis.getMainTickLine()); @@ -796,7 +789,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { axis.setAxisStyle(axisLineStyle.getSelectedLineStyle()); } if (axisLineColor != null) { - axis.setAxisColor(axisLineColor.getSelectObject()); + axis.setLineColorWithPreStyle(axisLineColor.update()); } if (mainTick != null) { axis.setMainTickLine(mainTick.getSelectedItem()); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java index 39c6321a2b..60c77734c1 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java @@ -8,6 +8,7 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithAuto; +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithPreStyle; import com.fr.design.style.color.ColorSelectBox; import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.axis.VanChartGaugeAxis; @@ -102,7 +103,7 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane { if (isMulti(gaugeStyle)) { return new ChartTextAttrPaneWithAuto(FontAutoType.SIZE_AND_COLOR); } else { - return new ChartTextAttrPane(); + return new ChartTextAttrPaneWithPreStyle(); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/radar/VanChartRadarXAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/radar/VanChartRadarXAxisPane.java index c69fc9b52e..a280bc3942 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/radar/VanChartRadarXAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/radar/VanChartRadarXAxisPane.java @@ -41,7 +41,7 @@ public class VanChartRadarXAxisPane extends VanChartBaseAxisPane { return new Component[][]{ new Component[]{null,null} , new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Type")),axisLineStyle} , - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")),axisLineColor}, + new Component[]{axisLineColor, null}, }; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/radar/VanChartRadarYAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/radar/VanChartRadarYAxisPane.java index d30d245731..c528fe7341 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/radar/VanChartRadarYAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/radar/VanChartRadarYAxisPane.java @@ -90,7 +90,7 @@ public class VanChartRadarYAxisPane extends VanChartValueAxisPane { return new Component[][]{ new Component[]{null,null} , new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Type")), axisLineStyle}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")), axisLineColor}, + new Component[]{axisLineColor, null}, }; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaBackgroundPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaBackgroundPane.java index 48473996f3..d53a7ebc64 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaBackgroundPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaBackgroundPane.java @@ -10,6 +10,7 @@ import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.van.chart.designer.AbstractVanChartScrollPane; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.background.VanChartBackgroundPane; +import com.fr.van.chart.designer.component.background.VanChartBackgroundPaneWithPreStyle; import com.fr.van.chart.designer.component.border.VanChartBorderWithRadiusPane; import com.fr.van.chart.designer.style.background.radar.VanChartRadarAxisAreaPane; @@ -41,7 +42,11 @@ public class VanChartAreaBackgroundPane extends AbstractVanChartScrollPane { private LineTypeComboBox horizonLineType; private LineTypeComboBox verticalLineType; - private ColorSelectBox horizontalColorBox; - private ColorSelectBox verticalColorBox; + private ColorSelectBoxWithPreStyle horizontalColorBox; + private ColorSelectBoxWithPreStyle verticalColorBox; private JPanel horizontalColorPane; private JPanel verticalColorPane; @@ -53,8 +54,8 @@ public class VanChartAxisAreaPane extends BasicBeanPane { } private void initComponents() { - horizontalColorBox = new ColorSelectBox(PREFERRED_WIDTH); - verticalColorBox = new ColorSelectBox(PREFERRED_WIDTH); + horizontalColorBox = new ColorSelectBoxWithPreStyle(PREFERRED_WIDTH); + verticalColorBox = new ColorSelectBoxWithPreStyle(PREFERRED_WIDTH); horizonLineType = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.SOLID, LineType.DASHED}); verticalLineType = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.SOLID, LineType.DASHED}); @@ -89,13 +90,13 @@ public class VanChartAxisAreaPane extends BasicBeanPane { protected void initGridLineComponents() { Component[][] upComponent = new Component[][]{ new Component[]{null, null}, - new Component[]{null, horizontalColorBox} + new Component[]{horizontalColorBox, null} }; horizontalColorPane = TableLayout4VanChartHelper.createGapTableLayoutPane(upComponent); Component[][] downComponent = new Component[][]{ new Component[]{null, null}, - new Component[]{null, verticalColorBox} + new Component[]{verticalColorBox, null} }; verticalColorPane = TableLayout4VanChartHelper.createGapTableLayoutPane(downComponent); @@ -143,7 +144,7 @@ public class VanChartAxisAreaPane extends BasicBeanPane { return panel; } - protected AlertLineListControlPane getAlertLinePane () { + protected AlertLineListControlPane getAlertLinePane() { return new AlertLineListControlPane(); } @@ -153,7 +154,7 @@ public class VanChartAxisAreaPane extends BasicBeanPane { verticalColorBackground = new ColorSelectBox(100); Component[][] components = getIntervalPaneComponents(); JPanel defaultPane = TableLayoutHelper.createTableLayoutPane(components, row, col); - defaultPane.setBorder(BorderFactory.createEmptyBorder(0,12,0,0)); + defaultPane.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0)); customIntervalBackground = getBackgroundListControlPane(); cardLayout = new CardLayout(); @@ -220,12 +221,12 @@ public class VanChartAxisAreaPane extends BasicBeanPane { VanChartAxis defaultYAxis = rectanglePlot.getDefaultYAxis(); if (defaultXAxis != null) { - verticalColorBox.setSelectObject(defaultXAxis.getMainGridColor()); + verticalColorBox.populate(defaultXAxis.getMainGridColorWithPreStyle()); verticalLineType.setSelectedItem(defaultXAxis.getGridLineType()); } if (defaultYAxis != null) { - horizontalColorBox.setSelectObject(defaultYAxis.getMainGridColor()); + horizontalColorBox.populate(defaultYAxis.getMainGridColorWithPreStyle()); horizonLineType.setSelectedItem(defaultYAxis.getGridLineType()); } } @@ -253,12 +254,12 @@ public class VanChartAxisAreaPane extends BasicBeanPane { VanChartAxis defaultYAxis = rectanglePlot.getDefaultYAxis(); if (defaultXAxis != null) { - defaultXAxis.setMainGridColor(verticalColorBox.getSelectObject()); + defaultXAxis.setMainGridColorWithPreStyle(verticalColorBox.update()); defaultXAxis.setGridLineType((LineType) verticalLineType.getSelectedItem()); } if (defaultYAxis != null) { - defaultYAxis.setMainGridColor(horizontalColorBox.getSelectObject()); + defaultYAxis.setMainGridColorWithPreStyle(horizontalColorBox.update()); defaultYAxis.setGridLineType((LineType) horizonLineType.getSelectedItem()); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/datasheet/VanChartDataSheetPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/datasheet/VanChartDataSheetPane.java index 884a1e1c46..724fb64267 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/datasheet/VanChartDataSheetPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/datasheet/VanChartDataSheetPane.java @@ -1,6 +1,5 @@ package com.fr.van.chart.designer.style.datasheet; -import com.fr.base.FRContext; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.DataSheet; @@ -11,9 +10,9 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithPreStyle; import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.general.ComparatorUtils; -import com.fr.general.FRFont; import com.fr.plugin.chart.VanChartAttrHelper; import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; import com.fr.plugin.chart.base.VanChartConstants; @@ -21,6 +20,7 @@ import com.fr.plugin.chart.type.AxisType; import com.fr.van.chart.designer.AbstractVanChartScrollPane; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.border.VanChartBorderPane; +import com.fr.van.chart.designer.component.border.VanChartBorderPaneWithPreStyle; import com.fr.van.chart.designer.component.format.FormatPaneWithNormalType; import javax.swing.JPanel; @@ -58,11 +58,11 @@ public class VanChartDataSheetPane extends AbstractVanChartScrollPane { double f = TableLayout.FILL; double[] columnSize = {f}; double[] rowSize = {p, p, p}; - Component[][] components =creatComponent(dataSheetPane); + Component[][] components = creatComponent(dataSheetPane); JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); this.setLayout(new BorderLayout()); - this.add(panel,BorderLayout.CENTER); + this.add(panel, BorderLayout.CENTER); isShowDataSheet.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -71,7 +71,8 @@ public class VanChartDataSheetPane extends AbstractVanChartScrollPane { }); } } - protected Component[][] creatComponent(JPanel dataSheetPane){ + + protected Component[][] creatComponent(JPanel dataSheetPane) { Component[][] components = new Component[][]{ new Component[]{isShowDataSheet}, @@ -79,28 +80,37 @@ public class VanChartDataSheetPane extends AbstractVanChartScrollPane { }; return components; } + // 检查数据表界面是否可用. private void checkDataSheetPaneUse() { dataSheetPane.setVisible(isShowDataSheet.isSelected()); } - private JPanel createDataSheetPane(){ - textAttrPane = new ChartTextAttrPane(); + private JPanel createDataSheetPane() { + textAttrPane = createChartTextAttrPane(); formatPane = new FormatPaneWithNormalType(); - borderPane = new VanChartBorderPane(); + borderPane = createBorderPanePane(); double p = TableLayout.PREFERRED; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; double[] columnSize = {d, e}; - double[] rowSize = {p,p,p}; + double[] rowSize = {p, p, p}; Component[][] components = new Component[][]{ - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Format"),formatPane),null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Style"),textAttrPane),null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Border"),borderPane),null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Format"), formatPane), null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), textAttrPane), null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane), null}, }; - return TableLayout4VanChartHelper.createGapTableLayoutPane(components,rowSize,columnSize); + return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); + } + + protected VanChartBorderPane createBorderPanePane() { + return new VanChartBorderPaneWithPreStyle(); + } + + protected ChartTextAttrPane createChartTextAttrPane() { + return new ChartTextAttrPaneWithPreStyle(); } @Override @@ -119,11 +129,11 @@ public class VanChartDataSheetPane extends AbstractVanChartScrollPane { @Override public void updateBean(Chart chart) { - if(chart == null) { + if (chart == null) { return; } Plot plot = chart.getPlot(); - if(plot == null) { + if (plot == null) { return; } DataSheet dataSheet = plot.getDataSheet(); @@ -133,7 +143,7 @@ public class VanChartDataSheetPane extends AbstractVanChartScrollPane { plot.setDataSheet(dataSheet); } dataSheet.setVisible(isShowDataSheet.isSelected()); - if(isShowDataSheet.isSelected()){ + if (isShowDataSheet.isSelected()) { update(dataSheet); } @@ -144,14 +154,14 @@ public class VanChartDataSheetPane extends AbstractVanChartScrollPane { @Override public void populateBean(Chart chart) { - if(chart == null || chart.getPlot() == null) { + if (chart == null || chart.getPlot() == null) { return; } - VanChartRectanglePlot rectanglePlot = (VanChartRectanglePlot)chart.getPlot(); - if(rectanglePlot.getXAxisList().size() == 1){ - if(ComparatorUtils.equals(rectanglePlot.getDefaultXAxis().getAxisType(), AxisType.AXIS_CATEGORY) + VanChartRectanglePlot rectanglePlot = (VanChartRectanglePlot) chart.getPlot(); + if (rectanglePlot.getXAxisList().size() == 1) { + if (ComparatorUtils.equals(rectanglePlot.getDefaultXAxis().getAxisType(), AxisType.AXIS_CATEGORY) && rectanglePlot.getDefaultXAxis().getPosition() == VanChartConstants.AXIS_BOTTOM - && rectanglePlot.getCategoryNum() == 1 ){ + && rectanglePlot.getCategoryNum() == 1) { //只有单个分类坐标轴且坐标轴位置在下面,数据表才可以用 isShowDataSheet.setEnabled(!rectanglePlot.isAxisRotation()); @@ -173,16 +183,14 @@ public class VanChartDataSheetPane extends AbstractVanChartScrollPane { } public void populate(DataSheet dataSheet) { - FRFont font = FRContext.getDefaultValues().getFRFont() == null ? FRFont.getInstance() : FRContext.getDefaultValues().getFRFont(); - textAttrPane.populate(dataSheet.getFont() == null ? font : dataSheet.getFont()); + textAttrPane.populate(dataSheet.getTextAttr()); formatPane.populateBean(dataSheet.getFormat()); borderPane.populate(dataSheet); } public DataSheet update(DataSheet dataSheet) { - - dataSheet.setFont(textAttrPane.updateFRFont()); + textAttrPane.update(dataSheet.getTextAttr()); dataSheet.setFormat(formatPane.update()); borderPane.update(dataSheet); return dataSheet; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/datasheet/VanchartDataSheetNoCheckPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/datasheet/VanchartDataSheetNoCheckPane.java index cc47a3fc1e..a81ed1902d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/datasheet/VanchartDataSheetNoCheckPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/datasheet/VanchartDataSheetNoCheckPane.java @@ -2,7 +2,9 @@ package com.fr.van.chart.designer.style.datasheet; import com.fr.chart.chartglyph.DataSheet; import com.fr.design.gui.iscrollbar.UIScrollBar; +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.plugin.chart.base.AttrDataSheet; +import com.fr.van.chart.designer.component.border.VanChartBorderPane; import javax.swing.JPanel; import java.awt.Component; @@ -46,4 +48,13 @@ public class VanchartDataSheetNoCheckPane extends VanChartDataSheetPane { update(dataSheet); return attrDataSheet; } + + @Override + protected ChartTextAttrPane createChartTextAttrPane(){ + return new ChartTextAttrPane(); + } + + protected VanChartBorderPane createBorderPanePane() { + return new VanChartBorderPane(); + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java index 9a5c453828..d8c3217380 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java @@ -49,10 +49,6 @@ public class VanChartGaugeCateOrPercentLabelDetailPane extends VanChartGaugeLabe return getGaugeStyle() == GaugeStyle.RING || getGaugeStyle() == GaugeStyle.SLOT; } - protected boolean isFontColorAuto() { - return getGaugeStyle() == GaugeStyle.RING || getGaugeStyle() == GaugeStyle.SLOT; - } - protected boolean hasLabelPosition(Plot plot) { switch (getGaugeStyle()) { case RING: diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java index 665fdc2565..7518057297 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java @@ -81,7 +81,7 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { } protected boolean isFontColorAuto() { - return false; + return true; } private FontAutoType getFontAutoType() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java index 22f8ace786..e7a0e36038 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java @@ -376,4 +376,4 @@ public class VanChartPlotLabelDetailPane extends BasicPane { } } -} +} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java index e8f9def4b3..667c73d3ac 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java @@ -5,6 +5,7 @@ import com.fr.base.chart.chartdata.model.LargeDataModel; import com.fr.base.chart.chartdata.model.NormalDataModel; import com.fr.chart.base.AttrAlpha; import com.fr.chart.base.AttrBorder; +import com.fr.chart.base.AttrFillStyle; import com.fr.chart.base.GradientStyle; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; @@ -81,6 +82,14 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP super(parent, plot); } + public UINumberDragPane getTransparent() { + return transparent; + } + + public void setTransparent(UINumberDragPane transparent) { + this.transparent = transparent; + } + protected JPanel getContentPane(boolean custom) { if (custom) { JScrollPane scrollPane = new JScrollPane(); @@ -245,7 +254,7 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP } protected VanChartBorderPane createDiffBorderPane() { - return new VanChartBorderPane(); + return new VanChartBorderPane(true); } @@ -340,7 +349,12 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP checkoutMapType(plot); if (vanChartFillStylePane != null) {//配色 - plot.setPlotFillStyle(vanChartFillStylePane.updateBean()); + AttrFillStyle plotFillStyle = plot.getPlotFillStyle(); + if (plotFillStyle == null) { + plotFillStyle = new AttrFillStyle(); + plot.setPlotFillStyle(plotFillStyle); + } + vanChartFillStylePane.updateBean(plotFillStyle); } if (stylePane != null) {//风格 diff --git a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelLabelContentPane.java index af29cddf39..7f57e47d63 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelLabelContentPane.java @@ -1,8 +1,6 @@ package com.fr.van.chart.funnel.designer.style; import com.fr.plugin.chart.base.AttrTooltipContent; -import com.fr.plugin.chart.base.AttrTooltipRichText; -import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipNameFormat; import com.fr.van.chart.designer.component.VanChartLabelContentPane; import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; @@ -11,7 +9,6 @@ import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckB import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithoutCheckBox; -import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -61,29 +58,10 @@ public class VanChartFunnelLabelContentPane extends VanChartLabelContentPane { setRichTextPercentFormatPane(new FunnelPercentFormatPaneWithoutCheckBox(parent, showOnPane)); } - protected void populateRichEditor(AttrTooltipContent attrTooltipContent) { - VanChartFormatPaneWithoutCheckBox[] formatPaneGroup = new VanChartFormatPaneWithoutCheckBox[]{ - getRichTextSeriesNameFormatPane(), - getRichTextValueFormatPane(), - getRichTextPercentFormatPane() - }; - - AttrTooltipFormat[] formatGroup = new AttrTooltipFormat[]{ - attrTooltipContent.getRichTextSeriesFormat(), - attrTooltipContent.getRichTextValueFormat(), - attrTooltipContent.getRichTextPercentFormat() - }; - - setRichTextAttr(new AttrTooltipRichText()); - populateRichTextFormat(formatPaneGroup, formatGroup); - populateRichText(attrTooltipContent.getRichTextAttr()); - } - protected AttrTooltipContent createAttrTooltip() { AttrTooltipContent attrTooltipContent = new AttrTooltipContent(); attrTooltipContent.getCategoryFormat().setEnable(false); attrTooltipContent.setSeriesFormat(new AttrTooltipNameFormat()); - attrTooltipContent.setRichTextSeriesFormat(new AttrTooltipNameFormat()); return attrTooltipContent; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelRefreshTooltipContentPane.java index b7f817eb3c..3b45d188bd 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelRefreshTooltipContentPane.java @@ -16,11 +16,6 @@ public class VanChartFunnelRefreshTooltipContentPane extends VanChartFunnelToolt public VanChartFunnelRefreshTooltipContentPane(VanChartStylePane parent, JPanel showOnPane) { super(null, showOnPane); } - - protected boolean supportRichEditor() { - return false; - } - @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { super.initFormatPane(parent, showOnPane); diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttLabelContentPane.java index 25d7aa030e..54ab3fd1f1 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttLabelContentPane.java @@ -3,7 +3,7 @@ package com.fr.van.chart.gantt.designer.style.label; import com.fr.design.i18n.Toolkit; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.gantt.attr.AttrGanttTooltipContent; -import com.fr.van.chart.designer.component.VanChartTooltipContentPane; +import com.fr.van.chart.designer.component.VanChartLabelContentPaneWithoutRichText; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; @@ -16,7 +16,7 @@ import java.awt.Component; /** * Created by hufan on 2017/1/13. */ -public class VanChartGanttLabelContentPane extends VanChartTooltipContentPane { +public class VanChartGanttLabelContentPane extends VanChartLabelContentPaneWithoutRichText { private VanChartFormatPaneWithCheckBox processesFormatPane; private VanChartDateFormatPaneWithCheckBox startTimeFormatPane; @@ -57,10 +57,6 @@ public class VanChartGanttLabelContentPane extends VanChartTooltipContentPane { }; } - protected boolean supportRichEditor() { - return false; - } - protected Component[][] getPaneComponents() { return new Component[][]{ new Component[]{processesFormatPane, null}, diff --git a/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java index af7aaf0014..ed237d4c35 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java @@ -29,6 +29,9 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; /** * Created by Mitisky on 15/11/27. @@ -38,6 +41,9 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { private static final long serialVersionUID = -4414343926082129759L; private UIButtonGroup gaugeLayout;//布局:横向、纵向 + private UIButtonGroup hingeColorAuto; + private UIButtonGroup paneBackgroundColorAuto; + private UIButtonGroup slotBackgroundColorAuto; private ColorSelectBox hingeColor;//枢纽颜色 private ColorSelectBox hingeBackgroundColor;//枢纽背景颜色 private ColorSelectBox needleColor;//指针颜色 @@ -62,7 +68,7 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double[] columnSize = {f}; - double[] rowSize = {p,p,p,p,p,p}; + double[] rowSize = {p,p,p,p,p,p,p}; Component[][] components = new Component[][]{ new Component[]{createGaugeLayoutPane()}, new Component[]{createGaugeStylePane(rowSize, new double[]{f,e})}, @@ -138,7 +144,8 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { initRotate(); return new Component[][]{ new Component[]{null, null}, - getPaneBackgroundColor(), + getPaneBackgroundColorAuto(), + new Component[]{null, paneBackgroundColor}, getInnerPaneBackgroundColor(), new Component[]{createRadiusPane(Toolkit.i18nText("Fine-Design_Chart_Radius_Set")), null}, getChutePercent() @@ -147,7 +154,8 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { return new Component[][]{ new Component[]{null, null}, getNeedleColor(), - getSlotBackgroundColor(), + getSlotBackgroundColorAuto(), + new Component[]{null, slotBackgroundColor}, new Component[]{createRadiusPane(Toolkit.i18nText("Fine-Design_Chart_Radius_Set")), null}, getChutePercent() }; @@ -155,25 +163,37 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { return new Component[][]{ new Component[]{null, null}, getNeedleColor(), - getSlotBackgroundColor(), + getSlotBackgroundColorAuto(), + new Component[]{null, slotBackgroundColor}, new Component[]{createRadiusPane(Toolkit.i18nText("Fine-Design_Chart_Length_Set")), null}, getThermometerWidth() }; default: return new Component[][]{ new Component[]{null, null}, - getHingeColor(), + getHingeColorAuto(), + new Component[]{null, hingeColor}, getHingeBackgroundColor(), getNeedleColor(), - getPaneBackgroundColor(), + getPaneBackgroundColorAuto(), + new Component[]{null, paneBackgroundColor}, new Component[]{createRadiusPane(Toolkit.i18nText("Fine-Design_Chart_Radius_Set")), null} }; } } - private Component[] getHingeColor() { + private Component[] getHingeColorAuto() { hingeColor = new ColorSelectBox(120); - return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Hinge")),hingeColor}; + hingeColorAuto = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Auto"), + Toolkit.i18nText("Fine-Design_Chart_Custom")}); + + hingeColorAuto.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkHingeColorAutoButton(); + } + }); + return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Hinge")), hingeColorAuto}; } private Component[] getHingeBackgroundColor() { @@ -186,11 +206,39 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Needle")),needleColor}; } + private Component[] getPaneBackgroundColorAuto() { + paneBackgroundColor = new ColorSelectBox(120); + paneBackgroundColorAuto = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Auto"), + Toolkit.i18nText("Fine-Design_Chart_Custom")}); + + paneBackgroundColorAuto.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkPaneBackgroundColorAutoButton(); + } + }); + return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Pane_Background")), paneBackgroundColorAuto}; + } + private Component[] getPaneBackgroundColor() { paneBackgroundColor = new ColorSelectBox(120); return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Pane_Background")),paneBackgroundColor}; } + private Component[] getSlotBackgroundColorAuto() { + slotBackgroundColor = new ColorSelectBox(120); + slotBackgroundColorAuto = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Auto"), + Toolkit.i18nText("Fine-Design_Chart_Custom")}); + + slotBackgroundColorAuto.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkSlotBackgroundColorAutoButton(); + } + }); + return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Slot_Background")), slotBackgroundColorAuto}; + } + private Component[] getSlotBackgroundColor() { slotBackgroundColor = new ColorSelectBox(120); return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Slot_Background")),slotBackgroundColor}; @@ -220,6 +268,20 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Range"), colorPickerPane); } + private void checkHingeColorAutoButton() { + hingeColor.setVisible(hingeColorAuto.getSelectedIndex() == 1); + hingeColor.setPreferredSize(hingeColorAuto.getSelectedIndex() == 1 ? new Dimension(0, 20) : new Dimension(0, 0)); + } + + private void checkSlotBackgroundColorAutoButton() { + slotBackgroundColor.setVisible(slotBackgroundColorAuto.getSelectedIndex() == 1); + slotBackgroundColor.setPreferredSize(slotBackgroundColorAuto.getSelectedIndex() == 1 ? new Dimension(0, 20) : new Dimension(0, 0)); + } + + private void checkPaneBackgroundColorAutoButton() { + paneBackgroundColor.setVisible(paneBackgroundColorAuto.getSelectedIndex() == 1); + paneBackgroundColor.setPreferredSize(paneBackgroundColorAuto.getSelectedIndex() == 1 ? new Dimension(0, 20) : new Dimension(0, 0)); + } public void populateBean(Plot plot) { if(plot == null) { @@ -231,6 +293,18 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { GaugeDetailStyle detailStyle = gaugePlot.getGaugeDetailStyle(); gaugeLayout.setSelectedIndex(detailStyle.isHorizontalLayout() ? 0 : 1); + if (hingeColorAuto != null) { + hingeColorAuto.setSelectedIndex(detailStyle.isHingeColorAuto() ? 0 : 1); + checkHingeColorAutoButton(); + } + if (paneBackgroundColorAuto != null) { + paneBackgroundColorAuto.setSelectedIndex(detailStyle.isPaneBackgroundColorAuto() ? 0 : 1); + checkPaneBackgroundColorAutoButton(); + } + if (slotBackgroundColorAuto != null) { + slotBackgroundColorAuto.setSelectedIndex(detailStyle.isSlotBackgroundColorAuto() ? 0 : 1); + checkSlotBackgroundColorAutoButton(); + } if(hingeColor != null){ hingeColor.setSelectObject(detailStyle.getHingeColor()); } @@ -275,6 +349,15 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { GaugeDetailStyle detailStyle = gaugePlot.getGaugeDetailStyle(); detailStyle.setHorizontalLayout(gaugeLayout.getSelectedIndex() == 0); + if (hingeColorAuto != null) { + detailStyle.setHingeColorAuto(hingeColorAuto.getSelectedIndex() == 0); + } + if (paneBackgroundColorAuto != null) { + detailStyle.setPaneBackgroundColorAuto(paneBackgroundColorAuto.getSelectedIndex() == 0); + } + if (slotBackgroundColorAuto != null) { + detailStyle.setSlotBackgroundColorAuto(slotBackgroundColorAuto.getSelectedIndex() == 0); + } if(hingeColor != null){ detailStyle.setHingeColor(hingeColor.getSelectObject()); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java index bf44ded481..714afadc2c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java @@ -3,15 +3,19 @@ package com.fr.van.chart.map; import com.fr.base.chart.chartdata.model.DataProcessor; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; +import com.fr.design.constants.LayoutConstants; import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.style.color.ColorSelectBox; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.design.utils.gui.UIComponentUtils; +import com.fr.design.widget.FRWidgetFactory; import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.VanChartAttrHelper; import com.fr.plugin.chart.base.AttrBorderWithAlpha; @@ -40,12 +44,15 @@ import com.fr.van.chart.map.line.VanChartLineMapEffectPane; import javax.swing.BorderFactory; import javax.swing.DefaultComboBoxModel; import javax.swing.JPanel; +import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Component; import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; @@ -72,6 +79,8 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { //area private VanChartBorderWithAlphaPane borderWithAlphaPane; + + private UIButtonGroup nullValueAuto; private ColorSelectBox nullValueColorBox; //point @@ -235,9 +244,24 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { } } + //不透明度 + protected JPanel createAlphaPane() { + setTransparent(new UINumberDragPane(0, 100)); + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {f, TableLayout4VanChartHelper.EDIT_AREA_WIDTH}; + double[] rowSize = {p, p}; + UILabel label = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Alpha")); + label.setVerticalAlignment(SwingConstants.TOP); + Component[][] components = new Component[][]{ + new Component[]{null, null}, + new Component[]{label, UIComponentUtils.wrapWithBorderLayoutPane(getTransparent())}, + }; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, TableLayout4VanChartHelper.COMPONENT_INTERVAL, LayoutConstants.VGAP_LARGE); + } protected JPanel createAreaPane() { - borderWithAlphaPane = new VanChartBorderWithAlphaPane(); + borderWithAlphaPane = new VanChartBorderWithAlphaPane(true); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; @@ -253,9 +277,39 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { } protected JPanel createNullValueColorPane() { + nullValueAuto = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Auto"), + Toolkit.i18nText("Fine-Design_Chart_Custom")}); nullValueColorBox = new ColorSelectBox(80); + initNullValueListener(); - return TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_NULL_Value_Color"), nullValueColorBox); + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + double[] columnSize = {f, e}; + double p = TableLayout.PREFERRED; + + double[] rowSize = {p, p, p}; + UILabel text = new UILabel(Toolkit.i18nText("Fine-Design_Chart_NULL_Value_Color"), SwingConstants.LEFT); + Component[][] components = { + new Component[]{null, null}, + new Component[]{text, nullValueAuto}, + new Component[]{null, nullValueColorBox}, + }; + return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); + } + + + private void initNullValueListener() { + nullValueAuto.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkNullValueButton(); + } + }); + } + + private void checkNullValueButton() { + nullValueColorBox.setVisible(nullValueAuto.getSelectedIndex() == 1); + nullValueColorBox.setPreferredSize(nullValueAuto.getSelectedIndex() == 1 ? new Dimension(0, 20) : new Dimension(0, 0)); } private JPanel createPointPane() { @@ -445,7 +499,13 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { markerTypeCom.setSelectedItem(((VanChartMapPlot) plot).getMapMarkerType().toLocalString()); } if (nullValueColorBox != null) { + if (((VanChartMapPlot) plot).isAutoNullValue()) { + nullValueAuto.setSelectedIndex(0); + } else { + nullValueAuto.setSelectedIndex(1); + } nullValueColorBox.setSelectObject(((VanChartMapPlot) plot).getNullValueColor()); + checkNullValueButton(); } //大数据模式 恢复用注释。下面3行删除。 if (lineMapLargeDataModelGroup != null) { @@ -461,6 +521,7 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { ((VanChartMapPlot) plot).setMapMarkerType(MapMarkerType.parseInt(markerTypeCom.getSelectedIndex())); } if (nullValueColorBox != null) { + ((VanChartMapPlot) plot).setAutoNullValue(nullValueAuto.getSelectedIndex() == 0); ((VanChartMapPlot) plot).setNullValueColor(nullValueColorBox.getSelectObject()); } //大数据模式 恢复用注释。下面3行删除。 diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapRefreshTooltipContentPane.java index 7dca0fb3bc..21b8995f30 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapRefreshTooltipContentPane.java @@ -23,10 +23,6 @@ public class VanChartMapRefreshTooltipContentPane extends VanChartMapTooltipCont return new double[]{p,p,p,p,p,p}; } - protected boolean supportRichEditor() { - return false; - } - @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { super.initFormatPane(parent, showOnPane); diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java index e58797dca3..17b275e30b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java @@ -646,10 +646,8 @@ public class VanChartMapSourceChoosePane extends JPanel implements UIObserver { private void resetGisLayer(VanChartMapPlot mapPlot) { - String layerName = mapPlot.getDefaultGisLayerName(); - - mapPlot.getGisLayer().setGisLayerType(GISLayerType.PREDEFINED_LAYER); - mapPlot.getGisLayer().setLayerName(layerName); + mapPlot.getGisLayer().setGisLayerType(GISLayerType.AUTO); + mapPlot.getGisLayer().setLayerName(GISLayerType.getLocString(GISLayerType.AUTO)); gisLayer.setSelectedItem(mapPlot.getGisLayer().getShowItemName()); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMutiPieRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMutiPieRefreshTooltipContentPane.java index f375fa78fa..a38383306d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMutiPieRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMutiPieRefreshTooltipContentPane.java @@ -19,10 +19,6 @@ public class VanChartMutiPieRefreshTooltipContentPane extends VanChartMultiPieTo super(null, showOnPane); } - protected boolean supportRichEditor() { - return false; - } - @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { super.initFormatPane(parent, showOnPane); diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRefreshTooltipContentPane.java index db7ce4152f..43d70e0b66 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRefreshTooltipContentPane.java @@ -41,10 +41,6 @@ public class VanChartScatterRefreshTooltipContentPane extends VanChartScatterToo setRichTextChangedPercentFormatPane(richTextChangedPercentFormatPane); } - protected boolean supportRichEditor() { - return false; - } - protected double[] getRowSize(double p) { return new double[]{p, p, p, p, p, p}; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java index cdc2b040e7..9431b4ab76 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java @@ -1,7 +1,6 @@ package com.fr.van.chart.scatter; import com.fr.plugin.chart.base.AttrTooltipContent; -import com.fr.plugin.chart.base.AttrTooltipRichText; import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.scatter.attr.ScatterAttrTooltipContent; import com.fr.van.chart.designer.component.VanChartTooltipContentPane; @@ -108,24 +107,21 @@ public class VanChartScatterTooltipContentPane extends VanChartTooltipContentPa } protected void populateRichEditor(AttrTooltipContent attrTooltipContent) { + super.populateRichEditor(attrTooltipContent); + if (attrTooltipContent instanceof ScatterAttrTooltipContent) { ScatterAttrTooltipContent scatterAttrTooltipContent = (ScatterAttrTooltipContent) attrTooltipContent; VanChartFormatPaneWithoutCheckBox[] formatPaneGroup = new VanChartFormatPaneWithoutCheckBox[]{ - getRichTextSeriesNameFormatPane(), - richTextXFormatPane, - richTextYFormatPane, - richTextSizeFormatPane + richTextXFormatPane, richTextYFormatPane, richTextSizeFormatPane }; AttrTooltipFormat[] formatGroup = new AttrTooltipFormat[]{ - scatterAttrTooltipContent.getRichTextSeriesFormat(), scatterAttrTooltipContent.getRichTextXFormat(), scatterAttrTooltipContent.getRichTextYFormat(), scatterAttrTooltipContent.getRichTextSizeFormat() }; - setRichTextAttr(new AttrTooltipRichText()); populateRichTextFormat(formatPaneGroup, formatGroup); populateRichText(attrTooltipContent.getRichTextAttr()); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelPane.java index fb8be90163..2830b4c3bd 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelPane.java @@ -22,4 +22,4 @@ public class VanChartScatterPlotLabelPane extends VanChartPlotLabelPane { setLabelDetailPane(labelDetailPane); getLabelPane().add(labelDetailPane, BorderLayout.CENTER); } -} +} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureLabelContentPane.java index 979c7ba093..f380c8267a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureLabelContentPane.java @@ -4,7 +4,7 @@ package com.fr.van.chart.structure.desinger.style; import com.fr.design.i18n.Toolkit; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.multilayer.style.AttrTooltipMultiLevelNameFormat; -import com.fr.van.chart.designer.component.VanChartTooltipContentPane; +import com.fr.van.chart.designer.component.VanChartLabelContentPaneWithoutRichText; import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; @@ -17,7 +17,7 @@ import java.awt.Component; /** * Created by shine on 2017/2/15. */ -public class VanChartStructureLabelContentPane extends VanChartTooltipContentPane { +public class VanChartStructureLabelContentPane extends VanChartLabelContentPaneWithoutRichText { public VanChartStructureLabelContentPane(VanChartStylePane parent, JPanel showOnPane) { super(parent, showOnPane); } @@ -54,10 +54,6 @@ public class VanChartStructureLabelContentPane extends VanChartTooltipContentPan setPercentFormatPane(percentFormatPane); } - protected boolean supportRichEditor() { - return false; - } - @Override protected AttrTooltipContent createAttrTooltip() { AttrTooltipContent attrTooltipContent = new AttrTooltipContent(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureRefreshTooltipContentPane.java index ea09ff3c83..52295346bf 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureRefreshTooltipContentPane.java @@ -38,10 +38,6 @@ public class VanChartStructureRefreshTooltipContentPane extends VanChartStructur setRichTextChangedPercentFormatPane(richTextChangedPercentFormatPane); } - protected boolean supportRichEditor() { - return false; - } - protected double[] getRowSize(double p) { return new double[]{p, p, p, p, p}; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRefreshTooltipContentPane.java index cab4d85584..30b754dd00 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRefreshTooltipContentPane.java @@ -51,10 +51,6 @@ public class VanChartWordCloudRefreshTooltipContentPane extends VanChartWordClou setRichTextChangedPercentFormatPane(richTextChangedPercentFormatPane); } - protected boolean supportRichEditor() { - return false; - } - protected double[] getRowSize(double p) { return new double[]{p, p, p, p, p, p}; } diff --git a/designer-chart/src/main/resources/com/fr/design/editor/script/editor.js b/designer-chart/src/main/resources/com/fr/design/editor/script/editor.js index 1a2a07dc4b..d42f978cd8 100644 --- a/designer-chart/src/main/resources/com/fr/design/editor/script/editor.js +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/editor.js @@ -128,8 +128,8 @@ } str += " " + key + "=\"" + value + "\""; - if (key === "alt" && dataIdMap[value.trim()]) { - str += " " + "data-id" + "=\"" + dataIdMap[value.trim()] + "\""; + if (key === "alt" && dataIdMap[value]) { + str += " " + "data-id" + "=\"" + dataIdMap[value] + "\""; } }); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java b/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java index c002bceb38..7c67065f6d 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java @@ -20,6 +20,8 @@ import com.fr.design.mainframe.HelpDialogManager; import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; import com.fr.design.module.DesignModuleFactory; import com.fr.form.ui.BaseChartEditor; +import com.fr.form.ui.NameLayoutBorderStyle; +import com.fr.form.ui.NamePaddingMargin; import com.fr.form.ui.Widget; import com.fr.stable.Constants; import com.fr.stable.core.PropertyChangeAdapter; @@ -362,4 +364,14 @@ public class XChartEditor extends XBorderStyleWidgetCreator { return false; } + /** + * 初始化组件的预定义信息 + */ + public void initWidgetPredefinedInfo(String styleName){ + this.toData().setNameMargin(NamePaddingMargin.createPredefinedStyle(styleName)); + this.toData().setNameBorderStyle(NameLayoutBorderStyle.createPredefinedStyle(styleName)); + initBorderStyle(); + + } + } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java index ec83a1f9a5..f3218e9a56 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java @@ -24,11 +24,16 @@ import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WTitleLayout; import com.fr.stable.Constants; +import com.fr.stable.CoreGraphHelper; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; +import com.fr.third.javax.annotation.Nullable; import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.ImageIcon; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.Border; import java.awt.BorderLayout; @@ -38,6 +43,7 @@ import java.awt.Dimension; import java.awt.Graphics; import java.awt.Rectangle; import java.awt.event.MouseEvent; +import java.awt.image.BufferedImage; import java.beans.IntrospectionException; import java.util.ArrayList; import java.util.List; @@ -805,11 +811,18 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo return false; } - /** - * 是否支持置顶显示 - */ + public boolean isTopable() { return true; } + /** + * 初始化组件的预定义信息 + */ + public void initWidgetPredefinedInfo(String styleName){ + + } + + + } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java b/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java index 718c30aeb6..d8dc28667d 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java @@ -19,9 +19,12 @@ import com.fr.form.FormProvider; import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.ElementCaseEditorProvider; +import com.fr.form.ui.NameLayoutBorderStyle; +import com.fr.form.ui.NamePaddingMargin; import com.fr.report.fit.ReportFitAttr; import com.fr.stable.ArrayUtils; import com.fr.stable.CoreGraphHelper; +import com.fr.stable.StringUtils; import com.fr.stable.core.PropertyChangeAdapter; import com.fr.report.fit.FitProvider; @@ -372,4 +375,15 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme return true; } + /** + * 初始化组件的预定义信息 + */ + public void initWidgetPredefinedInfo(String styleName){ + this.toData().setNameMargin(NamePaddingMargin.createPredefinedStyle(styleName)); + this.toData().setNameBorderStyle(NameLayoutBorderStyle.createPredefinedStyle(styleName)); + initBorderStyle(); + + } + + } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java index 2c88e62525..917b73434b 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java @@ -7,8 +7,10 @@ import com.fr.design.form.util.XCreatorConstants; import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; +import com.fr.form.ui.NameFormBackground; import com.fr.form.ui.container.WAbsoluteBodyLayout; +import com.fr.stable.StringUtils; import com.fr.stable.core.PropertyChangeAdapter; import java.awt.Component; @@ -135,4 +137,11 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout { public boolean isTopable() { return false; } + + /** + * 初始化组件的预定义信息 + */ + public void initWidgetPredefinedInfo(String styleName){ + this.toData().setNameBackground(NameFormBackground.createPredefinedStyle(styleName)); + } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java index 3e425b4cd9..7379b83107 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java @@ -12,6 +12,7 @@ import com.fr.design.mainframe.FormArea; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.utils.gui.LayoutUtils; +import com.fr.form.ui.NameFormBackground; import com.fr.form.ui.PaddingMargin; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; @@ -23,6 +24,7 @@ import com.fr.general.FRLogger; import com.fr.general.FRScreen; import com.fr.stable.ArrayUtils; import com.fr.stable.AssistUtils; +import com.fr.stable.StringUtils; import javax.swing.JOptionPane; import java.awt.Component; @@ -1342,4 +1344,11 @@ public class XWFitLayout extends XLayoutContainer { } } } + /** + * 初始化组件的预定义信息 + */ + public void initWidgetPredefinedInfo(String styleName){ + this.toData().setNameBackground(NameFormBackground.createPredefinedStyle(styleName)); + } + } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java index a706674c7b..6ec61225b2 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java @@ -21,12 +21,14 @@ import com.fr.design.mainframe.widget.editors.ButtonTypeEditor; import com.fr.design.mainframe.widget.editors.ImgBackgroundEditor; import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.ui.CardSwitchButton; +import com.fr.form.ui.NameFormBackground; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout; import com.fr.general.Background; import com.fr.stable.ArrayUtils; +import com.fr.stable.StringUtils; import com.fr.stable.core.PropertyChangeAdapter; import javax.swing.border.Border; @@ -643,4 +645,14 @@ public class XWTabFitLayout extends XWFitLayout { public boolean isTopable() { return true; } + + + + /** + * 初始化组件的预定义信息 + */ + public void initWidgetPredefinedInfo(String styleName){ + this.toData().setNameBackground(NameFormBackground.createCustomStyleWithBackground(null)); + } + } diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/FormPredefinedBackgroundPane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/FormPredefinedBackgroundPane.java new file mode 100644 index 0000000000..5cc54f37c6 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/FormPredefinedBackgroundPane.java @@ -0,0 +1,101 @@ +package com.fr.design.gui.xpane; + +import com.fr.config.predefined.BackgroundWithAlpha; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.predefined.ui.PredefinedStyleSettingPane; +import com.fr.design.mainframe.predefined.ui.detail.background.BackgroundWithAlphaSettingPane; +import com.fr.design.mainframe.predefined.ui.preview.StyleSettingPreviewPane; +import com.fr.form.ui.NameFormBackground; + +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.geom.Rectangle2D; + +/** + * Created by kerry on 2020-09-02 + */ +public class FormPredefinedBackgroundPane extends PredefinedStyleSettingPane { + private BackgroundWithAlphaSettingPane backgroundPane; + + @Override + protected StyleSettingPreviewPane createPreviewPane() { + return new PreviewPane(); + } + + @Override + protected JPanel createCustomDetailPane() { + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + backgroundPane = new BackgroundWithAlphaSettingPane(); + backgroundPane.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + previewPane.refresh(); + } + }); + panel.add(backgroundPane, BorderLayout.CENTER); + return panel; + } + + @Override + public void populateBean(NameFormBackground ob) { + this.setPopulating(true); + super.populate(ob); + this.backgroundPane.populateBean(ob.createRealStyle()); + this.previewPane.refresh(); + this.setPopulating(false); + } + + + @Override + public NameFormBackground updateBean() { + if (this.predefinedRadioBtn.isSelected()) { + return NameFormBackground.createPredefinedStyle(getPredefinedStyleName()); + } else { + return NameFormBackground.createCustomStyle(this.backgroundPane.updateBean()); + } + } + + private BackgroundWithAlpha getCurrentValue() { + if (this.predefinedRadioBtn.isSelected()) { + NameFormBackground nameFormBackground = NameFormBackground.createPredefinedStyle(getPredefinedStyleName()); + return nameFormBackground.createRealStyle(); + } else { + return this.backgroundPane.updateBean(); + } + } + + @Override + public String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background"); + } + + class PreviewPane extends StyleSettingPreviewPane { + private BackgroundWithAlpha background; + + public PreviewPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setPreferredSize(new Dimension(390, 511)); + this.setBackground(Color.WHITE); + } + + + public void refresh() { + background = getCurrentValue(); + this.repaint(); + } + + @Override + public void paint(Graphics g) { + super.paint(g); + if (background != null && background.getBackground() != null) { + background.getBackground().paint(g, new Rectangle2D.Double(0, 0, this.getWidth(), this.getHeight())); + } + } + } + +} diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/PredefinedComponentStyleSettingPane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/PredefinedComponentStyleSettingPane.java new file mode 100644 index 0000000000..2abb1c528c --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/PredefinedComponentStyleSettingPane.java @@ -0,0 +1,168 @@ +package com.fr.design.gui.xpane; + +import com.fr.config.predefined.PredefinedComponentStyle; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.predefined.ui.PredefinedStyleSettingPane; +import com.fr.design.mainframe.predefined.ui.detail.component.ComponentFrameStylePane; +import com.fr.design.mainframe.predefined.ui.detail.component.ComponentMarginStylePane; +import com.fr.design.mainframe.predefined.ui.detail.component.ComponentTitleStylePane; +import com.fr.design.mainframe.predefined.ui.preview.StyleSettingPreviewPane; +import com.fr.design.widget.ui.designer.layout.ComponentStyle; +import com.fr.form.ui.LayoutBorderStyle; +import com.fr.form.ui.NameLayoutBorderStyle; +import com.fr.form.ui.NamePaddingMargin; +import com.fr.form.ui.PaddingMargin; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; + +/** + * Created by kerry on 2020-09-02 + */ +public class PredefinedComponentStyleSettingPane extends PredefinedStyleSettingPane { + private StyleSettingPane styleSettingPane; + private TinyFormulaPane formulaPane; + + @Override + protected StyleSettingPreviewPane createPreviewPane() { + return new PreviewPane(); + } + + protected JPanel createPredefinedSettingPane() { + JPanel jPanel = new JPanel(); + jPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); + jPanel.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Content"))); + formulaPane = new TinyFormulaPane(); + formulaPane.setPreferredSize(new Dimension(158, 30)); + jPanel.add(formulaPane); + return jPanel; + + } + + @Override + protected JPanel createCustomDetailPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + styleSettingPane = new StyleSettingPane(); + jPanel.add(styleSettingPane, BorderLayout.CENTER); + return jPanel; + } + + @Override + public void populateBean(ComponentStyle ob) { + this.setPopulating(true); + NameLayoutBorderStyle layoutBorderStyle = ob.getNameLayoutBorderStyle(); + super.populate(layoutBorderStyle); + this.formulaPane.populateBean(layoutBorderStyle.getTitleText().toString()); + styleSettingPane.populateBean(ob); + this.previewPane.refresh(); + this.setPopulating(false); + } + + + @Override + public ComponentStyle updateBean() { + if (predefinedRadioBtn.isSelected()) { + NameLayoutBorderStyle layoutBorderStyle = NameLayoutBorderStyle.createPredefinedStyle(getPredefinedStyleName()); + layoutBorderStyle.setTitleText(formulaPane.updateBean()); + return new ComponentStyle(layoutBorderStyle, + NamePaddingMargin.createPredefinedStyle(getPredefinedStyleName())); + } + return styleSettingPane.updateBean(); + } + + @Override + public String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Style"); + } + + class StyleSettingPane extends BasicBeanPane { + private ComponentFrameStylePane frameStylePane; + private ComponentTitleStylePane titleStylePane; + private ComponentMarginStylePane marginStylePane; + + public StyleSettingPane() { + initPane(); + } + + private void initPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel frame = FRGUIPaneFactory.createTitledBorderNoGapPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Frame")); + frameStylePane = new ComponentFrameStylePane(); + frameStylePane.setPreferredSize(new Dimension(233, 183)); + frame.add(frameStylePane); + + JPanel title = FRGUIPaneFactory.createTitledBorderNoGapPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title")); + titleStylePane = ComponentTitleStylePane.createStyleSettingPane(); + titleStylePane.setPreferredSize(new Dimension(233, 140)); + title.add(titleStylePane); + + + JPanel margin = FRGUIPaneFactory.createTitledBorderNoGapPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Base_Margin")); + marginStylePane = new ComponentMarginStylePane(); + marginStylePane.setPreferredSize(new Dimension(233, 100)); + margin.add(marginStylePane); + + this.add(frame, BorderLayout.NORTH); + this.add(title, BorderLayout.CENTER); + this.add(margin, BorderLayout.SOUTH); + } + + @Override + public void populateBean(ComponentStyle ob) { + PredefinedComponentStyle componentStyle = new PredefinedComponentStyle(); + componentStyle.setBorderStyle(ob.getNameLayoutBorderStyle().createRealStyle()); + PaddingMargin margin = ob.getNamePaddingMargin().createRealStyle(); + componentStyle.setTop(margin.getTop()); + componentStyle.setBottom(margin.getBottom()); + componentStyle.setLeft(margin.getLeft()); + componentStyle.setRight(margin.getRight()); + frameStylePane.populate(componentStyle); + titleStylePane.populate(componentStyle); + marginStylePane.populate(componentStyle); + } + + @Override + public ComponentStyle updateBean() { + PredefinedComponentStyle componentStyle = update(); + NameLayoutBorderStyle nameLayoutBorderStyle = NameLayoutBorderStyle.createCustomStyle(componentStyle.getBorderStyle()); + NamePaddingMargin namePaddingMargin = NamePaddingMargin.createCustomStyle( + new PaddingMargin(componentStyle.getTop(), componentStyle.getLeft(), componentStyle.getBottom(), componentStyle.getRight())); + return new ComponentStyle(nameLayoutBorderStyle, namePaddingMargin); + } + + public PredefinedComponentStyle update() { + PredefinedComponentStyle componentStyle = new PredefinedComponentStyle(); + frameStylePane.update(componentStyle); + titleStylePane.update(componentStyle); + marginStylePane.update(componentStyle); + return componentStyle; + } + + @Override + protected String title4PopupWindow() { + return null; + } + } + + class PreviewPane extends StyleSettingPreviewPane { + private LayoutBorderPreviewPane layoutBorderPreviewPane; + + public PreviewPane() { + this.setPreferredSize(new Dimension(390, 511)); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.layoutBorderPreviewPane = new LayoutBorderPreviewPane(new LayoutBorderStyle()); + this.add(this.layoutBorderPreviewPane, BorderLayout.CENTER); + } + + public void refresh() { + ComponentStyle componentStyle = PredefinedComponentStyleSettingPane.this.updateBean(); + NameLayoutBorderStyle borderStyle = componentStyle.getNameLayoutBorderStyle(); + this.layoutBorderPreviewPane.repaint((LayoutBorderStyle) borderStyle.createRealStyle()); + } + + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java index a80032ed6f..7be278d0f9 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java @@ -37,10 +37,10 @@ import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWBorderLayout; import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; -import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.event.DesignerOpenedListener; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.fun.RightSelectionHandlerProvider; @@ -969,7 +969,9 @@ public class FormDesigner extends TargetComponent
implements TreeSelection private void refreshCenter(Widget centerWidget, XLayoutContainer formLayoutContainer) { // 不存在center块, 说明是新建的模板 if (centerWidget == null) { + String styleName = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplatePredefinedStyle(); XLayoutContainer layoutContainer = (XLayoutContainer) XCreatorUtils.createXCreator(new WFitLayout("body")); + layoutContainer.initWidgetPredefinedInfo(styleName); layoutContainer.setSize(LARGE_PREFERRED_SIZE); setRootComponent(layoutContainer); formLayoutContainer.add(rootComponent, WBorderLayout.CENTER); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/ToolBarButton.java b/designer-form/src/main/java/com/fr/design/mainframe/ToolBarButton.java index f7558b07f1..a776c0cdd6 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/ToolBarButton.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/ToolBarButton.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.base.vcs.DesignerMode; import com.fr.design.designer.creator.XCreator; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.core.WidgetOption; @@ -93,7 +94,9 @@ public class ToolBarButton extends UIButton implements MouseListener, MouseMotio creatorSource = no.getNameOption().createWidget(); } if (creatorSource != null) { + String styleName = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplatePredefinedStyle(); XCreator xCreator = XCreatorUtils.createXCreator(creatorSource); + xCreator.initWidgetPredefinedInfo(styleName); WidgetToolBarPane.getTarget().startDraggingBean(xCreator); FormDesignerUtils.addWidgetProcessInfo(xCreator.toData()); lastPressEvent = null; diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleBodyBackgroundEditor.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleBodyBackgroundEditor.java new file mode 100644 index 0000000000..2b30721825 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleBodyBackgroundEditor.java @@ -0,0 +1,99 @@ +package com.fr.design.mainframe.widget.accessibles; + +import com.fr.design.Exception.ValidationException; +import com.fr.design.designer.properties.Decoder; +import com.fr.design.designer.properties.Encoder; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.gui.xpane.FormPredefinedBackgroundPane; +import com.fr.design.mainframe.widget.editors.ITextComponent; +import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer; +import com.fr.form.ui.NameFormBackground; + +import javax.swing.SwingUtilities; +import java.awt.Dimension; + +/** + * Created by kerry on 2020-09-02 + */ +public class AccessibleBodyBackgroundEditor extends UneditableAccessibleEditor { + private FormPredefinedBackgroundPane backgroundPane; + + public AccessibleBodyBackgroundEditor() { + super(new BackgroundStyleWrapper()); + } + + @Override + protected ITextComponent createTextField() { + return new RendererField(new BackgroundStyleRender()); + } + + @Override + protected void showEditorPane() { + if (backgroundPane == null) { + backgroundPane = new FormPredefinedBackgroundPane(); + backgroundPane.setPreferredSize(new Dimension(600, 400)); + } + BasicDialog dlg = backgroundPane.showWindow(SwingUtilities.getWindowAncestor(this)); + dlg.addDialogActionListener(new DialogActionAdapter() { + + @Override + public void doOk() { + setValue(backgroundPane.updateBean()); + fireStateChanged(); + } + }); + backgroundPane.populateBean((NameFormBackground) getValue()); + dlg.setVisible(true); + } + + private static class BackgroundStyleWrapper implements Encoder, Decoder { + public BackgroundStyleWrapper() { + + } + + /** + * 将属性转化成字符串 + * + * @param v 属性对象 + * @return 字符串 + */ + public String encode(Object v) { + if (v == null) { + return null; + } + NameFormBackground style = (NameFormBackground) v; + return style.usePredefinedStyle() ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Predefined") + : com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom"); + } + + /** + * 将字符串转化成属性 + * + * @param txt 字符串 + * @return 属性对象 + */ + public Object decode(String txt) { + return null; + } + + /** + * 符合规则 + * + * @param txt 字符串 + * @throws ValidationException 抛错 + */ + public void validate(String txt) throws ValidationException { + + } + + } + + private static class BackgroundStyleRender extends EncoderCellRenderer { + + public BackgroundStyleRender() { + super(new BackgroundStyleWrapper()); + } + + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleBorderStyleEditor.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleBorderStyleEditor.java new file mode 100644 index 0000000000..d6e14d1b85 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleBorderStyleEditor.java @@ -0,0 +1,100 @@ +package com.fr.design.mainframe.widget.accessibles; + +import com.fr.design.Exception.ValidationException; +import com.fr.design.designer.properties.Decoder; +import com.fr.design.designer.properties.Encoder; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.gui.xpane.PredefinedComponentStyleSettingPane; +import com.fr.design.mainframe.widget.editors.ITextComponent; +import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer; +import com.fr.design.widget.ui.designer.layout.ComponentStyle; + +import javax.swing.SwingUtilities; +import java.awt.Dimension; + +/** + * Created by kerry on 2020-09-07 + */ +public class AccessibleBorderStyleEditor extends UneditableAccessibleEditor { + private PredefinedComponentStyleSettingPane borderPane; + + public AccessibleBorderStyleEditor() { + super(new ComponentStyleWrapper()); + } + + @Override + protected ITextComponent createTextField() { + return new RendererField(new ComponentStyleRenderer()); + } + + @Override + protected void showEditorPane() { + if (borderPane == null) { + borderPane = new PredefinedComponentStyleSettingPane(); + borderPane.setPreferredSize(new Dimension(600, 400)); + } + BasicDialog dlg = borderPane.showWindow(SwingUtilities.getWindowAncestor(this)); + dlg.addDialogActionListener(new DialogActionAdapter() { + + @Override + public void doOk() { + setValue(borderPane.updateBean()); + fireStateChanged(); + } + }); + borderPane.populateBean((ComponentStyle) getValue()); + dlg.setVisible(true); + } + + + private static class ComponentStyleWrapper implements Encoder, Decoder { + public ComponentStyleWrapper() { + + } + + /** + * 将属性转化成字符串 + * + * @param v 属性对象 + * @return 字符串 + */ + public String encode(Object v) { + if (v == null) { + return null; + } + ComponentStyle style = (ComponentStyle) v; + return style.usePredefinedStyle() ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Predefined") : + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Custom"); + } + + /** + * 将字符串转化成属性 + * + * @param txt 字符串 + * @return 属性对象 + */ + public Object decode(String txt) { + return null; + } + + /** + * 符合规则 + * + * @param txt 字符串 + * @throws ValidationException 抛错 + */ + public void validate(String txt) throws ValidationException { + + } + + } + + private static class ComponentStyleRenderer extends EncoderCellRenderer { + + public ComponentStyleRenderer() { + super(new ComponentStyleWrapper()); + } + + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleWLayoutBorderStyleEditor.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleWLayoutBorderStyleEditor.java index ce68ff7487..628c65c8ef 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleWLayoutBorderStyleEditor.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleWLayoutBorderStyleEditor.java @@ -17,11 +17,11 @@ import java.awt.*; public class AccessibleWLayoutBorderStyleEditor extends UneditableAccessibleEditor { private LayoutBorderPane borderPane; - + public AccessibleWLayoutBorderStyleEditor() { super(new LayoutBorderStyleWrapper()); } - + @Override protected ITextComponent createTextField() { return new RendererField(new LayoutBorderStyleRenderer()); @@ -45,4 +45,4 @@ public class AccessibleWLayoutBorderStyleEditor extends UneditableAccessibleEdit borderPane.populate((LayoutBorderStyle)getValue()); dlg.setVisible(true); } -} \ No newline at end of file +} diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/BorderStyleWidgetDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/BorderStyleWidgetDefinePane.java index dbe2735e3f..4a2ac45c28 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/BorderStyleWidgetDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/BorderStyleWidgetDefinePane.java @@ -7,10 +7,9 @@ import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.widget.accessibles.AccessibleWLayoutBorderStyleEditor; +import com.fr.design.mainframe.widget.accessibles.AccessibleBorderStyleEditor; import com.fr.design.widget.ui.designer.AbstractDataModify; import com.fr.form.ui.AbstractBorderStyleWidget; -import com.fr.form.ui.LayoutBorderStyle; import javax.swing.*; @@ -20,7 +19,7 @@ import java.awt.*; * Created by kerry on 2017/8/29. */ public class BorderStyleWidgetDefinePane extends AbstractDataModify { - private AccessibleWLayoutBorderStyleEditor borderStyleEditor; + private AccessibleBorderStyleEditor borderStyleEditor; public BorderStyleWidgetDefinePane(XCreator xCreator) { super(xCreator); @@ -29,7 +28,7 @@ public class BorderStyleWidgetDefinePane extends AbstractDataModify { - private PaddingBoundPane paddingBoundPane; private AccessibleElementCaseToolBarEditor elementCaseToolBarEditor; private PropertyGroupPane extraPropertyGroupPane; @@ -32,35 +27,33 @@ public class ElementEditorDefinePane extends WTitleLayoutDefinePane 0) { + extraPropertyGroupPane = new PropertyGroupPane(extraTableEditor, creator); + centerPane.add(extraPropertyGroupPane, BorderLayout.CENTER); + } return centerPane; } protected ElementCaseEditor updateSubBean() { ElementCaseEditor elementCaseEditor = (ElementCaseEditor) creator.toData(); - if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"))) { - paddingBoundPane.update(elementCaseEditor); - } elementCaseEditor.setToolBars((FormToolBarManager[]) elementCaseToolBarEditor.getValue()); return elementCaseEditor; } protected void populateSubBean(ElementCaseEditor ob) { - paddingBoundPane.populate(ob); elementCaseToolBarEditor.setValue(ob.getToolBars()); - extraPropertyGroupPane.populate(ob); + if (extraPropertyGroupPane != null) { + extraPropertyGroupPane.populate(ob); + } } } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java index 3a53cf5ffb..eca5b10693 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java @@ -15,12 +15,13 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.design.mainframe.widget.accessibles.AccessibleBodyBackgroundEditor; import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor; -import com.fr.design.mainframe.widget.accessibles.AccessibleWLayoutBorderStyleEditor; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.design.widget.ui.designer.component.WidgetBoundPane; import com.fr.form.ui.LayoutBorderStyle; +import com.fr.form.ui.NameFormBackground; import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WBodyLayoutType; @@ -38,7 +39,7 @@ import java.awt.Component; public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane { private static final int MAX_LABEL_WIDTH = 80; - private AccessibleWLayoutBorderStyleEditor borderStyleEditor; + private AccessibleBodyBackgroundEditor backgroundEditor; private AccessibleBodyWatermarkEditor watermarkEditor; private WidgetBoundPane boundPane; @@ -55,11 +56,11 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane { JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); boundPane = new WidgetBoundPane(creator); centerPane.add(boundPane, BorderLayout.CENTER); - borderStyleEditor = new AccessibleWLayoutBorderStyleEditor(); + backgroundEditor = new AccessibleBodyBackgroundEditor(); watermarkEditor = new AccessibleBodyWatermarkEditor(); JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane( new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style")), borderStyleEditor}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background")), backgroundEditor}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), watermarkEditor} }, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1); JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); @@ -113,7 +114,9 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane { public void populateSubPane(WAbsoluteLayout ob) { layoutCombox.setSelectedIndex(1); - borderStyleEditor.setValue(ob.getBorderStyle()); + NameFormBackground formBackground = ob.getNameBackground(); + backgroundEditor.setValue(formBackground); + boundPane.populate(); watermarkEditor.setValue(ReportUtils.getWatermarkAttrFromTemplate(getCurrentIOFile())); } @@ -131,16 +134,27 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane { if (layoutType == WBodyLayoutType.ABSOLUTE) { ((XWFitLayout) creator.getBackupParent()).toData().resetStyle(); if (state == WBodyLayoutType.FIT.getTypeValue()) { - XWFitLayout xwFitLayout = ((XWFitLayout)creator.getBackupParent()); - xwFitLayout.switch2FitBodyLayout(creator); - copyLayoutAttr(layout, xwFitLayout.toData()); + XWFitLayout xwFitLayout = ((XWFitLayout) creator.getBackupParent()); + xwFitLayout.switch2FitBodyLayout(creator); + copyLayoutAttr(layout, xwFitLayout.toData()); } } - layout.setBorderStyle((LayoutBorderStyle) borderStyleEditor.getValue()); + LayoutBorderStyle borderStyle = new LayoutBorderStyle(); + NameFormBackground background = (NameFormBackground) backgroundEditor.getValue(); + updateBodyBackground(background, borderStyle); + layout.setBorderStyle(borderStyle); + layout.setNameBackground(background); updateWatermark(); return layout; } + private void updateBodyBackground(NameFormBackground background, LayoutBorderStyle borderStyle) { + if (background != null) { + borderStyle.setBackground(background.createRealStyle().getBackground()); + borderStyle.setAlpha(background.getBackgroundAlphaValue()); + } + } + private void updateWatermark() { WatermarkAttr watermark = (WatermarkAttr) watermarkEditor.getValue(); if (watermark != null) { diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java index 4481307bff..a3a703fae1 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java @@ -22,12 +22,13 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormSelectionUtils; import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.design.mainframe.widget.accessibles.AccessibleBodyBackgroundEditor; import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor; -import com.fr.design.mainframe.widget.accessibles.AccessibleWLayoutBorderStyleEditor; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.design.widget.ui.designer.component.PaddingBoundPane; import com.fr.form.ui.LayoutBorderStyle; +import com.fr.form.ui.NameFormBackground; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.form.ui.container.WAbsoluteLayout; @@ -55,7 +56,7 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane extends AbstractDataModify { - private AccessibleWLayoutBorderStyleEditor borderStyleEditor; + private AccessibleBorderStyleEditor borderStyleEditor; public WTitleLayoutDefinePane(XCreator xCreator) { super(xCreator); @@ -34,7 +30,7 @@ public abstract class WTitleLayoutDefinePane { public JWorkBook() { super(new WorkBook(new WorkSheet()), DEFAULT_WB_FILE_PREFIX); + initPredefinedInfo(); populateReportParameterAttr(); } + private void initPredefinedInfo() { + WorkBook workBook = this.getTarget(); + for (int i = 0; i < workBook.getReportCount(); i++) { + Report report = workBook.getReport(i); + if (report != null) { + NameBackground initBackground = NameBackground.createPredefinedStyle(StringUtils.EMPTY); + ((ReportSettings) report.getReportSettings()).setNameBackground(initBackground); + } + } + } + public JWorkBook(WorkBookX workBookX) { super(new WorkBookAdapter(workBookX), DEFAULT_WBX_FILE_PREFIX); populateReportParameterAttr(); @@ -153,6 +168,7 @@ public class JWorkBook extends JTemplate { populateReportParameterAttr(); } + @Override protected void addPane(PropertyItemPaneProvider provider) { PaneHolder holder = provider.getPaneHolder(JWorkBook.class); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java index 3706778609..fad55e1491 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java @@ -1,8 +1,9 @@ package com.fr.design.mainframe.cell.settingpane; +import com.fr.base.NameStyle; import com.fr.base.Style; import com.fr.design.constants.UIConstants; -import com.fr.design.mainframe.cell.settingpane.style.StylePane; +import com.fr.design.mainframe.cell.settingpane.style.CellPredefinedStyleSettingPane; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.report.cell.DefaultTemplateCellElement; @@ -10,8 +11,6 @@ import com.fr.report.cell.TemplateCellElement; import com.fr.report.elementcase.TemplateElementCase; import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import java.awt.*; /** @@ -19,26 +18,15 @@ import java.awt.*; * @since 2012-5-11下午3:59:39 */ public class CellStylePane extends AbstractCellAttrPane { - private StylePane stylePane; + private CellPredefinedStyleSettingPane stylePane; @Override public JPanel createContentPane() { JPanel content = new JPanel(new BorderLayout()); - stylePane = new StylePane(); + content.setBorder(BorderFactory.createEmptyBorder()); + stylePane = new CellPredefinedStyleSettingPane(); content.add(stylePane, BorderLayout.CENTER); stylePane.setBorder(UIConstants.CELL_ATTR_PRESENTBORDER); - stylePane.addPredefinedChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - attributeChanged(); - } - }); - stylePane.addCustomTabChangeListener(new ChangeListener() { - - @Override - public void stateChanged(ChangeEvent e) { - adjustValues();// 里面的Tab切换后要及时调整滚动条,因为一些界面可能不需要滚动条 - } - }); return content; } @@ -67,56 +55,36 @@ public class CellStylePane extends AbstractCellAttrPane { @Override public void updateBeans() { - if (stylePane.getSelectedIndex() == 1) { - Style s = stylePane.updateBean(); - TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); - int cellRectangleCount = cs.getCellRectangleCount(); - for (int rect = 0; rect < cellRectangleCount; rect++) { - Rectangle cellRectangle = cs.getCellRectangle(rect); - for (int j = 0; j < cellRectangle.height; j++) { - for (int i = 0; i < cellRectangle.width; i++) { - int column = i + cellRectangle.x; - int row = j + cellRectangle.y; - TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); - if (cellElement == null) { - cellElement = new DefaultTemplateCellElement(column, row); - elementCase.addCellElement(cellElement); - } - cellElement.setStyle(s); - } - } - } - } else { - TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); - int cellRectangleCount = cs.getCellRectangleCount(); - for (int rect = 0; rect < cellRectangleCount; rect++) { - Rectangle cellRectangle = cs.getCellRectangle(rect); - for (int j = 0; j < cellRectangle.height; j++) { - for (int i = 0; i < cellRectangle.width; i++) { - int column = i + cellRectangle.x; - int row = j + cellRectangle.y; - TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); - if (cellElement == null) { - cellElement = new DefaultTemplateCellElement(column, row); - elementCase.addCellElement(cellElement); - } - Style style = cellElement.getStyle(); - if (style == null) { - style = Style.DEFAULT_STYLE; - - } - style = stylePane.updateStyle(style); - cellElement.setStyle(style); + NameStyle s = stylePane.updateBean(); + TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); + int cellRectangleCount = cs.getCellRectangleCount(); + for (int rect = 0; rect < cellRectangleCount; rect++) { + Rectangle cellRectangle = cs.getCellRectangle(rect); + for (int j = 0; j < cellRectangle.height; j++) { + for (int i = 0; i < cellRectangle.width; i++) { + int column = i + cellRectangle.x; + int row = j + cellRectangle.y; + TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); + if (cellElement == null) { + cellElement = new DefaultTemplateCellElement(column, row); + elementCase.addCellElement(cellElement); } + cellElement.setStyle(s); } } - stylePane.updateBorder();// border必须特别处理 } + stylePane.updateBorder();// border必须特别处理 } @Override protected void populateBean() { - stylePane.populateBean(cellElement.getStyle()); + Style style = cellElement.getStyle(); + if (style instanceof NameStyle) { + stylePane.populateBean((NameStyle) style); + } else { + //说明是未经过转换的 + stylePane.populateBean(NameStyle.createCustomStyle(cellElement.getStyle())); + } stylePane.dealWithBorder(elementCasePane); } @@ -126,7 +94,6 @@ public class CellStylePane extends AbstractCellAttrPane { } public void setSelectedByIds(int level, String... id) { - stylePane.setSelctedByName(id[level]); } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CellPredefinedStyleSettingPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CellPredefinedStyleSettingPane.java new file mode 100644 index 0000000000..0724c98737 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CellPredefinedStyleSettingPane.java @@ -0,0 +1,243 @@ +package com.fr.design.mainframe.cell.settingpane.style; + +import com.fr.base.CellBorderStyle; +import com.fr.base.NameStyle; +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.config.ServerPreferenceConfig; +import com.fr.design.actions.utils.ReportActionUtils; +import com.fr.design.constants.UIConstants; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.MultiTabPane; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.style.AbstractBasicStylePane; +import com.fr.design.gui.style.AlignmentPane; +import com.fr.design.gui.style.BackgroundPane; +import com.fr.design.gui.style.BorderPane; +import com.fr.design.gui.style.FormatPane; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.predefined.ui.PredefinedStyleSettingPane; +import com.fr.design.mainframe.predefined.ui.preview.StyleSettingPreviewPane; +import com.fr.design.style.BorderUtils; +import com.fr.stable.Constants; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * Created by kerry on 2020-09-02 + */ +public class CellPredefinedStyleSettingPane extends PredefinedStyleSettingPane { + + private CustomStylePane customPredefinedStylePane; + + private UIComboBox applicationFormat; + + + @Override + protected StyleSettingPreviewPane createPreviewPane() { + return null; + } + + @Override + protected JPanel createCustomDetailPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + customPredefinedStylePane = new CustomStylePane(); + jPanel.add(customPredefinedStylePane, BorderLayout.CENTER); + return jPanel; + } + + protected JPanel createPredefinedSettingPane() { + + applicationFormat = new UIComboBox(); + applicationFormat.setPreferredSize(new Dimension(140, 20)); + JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_Applicate_Format")), applicationFormat} + }, TableLayoutHelper.FILL_NONE, IntervalConstants.INTERVAL_W4, IntervalConstants.INTERVAL_L1); + + return centerPane; + } + + + @Override + public String title4PopupWindow() { + return null; + } + + @Override + public void populateBean(NameStyle ob) { + this.setPopulating(true); + super.populate(ob); + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + String styleName = template.getTemplatePredefinedStyle(); + PredefinedStyle predefinedStyle = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig().getStyle(styleName); + PredefinedCellStyleConfig config = predefinedStyle.getCellStyleConfig(); + Map allStyle = config.getAllStyles(); + this.applicationFormat.clearBoxItems(); + for (String name : allStyle.keySet()) { + this.applicationFormat.addItem(name); + } + if (allStyle.containsKey(ob.getName())) { + this.applicationFormat.setSelectedItem(ob.getName()); + }else { + this.applicationFormat.setSelectedItem(config.getDefaultStyleName()); + } + this.customPredefinedStylePane.populateBean(ob); + this.setPopulating(false); + } + + public void dealWithBorder(ElementCasePane ePane) { + + this.customPredefinedStylePane.dealWithBorder(ePane); + } + + public void updateBorder() { + this.customPredefinedStylePane.updateBorder(); + } + + @Override + public NameStyle updateBean() { + NameStyle nameStyle = null; + if (this.predefinedRadioBtn.isSelected()) { + Object selectItem = this.applicationFormat.getSelectedItem(); + nameStyle = NameStyle.createPredefinedStyle(getPredefinedStyleName(), selectItem == null ? StringUtils.EMPTY : selectItem.toString(), Style.getInstance()); + } else { + Style style = this.customPredefinedStylePane.updateBean(); + if (!(style instanceof NameStyle)) { + nameStyle = NameStyle.createCustomStyle(style); + } + } + return nameStyle; + } + + class CustomStylePane extends MultiTabPane