diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index ce495cdb97..0ddb749269 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -5,6 +5,7 @@ import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.dialog.link.MessageWithLink; import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceType; @@ -18,7 +19,10 @@ import com.fr.design.mainframe.JTemplate; import com.fr.design.utils.DesignUtils; import com.fr.env.CheckServiceDialog; import com.fr.env.EnvListPane; +import com.fr.env.RemoteWorkspaceURL; +import com.fr.env.TestConnectionResult; import com.fr.exit.DesignerExiter; +import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; import com.fr.invoke.Reflect; import com.fr.json.JSONArray; @@ -40,6 +44,7 @@ import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.engine.base.FineObjectPool; import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; import com.fr.workspace.engine.exception.WorkspaceAuthException; +import com.fr.workspace.engine.exception.WorkspaceCheckException; import com.fr.workspace.engine.exception.WorkspaceConnectionException; import com.fr.workspace.engine.rpc.WorkspaceProxyPool; @@ -145,21 +150,28 @@ public class EnvChangeEntrance { strategy.showTip(new PopTip() { @Override public void show() { - FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), + Toolkit.i18nText("Fine-Design_Basic_Error"), + ERROR_MESSAGE, + UIManager.getIcon("OptionPane.errorIcon")); } }); return false; + } catch (WorkspaceCheckException e) { + handleWorkspaceCheckException(e, strategy, connectionInfo); + return false; } catch (Exception exception) { - FineLoggerFactory.getLogger().error(exception.getMessage(), exception); - strategy.showTip(new PopTip() { - @Override - public void show() { - FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); - } - }); - + if (exception.getCause() instanceof WorkspaceCheckException) { + handleWorkspaceCheckException((WorkspaceCheckException) exception.getCause(), strategy, connectionInfo); + } else { + FineLoggerFactory.getLogger().error(exception.getMessage(), exception); + strategy.showTip(() -> FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), + Toolkit.i18nText("Fine-Design_Basic_Error"), + ERROR_MESSAGE, + UIManager.getIcon("OptionPane.errorIcon"))); + } return false; } TemplateTreePane.getInstance().refreshDockingView(); @@ -170,6 +182,29 @@ public class EnvChangeEntrance { return true; } + public void handleWorkspaceCheckException(WorkspaceCheckException e, PopTipStrategy strategy, WorkspaceConnectionInfo info) { + TestConnectionResult result = TestConnectionResult.parseByException(e); + FineLoggerFactory.getLogger().error(e.getMessage(), e); + if (ComparatorUtils.equals(result, TestConnectionResult.AUTH_FAILED)) { + strategy.showTip(() -> FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), + Toolkit.i18nText("Fine-Design_Basic_Error"), + ERROR_MESSAGE, + UIManager.getIcon("OptionPane.errorIcon"))); + } else { + if (result.isVerifyResult()) { + FineLoggerFactory.getLogger().error(result.getText().replaceAll(TestConnectionResult.WRAP, StringUtils.EMPTY) + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord")); + } + strategy.showTip(() -> FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + result.isVerifyResult() + ? new MessageWithLink(result.getText(), Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"), info.getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH) + : result.getText(), + Toolkit.i18nText("Fine-Design_Basic_Error"), + ERROR_MESSAGE, + UIManager.getIcon("OptionPane.errorIcon"))); + } + } + /** * 这个功能留着,可能会加回来,先做注释处理 * 切换远程环境之前,进行版本检测,当版本不一致的时候,提示。 @@ -461,7 +496,7 @@ public class EnvChangeEntrance { /** * 提示显示策略 */ - enum PopTipStrategy { + public enum PopTipStrategy { /** * 切换失败,就马上提示失败,不关闭选择列表对话框 diff --git a/designer-base/src/main/java/com/fr/design/condition/ObjectLiteConditionPane.java b/designer-base/src/main/java/com/fr/design/condition/ObjectLiteConditionPane.java index b863717f60..c39d5b7446 100644 --- a/designer-base/src/main/java/com/fr/design/condition/ObjectLiteConditionPane.java +++ b/designer-base/src/main/java/com/fr/design/condition/ObjectLiteConditionPane.java @@ -77,7 +77,7 @@ public class ObjectLiteConditionPane extends LiteConditionPane } }); - conditionValuePane = ValueEditorPaneFactory.createAllValueEditorPane(); + conditionValuePane = ValueEditorPaneFactory.createAllValueEditorPaneWithGlobalListener(); Component[][] components = { { new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ConditionB_Operator") + ":"), new UILabel() }, { conditionOPComboBox, conditionValuePane } }; diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java index 94efc5faa8..80471b9e65 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java @@ -113,6 +113,11 @@ public class TableDataTree extends UserObjectRefreshJTree { break; } new_nodes[ci].setExpanded(cTreeNode.isExpanded()); + // REPORT-41299 如果建立的是错误的数据集(没有Child的情况)且这个错误数据集处于isExpanded状态,会在后面的if语句中调用getFirstChild()产生异常,因此这里判断一下 + if (cTreeNode.isExpanded() && cTreeNode.getChildCount() == 0) { + new_nodes[ci].setExpanded(false); + break; + } if (cTreeNode.getFirstChild() instanceof ExpandMutableTreeNode && cTreeNode.isExpanded()) { checkChildNodes(cTreeNode, new_nodes[ci]); } @@ -242,4 +247,4 @@ public class TableDataTree extends UserObjectRefreshJTree { treeModel.reload(root); } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java b/designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java new file mode 100644 index 0000000000..8a1f55cbdf --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java @@ -0,0 +1,55 @@ +package com.fr.design.dialog.link; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; +import java.awt.Color; +import java.awt.Desktop; +import java.awt.Font; +import java.net.URI; +import javax.swing.JEditorPane; +import javax.swing.event.HyperlinkEvent; + +/** + * 用来构建JOptionPane带超链的消息提示 + * + * @author hades + * @version 10.0 + * Created by hades on 2020/10/23 + */ +public class MessageWithLink extends JEditorPane { + + public MessageWithLink(String message, String linkName, String link) { + super("text/html", "" + message + "" + linkName + "" + ""); + addHyperlinkListener(e -> { + if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { + try { + Desktop.getDesktop().browse(URI.create(link)); + } catch (Exception exception) { + FineLoggerFactory.getLogger().error(exception.getMessage(), exception); + } + } + }); + setEditable(false); + setBorder(null); + } + + public MessageWithLink(String linkName, String link ) { + this(StringUtils.EMPTY, linkName, link); + } + + private static StringBuilder getStyle() { + // 构建和相同风格样式 + UILabel label = new UILabel(); + Font font = label.getFont(); + Color color = label.getBackground(); + + StringBuilder style = new StringBuilder("font-family:" + font.getFamily() + ";"); + style.append("font-weight:").append(font.isBold() ? "bold" : "normal").append(";"); + style.append("font-size:").append(font.getSize()).append("pt;"); + style.append("background-color: rgb(").append(color.getRed()).append(",").append(color.getGreen()).append(",").append(color.getBlue()).append(");"); + + return style; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/editor/ValueEditorPaneFactory.java b/designer-base/src/main/java/com/fr/design/editor/ValueEditorPaneFactory.java index 71959b72da..4622920996 100644 --- a/designer-base/src/main/java/com/fr/design/editor/ValueEditorPaneFactory.java +++ b/designer-base/src/main/java/com/fr/design/editor/ValueEditorPaneFactory.java @@ -19,17 +19,18 @@ import com.fr.design.editor.editor.TextEditor; import com.fr.design.editor.editor.WidgetNameEditor; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itableeditorpane.ParameterTableModel; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.stable.StringUtils; -import javax.swing.*; -import java.awt.*; +import java.awt.BorderLayout; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import javax.swing.JPanel; public class ValueEditorPaneFactory { @@ -155,6 +156,16 @@ public class ValueEditorPaneFactory { return createValueEditorPane(allEditors(), StringUtils.EMPTY, StringUtils.EMPTY); } + /** + * 带有所有编辑器的ValueEditorPane + * 同时需要注册全局监听的编辑器注册下监听 + * + * @return 值编辑器面板 + */ + public static ValueEditorPane createAllValueEditorPaneWithGlobalListener() { + return createValueEditorPane(allEditorsWithGlobalListener(), StringUtils.EMPTY, StringUtils.EMPTY); + } + /** * 创建不带公式面板的pane * @@ -359,6 +370,29 @@ public class ValueEditorPaneFactory { }; } + /** + * 所有类型的编辑器 + * 同时注册需要的监听 + * + * @return 值编辑器 + */ + public static Editor[] allEditorsWithGlobalListener() { + FormulaEditor formulaEditor = new FormulaEditor(Toolkit.i18nText("Fine-Design_Basic_Parameter_Formula")); + ColumnSelectedEditor columnSelectedEditor = new ColumnSelectedEditor(); + columnSelectedEditor.registerDSChangeListener(); + return new Editor[]{ + new TextEditor(), + new IntegerEditor(), + new DoubleEditor(), + new DateEditor(true, Toolkit.i18nText("Fine-Design_Basic_Date")), + new BooleanEditor(), + formulaEditor, + new ParameterEditor(), + new ColumnRowEditor(Toolkit.i18nText("Fine-Design_Basic_Cell")), + columnSelectedEditor, + }; + } + /** * 不带公式编辑器 * diff --git a/designer-base/src/main/java/com/fr/design/editor/editor/ColumnSelectedEditor.java b/designer-base/src/main/java/com/fr/design/editor/editor/ColumnSelectedEditor.java index ade55ae8bf..5260ce1752 100644 --- a/designer-base/src/main/java/com/fr/design/editor/editor/ColumnSelectedEditor.java +++ b/designer-base/src/main/java/com/fr/design/editor/editor/ColumnSelectedEditor.java @@ -3,6 +3,7 @@ package com.fr.design.editor.editor; import com.fr.design.data.DesignTableDataManager; import com.fr.data.SimpleDSColumn; import com.fr.design.data.datapane.TableDataComboBox; +import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.layout.FRGUIPaneFactory; @@ -22,7 +23,7 @@ import java.util.regex.Pattern; * @author zhou * @since 2012-3-29下午6:05:08 */ -public class ColumnSelectedEditor extends Editor { +public class ColumnSelectedEditor extends Editor implements Prepare4DataSourceChange { TableDataComboBox tableDataComboBox; private UIComboBox columnNameComboBox; protected String[] columnNames; @@ -107,4 +108,9 @@ public class ColumnSelectedEditor extends Editor { tableDataComboBox.setSelectedItem(null); columnNameComboBox.setSelectedItem(null); } + + @Override + public void registerDSChangeListener() { + tableDataComboBox.registerGlobalDSChangeListener(); + } } diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java index 37a671eeb8..f9de1cfa41 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java @@ -169,7 +169,8 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { return result; } try { - result = WorkContext.getConnector().testConnection(connection); + WorkContext.getConnector().validateVT(connection); + result = true; } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); return result; diff --git a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java index ba1cce5563..763ffcd1ff 100644 --- a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java +++ b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java @@ -13,6 +13,7 @@ import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplateFactory; import com.fr.design.mainframe.JVirtualTemplate; import com.fr.design.module.DesignModuleFactory; +import com.fr.design.ui.util.UIUtil; import com.fr.file.FILE; import com.fr.file.FileNodeFILE; import com.fr.file.StashedFILE; @@ -22,6 +23,7 @@ import com.fr.stable.CoreConstants; import com.fr.stable.StringUtils; import com.fr.third.org.apache.commons.io.FilenameUtils; +import javax.swing.SwingUtilities; import java.io.ByteArrayOutputStream; import java.util.ArrayList; import java.util.Collections; @@ -427,4 +429,16 @@ public class HistoryTemplateListCache implements CallbackEvent { jt.refreshResource(); } } + + /** + * 重绘当前模板 + */ + public void repaintCurrentEditingTemplate(){ + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + getCurrentEditingTemplate().repaint(); + } + }); + } } diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/UINumberDragPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/UINumberDragPane.java index b1958a8c19..7314025724 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/UINumberDragPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/UINumberDragPane.java @@ -1,17 +1,16 @@ package com.fr.design.gui.frpane; -import java.awt.BorderLayout; -import java.awt.Dimension; - -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - import com.fr.design.beans.BasicBeanPane; import com.fr.design.event.GlobalNameListener; import com.fr.design.event.GlobalNameObserver; import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.style.NumberDragBar; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Dimension; + public class UINumberDragPane extends BasicBeanPane implements GlobalNameObserver { private static final long serialVersionUID = -8681716725163358249L; @@ -35,7 +34,7 @@ public class UINumberDragPane extends BasicBeanPane implements GlobalNam public UINumberDragPane(double minValue, double maxValue, double dierta) { dragBar = new NumberDragBar((int) minValue, (int) maxValue); - spinner = new UISpinner(minValue, maxValue, dierta, minValue); + spinner = createUISpinner(minValue, maxValue, dierta); spinner.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_StyleAlignment_Text_Rotation")); this.setLayout(new BorderLayout(4, 0)); this.add(spinner, BorderLayout.EAST); @@ -66,6 +65,10 @@ public class UINumberDragPane extends BasicBeanPane implements GlobalNam }); } + protected UISpinner createUISpinner(double minValue, double maxValue, double dierta) { + return new UISpinner(minValue, maxValue, dierta, minValue); + } + /** * 添加事件 * @param l 事件 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/BackgroundNoImagePane.java b/designer-base/src/main/java/com/fr/design/gui/style/BackgroundNoImagePane.java index 54ad9623ef..d3ed4f1af1 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 @@ -42,4 +42,4 @@ public class BackgroundNoImagePane extends BackgroundPane{ gradientPane }; } -} \ No newline at end of file +} 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..13dd9e3c9d 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 @@ -172,4 +172,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..7fa2664235 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 @@ -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,7 @@ public class BackgroundSpecialPane extends BackgroundPane{ }); kinds.add(newTypePane); } - + return kinds.toArray(new BackgroundQuickPane[kinds.size()]); } -} \ No newline at end of file +} 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/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index 2f65fca0a8..490b4e7e99 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -548,10 +548,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta contentHeight = layeredPane.getHeight(); contentWidth = layeredPane.getWidth(); - layeredPane.remove(basePane); + // 这个地方remove和add都是一个对象 完全没有必要remove再add 改变了窗口大小重新设置下 然后有repaint即可 basePane.setBounds(0, 0, contentWidth, contentHeight); - layeredPane.add(basePane); layeredPane.repaint(); + layeredPane.revalidate(); } /** 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..73d5d0bb1f 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 @@ -1323,4 +1323,8 @@ public abstract class JTemplate> return getEditingFILE().getName(); } + public String getTemplatePredefinedStyle(){ + return StringUtils.EMPTY; + } + } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplateActionListenerAdapter.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateActionListenerAdapter.java new file mode 100644 index 0000000000..7065f3e94f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateActionListenerAdapter.java @@ -0,0 +1,22 @@ +package com.fr.design.mainframe; + +/** + * @Author: Yuan.Wang + * @Date: 2020/10/27 + */ +public class JTemplateActionListenerAdapter implements JTemplateActionListener { + @Override + public void templateOpened(JTemplate jt) { + + } + + @Override + public void templateSaved(JTemplate jt) { + + } + + @Override + public void templateClosed(JTemplate jt) { + + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/VanChartGradientPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/VanChartGradientPane.java new file mode 100644 index 0000000000..e891bd934a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/VanChartGradientPane.java @@ -0,0 +1,103 @@ +package com.fr.design.mainframe.backgroundpane; + +import com.fr.base.background.GradientBackground; +import com.fr.design.event.UIObserverListener; +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.style.background.gradient.FixedGradientBar; +import com.fr.general.Background; + +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Component; + +/** + * 渐变色设置界面,bar无法拖拽 + */ +public class VanChartGradientPane extends GradientBackgroundQuickPane { + protected static final int CHART_GRADIENT_WIDTH = 150; + private static final long serialVersionUID = 256594362341221087L; + + private FixedGradientBar gradientBar; + private UIButtonGroup directionPane; + + public VanChartGradientPane() { + constructPane(); + } + + protected void constructPane(){ + String[] textArray = {com.fr.design.i18n.Toolkit.i18nText("FIne-Design_Report_Utils_Left_To_Right"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Top_To_Bottom")}; + Integer[] valueArray = {GradientBackground.LEFT2RIGHT, GradientBackground.TOP2BOTTOM}; + directionPane = new UIButtonGroup(textArray, valueArray); + directionPane.setSelectedIndex(0); + gradientBar = new FixedGradientBar(4, CHART_GRADIENT_WIDTH); + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p, p, p}; + + Component[][] components = new Component[][]{ + new Component[]{gradientBar, null}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Gradient_Direction")),directionPane}, + }; + JPanel Gradient = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + this.setLayout(new BorderLayout()); + this.add(Gradient, BorderLayout.CENTER); + } + + public void populateBean(Background background) { + GradientBackground bg = (GradientBackground) background; + this.gradientBar.getSelectColorPointBtnP1().setColorInner(bg.getStartColor()); + this.gradientBar.getSelectColorPointBtnP2().setColorInner(bg.getEndColor()); + directionPane.setSelectedItem(bg.getDirection()); + this.gradientBar.repaint(); + } + + public GradientBackground updateBean() { + GradientBackground gb = new GradientBackground(gradientBar.getSelectColorPointBtnP1().getColorInner(), gradientBar.getSelectColorPointBtnP2().getColorInner()); + gb.setDirection(directionPane.getSelectedItem()); + + return gb; + } + + /** + * 给组件登记一个观察者监听事件 + * + * @param listener 观察者监听事件 + */ + public void registerChangeListener(final UIObserverListener listener) { + gradientBar.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + listener.doChange(); + } + }); + directionPane.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + listener.doChange(); + } + }); + } + + /** + * 是否接受 + * @param background 背景 + * @return 是则返回true + */ + public boolean accept(Background background) { + return background instanceof GradientBackground; + } + + /** + * 名称 + * @return 名称 + */ + public String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Gradient_Color"); + } + +} 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..c4ebcf225f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/PatternStyle.java @@ -0,0 +1,40 @@ +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(); + return new PredefinedStyle(); + } + }, + LIGHT_STYLE(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Light_Pattern")) { + @Override + public PredefinedStyle getPredefinedStyle() { +// return PredefinedPatternStyleManager.INSTANCE.getLightMode(); + return new PredefinedStyle(); + } + }; + + + 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/ui/PredefinedStyleBlock.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleBlock.java new file mode 100644 index 0000000000..67b369a6c9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleBlock.java @@ -0,0 +1,143 @@ +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.setParent(this); + content.setPreferredSize(new Dimension(200, 180)); + 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, 210)); + 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..33698d7c1e --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java @@ -0,0 +1,374 @@ +package com.fr.design.mainframe.predefined.ui; + +import com.fr.base.ChartColorMatching; +import com.fr.base.ChartPreStyleConfig; +import com.fr.base.Style; +import com.fr.base.background.ColorBackground; +import com.fr.config.predefined.ColorFillStyle; +import com.fr.config.predefined.PredefinedCellStyle; +import com.fr.config.predefined.PredefinedCellStyleConfig; +import com.fr.config.predefined.PredefinedColorStyle; +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.file.HistoryTemplateListCache; +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.ui.util.UIUtil; +import com.fr.design.utils.DesignUtils; +import com.fr.general.FRFont; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; +import com.fr.transaction.Configurations; +import com.fr.transaction.WorkerFacade; + +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.Color; +import java.awt.Dimension; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Created by kerry on 2020-08-26 + */ +public class PredefinedStyleEditPane extends AbstractAttrNoScrollPane { + private static final Color TIP_COLOR = Color.decode("#8F8F92"); + + 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, 500)); + + 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(); + this.cellStyleSettingPane.registerAttrChangeListener(new AttributeChangeListener() { + @Override + public void attributeChange() { + valueChangeAction(); + } + }); + 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.setLayout(new BorderLayout(0, 5)); + jPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5)); + this.componentStyleSettingPane = new ComponentStyleSettingPane(); + UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_ComponentStyle_Setting_Tip")); + label.setForeground(TIP_COLOR); + jPanel.add(label, BorderLayout.NORTH); + jPanel.add(this.componentStyleSettingPane, BorderLayout.CENTER); + 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()); + PredefinedCellStyleConfig cellStyleConfig = this.cellStyleSettingPane.updateBean(); + predefinedStyle.setCellStyleConfig(cellStyleConfig); + + predefinedStyle.setPredefinedBackground(this.backgroundSettingPane.updateBean()); + predefinedStyle.setComponentStyle(this.componentStyleSettingPane.updateBean()); + + PredefinedColorStyle colorStyle = this.colorFillStylePane.update(); + updateCellStyleByColorStyle(colorStyle, cellStyleConfig); + predefinedStyle.setPredefinedColorStyle(colorStyle); + predefinedStyle.setPredefinedChartStyle(this.chartStyleSettingPane.updateBean()); + return predefinedStyle; + } + + private void updateCellStyleByColorStyle(PredefinedColorStyle colorStyle, PredefinedCellStyleConfig cellStyleConfig) { + PredefinedCellStyle headerStyle = cellStyleConfig.getStyle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header")); + PredefinedCellStyle highlightStyle = cellStyleConfig.getStyle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Highlight_Text")); + ColorFillStyle colorFillStyle = colorStyle.getColorFillStyle(); + List colorList = new ArrayList<>(); + if (colorFillStyle == null || colorFillStyle.getColorList().size() == 0){ + ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); + String defaultName = config.getCurrentStyle(); + ChartColorMatching defaultStyle = (ChartColorMatching) config.getPreStyle(defaultName); + if (defaultStyle != null) { + colorList = defaultStyle.getColorList(); + } + } else { + colorList = colorFillStyle.getColorList(); + } + if (colorList.size() < 2) { + return; + } + if (headerStyle != null) { + Style style = headerStyle.getStyle(); + Color color = colorList.get(0); + headerStyle.setStyle(style.deriveBackground(ColorBackground.getInstance(color))); + } + if (highlightStyle != null) { + Style style = highlightStyle.getStyle(); + Color color = colorList.get(1); + FRFont font = style.getFRFont(); + font.setForeground(color); + highlightStyle.setStyle(style.deriveFRFont(font)); + } + } + + 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; + } + HistoryTemplateListCache.getInstance().repaintCurrentEditingTemplate(); + 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); + PredefinedStyleConfig sortedConfig = resortConfigStyles(previewObject, config); +// Configurations.modify(new WorkerFacade(ServerPreferenceConfig.class) { +// @Override +// public void run() { +// ServerPreferenceConfig.getInstance().setPreferenceStyleConfig(sortedConfig); +// } +// }); + 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; + } + + private PredefinedStyleConfig resortConfigStyles(PredefinedStyle priorityStyle, PredefinedStyleConfig config){ + PredefinedStyleConfig sortedConfig = new PredefinedStyleConfig(); + PredefinedStyle defaultStyle = config.getDefaultPredefinedStyle(); + if (defaultStyle != null) { + sortedConfig.add(defaultStyle); + config.removeStyle(defaultStyle.getStyleName()); + sortedConfig.setDefaultPredefinedStyle(defaultStyle.getStyleName()); + } + if (priorityStyle != null && !priorityStyle.isDefaultStyle()) { + sortedConfig.add(priorityStyle); + config.removeStyle(priorityStyle.getStyleName()); + } + Iterator iterator = config.getPredefinedStyleIterator(); + while (iterator.hasNext()) { + PredefinedStyle entry = iterator.next(); + sortedConfig.add(entry); + } + sortedConfig.setCompatibleStyleName(config.getCompatibleStyleName()); + return sortedConfig; + } + + + + +} 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..227c9e30d0 --- /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.ServerPreferenceConfig; +import com.fr.config.predefined.PredefinedStyle; +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.util.Iterator; +import java.awt.BorderLayout; +import java.awt.Dimension; + +/** + * 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, 220 * 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..bd849414fe --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSettingPane.java @@ -0,0 +1,159 @@ +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) { + populateCustomPane(); + 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(); + } + + + /** + * 用于在切换到预定义样式后重置自定义样式的设置 + */ + protected abstract void populateCustomPane(); + + + /** + * 展示数据 + * + * @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..b29e7ffdf9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ReportPredefinedStylePane.java @@ -0,0 +1,51 @@ +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; + + public ReportPredefinedStylePane(JTemplate jTemplate) { + this.currentTemplate = jTemplate; + 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()); + } + } + + 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..cc0cbf15fd --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ServerPredefinedStylePane.java @@ -0,0 +1,218 @@ +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 com.fr.transaction.Configurations; +import com.fr.transaction.WorkerFacade; + +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()); +// Configurations.modify(new WorkerFacade(ServerPreferenceConfig.class) { +// @Override +// public void run() { +// ServerPreferenceConfig.getInstance().setPreferenceStyleConfig(config); +// } +// }); + } + + } + + + @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); + PredefinedStyle predefinedStyle = style.getPredefinedStyle(); + predefinedStyle.setStyleName(StringUtils.EMPTY); + editPane.populate(predefinedStyle); + editDialog.setVisible(true); + } + } + + + private void removeStyle(String name) { + PredefinedStyleConfig config = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig(); + config.removeStyle(name); +// Configurations.modify(new WorkerFacade(ServerPreferenceConfig.class) { +// @Override +// public void run() { +// ServerPreferenceConfig.getInstance().setPreferenceStyleConfig(config); +// } +// }); + } + +} 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..3c966c3c49 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleListControlPane.java @@ -0,0 +1,308 @@ +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.BasicPane; +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.frpane.AttributeChangeListener; +import com.fr.design.gui.ilist.ListModelElement; +import com.fr.design.gui.ilist.ModNameActionListener; +import com.fr.design.gui.style.AlignmentPane; +import com.fr.design.gui.style.FormatPane; +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.invoke.Reflect; +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; + private AttributeChangeListener attributeChangeListener; + + + + 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(); + } + }); + } + + + + public void registerAttrChangeListener(AttributeChangeListener listener){ + this.attributeChangeListener = listener; + } + + + 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(Toolkit.i18nText("Fine-Design_Predefined_Cell_New_Style"), + PredefinedCellStyle.class, CustomPredefinedStylePaneNoBorder.class) { + @Override + public boolean acceptDefaultNameObject(Object ob) { + return ((PredefinedCellStyle) ob).isDefaultStyle(); + } + }, + new CellStyleNameObjectCreator(Toolkit.i18nText("Fine-Design_Predefined_Cell_New_Style"), + PredefinedCellStyle.class, CustomPredefinedStylePane.class)}; + } + + @Override + public BasicBeanPane createPaneByCreators(NameableCreator creator) { + CustomPredefinedStylePane stylePane = (CustomPredefinedStylePane) super.createPaneByCreators(creator); + stylePane.registerAttrChangeListener(attributeChangeListener); + return stylePane; + } + + + + @Override + protected String title4PopupWindow() { + return StringUtils.EMPTY; + } + + 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[]{ + createAddItemShortCut4JControlPane(), + new RemoveItemShortCut4JControlPane(new RemoveItemAction()) + }; + } + + + private static class CustomPredefinedStylePaneNoBorder extends CustomPredefinedStylePane { + @Override + protected List initPaneList() { + paneList = new ArrayList(); + paneList.add(new FormatPane()); + paneList.add(new AlignmentPane()); + return paneList; + } + + } + + + private ShortCut4JControlPane createAddItemShortCut4JControlPane (){ + ShortCut shortCut = shortCutFactory.createAddItemUpdateAction(new NameableCreator[]{ + new CellStyleNameObjectCreator(Toolkit.i18nText("Fine-Design_Predefined_Cell_New_Style"), + PredefinedCellStyle.class, CustomPredefinedStylePane.class)}); + return new AddItemShortCut4JControlPane(shortCut); + } + + private class AddItemShortCut4JControlPane extends ShortCut4JControlPane{ + AddItemShortCut4JControlPane(ShortCut shortCut) { + this.shortCut = shortCut; + } + + + @Override + public void checkEnable() { + this.shortCut.setEnabled(true); + } + } + + + private 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; + } + /** + * + * @param ob + * @return + */ + public Object acceptObject2Populate(Object ob) { + if (ob instanceof NameObject) { + ob = ((NameObject) ob).getObject(); + } + if (clazzOfObject != null && clazzOfObject.isInstance(ob) && acceptDefaultNameObject(ob)) { + doSthChanged4Icon(ob); + return ob; + } + return null; + } + + public boolean acceptDefaultNameObject(Object ob) { + return !((PredefinedCellStyle) ob).isDefaultStyle(); + } + } + + + /** + * 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..e2d306933c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ComponentStyleSettingPane.java @@ -0,0 +1,63 @@ +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.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; + + public ComponentStyleSettingPane() { + } + + + @Override + protected List initPaneList() { + this.frameStylePane = new ComponentFrameStylePane(); + this.titleStylePane = ComponentTitleStylePane.createPredefinedSettingPane(); + paneList = new ArrayList(); + paneList.add(this.frameStylePane); + paneList.add(this.titleStylePane); + return paneList; + } + + @Override + public void populateBean(PredefinedComponentStyle ob) { + this.frameStylePane.populate(ob); + this.titleStylePane.populate(ob); + } + + @Override + public void updateBean(PredefinedComponentStyle ob) { + + } + + + @Override + public PredefinedComponentStyle updateBean() { + PredefinedComponentStyle componentStyle = new PredefinedComponentStyle(); + this.frameStylePane.update(componentStyle); + this.titleStylePane.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..b7034fd669 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ColorDetailPane.java @@ -0,0 +1,105 @@ +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(); + UIButton transpanrentBtn = new UIButton(); + 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 centerPane = new JPanel(); + + 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..74851c38f2 --- /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, 140); + 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..5873755f57 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ImageDetailPane.java @@ -0,0 +1,215 @@ +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_L4, 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()); + 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..05667021c6 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/PatternDetailPane.java @@ -0,0 +1,119 @@ +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.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); + jPanel1.setBorder(BorderFactory.createEmptyBorder()); + this.add(jPanel1, 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..5e66afb8aa --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/cell/CustomPredefinedStylePane.java @@ -0,0 +1,223 @@ +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; + private AttributeChangeListener attributeChangeListener; + + + 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 void registerAttrChangeListener(AttributeChangeListener listener){ + this.attributeChangeListener = listener; + } + + private void fireAttrChangeListener() { + if (this.attributeChangeListener != null) { + this.attributeChangeListener.attributeChange(); + } + } + + /** + * @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()); + } + fireAttrChangeListener(); + } + }); + BasicScrollPane basicScrollPane = new AttrScrollPane() { + @Override + protected JPanel createContentPane() { + return centerPane; + } + }; + return basicScrollPane; + } + }; + jPanel.add(attrListenerPane, BorderLayout.CENTER); + } + + @Override + /** + * + */ + public void updateBean(PredefinedCellStyle ob) { + return; + } + + + + + /** + * 预览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..3d04a3cd5d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentFrameStylePane.java @@ -0,0 +1,148 @@ +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(); + 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..73dc561064 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentTitleStylePane.java @@ -0,0 +1,253 @@ +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(); + + 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..0bfe1f117b --- /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, 140)); + 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..658032a683 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/ReportPredefinedStyleDialog.java @@ -0,0 +1,97 @@ +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 com.fr.workspace.WorkContext; + +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(); + + if (WorkContext.getCurrent().isRoot()){ + 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/ChartPreStylePreView.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ChartPreStylePreView.java new file mode 100644 index 0000000000..fe3275eb66 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ChartPreStylePreView.java @@ -0,0 +1,111 @@ +package com.fr.design.mainframe.predefined.ui.preview; + +import com.fr.base.chart.BaseChartCollection; +import com.fr.base.chart.BaseChartPainter; +import com.fr.base.chart.chartdata.CallbackEvent; +import com.fr.base.chart.result.WebChartIDInfo; +import com.fr.chart.base.ChartPreStyleProvider; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.config.predefined.PredefinedStyle; +import com.fr.design.gui.chart.MiddleChartComponent; +import com.fr.general.Background; +import com.fr.plugin.chart.vanchart.VanChart; +import com.fr.script.Calculator; +import com.fr.stable.core.PropertyChangeListener; + +import javax.swing.BorderFactory; +import java.util.List; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-28 + */ +public class ChartPreStylePreView extends MiddleChartComponent { + + private ChartCollection chartCollection; + + private double scaleX = 1.0; + private double scaleY = 1.0; + + private CallbackEvent callbackEvent; + + private static final int BOUNDS = 10; + + private Background componentBackground; + + public ChartPreStylePreView() { + } + + public ChartPreStylePreView(ChartCollection cc) { + this(cc, 1.0, 1.0); + } + + public ChartPreStylePreView(ChartCollection cc, double scaleX, double scaleY) { + this.scaleX = scaleX; + this.scaleY = scaleY; + this.setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10)); + populate(cc); + } + + public void setCallbackEvent(CallbackEvent callbackEvent) { + this.callbackEvent = callbackEvent; + } + + public void paintComponent(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + g2d.translate(BOUNDS, BOUNDS); + g2d.scale(scaleX, scaleY); + super.paintComponent(g); + drawChart(g2d); + g2d.scale(1 / scaleX, 1 / scaleY); + g2d.translate(-BOUNDS, -BOUNDS); + } + + private void drawChart(Graphics2D g2d) { + Dimension d = getBounds().getSize(); + int chartWidth = (int) (d.width / scaleX) - BOUNDS * 2; + int chartHeight = (int) (d.height / scaleX) - BOUNDS * 2; + if (componentBackground != null) { + Graphics clipg = g2d.create(0, 0, chartWidth, chartHeight); + componentBackground.paint(clipg, clipg.getClipBounds()); + } + BaseChartPainter painter = chartCollection.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(), + WebChartIDInfo.createEmptyDesignerInfo(), chartWidth, chartHeight); + painter.paint(g2d, chartWidth, chartHeight, 0, null, callbackEvent); + } + + public void refresh(PredefinedStyle style) { + VanChart vanChart = chartCollection.getSelectedChartProvider(VanChart.class); + List chartPreStyleProviders = vanChart.getChartPreStyleProvider(); + for (ChartPreStyleProvider chartPreStyleProvider : chartPreStyleProviders) { + chartPreStyleProvider.updatePreDefinedStyle(style); + } + componentBackground = style.getComponentStyle().getBorderStyle().getBackground(); + vanChart.attrChange(); + } + + @Override + public void populate(BaseChartCollection cc) { + this.chartCollection = (ChartCollection) cc; + } + + @Override + public BaseChartCollection update() { + return this.chartCollection; + } + + @Override + public void addStopEditingListener(PropertyChangeListener l) { + + } + + + @Override + public void reset() { + + } +} 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..1c829c0ee6 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ComponentPreviewPane.java @@ -0,0 +1,142 @@ +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 com.fr.stable.Constants; + +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 = 10; + 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; + } + + public void paintComponents(Graphics g) { + BorderPacker borderStyle = style.getComponentStyle().getBorderStyle(); + + updateBorders(g, borderStyle); + + paintTitle(g, borderStyle.getTitle()); + + paintContentPane(g, borderStyle); + + super.paintComponents(g); + } + + 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()); + } + clipg.dispose(); + } + + private void paintTitle(Graphics g, TitlePacker titlePacker) { + Background background = titlePacker.getBackground(); + if (background != null) { + background.paint(g, new Rectangle2D.Double(10, 5, this.titlePane.getWidth(), this.titlePane.getHeight())); + } + titlePane.setTitleObject(titlePacker); + 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; + private int titlePosition = Constants.LEFT; + + 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.applyResolutionNP(96)); + String paintText = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_Preview_Title_Text"); + int startY = 0, startX = 0; + startX = (d.width - fm.stringWidth(paintText)) / 2; + startY = (d.height - fm.getHeight()) / 2 + fm.getAscent(); + if (this.titlePosition == Constants.LEFT) { + startX = GAP; + } else if (this.titlePosition == Constants.RIGHT) { + startX = d.width - fm.stringWidth(paintText) - GAP - fm.getMaxAdvance(); + } + GraphHelper.drawString(g2d, paintText, startX, startY); + + } + + public void setTitleObject(TitlePacker titlePacker) { + this.frFont = titlePacker.getFrFont(); + this.titlePosition = titlePacker.getPosition(); + } + } + +} 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..a7ec75e89c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ElementCasePreview.java @@ -0,0 +1,171 @@ +package com.fr.design.mainframe.predefined.ui.preview; + +import com.fr.base.ScreenResolution; +import com.fr.base.Style; +import com.fr.config.predefined.PredefinedCellStyle; +import com.fr.config.predefined.PredefinedCellStyleConfig; +import com.fr.config.predefined.PredefinedStyle; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.log.FineLoggerFactory; +import com.fr.third.javax.annotation.Nonnull; +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.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 = " "; + private List gridRowPanes; + + 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() { + gridRowPanes = new ArrayList<>(); + JPanel jPanel = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); + jPanel.setOpaque(false); + jPanel.setBackground(null); + for (int i = 0; i < PREVIEW_DATA_LIST.size(); i++) { + GridRowPane gridRowPane = new GridRowPane(PREVIEW_DATA_LIST.get(i), Style.DEFAULT_STYLE); + gridRowPanes.add(gridRowPane); + jPanel.add(gridRowPane); + } + return jPanel; + } + + + public void refresh(PredefinedStyle style) { + super.refresh(style); + PredefinedCellStyleConfig cellStyleConfig = style.getCellStyleConfig(); + for (int i = 0; i < gridRowPanes.size(); i++) { + Style renderStyle = getMainContentStyle(cellStyleConfig); + if (i == 0) { + renderStyle = getReportHeaderStyle(cellStyleConfig); + } + if (i == PREVIEW_DATA_LIST.size() - 1) { + renderStyle = getHighLightStyle(cellStyleConfig); + } + gridRowPanes.get(i).preview(renderStyle); + } + } + + + private Style getReportHeaderStyle(PredefinedCellStyleConfig config) { + return getCellStyle(config, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header")); + } + + private Style getMainContentStyle(PredefinedCellStyleConfig config) { + return getCellStyle(config, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Main_Text")); + } + + private Style getHighLightStyle(PredefinedCellStyleConfig config) { + return getCellStyle(config, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Highlight_Text")); + } + + @Nonnull + private Style getCellStyle(PredefinedCellStyleConfig config, String styleName) { + PredefinedCellStyle cellStyle = config.getStyle(styleName); + if (cellStyle == null) { + return Style.DEFAULT_STYLE; + } + return cellStyle.getStyle(); + } + + + class GridRowPane extends JPanel { + private List gridPreviews = new ArrayList<>(); + + public GridRowPane(String[] data, Style style) { + this.setOpaque(false); + this.setBackground(null); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel panel = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(4, 0, 0); + panel.setOpaque(false); + panel.setBackground(null); + for (String text : data) { + GridPreview gridPreview = new GridPreview(text); + gridPreviews.add(gridPreview); + panel.add(gridPreview); + } + this.add(panel, BorderLayout.CENTER); + preview(style); + } + + public void preview(Style style) { + for (GridPreview grid : gridPreviews) { + grid.preview(style); + } + } + } + + + private static class GridPreview extends JComponent { + + private Style style = Style.DEFAULT_STYLE; + private String value; + + public GridPreview(String value) { + this.value = value; + setPreferredSize(new Dimension(125, 30)); + } + + public void preview(Style style) { + this.style = style; + } + + public void paint(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + int resolution = ScreenResolution.getScreenResolution(); + + if (style == Style.DEFAULT_STYLE) { + Style.paintContent(g2d, value, style, getWidth() - 3, getHeight() - 3, resolution); + return; + } + + Style.paintBackground(g2d, style, getWidth(), getHeight()); + + Style.paintContent(g2d, value, style, getWidth() - 3, getHeight() - 3, resolution); + + Style.paintBorder(g2d, style, getWidth() , getHeight() ); + } + + + @Override + public Dimension getMinimumSize() { + return getPreferredSize(); + } + } + +} 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..5b6d200491 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/PredefinedStylePreviewPane.java @@ -0,0 +1,157 @@ +package com.fr.design.mainframe.predefined.ui.preview; + +import com.fr.base.background.ColorBackground; +import com.fr.base.chart.chartdata.CallbackEvent; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.chartattr.Title; +import com.fr.chart.charttypes.ChartTypeManager; +import com.fr.config.predefined.PredefinedStyle; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.utils.ComponentUtils; +import com.fr.general.Background; +import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.attr.axis.VanChartAxis; +import com.fr.plugin.chart.base.AttrLabel; +import com.fr.plugin.chart.base.VanChartTools; +import com.fr.plugin.chart.column.VanChartColumnPlot; +import com.fr.plugin.chart.vanchart.VanChart; + +import javax.swing.JComponent; +import javax.swing.JPanel; +import java.util.ArrayList; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; + +/** + * Created by kerry on 2020-09-06 + */ +public class PredefinedStylePreviewPane extends StyleSettingPreviewPane implements CallbackEvent { + private ElementCasePreview elementCasePreview; + private Background background; + private double scaleX = 1.0; + private double scaleY = 1.0; + private ChartPreStylePreView columnChartPane; + + private int COLUMN_CHART_WIDTH = 517; + private int COLUMN_CHART_HEIGHT = 290; + + private JPanel parent; + + 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.add(initChartPreViewPane()); + this.elementCasePreview.setPreferredSize(new Dimension(517, 200)); + this.add(this.elementCasePreview); + } + + public void setParent(JPanel parent) { + this.parent = parent; + } + + private JPanel initChartPreViewPane() { + columnChartPane = new ChartPreStylePreView(initVanColumnChart()); + columnChartPane.setPreferredSize(new Dimension(COLUMN_CHART_WIDTH, COLUMN_CHART_HEIGHT)); + columnChartPane.setCallbackEvent(this); + + JPanel panel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + panel.add(columnChartPane); + return panel; + } + + //柱形图 + private ChartCollection initVanColumnChart() { + try { + VanChart chart = (VanChart) ChartTypeManager.getInstance().getCharts(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID)[0].clone(); + VanChartTools vanChartTools = chart.getVanChartTools(); + vanChartTools.setSort(false); + vanChartTools.setExport(false); + vanChartTools.setFullScreen(false); + VanChartColumnPlot plot = chart.getPlot(); + AttrLabel defaultAttrLabel = plot.getDefaultAttrLabel(); + defaultAttrLabel.setEnable(true); + defaultAttrLabel.getAttrLabelDetail().getBorder().setBorderStyle(0); + defaultAttrLabel.getAttrLabelDetail().getBackground().setBackground(null); + plot.getConditionCollection().getDefaultAttr().addDataSeriesCondition(defaultAttrLabel); + plot.getLegend().setLegendVisible(false); + plot.getDataSheet().setVisible(true); + + VanChartAxis defaultYAxis = plot.getDefaultYAxis(); + Title title = new Title(); + title.setTextObject(Toolkit.i18nText("Fine-Design_Chart_Axis_Title")); + title.getTextAttr().setRotation(-90); + defaultYAxis.setTitle(title); + defaultYAxis.setShowAxisTitle(true); + + ChartCollection chartCollection = new ChartCollection(chart); + return chartCollection; + } catch (Exception ex) { + FineLoggerFactory.getLogger().error(ex.getMessage(), ex); + } + return null; + } + + @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, 500)); + this.columnChartPane.paintComponent(g); + + g.translate(0, COLUMN_CHART_HEIGHT); + this.elementCasePreview.paintComponents(g); + g.translate(0, -COLUMN_CHART_HEIGHT); + // 恢复双缓冲 + 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); + columnChartPane.refresh(style); + background = displayFormBackground ? style.getFormBackground().getBackground() : style.getReportBackground(); + this.repaint(); + } + + @Override + public void callback() { + if (parent != null) { + parent.repaint(); + } else { + 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/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 078d4d1289..d1abb908bb 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -539,7 +539,9 @@ public abstract class ToolBarMenuDock { //远程不使用更新升级,产品演示 if (WorkContext.getCurrent().isLocal()) { shortCuts.add(new WebDemoAction()); - LocaleCenter.buildAction(() -> shortCuts.add(new SoftwareUpdateAction()), SupportLocaleImpl.UPDATE_HELP); + if (!Locale.getDefault().equals(Locale.JAPAN) && !Locale.getDefault().equals(Locale.JAPANESE)) { + LocaleCenter.buildAction(() -> shortCuts.add(new SoftwareUpdateAction()), SupportLocaleImpl.UPDATE_HELP); + } } if (AlphaFineConfigManager.isALPHALicAvailable()) { shortCuts.add(new AlphaFineAction()); @@ -561,12 +563,12 @@ public abstract class ToolBarMenuDock { * @return 社区菜单的子菜单 */ public ShortCut[] createCommunityShortCuts() { - + final java.util.List shortCuts = new ArrayList(); shortCuts.add(new BBSAction()); - + shortCuts.add(SeparatorDef.DEFAULT); - + shortCuts.add(new VideoAction()); LocaleCenter.buildAction(new LocaleAction() { @Override @@ -576,7 +578,7 @@ public abstract class ToolBarMenuDock { }, SupportLocaleImpl.TUTORIAL_COMMUNITY); shortCuts.add(new QuestionAction()); shortCuts.add(new TechSolutionAction()); - + shortCuts.add(SeparatorDef.DEFAULT); LocaleCenter.buildAction(new LocaleAction() { @@ -606,9 +608,9 @@ public abstract class ToolBarMenuDock { shortCuts.add(new TechSupportAction()); } }, SupportLocaleImpl.TECH_SUPPORT_COMMUNITY); - + shortCuts.add(SeparatorDef.DEFAULT); - + shortCuts.add(new CenterAction()); shortCuts.add(new SignAction()); LocaleCenter.buildAction(new LocaleAction() { 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..d94da0c887 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,33 @@ 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()}, "-" ); } } - + } diff --git a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBackgroundPane.java b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBackgroundPane.java index 59aed2a6f0..1cbf543a4b 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBackgroundPane.java +++ b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBackgroundPane.java @@ -26,6 +26,7 @@ import java.awt.event.ActionListener; */ public class GradientBackgroundPane extends BackgroundDetailPane { private static final long serialVersionUID = -6854603990673031897L; + public static final int DEFAULT_GRADIENT_WIDTH = 254; private UIRadioButton left2right, top2bottom; private GradientBar gradientBar; @@ -41,7 +42,7 @@ public class GradientBackgroundPane extends BackgroundDetailPane { // neil:增加渐变色拖动条 JPanel gradientPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel blankJp = new JPanel(); - gradientBar = new GradientBar(4, 254); + gradientBar = new GradientBar(4, DEFAULT_GRADIENT_WIDTH); blankJp.add(gradientBar); UILabel jl = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Drag_To_Select_Gradient")); jl.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20)); diff --git a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java index 46d1b9165b..b088864c0f 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java +++ b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java @@ -192,7 +192,15 @@ public class GradientBar extends JComponent implements UIObserver, ColorSelectab } float[] dist = new float[list.size()]; for (int i = 0; i < list.size(); i++) { - dist[i] = (float) ((list.get(i).getX() - 4) / (max - 4)); + double value = list.get(i).getX() - 4; + double defaultMax = max - 4; + if (Double.compare(value, defaultMax) > 0) { + // 设置了预定义的渐变色 渐变色起始位置比较大 然后由预定义样式切换到自定义样式 做下等比例转换 + dist[i] = (float) (value / (GradientBackgroundPane.DEFAULT_GRADIENT_WIDTH - 4)); + list.get(i).setX(max * dist[i]); + } else { + dist[i] = (float) (value / defaultMax); + } } LinearGradientPaint paint = new LinearGradientPaint(start, end, dist, c); 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/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/upm/UpmFinder.java b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java index 2aaa9556bc..4424d9d741 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java @@ -101,7 +101,8 @@ public class UpmFinder { private static void showUpdatePane() { JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Update_Info_Plugin_Message")); - if (!GeneralContext.getLocale().equals(Locale.JAPAN)) { + if (!GeneralContext.getLocale().equals(Locale.JAPANESE) && !GeneralContext.getLocale().equals(Locale.JAPAN) + && !Locale.getDefault().equals(Locale.JAPAN) && !Locale.getDefault().equals(Locale.JAPANESE)) { UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame()); dialog.setAutoUpdateAfterInit(); dialog.showDialog(); diff --git a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java index 775118d285..58f5d2a5f6 100644 --- a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java @@ -25,7 +25,6 @@ import com.fr.start.ServerStarter; import com.fr.value.NotNullLazyValue; import com.fr.workspace.WorkContext; import org.jetbrains.annotations.NotNull; - import javax.swing.SwingUtilities; import javax.swing.UIManager; import java.awt.Desktop; @@ -58,12 +57,13 @@ import java.util.concurrent.TimeoutException; public class DesignUtils { private static int port = DesignerPort.getInstance().getMessagePort(); + private static boolean started = false; + private DesignUtils() { } - public synchronized static void setPort(int port) { DesignUtils.port = port; } @@ -72,6 +72,7 @@ public class DesignUtils { return port; } + /** * 判断设计器有没有启动 * @@ -247,7 +248,6 @@ public class DesignUtils { } public static void refreshDesignerFrame() { - // 刷新DesignerFrame里面的面板 SwingUtilities.invokeLater(new Runnable() { @@ -417,4 +417,5 @@ public class DesignUtils { public static boolean sendFeedBack(FeedBackInfo feedBackInfo) throws Exception { return true; } + } diff --git a/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java index 590f9d1121..ccf01dd5e8 100644 --- a/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java +++ b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java @@ -53,6 +53,7 @@ import javax.swing.BorderFactory; import javax.swing.DefaultCellEditor; import javax.swing.DefaultComboBoxModel; import javax.swing.Icon; +import javax.swing.JFrame; import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -867,13 +868,14 @@ public class DBManipulationPane extends BasicBeanPane { textLabel = new UILabel(); textLabel.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { + vPaneDLG.setAlwaysOnTop(true); vPaneDLG.setVisible(true); } }); vPane = new ValuePane(types); - vPaneDLG = vPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + vPaneDLG = vPane.showSmallWindow(new JFrame(), new DialogActionAdapter() { public void doOk() { fireEditingStopped(); // Make the renderer // reappear. diff --git a/designer-base/src/main/java/com/fr/env/EnvListPane.java b/designer-base/src/main/java/com/fr/env/EnvListPane.java index 2d875cb458..454388e124 100644 --- a/designer-base/src/main/java/com/fr/env/EnvListPane.java +++ b/designer-base/src/main/java/com/fr/env/EnvListPane.java @@ -34,7 +34,7 @@ public class EnvListPane extends JListControlPane { public void propertyChange() { String tempName = getEditingName(); String[] allListNames = nameableList.getAllNames(); - allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY; + allListNames[editingIndex] = StringUtils.EMPTY; if (StringUtils.isEmpty(tempName)) { nameableList.stopEditing(); FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(EnvListPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Workspace_Empty_Name_Warn_Text")); diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java index 5257e74f42..5be56bfbf7 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -4,6 +4,8 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.beans.BasicBeanPane; import com.fr.design.border.UITitledBorder; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.dialog.link.MessageWithLink; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.fun.DesignerEnvProcessor; import com.fr.design.gui.ibutton.UIButton; @@ -16,6 +18,7 @@ import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.scrollruler.ModLineBorder; import com.fr.license.exception.RegistEditionException; import com.fr.log.FineLoggerFactory; @@ -25,6 +28,7 @@ import com.fr.workspace.WorkContext; import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.engine.exception.WorkspaceAuthException; +import com.fr.workspace.engine.exception.WorkspaceCheckException; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JDialog; @@ -53,12 +57,13 @@ import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; -import java.util.function.Supplier; + import static com.fr.design.layout.TableLayout.FILL; import static com.fr.design.layout.TableLayout.PREFERRED; import static com.fr.env.TestConnectionResult.AUTH_FAILED; import static com.fr.third.guava.base.Optional.fromNullable; +import static javax.swing.JOptionPane.ERROR_MESSAGE; /** * @author yaohwu @@ -583,6 +588,8 @@ public class RemoteEnvPane extends BasicBeanPane { } catch (RegistEditionException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); throw e; + } catch (WorkspaceCheckException e) { + return TestConnectionResult.parseByException(e); } } @@ -591,6 +598,15 @@ public class RemoteEnvPane extends BasicBeanPane { okButton.setEnabled(true); try { TestConnectionResult result = get(); + if (result.isVerifyResult()) { + dialog.dispose(); + FineLoggerFactory.getLogger().error(result.getText().replaceAll(TestConnectionResult.WRAP, StringUtils.EMPTY) + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord")); + FineJOptionPane.showMessageDialog(RemoteEnvPane.this, + new MessageWithLink(result.getText(), Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"), connection.getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH), + Toolkit.i18nText("Fine-Design_Basic_Dialog_Message_Title"), + ERROR_MESSAGE, + UIManager.getIcon("OptionPane.errorIcon")); + } message.setText(result.getText()); uiLabel.setIcon(result.getIcon()); } catch (Exception e) { @@ -635,7 +651,7 @@ public class RemoteEnvPane extends BasicBeanPane { message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0)); okButton.setEnabled(false); - dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane.this), UIManager.getString("OptionPane.messageDialogTitle"), true); + dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane.this), Toolkit.i18nText("Fine-Design_Basic_Dialog_Message_Title"), true); dialog.setSize(new Dimension(308, 132)); okButton.setEnabled(false); diff --git a/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java b/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java index dee40422c7..4ea950e845 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java +++ b/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java @@ -9,6 +9,8 @@ import com.fr.stable.StringUtils; */ public class RemoteWorkspaceURL implements FCloneable { + public static final String SYSTEM_LOGIN_PATH = "#management/system/login"; + /** * 默认 web app name */ diff --git a/designer-base/src/main/java/com/fr/env/TestConnectionResult.java b/designer-base/src/main/java/com/fr/env/TestConnectionResult.java index 4524254f40..1dee557980 100644 --- a/designer-base/src/main/java/com/fr/env/TestConnectionResult.java +++ b/designer-base/src/main/java/com/fr/env/TestConnectionResult.java @@ -1,12 +1,15 @@ package com.fr.env; +import com.fr.decision.webservice.exception.login.UserLoginLockException; +import com.fr.decision.webservice.exception.login.UserPasswordNeedUpdateException; +import com.fr.decision.webservice.exception.user.UserPasswordStrengthLimitException; import com.fr.design.i18n.Toolkit; -import com.fr.log.FineLoggerFactory; -import com.fr.stable.AssistUtils; -import com.fr.workspace.WorkContext; +import com.fr.exception.RemoteDesignPermissionDeniedException; +import com.fr.general.ComparatorUtils; +import com.fr.stable.StringUtils; import com.fr.workspace.connect.WorkspaceConnectionInfo; -import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; +import com.fr.workspace.engine.exception.WorkspaceCheckException; import javax.swing.Icon; import javax.swing.UIManager; @@ -76,12 +79,129 @@ public enum TestConnectionResult { public String getText() { return Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"); } + }, + + /** + * 登录锁定 + */ + LOGIN_LOCK { + + private String value; + + @Override + public Icon getIcon() { + return UIManager.getIcon("OptionPane.errorIcon"); + } + + @Override + public String getText() { + return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Login_Lock", value); + } + + @Override + public String errorCode() { + return UserLoginLockException.ERROR_CODE; + } + + @Override + public void setValue(String lockMin) { + this.value = lockMin; + } + + @Override + public boolean isVerifyResult() { + return true; + } + }, + + /** + * 没有远程设计权限 + */ + PERMISSION_DENIED { + @Override + public Icon getIcon() { + return UIManager.getIcon("OptionPane.errorIcon"); + } + + @Override + public String getText() { + return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Permission_Denied"); + } + + @Override + public String errorCode() { + return RemoteDesignPermissionDeniedException.ERROR_CODE; + } + }, + + /** + * 弱密码 + */ + PASSWORD_STRENGTH_LIMIT () { + @Override + public Icon getIcon() { + return UIManager.getIcon("OptionPane.errorIcon"); + } + + @Override + public String getText() { + return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Weak_Password"); + } + + @Override + public String errorCode() { + return UserPasswordStrengthLimitException.ERROR_CODE; + } + + @Override + public boolean isVerifyResult() { + return true; + } + }, + + /** + * 密码更新 + */ + PASSWORD_NEED_UPDATE { + @Override + public Icon getIcon() { + return UIManager.getIcon("OptionPane.errorIcon"); + } + + @Override + public String getText() { + return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Update_Password"); + } + + @Override + public String errorCode() { + return UserPasswordNeedUpdateException.ERROR_CODE; + } + + @Override + public boolean isVerifyResult() { + return true; + } }; public abstract Icon getIcon(); public abstract String getText(); + public void setValue(String value) { + // do noting + } + + public String errorCode() { + return StringUtils.EMPTY; + } + + public boolean isVerifyResult() { + return false; + } + + public static final String WRAP = "
"; + public static TestConnectionResult parse(Boolean value, WorkspaceConnectionInfo info) { if (value == null) { return AUTH_FAILED; @@ -92,4 +212,17 @@ public enum TestConnectionResult { //去掉测试连接时所做的检测 return FULLY_SUCCESS; } + + public static TestConnectionResult parseByException(WorkspaceCheckException e) { + for (TestConnectionResult result : values()) { + if (ComparatorUtils.equals(e.errorCode(), result.errorCode())) { + // 登录锁定 获取下锁定的时间 + if (ComparatorUtils.equals(result, LOGIN_LOCK)) { + result.setValue(e.getMessage().replaceAll("\\D+", StringUtils.EMPTY)); + } + return result; + } + } + return AUTH_FAILED; + } } 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..cfcf502f3f --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/mainframe/predefined/previewData @@ -0,0 +1,5 @@ +城市 当月目标 当月实际完成 月度完成率 +南通市 324,646 324,646 100% +合肥市 248,938 348,938 140% +邵阳市 248,938 348,938 140% +合计 1,071,460 1,371,460 128% diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java index 85b13aef7e..1a5088a272 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java @@ -7,6 +7,7 @@ import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.base.chart.result.WebChartIDInfo; import com.fr.chart.base.ChartConstants; import com.fr.chart.chartattr.ChartCollection; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.chart.MiddleChartComponent; import com.fr.log.FineLoggerFactory; @@ -144,6 +145,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene return; } + chartCollection4Design.setPredefinedStyleName(getGlobalPredefinedStyleName(), false); Graphics2D g2d = (Graphics2D) g; Paint oldPaint = g2d.getPaint(); @@ -268,4 +270,8 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene public void callback() { this.repaint(); } + + private String getGlobalPredefinedStyleName() { + return HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplatePredefinedStyle(); + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MapDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MapDataSetFieldsPane.java index 250e021c49..b813f2dc01 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MapDataSetFieldsPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MapDataSetFieldsPane.java @@ -18,11 +18,11 @@ import com.fr.plugin.chart.vanchart.VanChart; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.tree.DefaultMutableTreeNode; +import java.util.Set; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.Set; /** * @author Bjorn @@ -64,7 +64,7 @@ public abstract class MapDataSetFieldsPane 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/box/data/table/BoxPlotTableResultDataSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableResultDataSeriesPane.java index 5af1fa4168..434eff452a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableResultDataSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableResultDataSeriesPane.java @@ -59,6 +59,7 @@ public class BoxPlotTableResultDataSeriesPane extends AbstractTableDataContentPa addNoneItem(); + category.setSelectedItem(null); seriesName.setSelectedItem(null); median.populateComboBox(null); } @@ -158,6 +159,7 @@ public class BoxPlotTableResultDataSeriesPane extends AbstractTableDataContentPa } private void addNoneItem() { + category.addItem(Toolkit.i18nText("Fine-Design_Chart_Use_None")); seriesName.addItem(Toolkit.i18nText("Fine-Design_Chart_Use_None")); median.addItem(Toolkit.i18nText("Fine-Design_Chart_Use_None")); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleConditionPane.java index 4ee0719870..18408d7e72 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleConditionPane.java @@ -20,7 +20,6 @@ import com.fr.van.chart.designer.other.condition.item.VanChartEffectConditionPan import com.fr.van.chart.designer.other.condition.item.VanChartLabelConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartSeriesColorConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartTooltipConditionPane; -import com.fr.van.chart.scatter.component.label.VanChartScatterLabelConditionPane; import com.fr.van.chart.scatter.component.tooltip.VanChartScatterTooltipConditionPane; import java.awt.Dimension; @@ -66,7 +65,7 @@ public class VanChartBubbleConditionPane extends DataSeriesConditionPane { } private void addNormalAction() { - classPaneMap.put(ScatterAttrLabel.class, new VanChartScatterLabelConditionPane(this, plot)); + classPaneMap.put(ScatterAttrLabel.class, new VanChartLabelConditionPane(this, plot)); classPaneMap.put(ScatterAttrTooltip.class, new VanChartScatterTooltipConditionPane(this, plot)); classPaneMap.put(AttrEffect.class, new VanChartEffectConditionPane(this, EffectHelper.getBubblePlotDefaultEffect())); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleStylePane.java b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleStylePane.java index 63ebd17bb8..de4e88070f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleStylePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleStylePane.java @@ -6,7 +6,6 @@ import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.mainframe.chart.gui.style.series.ChartSeriesPane; import com.fr.plugin.chart.bubble.VanChartBubblePlot; import com.fr.van.chart.bubble.force.VanChartForceBubbleAreaPane; -import com.fr.van.chart.bubble.force.VanChartForceBubbleLabelPane; import com.fr.van.chart.bubble.force.VanChartForceBubbleTooltipPane; import com.fr.van.chart.designer.style.background.VanChartAreaPane; import com.fr.van.chart.scatter.component.VanChartScatterStylePane; @@ -22,17 +21,6 @@ public class VanChartBubbleStylePane extends VanChartScatterStylePane { super(listener); } - @Override - protected void createVanChartLabelPane(List paneList) { - Plot plot = getChart().getPlot(); - - if(((VanChartBubblePlot) plot).isForceBubble()){ - paneList.add(new VanChartForceBubbleLabelPane(VanChartBubbleStylePane.this)); - } else { - super.createVanChartLabelPane(paneList); - } - } - protected void addVanChartTooltipPane(List paneList){ Plot plot = getChart().getPlot(); if(((VanChartBubblePlot) plot).isForceBubble()){ diff --git a/designer-chart/src/main/java/com/fr/van/chart/bubble/force/VanChartForceBubbleLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/bubble/force/VanChartForceBubbleLabelPane.java deleted file mode 100644 index 13bcac26e5..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/bubble/force/VanChartForceBubbleLabelPane.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.fr.van.chart.bubble.force; - -import com.fr.chart.chartattr.Plot; -import com.fr.van.chart.designer.style.VanChartStylePane; -import com.fr.van.chart.designer.style.label.VanChartLabelPane; -import com.fr.van.chart.designer.style.label.VanChartPlotLabelPane; - -/** - * Created by Mitisky on 16/3/31. - */ -public class VanChartForceBubbleLabelPane extends VanChartLabelPane { - public VanChartForceBubbleLabelPane(VanChartStylePane parent) { - super(parent); - } - - protected VanChartPlotLabelPane getLabelPane(Plot plot) { - return new VanChartPlotLabelPane(plot, parent); - } -} diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnConditionPane.java index 3f9978f75c..c4184f3b17 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnConditionPane.java @@ -49,7 +49,7 @@ public class VanChartColumnConditionPane extends DataSeriesConditionPane{ classPaneMap.put(AttrBackground.class, new VanChartColumnSeriesColorConditionPane(this)); classPaneMap.put(AttrAlpha.class, new LabelAlphaPane(this)); classPaneMap.put(AttrBorder.class, new VanChartColumnLabelBorderPane(this)); - classPaneMap.put(AttrLabel.class, new VanChartColumnLabelConditionPane(this, plot)); + classPaneMap.put(AttrLabel.class, new VanChartLabelConditionPane(this, plot)); classPaneMap.put(AttrFloatColor.class, new VanChartFloatColorConditionPane(this)); classPaneMap.put(VanChartAttrTrendLine.class, new VanChartTrendLineConditionPane(this)); classPaneMap.put(AttrSeriesImageBackground.class, new VanChartSeriesImageBackgroundConditionPane(this)); diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnLabelConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnLabelConditionPane.java deleted file mode 100644 index ec870a98fe..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnLabelConditionPane.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.fr.van.chart.column; - -import com.fr.chart.chartattr.Plot; -import com.fr.design.condition.ConditionAttributesPane; -import com.fr.van.chart.designer.other.condition.item.VanChartLabelConditionPane; -import com.fr.van.chart.designer.style.label.VanChartPlotLabelPane; - -public class VanChartColumnLabelConditionPane extends VanChartLabelConditionPane { - - public VanChartColumnLabelConditionPane(ConditionAttributesPane conditionAttributesPane, Plot plot) { - super(conditionAttributesPane, plot); - } - - protected VanChartPlotLabelPane createLabelPane() { - return new VanChartColumnPlotLabelNoCheckPane(getPlot(),null); - } -} diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotLabelDetailPane.java index a2be5f2905..b2b287087e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotLabelDetailPane.java @@ -12,12 +12,12 @@ import com.fr.van.chart.designer.style.label.VanChartPlotLabelDetailPane; public class VanChartColumnPlotLabelDetailPane extends VanChartPlotLabelDetailPane { - public VanChartColumnPlotLabelDetailPane(Plot plot, VanChartStylePane parent) { - super(plot, parent); + public VanChartColumnPlotLabelDetailPane(Plot plot, VanChartStylePane parent, boolean inCondition) { + super(plot, parent, inCondition); } protected void initToolTipContentPane(Plot plot) { - VanChartLabelContentPane dataLabelContentPane = new VanChartLabelContentPane(getParentPane(), VanChartColumnPlotLabelDetailPane.this) { + VanChartLabelContentPane dataLabelContentPane = new VanChartLabelContentPane(getParentPane(), VanChartColumnPlotLabelDetailPane.this, isInCondition()) { protected void checkCardPane() { super.checkCardPane(); checkOrientationPane(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotLabelNoCheckPane.java b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotLabelNoCheckPane.java deleted file mode 100644 index b08734782a..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotLabelNoCheckPane.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.fr.van.chart.column; - -import com.fr.chart.chartattr.Plot; -import com.fr.plugin.chart.base.AttrLabel; -import com.fr.van.chart.designer.style.VanChartStylePane; - -import java.awt.BorderLayout; - -public class VanChartColumnPlotLabelNoCheckPane extends VanChartColumnPlotLabelPane { - - public VanChartColumnPlotLabelNoCheckPane(Plot plot, VanChartStylePane parent) { - super(plot, parent); - } - - protected void addComponents() { - this.setLayout(new BorderLayout()); - this.add(getLabelPane(), BorderLayout.CENTER); - } - - public void populate(AttrLabel attr) { - super.populate(attr); - getLabelShowCheckBox().setSelected(true); - getLabelPane().setVisible(true); - } -} diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotLabelPane.java deleted file mode 100644 index e80f6310d5..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotLabelPane.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.fr.van.chart.column; - -import com.fr.chart.chartattr.Plot; -import com.fr.van.chart.designer.style.VanChartStylePane; -import com.fr.van.chart.designer.style.label.VanChartPlotLabelPane; - -import java.awt.BorderLayout; - -public class VanChartColumnPlotLabelPane extends VanChartPlotLabelPane { - - public VanChartColumnPlotLabelPane(Plot plot, VanChartStylePane parent) { - super(plot, parent); - } - - protected void createLabelPane() { - VanChartColumnPlotLabelDetailPane labelDetailPane = new VanChartColumnPlotLabelDetailPane(getPlot(), getParentPane()); - setLabelDetailPane(labelDetailPane); - getLabelPane().add(labelDetailPane, BorderLayout.CENTER); - } -} 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..eb2c3914ac 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 @@ -70,6 +70,8 @@ public class VanChartColumnSeriesPane extends VanChartAbstractPlotSeriesPane { //边框(有圆角) protected VanChartBorderPane createDiffBorderPane() { return new VanChartBorderWithRadiusPane(); + //TODO Bjorn 边框自动回退 + //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..46126d277a 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 @@ -24,23 +24,25 @@ import com.fr.plugin.chart.structure.VanChartStructurePlot; import com.fr.plugin.chart.treemap.VanChartTreeMapPlot; import com.fr.plugin.chart.wordcloud.VanChartWordCloudPlot; import com.fr.van.chart.bubble.force.VanChartBubbleRefreshTooltipPane; -import com.fr.van.chart.column.VanChartColumnPlotLabelPane; +import com.fr.van.chart.column.VanChartColumnPlotLabelDetailPane; 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; import com.fr.van.chart.designer.style.VanLegendPaneWidthOutHighlight; import com.fr.van.chart.designer.style.label.VanChartGaugePlotLabelPane; +import com.fr.van.chart.designer.style.label.VanChartPlotLabelDetailPane; import com.fr.van.chart.designer.style.label.VanChartPlotLabelPane; import com.fr.van.chart.designer.style.tooltip.VanChartPlotRefreshTooltipPane; import com.fr.van.chart.designer.style.tooltip.VanChartPlotTooltipPane; import com.fr.van.chart.funnel.designer.style.VanChartFunnelLabelContentPane; import com.fr.van.chart.funnel.designer.style.VanChartFunnelRefreshTooltipContentPane; import com.fr.van.chart.funnel.designer.style.VanChartFunnelTooltipContentPane; -import com.fr.van.chart.gantt.designer.style.label.VanChartGanttPlotLabelPane; +import com.fr.van.chart.gantt.designer.style.label.VanChartGanttLabelContentPane; import com.fr.van.chart.gantt.designer.style.tooltip.VanChartGanttPlotTooltipPane; import com.fr.van.chart.gantt.designer.style.tooltip.VanChartGanttTooltipContentPane; import com.fr.van.chart.gauge.VanChartGaugePlotRefreshTooltipPane; @@ -52,10 +54,10 @@ import com.fr.van.chart.multilayer.style.VanChartMultiPieLabelContentPane; import com.fr.van.chart.multilayer.style.VanChartMultiPiePlotTooltipPane; import com.fr.van.chart.multilayer.style.VanChartMultiPieTooltipContentPane; import com.fr.van.chart.multilayer.style.VanChartMutiPieRefreshTooltipContentPane; +import com.fr.van.chart.scatter.VanChartScatterLabelContentPane; import com.fr.van.chart.scatter.VanChartScatterPlotTooltipPane; import com.fr.van.chart.scatter.VanChartScatterRefreshTooltipContentPane; -import com.fr.van.chart.scatter.component.label.VanChartScatterPlotLabelPane; -import com.fr.van.chart.structure.desinger.style.VanChartStructurePlotLabelPane; +import com.fr.van.chart.structure.desinger.style.VanChartStructureLabelContentPane; import com.fr.van.chart.structure.desinger.style.VanChartStructureRefreshTooltipContentPane; import com.fr.van.chart.structure.desinger.style.VanChartStructureTooltipContentPane; import com.fr.van.chart.wordcloud.designer.style.VanChartWordCloudRefreshTooltipContentPane; @@ -65,12 +67,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. @@ -104,20 +106,6 @@ public class PlotFactory { return borderAndBackgroundLabelPlots.contains(plot.getClass()); } - /** - * 标签Map - */ - private static Map, Class> labelMap = new HashMap<>(); - - static { - labelMap.put(VanChartColumnPlot.class, VanChartColumnPlotLabelPane.class); - labelMap.put(VanChartGaugePlot.class, VanChartGaugePlotLabelPane.class); - labelMap.put(VanChartScatterPlot.class, VanChartScatterPlotLabelPane.class); - labelMap.put(VanChartBubblePlot.class, VanChartScatterPlotLabelPane.class); - labelMap.put(VanChartGanttPlot.class, VanChartGanttPlotLabelPane.class); - labelMap.put(VanChartStructurePlot.class, VanChartStructurePlotLabelPane.class); - } - /** * 图例Map */ @@ -128,8 +116,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); } @@ -157,6 +145,10 @@ public class PlotFactory { labelContentMap.put(VanChartTreeMapPlot.class, VanChartMultiPieLabelContentPane.class); labelContentMap.put(VanChartFunnelPlot.class, VanChartFunnelLabelContentPane.class); labelContentMap.put(VanChartHeatMapPlot.class, VanChartMapLabelContentPane.class); + labelContentMap.put(VanChartBubblePlot.class, VanChartScatterLabelContentPane.class); + labelContentMap.put(VanChartScatterPlot.class, VanChartScatterLabelContentPane.class); + labelContentMap.put(VanChartStructurePlot.class, VanChartStructureLabelContentPane.class); + labelContentMap.put(VanChartGanttPlot.class, VanChartGanttLabelContentPane.class); } private static Map, Class> tooltipContentMap = new HashMap, Class>(); @@ -211,19 +203,24 @@ public class PlotFactory { * @return 标签界面 */ public static VanChartPlotLabelPane createPlotLabelPane(Plot plot, VanChartStylePane stylePane) { - Class key = plot.getClass(); - if (labelMap.containsKey(key)) { - try { - Class cl = labelMap.get(key); - Constructor constructor = cl.getConstructor(Plot.class, VanChartStylePane.class); - return constructor.newInstance(plot, stylePane); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } + return createPlotLabelPane(plot, stylePane, false); + } + + public static VanChartPlotLabelPane createPlotLabelPane(Plot plot, VanChartStylePane stylePane, boolean inCondition) { + if (plot instanceof VanChartGaugePlot) { + return new VanChartGaugePlotLabelPane(plot, stylePane); } - return new VanChartPlotLabelPane(plot, stylePane); + return new VanChartPlotLabelPane(plot, stylePane, inCondition); } + public static VanChartPlotLabelDetailPane createPlotLabelDetailPane(Plot plot, VanChartStylePane stylePane, boolean inCondition) { + if (plot instanceof VanChartColumnPlot) { + return new VanChartColumnPlotLabelDetailPane(plot, stylePane, inCondition); + } + return new VanChartPlotLabelDetailPane(plot, stylePane, inCondition); + } + + /** * 根据图表类型创建图例界面 * @@ -274,18 +271,22 @@ public class PlotFactory { * @param showOnPane formatpane用到 * @return 标签的具体内容界面 */ - public static VanChartTooltipContentPane createPlotLabelContentPane(Plot plot, VanChartStylePane parent, JPanel showOnPane) { + public static VanChartTooltipContentPane createPlotLabelContentPane(Plot plot, VanChartStylePane parent, JPanel showOnPane, boolean inCondition) { Class key = plot.getClass(); + //力学气泡图特殊 + if (plot instanceof VanChartBubblePlot && ((VanChartBubblePlot) plot).isForceBubble()) { + return new VanChartLabelContentPane(parent, showOnPane, inCondition); + } if (labelContentMap.containsKey(key)) { try { Class cl = labelContentMap.get(key); - Constructor constructor = cl.getConstructor(VanChartStylePane.class, JPanel.class); - return constructor.newInstance(parent, showOnPane); + Constructor constructor = cl.getConstructor(VanChartStylePane.class, JPanel.class, boolean.class); + return constructor.newInstance(parent, showOnPane, inCondition); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } - return new VanChartLabelContentPane(parent, showOnPane); + return new VanChartLabelContentPane(parent, showOnPane, inCondition); } /** 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..057675a0a7 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,60 @@ 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() { + //TODO Bjorn 配色预定义回退 + //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(); + //TODO Bjorn 配色预定义回退 + //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 +62,33 @@ 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; + }*/ + //TODO Bjorn 配色预定义回退 + 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);*/ + //TODO Bjorn 配色预定义回退 + 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/VanChartLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPane.java index 957fcdaf72..e3bd8248f3 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 @@ -10,8 +10,8 @@ public class VanChartLabelContentPane extends VanChartTooltipContentPane { private static final long serialVersionUID = 5630276526789839288L; - public VanChartLabelContentPane(VanChartStylePane parent, JPanel showOnPane) { - super(parent, showOnPane); + public VanChartLabelContentPane(VanChartStylePane parent, JPanel showOnPane, boolean inCondition) { + super(parent, showOnPane, inCondition); } protected VanChartHtmlLabelPane createHtmlLabelPane() { @@ -21,4 +21,30 @@ public class VanChartLabelContentPane extends VanChartTooltipContentPane { protected AttrTooltipContent createAttrTooltip() { return new AttrTooltipContent(TextAlign.CENTER); } + + //TODO Bjorn 标签面板回退 + /* public JPanel createCommonStylePane() { + if (isInCondition()) { + return super.createCommonStylePane(); + } + setTextAttrPane(new ChartTextAttrPaneWithPreStyle()); + + JPanel stylePanel = new JPanel(new BorderLayout()); + stylePanel.add(getTextAttrPane(), BorderLayout.CENTER); + + return stylePanel; + } + + public void updateTextAttr(AttrTooltipContent attrTooltipContent) { + if (isInCondition()) { + super.updateTextAttr(attrTooltipContent); + return; + } + if (hasTextStylePane()) { + this.getTextAttrPane().update(attrTooltipContent.getTextAttr()); + if (!attrTooltipContent.getTextAttr().isPredefinedStyle()) { + attrTooltipContent.setCustom(true); + } + } + }*/ } 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 d4ef4ac774..b5f03a728a 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 @@ -93,8 +93,14 @@ public class VanChartTooltipContentPane extends BasicBeanPane(new String[]{ Toolkit.i18nText("Fine-Design_Chart_Automatic"), Toolkit.i18nText("Fine-Design_Chart_Custom") @@ -374,7 +392,9 @@ public class VanChartTooltipContentPane extends BasicBeanPane paneList; protected UIComboBox typeComboBox; + private UILabel transparentLabel; protected UINumberDragPane transparent; protected UIButtonGroup shadow; protected JPanel centerPane; + private boolean hasAuto; + + private static final int AUTO = 0; + public VanChartBackgroundPane() { + this(false); + } + + public VanChartBackgroundPane(boolean hasAuto) { + this.hasAuto = hasAuto; initComponents(); JPanel panel = initContentPanel(); this.setLayout(new BorderLayout()); this.add(panel, BorderLayout.CENTER); } + public UILabel getTransparentLabel() { + return transparentLabel; + } + + public boolean isHasAuto() { + return hasAuto; + } + protected JPanel initContentPanel() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; @@ -64,8 +83,9 @@ public class VanChartBackgroundPane extends BasicPane { protected void initComponents() { typeComboBox = new UIComboBox(); final CardLayout cardlayout = new CardLayout(); - paneList = new ArrayList(); + paneList = new ArrayList<>(); + initAutoPane(); initList(); centerPane = new JPanel(cardlayout) { @@ -86,26 +106,45 @@ public class VanChartBackgroundPane extends BasicPane { @Override public void itemStateChanged(ItemEvent e) { - cardlayout.show(centerPane, (String)typeComboBox.getSelectedItem()); + cardlayout.show(centerPane, (String) typeComboBox.getSelectedItem()); fireStateChanged(); + checkTransparent(); } }); - + transparentLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Alpha")); transparent = new UINumberDragPane(0, 100); } 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}); + shadow = new UIButtonGroup(new String[]{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[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Fill")), typeComboBox}, new Component[]{null, centerPane}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alpha")), transparent}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Shadow")), shadow}, + new Component[]{transparentLabel, transparent}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Shadow")), shadow}, }; } + protected void initAutoPane() { + if (isHasAuto()) { + paneList.add(new NullBackgroundQuickPane() { + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Automatic"); + } + }); + } + } + + private void checkTransparent() { + if (isHasAuto()) { + boolean enable = typeComboBox.getSelectedIndex() != AUTO; + transparentLabel.setEnabled(enable); + transparent.setEnabled(enable); + } + } + protected void initList() { paneList.add(new NullBackgroundQuickPane()); paneList.add(new ColorBackgroundQuickPane()); @@ -123,13 +162,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,36 +177,63 @@ 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++) { + + if (isHasAuto()) { + if (attr.isAutoBackground()) { + typeComboBox.setSelectedIndex(AUTO); + checkTransparent(); + return; + } + populateBackground(attr, 1); + } else { + 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); typeComboBox.setSelectedIndex(i); + checkTransparent(); return; } } + checkTransparent(); } public void update(GeneralInfo attr) { 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); - } attr.setAlpha((float) (transparent.updateBean() / ALPHA_V)); - if(shadow != null){ + if (shadow != null) { attr.setShadow(shadow.getSelectedIndex() == 0); } + if (isHasAuto()) { + if (typeComboBox.getSelectedIndex() == AUTO) { + attr.setAutoBackground(true); + return; + } + attr.setAutoBackground(false); + } + updateBackground(attr); + } + + 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/VanChartBackgroundPaneWithOutImageAndShadow.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundPaneWithOutImageAndShadow.java index 202df532e9..812dd5a091 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundPaneWithOutImageAndShadow.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundPaneWithOutImageAndShadow.java @@ -1,12 +1,10 @@ package com.fr.van.chart.designer.component.background; -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.ColorBackgroundQuickPane; import com.fr.design.mainframe.backgroundpane.NullBackgroundQuickPane; - import javax.swing.JPanel; import java.awt.Component; @@ -16,6 +14,15 @@ import java.awt.Component; */ public class VanChartBackgroundPaneWithOutImageAndShadow extends VanChartBackgroundPane { + public VanChartBackgroundPaneWithOutImageAndShadow() { + this(false); + } + + public VanChartBackgroundPaneWithOutImageAndShadow(boolean hasAuto) { + super(hasAuto); + } + + @Override protected JPanel initContentPanel() { double p = TableLayout.PREFERRED; @@ -49,7 +56,7 @@ public class VanChartBackgroundPaneWithOutImageAndShadow extends VanChartBackgro return new Component[][]{ new Component[]{typeComboBox, null}, new Component[]{centerPane, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alpha")), transparent}, + new Component[]{getTransparentLabel(), transparent}, }; } 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..d021640ff1 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; /** * 图表 属性表.背景设置 界面.(包括 无, 颜色, 渐变)+开启阴影 @@ -11,7 +12,11 @@ public class VanChartBackgroundWithOutImagePane extends VanChartBackgroundPane { private static final long serialVersionUID = 1322979785605013853L; public VanChartBackgroundWithOutImagePane() { - super(); + this(false); + } + + public VanChartBackgroundWithOutImagePane(boolean hasAuto) { + super(hasAuto); } protected void initList() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundWithOutShadowWithRadiusPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundWithOutShadowWithRadiusPane.java index dadd754d65..807ee62169 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundWithOutShadowWithRadiusPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundWithOutShadowWithRadiusPane.java @@ -3,7 +3,7 @@ package com.fr.van.chart.designer.component.background; import com.fr.chart.chartglyph.GeneralInfo; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; - +import com.fr.design.i18n.Toolkit; import java.awt.Component; @@ -15,23 +15,27 @@ public class VanChartBackgroundWithOutShadowWithRadiusPane extends VanChartBackg private UISpinner radius; - public VanChartBackgroundWithOutShadowWithRadiusPane(){ + public VanChartBackgroundWithOutShadowWithRadiusPane() { super(); } + public VanChartBackgroundWithOutShadowWithRadiusPane(boolean hasAuto) { + super(hasAuto); + } + protected Component[][] getPaneComponents() { - radius = new UISpinner(0,1000,1,0); - return new Component[][]{ + radius = new UISpinner(0, 1000, 1, 0); + return new Component[][]{ new Component[]{null, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Fill")), typeComboBox}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Fill")), typeComboBox}, new Component[]{null, centerPane}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alpha")), transparent}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")),radius} + new Component[]{getTransparentLabel(), transparent}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Radius")), radius} }; } public void populate(GeneralInfo attr) { - if(attr == null) { + if (attr == null) { return; } super.populate(attr); @@ -44,7 +48,7 @@ public class VanChartBackgroundWithOutShadowWithRadiusPane extends VanChartBackg if (attr == null) { attr = new GeneralInfo(); } - attr.setRoundRadius((int)radius.getValue()); + attr.setRoundRadius((int) radius.getValue()); } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartGradientPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartGradientPane.java index 2cdcf24017..c01b0a50da 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartGradientPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartGradientPane.java @@ -1,105 +1,13 @@ package com.fr.van.chart.designer.component.background; -import com.fr.base.background.GradientBackground; -import com.fr.design.event.UIObserverListener; -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; -import java.awt.BorderLayout; -import java.awt.Component; +import com.fr.common.annotations.Compatible; /** - * 渐变色设置界面,bar无法拖拽 + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-10-20 + * 扩展图表兼容 */ -public class VanChartGradientPane extends GradientBackgroundQuickPane { - protected static final int CHART_GRADIENT_WIDTH = 150; - private static final long serialVersionUID = 256594362341221087L; - - private FixedGradientBar gradientBar; - private UIButtonGroup directionPane; - - public VanChartGradientPane() { - constructPane(); - } - - protected void constructPane(){ - String[] textArray = {com.fr.design.i18n.Toolkit.i18nText("FIne-Design_Report_Utils_Left_To_Right"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Top_To_Bottom")}; - Integer[] valueArray = {GradientBackground.LEFT2RIGHT, GradientBackground.TOP2BOTTOM}; - directionPane = new UIButtonGroup(textArray, valueArray); - directionPane.setSelectedIndex(0); - gradientBar = new FixedGradientBar(4, CHART_GRADIENT_WIDTH); - - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {p, f}; - double[] rowSize = {p, p, p}; - - Component[][] components = new Component[][]{ - new Component[]{gradientBar, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Gradient_Direction")),directionPane}, - }; - JPanel Gradient = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - this.setLayout(new BorderLayout()); - this.add(Gradient, BorderLayout.CENTER); - } - - public void populateBean(Background background) { - GradientBackground bg = (GradientBackground) background; - this.gradientBar.getSelectColorPointBtnP1().setColorInner(bg.getStartColor()); - this.gradientBar.getSelectColorPointBtnP2().setColorInner(bg.getEndColor()); - directionPane.setSelectedItem(bg.getDirection()); - this.gradientBar.repaint(); - } - - public GradientBackground updateBean() { - GradientBackground gb = new GradientBackground(gradientBar.getSelectColorPointBtnP1().getColorInner(), gradientBar.getSelectColorPointBtnP2().getColorInner()); - gb.setDirection(directionPane.getSelectedItem()); - - return gb; - } - - /** - * 给组件登记一个观察者监听事件 - * - * @param listener 观察者监听事件 - */ - public void registerChangeListener(final UIObserverListener listener) { - gradientBar.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - listener.doChange(); - } - }); - directionPane.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - listener.doChange(); - } - }); - } - - /** - * 是否接受 - * @param background 背景 - * @return 是则返回true - */ - public boolean accept(Background background) { - return background instanceof GradientBackground; - } - - /** - * 名称 - * @return 名称 - */ - public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Gradient_Color"); - } - +@Compatible +public class VanChartGradientPane extends 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 690a6ab244..3e26c70418 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 @@ -13,7 +13,7 @@ import javax.swing.JPanel; public class GaugeLabelContentPane extends VanChartLabelContentPane { public GaugeLabelContentPane(VanChartStylePane parent, JPanel showOnPane) { - super(parent, showOnPane); + super(parent, showOnPane, false); } protected String getLabelContentTitle() { 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..115bdb9480 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,9 +3,8 @@ 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.PlotFactory; import com.fr.van.chart.designer.style.label.VanChartPlotLabelPane; import javax.swing.JPanel; @@ -27,7 +26,7 @@ public class VanChartLabelConditionPane extends AbstractNormalMultiLineCondition } protected VanChartPlotLabelPane createLabelPane() { - return new VanChartPlotLabelNoCheckPane(getPlot(),null); + return PlotFactory.createPlotLabelPane(getPlot(), null, true); } public VanChartLabelConditionPane(ConditionAttributesPane conditionAttributesPane, Plot plot) { @@ -36,6 +35,7 @@ public class VanChartLabelConditionPane extends AbstractNormalMultiLineCondition /** * 条件属性item的名称 + * * @return item的名称 */ public String nameForPopupMenuItem() { 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..7e68f99423 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/MapRangeLegendPane.java @@ -0,0 +1,27 @@ +package com.fr.van.chart.designer.style; + +import com.fr.van.chart.designer.component.background.VanChartBackgroundPane; +import com.fr.van.chart.designer.component.background.VanChartBackgroundWithOutImagePane; + +/** + * @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() { + //TODO Bjorn 地图图例背景自动逻辑 + return new VanChartBackgroundWithOutImagePane(); + //return new VanChartBackgroundWithOutImagePane(true); + } +} 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..8a0a62f62d 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 @@ -21,6 +21,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 +55,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 +136,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 +154,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,6 +286,8 @@ public class VanChartPlotLegendPane extends BasicPane { } private JPanel createTitleStylePane() { + //TODO Bjorn 图例预定义逻辑 + //textAttrPane = new ChartTextAttrPaneWithPreStyle(); textAttrPane = new ChartTextAttrPane(); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), textAttrPane); } @@ -382,7 +389,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 +415,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/VanChartStylePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java index 4dc9b6ba57..32a4f8e547 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java @@ -25,8 +25,8 @@ public class VanChartStylePane extends ChartStylePane { protected java.util.List getPaneList() { java.util.List paneList = new ArrayList(); Plot plot = getChart().getPlot(); - paneList.add(new VanChartTitlePane(VanChartStylePane.this)); - if(plot.isSupportLegend()){ + paneList.add(createVanChartTitlePane()); + if (plot.isSupportLegend()) { paneList.add(new VanChartLegendPane(VanChartStylePane.this)); } @@ -34,14 +34,14 @@ public class VanChartStylePane extends ChartStylePane { paneList.add(createChartSeriesPane()); - if(plot.isHaveAxis()){ - if(plot instanceof VanChartAxisPlot) { + if (plot.isHaveAxis()) { + if (plot instanceof VanChartAxisPlot) { createVanChartAxisPane(paneList, (VanChartAxisPlot) plot); } addOtherAxisPane(paneList, plot); - if(plot.isSupportDataSheet()) { + if (plot.isSupportDataSheet()) { paneList.add(new VanChartDataSheetPane()); } } @@ -53,6 +53,10 @@ public class VanChartStylePane extends ChartStylePane { return paneList; } + protected VanChartTitlePane createVanChartTitlePane() { + return new VanChartTitlePane(VanChartStylePane.this); + } + protected void addOtherAxisPane(java.util.List paneList, Plot plot) { } @@ -68,7 +72,7 @@ public class VanChartStylePane extends ChartStylePane { paneList.add(new VanChartLabelPane(VanChartStylePane.this)); } - protected void addVanChartTooltipPane(List paneList){ + protected void addVanChartTooltipPane(List paneList) { paneList.add(new VanChartTooltipPane(VanChartStylePane.this)); } } \ No newline at end of file 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..1c02f342ca 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 @@ -112,7 +112,7 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { } private JPanel createTitlePane() { - backgroundPane = new VanChartBackgroundWithOutShadowWithRadiusPane(); + backgroundPane = createBackgroundPane(); double p = TableLayout.PREFERRED; @@ -132,6 +132,10 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } + protected VanChartBackgroundWithOutShadowWithRadiusPane createBackgroundPane() { + return new VanChartBackgroundWithOutShadowWithRadiusPane(); + } + private JPanel createTitleContentPane(double[] row, double[] col) { titleContent = new TinyFormulaPane(); useHtml = new UIToggleButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Html")); @@ -171,6 +175,8 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { } private JPanel createTitleStylePane() { + //TODO Bjorn 标题预定义逻辑 + //textAttrPane = new ChartTextAttrPaneWithPreStyle(); textAttrPane = new ChartTextAttrPane(); 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/VanChartTitleWithAutoBackground.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitleWithAutoBackground.java new file mode 100644 index 0000000000..e126c53598 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitleWithAutoBackground.java @@ -0,0 +1,21 @@ +package com.fr.van.chart.designer.style; + +import com.fr.van.chart.designer.component.background.VanChartBackgroundWithOutShadowWithRadiusPane; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-10-20 + */ +public class VanChartTitleWithAutoBackground extends VanChartTitlePane { + + public VanChartTitleWithAutoBackground(VanChartStylePane parent) { + super(parent); + } + + protected VanChartBackgroundWithOutShadowWithRadiusPane createBackgroundPane() { + //TODO Bjorn 地图标题背景自动逻辑 + //return new VanChartBackgroundWithOutShadowWithRadiusPane(true); + return new VanChartBackgroundWithOutShadowWithRadiusPane(); + } +} 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..955be0a8c4 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 @@ -34,6 +34,7 @@ import com.fr.stable.StringUtils; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartHtmlLabelPane; import com.fr.van.chart.designer.style.VanChartStylePane; +import com.fr.van.chart.designer.style.axis.component.AxisLabelDisplayComboBox; import javax.swing.BorderFactory; import javax.swing.Icon; @@ -66,6 +67,8 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { protected ChartTextAttrPane labelTextAttrPane; protected UINumberDragPane labelTextRotation; + private AxisLabelDisplayComboBox labelDisplayComboBox; + //轴标签缩略间隔显示 恢复用注释。下面6行删除。 protected UITextField labelGapValue; @@ -75,11 +78,17 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { //protected UISpinner labelGapValue; protected JPanel labelPanel; + private JPanel labelGapPane; private JPanel labelGapStylePane; private JPanel labelGapValuePane; + private JPanel labelDisplayPane; protected LineComboBox axisLineStyle; + + //TODO Bjorn 坐标轴面板回退 protected ColorSelectBox axisLineColor; + //protected ColorSelectBoxWithPreStyle axisLineColor; + protected UIButtonGroup mainTick; protected UIButtonGroup secondTick; @@ -116,6 +125,10 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { this.add(createContentPane(isXAxis), BorderLayout.CENTER); } + protected boolean showLabelDisplay() { + return true; + } + protected JPanel createContentPane(boolean isXAxis) { double p = TableLayout.PREFERRED; @@ -127,7 +140,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { double[] rowSize = {p, p, p, p, p, p, p, p}; Component[][] components = new Component[][]{ new Component[]{createTitlePane(new double[]{p, p, p, p, p, p}, column, isXAxis), null}, - new Component[]{createLabelPane(new double[]{p, p}, column), null}, + new Component[]{createLabelPane(new double[]{p, p, p}, column), null}, new Component[]{createLineStylePane(new double[]{p, p, p, p, p}, columnSize), null}, new Component[]{createAxisPositionPane(new double[]{p, p, p}, columnSize, isXAxis), null}, new Component[]{createDisplayStrategy(), null}, @@ -142,7 +155,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { titleAlignPane = isXAxis ? getXAxisTitleAlignPane() : getYAxisTitleAlignPane(); titleAlignPane.setSelectedItem(Constants.CENTER); titleContent = new TinyFormulaPane(); - titleUseHtml = new UIToggleButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Html")); + titleUseHtml = new UIToggleButton(Toolkit.i18nText("Fine-Design_Chart_Html")); UIComponentUtils.setLineWrap(titleUseHtml); titleTextAttrPane = getChartTextAttrPane(); titleTextRotation = new UINumberDragPane(-ROTATION_MAX, ROTATION_MAX); @@ -153,12 +166,12 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { } Component[][] components = new Component[][]{ new Component[]{null, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content")), titleContent}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Content")), titleContent}, new Component[]{null, titleUseHtml}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Position")), titleAlignPane}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Layout_Position")), titleAlignPane}, new Component[]{titleTextAttrPane, null}, new Component[]{ - FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TextRotation")), + FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_TextRotation")), UIComponentUtils.wrapWithBorderLayoutPane(titleTextRotation) }, }; @@ -199,54 +212,95 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { } protected JPanel createLabelPane(double[] row, double[] col) { - showLabel = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Show"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Hidden")}); - labelTextAttrPane = getChartTextAttrPane(); + initLabelComponents(); + + labelGapPane = createLabelGapPane(row, col); + labelPanel = createLabelDetailPanel(); + + addComponentsListener(); + + JPanel showLabelPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Axis_Label"), showLabel); + + JPanel labelPane = new JPanel(new BorderLayout()); + labelPane.add(showLabelPane, BorderLayout.NORTH); + labelPane.add(labelPanel, BorderLayout.CENTER); + + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(PaneTitleConstants.CHART_STYLE_LABEL_TITLE, labelPane); + } + + private void initLabelComponents() { + showLabel = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Use_Show"), Toolkit.i18nText("Fine-Design_Chart_Hidden")}); + labelDisplayComboBox = new AxisLabelDisplayComboBox(); + labelDisplayPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Show"), labelDisplayComboBox, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); + labelDisplayPane.setVisible(showLabelDisplay()); + + labelTextAttrPane = getChartTextAttrPane(); labelTextRotation = new UINumberDragPane(-ROTATION_MAX, ROTATION_MAX); - labelGapStyle = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Automatic"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Fixed")}); + labelGapStyle = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Automatic"), Toolkit.i18nText("Fine-Design_Chart_Fixed")}); labelGapValue = new UITextField(); + } + + private JPanel createLabelGapPane(double[] row, double[] col) { Component[][] gapComponents = new Component[][]{ + new Component[]{null, null}, new Component[]{ - FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TextRotation")), + FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_TextRotation")), UIComponentUtils.wrapWithBorderLayoutPane(labelTextRotation) }, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Label_Interval")), labelGapStyle}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Label_Interval")), labelGapStyle} }; - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(gapComponents, row, col); - labelGapValuePane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText(""), labelGapValue, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); - JPanel gapPanel = new JPanel(new BorderLayout()); - gapPanel.add(panel, BorderLayout.CENTER); - gapPanel.add(labelGapValuePane, BorderLayout.SOUTH); - Component[][] components = new Component[][]{ - new Component[]{labelTextAttrPane, null}, - new Component[]{gapPanel, null}, - }; + JPanel gapDetailPane = TableLayout4VanChartHelper.createGapTableLayoutPane(gapComponents, row, col); + labelGapValuePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText(""), labelGapValue, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); + + JPanel panel = new JPanel(new BorderLayout()); + panel.add(gapDetailPane, BorderLayout.CENTER); + panel.add(labelGapValuePane, BorderLayout.SOUTH); - JPanel showLabelPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Label"), showLabel); - labelPanel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); - labelPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); + return panel; + } + + private JPanel createLabelDetailPanel() { + JPanel panel = new JPanel(new BorderLayout()); + panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); + + panel.add(labelDisplayPane, BorderLayout.NORTH); + panel.add(labelTextAttrPane, BorderLayout.CENTER); + panel.add(labelGapPane, BorderLayout.SOUTH); + + return panel; + } + + private void addComponentsListener() { + // 显示/隐藏 showLabel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { checkLabelPane(); } }); + + // 间隔/缩略/换行 + labelDisplayComboBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkLabelGapPane(); + } + }); + + // 自动/固定 labelGapStyle.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { checkLabelGapValuePane(); } }); - JPanel jPanel = new JPanel(new BorderLayout()); - jPanel.add(showLabelPane, BorderLayout.NORTH); - jPanel.add(labelPanel, BorderLayout.CENTER); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(PaneTitleConstants.CHART_STYLE_LABEL_TITLE, jPanel); } // protected JPanel createLabelPane(double[] row, double[] col){ // double p = TableLayout.PREFERRED; -// showLabel = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Show"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Hidden")}); +// showLabel = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Use_Show"), Toolkit.i18nText("Fine-Design_Chart_Hidden")}); // labelTextAttrPane = getChartTextAttrPane(); // // JPanel rotationPane = createLabelRotationPane(col); @@ -259,7 +313,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { // new Component[]{overlapPane, null}, // }; // -// JPanel showLabelPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Label"),showLabel); +// JPanel showLabelPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Axis_Label"),showLabel); // labelPanel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p, p, p}, col); // labelPanel.setBorder(BorderFactory.createEmptyBorder(0,10,0,0)); // showLabel.addActionListener(new ActionListener() { @@ -279,7 +333,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { Component[][] gapComponents = new Component[][]{ new Component[]{ - FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TextRotation")), + FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_TextRotation")), UIComponentUtils.wrapWithBorderLayoutPane(labelTextRotation) } }; @@ -327,8 +381,13 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { } protected ChartTextAttrPane getChartTextAttrPane() { + //TODO Bjorn 坐标轴面板回退 + /* return new ChartTextAttrPaneWithPreStyle() { + protected double getEdithAreaWidth() { + return TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; + } + };*/ return new ChartTextAttrPane() { - @Override protected JPanel getContentPane(JPanel buttonPane) { double p = TableLayout.PREFERRED; @@ -344,14 +403,16 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { protected JPanel createLineStylePane(double[] row, double[] col) { axisLineStyle = createLineComboBox(); + //TODO Bjorn 坐标轴面板回退 + //axisLineColor = new ColorSelectBoxWithPreStyle(100); axisLineColor = new ColorSelectBox(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")}; + String[] strings = new String[]{Toolkit.i18nText("Fine-Design_Chart_Open"), Toolkit.i18nText("Fine-Design_Chart_Close")}; AxisTickLineType[] values = new AxisTickLineType[]{AxisTickLineType.TICK_LINE_OUTSIDE, AxisTickLineType.TICK_LINE_NONE}; mainTick = new UIButtonGroup(strings, values); secondTick = new UIButtonGroup(strings, values); JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(getLineStylePaneComponents(), row, col); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Line_Style"), panel); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Axis_Line_Style"), panel); } protected LineComboBox createLineComboBox() { @@ -361,34 +422,36 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { protected Component[][] getLineStylePaneComponents() { 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[]{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}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Type")), axisLineStyle}, + //TODO Bjorn 坐标轴面板回退 + //new Component[]{axisLineColor, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), axisLineColor}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Main_Graduation_Line")), mainTick}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Second_Graduation_Line")), secondTick}, }; } protected JPanel createAxisPositionPane(double[] row, double[] col, boolean isXAxis) { position = new UIButtonGroup(getAxisPositionNameArray(isXAxis), getAxisPositionValueArray(isXAxis)); - reversed = 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}); + reversed = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_On"), Toolkit.i18nText("Fine-Design_Chart_Off")}, new Boolean[]{true, false}); Component[][] components = new Component[][]{ new Component[]{null, null}, new Component[]{ - FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Position")), + FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Position")), UIComponentUtils.wrapWithBorderLayoutPane(position) }, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_AxisReversed")), reversed}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_AxisReversed")), reversed}, }; JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), panel); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), panel); } private String[] getAxisPositionNameArray(boolean isXAxis) { if (isXAxis) { - return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Top"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Bottom"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Vertical_Zero")}; + return new String[]{Toolkit.i18nText("Fine-Design_Chart_Axis_Top"), Toolkit.i18nText("Fine-Design_Chart_Axis_Bottom"), Toolkit.i18nText("Fine-Design_Chart_Axis_Vertical_Zero")}; } else { - return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Left"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Right"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Vertical_Zero")}; + return new String[]{Toolkit.i18nText("Fine-Design_Chart_Layout_Left"), Toolkit.i18nText("Fine-Design_Chart_Layout_Right"), Toolkit.i18nText("Fine-Design_Chart_Axis_Vertical_Zero")}; } } @@ -403,10 +466,10 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { protected JPanel createDisplayStrategy() { //区域显示策略 恢复用注释。删除到return,即除了注释的代码都删除。 maxProportion = new UISpinner(0, 100, 1, 30); - axisLimitSize = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Limit"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Not_Limit")}); + axisLimitSize = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Limit"), Toolkit.i18nText("Fine-Design_Chart_Not_Limit")}); - JPanel limitSizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area_Size"), axisLimitSize); - maxProportionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Max_Proportion"), maxProportion, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); + JPanel limitSizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Area_Size"), axisLimitSize); + maxProportionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Max_Proportion"), maxProportion, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); maxProportionPane.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0)); JPanel panel = new JPanel(new BorderLayout()); panel.add(limitSizePane, BorderLayout.NORTH); @@ -419,7 +482,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { } }); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel); //区域显示策略 恢复用注释。取消注释。 // limitPane = new LimitPane(); @@ -427,8 +490,8 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { } protected JPanel createValueStylePane() { - valueFormatStyle = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Common"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")}); + valueFormatStyle = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Common"), + Toolkit.i18nText("Fine-Design_Chart_Custom")}); valueFormat = createFormatPane(); checkFormatType(); @@ -436,8 +499,8 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { htmlLabelPane = new VanChartHtmlLabelPane(); centerPane = new JPanel(new CardLayout()); - centerPane.add(valueFormat, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Common")); - centerPane.add(htmlLabelPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")); + centerPane.add(valueFormat, Toolkit.i18nText("Fine-Design_Chart_Common")); + centerPane.add(htmlLabelPane, Toolkit.i18nText("Fine-Design_Chart_Custom")); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; @@ -445,7 +508,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { double[] rowSize = {p, p, p}; Component[][] components = new Component[][]{ new Component[]{null, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Format"), SwingConstants.LEFT), valueFormatStyle}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Format"), SwingConstants.LEFT), valueFormatStyle}, new Component[]{null, centerPane}, }; JPanel contentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); @@ -458,7 +521,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { } }); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Format"), contentPane); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Use_Format"), contentPane); } protected FormatPane createFormatPane() { @@ -480,6 +543,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { protected void checkAllUse() { checkCardPane(); checkLabelPane(); + checkLabelGapPane(); checkTitlePane(); //区域显示策略 恢复用注释。删除下面一行。 checkMaxProPortionUse(); @@ -502,9 +566,9 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { if (centerPane != null && valueFormatStyle != null) { CardLayout cardLayout = (CardLayout) centerPane.getLayout(); if (valueFormatStyle.getSelectedIndex() == 1) { - cardLayout.show(centerPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")); + cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Custom")); } else { - cardLayout.show(centerPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Common")); + cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Common")); } } } @@ -539,6 +603,18 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { checkLabelGapValuePane(); } + protected void checkLabelGapPane() { + if (labelGapPane != null) { + boolean visible = true; + + if (showLabelDisplay() && labelDisplayPane != null && labelDisplayComboBox != null) { + visible = labelDisplayComboBox.getSelectedIndex() == 0; + } + + labelGapPane.setVisible(visible); + } + } + protected void checkLabelGapValuePane() { if (labelGapValuePane != null && labelGapStyle != null) { boolean visible = labelGapStyle.getSelectedIndex() == 1; @@ -568,7 +644,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { */ @Override public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Category_Axis"); + return Toolkit.i18nText("Fine-Design_Chart_Category_Axis"); } /** @@ -639,6 +715,9 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { // if (overlapHandleTypeGroup != null) { // overlapHandleTypeGroup.setSelectedItem(axis.getOverlapHandleType()); // } + if (labelDisplayComboBox != null) { + labelDisplayComboBox.populateBean(axis.getLabelDisplay()); + } if (labelGapStyle != null) { labelGapStyle.setSelectedIndex(axis.isAutoLabelGap() ? 0 : 1); } @@ -657,6 +736,8 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { } if (axisLineColor != null) { axisLineColor.setSelectObject(axis.getAxisColor()); + //TODO Bjorn 坐标轴面板回退 + //axisLineColor.populate(axis.getLineColorWithPreStyle()); } if (mainTick != null) { mainTick.setSelectedItem(axis.getMainTickLine()); @@ -775,6 +856,9 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { // if (overlapHandleTypeGroup != null) { // axis.setOverlapHandleType(overlapHandleTypeGroup.getSelectedItem()); // } + if (labelDisplayComboBox != null) { + axis.setLabelDisplay(labelDisplayComboBox.updateBean()); + } if (labelGapStyle != null) { axis.setAutoLabelGap(labelGapStyle.getSelectedIndex() == 0); } @@ -797,6 +881,8 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { } if (axisLineColor != null) { axis.setAxisColor(axisLineColor.getSelectObject()); + //TODO Bjorn 坐标轴面板回退 + //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/VanChartTimeAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java index 69a326ac44..f960b4aff7 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java @@ -12,6 +12,7 @@ import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.style.FormatPane; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -69,7 +70,7 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane { double[] rowSize = {p,p,p,p,p,p,p,p,p,p,p,p,p,p}; Component[][] components = new Component[][]{ new Component[]{createTitlePane(new double[]{p, p, p, p, p,p}, column, isXAxis),null}, - new Component[]{createLabelPane(new double[]{p, p}, column),null}, + new Component[]{createLabelPane(new double[]{p, p, p}, column),null}, new Component[]{createValueDefinition(),null}, new Component[]{createLineStylePane(new double[]{p, p,p,p,p}, columnSize),null}, new Component[]{createAxisPositionPane(new double[]{p, p, p}, columnSize, isXAxis),null}, @@ -80,6 +81,10 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane { return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } + protected boolean showLabelDisplay() { + return false; + } + @Override protected void addOverlapGroupButton(JPanel panel) { //do nothing @@ -87,7 +92,7 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane { private JPanel createValueDefinition(){ timeMinMaxValuePane = new TimeMinMaxValuePane(); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Value_Definition"), timeMinMaxValuePane); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Value_Definition"), timeMinMaxValuePane); } @Override @@ -127,7 +132,7 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane { */ @Override public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TimeAxis"); + return Toolkit.i18nText("Fine-Design_Chart_TimeAxis"); } private class TimeMinMaxValuePane extends JPanel{ @@ -174,10 +179,10 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane { secTickPane.add(secondUnitField); secTickPane.add(secondType); - minPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Min"),minValueField, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); - maxPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Max"),maxValueField, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); - mainPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Main_Type"),mainTickPane, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); - secPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_SecType"),secTickPane, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); + minPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Data_Min"),minValueField, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); + maxPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Data_Max"),maxValueField, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); + mainPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Main_Type"),mainTickPane, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); + secPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_SecType"),secTickPane, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); minPane.setBorder(BorderFactory.createEmptyBorder(0,TableLayout4VanChartHelper.COMPONENT_INTERVAL,0,0)); maxPane.setBorder(BorderFactory.createEmptyBorder(0,TableLayout4VanChartHelper.COMPONENT_INTERVAL,0,0)); @@ -208,10 +213,10 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane { private void initMin() { // 最小值. - minCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Min_Value")); + minCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Custom_Min_Value")); Date tmp = null; - DateEditor dateEditor = new DateEditor(tmp, true, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Date"), UIDatePicker.STYLE_CN_DATETIME1); - Editor formulaEditor = new FormulaEditor(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Formula")); + DateEditor dateEditor = new DateEditor(tmp, true, Toolkit.i18nText("Fine-Design_Basic_Date"), UIDatePicker.STYLE_CN_DATETIME1); + Editor formulaEditor = new FormulaEditor(Toolkit.i18nText("Fine-Design_Chart_Formula")); Editor[] editor = new Editor[]{dateEditor, formulaEditor}; minValueField = new ValueEditorPane(editor); minCheckBox.addActionListener(new ActionListener() { @@ -223,10 +228,10 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane { private void initMax() { // 最大值 - maxCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Max_Value")); + maxCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Custom_Max_Value")); Date tmp = null; - DateEditor dateEditor = new DateEditor(tmp, true, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Date"), UIDatePicker.STYLE_CN_DATETIME1); - Editor formulaEditor = new FormulaEditor(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Formula")); + DateEditor dateEditor = new DateEditor(tmp, true, Toolkit.i18nText("Fine-Design_Basic_Date"), UIDatePicker.STYLE_CN_DATETIME1); + Editor formulaEditor = new FormulaEditor(Toolkit.i18nText("Fine-Design_Chart_Formula")); Editor[] editor = new Editor[]{dateEditor, formulaEditor}; maxValueField = new ValueEditorPane(editor); maxCheckBox.addActionListener(new ActionListener() { @@ -238,7 +243,7 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane { private void initMain() { // 主要刻度单位 - mainTickBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Main_Type")); + mainTickBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Custom_Main_Type")); mainUnitField = new UITextField(); mainUnitField.setPreferredSize(new Dimension(20, 20)); mainType = new UIComboBox(TYPES); @@ -254,7 +259,7 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane { private void initSecond() { // 次要刻度单位 - secondTickBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Second_Type")); + secondTickBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Custom_Second_Type")); secondUnitField = new UITextField(); secondUnitField.setPreferredSize(new Dimension(20, 20)); secondType = new UIComboBox(TYPES); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartValueAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartValueAxisPane.java index 934185b38e..7633d0c1e4 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartValueAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartValueAxisPane.java @@ -5,6 +5,7 @@ import com.fr.chart.base.ChartBaseUtils; import com.fr.design.chart.ChartSwingUtils; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.plugin.chart.attr.axis.VanChartAxis; @@ -50,7 +51,7 @@ public class VanChartValueAxisPane extends VanChartBaseAxisPane { double[] rowSize = {p,p,p,p,p,p,p,p,p,p,p,p,p,p}; Component[][] components = new Component[][]{ new Component[]{createTitlePane(new double[]{p, p, p, p, p, p}, column, isXAxis), null}, - new Component[]{createLabelPane(new double[]{p, p}, column), null}, + new Component[]{createLabelPane(new double[]{p, p, p}, column), null}, new Component[]{createMinMaxValuePane(new double[]{p, p}, columnSize), null}, new Component[]{createLineStylePane(new double[]{p, p, p, p, p}, columnSize), null}, new Component[]{createAxisPositionPane(new double[]{p, p, p}, columnSize, isXAxis), null}, @@ -61,6 +62,10 @@ public class VanChartValueAxisPane extends VanChartBaseAxisPane { return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } + protected boolean showLabelDisplay() { + return false; + } + @Override protected void addOverlapGroupButton(JPanel panel) { //do nothing @@ -68,12 +73,12 @@ public class VanChartValueAxisPane extends VanChartBaseAxisPane { protected JPanel createMinMaxValuePane(double[] row, double[] col){ JPanel panel = createCommenValuePane(row,col); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Value_Definition"), panel); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Value_Definition"), panel); } protected JPanel createCommenValuePane(double[] row, double[] col){ initMinMaxValuePane(); - logBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_LogBase_Value")); + logBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Custom_LogBase_Value")); logBaseField = new UITextField(); logBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -87,7 +92,7 @@ public class VanChartValueAxisPane extends VanChartBaseAxisPane { // logPane.add(logBaseField); - logPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Log_Base_Value"), logBaseField, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); + logPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Log_Base_Value"), logBaseField, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); logPane.setBorder(BorderFactory.createEmptyBorder(0, TableLayout4VanChartHelper.COMPONENT_INTERVAL, 0, 0)); @@ -125,7 +130,7 @@ public class VanChartValueAxisPane extends VanChartBaseAxisPane { */ @Override public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Value_Axis"); + return Toolkit.i18nText("Fine-Design_Chart_Value_Axis"); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/AxisLabelDisplayComboBox.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/AxisLabelDisplayComboBox.java new file mode 100644 index 0000000000..33b837eb76 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/AxisLabelDisplayComboBox.java @@ -0,0 +1,48 @@ +package com.fr.van.chart.designer.style.axis.component; + +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.type.AxisLabelDisplay; + +public class AxisLabelDisplayComboBox extends UIComboBox { + + public static final String[] DISPLAY_ITEM_GROUP = { + Toolkit.i18nText("Fine-Design_Chart_Label_OverlapInterval"), + Toolkit.i18nText("Fine-Design_Chart_Label_OverlapAbbreviate"), + Toolkit.i18nText("Fine-Design_Chart_Label_OverlapMulti_Line") + }; + + public static final AxisLabelDisplay[] DISPLAY_TYPE_GROUP = { + AxisLabelDisplay.INTERVAL, + AxisLabelDisplay.ELLIPSIS, + AxisLabelDisplay.MULTI_LINE + }; + + public AxisLabelDisplayComboBox() { + super(DISPLAY_ITEM_GROUP); + setSelectedIndex(0); + } + + public void reset() { + this.setSelectedItem(DISPLAY_ITEM_GROUP[0]); + } + + public void populateBean(AxisLabelDisplay type) { + for (int i = 0; i < DISPLAY_TYPE_GROUP.length; i++) { + if (type != null && type == DISPLAY_TYPE_GROUP[i]) { + setSelectedIndex(i); + break; + } + } + } + + public AxisLabelDisplay updateBean() { + int selectIndex = getSelectedIndex(); + + if (selectIndex >= 0 && selectIndex < DISPLAY_TYPE_GROUP.length) { + return DISPLAY_TYPE_GROUP[selectIndex]; + } + + return null; + } +} 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..1a4fccf585 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 @@ -103,6 +103,8 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane { return new ChartTextAttrPaneWithAuto(FontAutoType.SIZE_AND_COLOR); } else { return new ChartTextAttrPane(); + //TODO Bjorn 坐标轴面板回退 + //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..309a7daa66 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 @@ -2,6 +2,7 @@ package com.fr.van.chart.designer.style.axis.radar; import com.fr.design.gui.icombobox.LineComboBox; 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; @@ -29,7 +30,7 @@ public class VanChartRadarXAxisPane extends VanChartBaseAxisPane { double[] column = {f, s}; double[] rowSize = {p,p,p,p,p,p}; Component[][] components = new Component[][]{ - new Component[]{createLabelPane(new double[]{p, p}, column),null}, + new Component[]{createLabelPane(new double[]{p, p, p}, column),null}, new Component[]{createLineStylePane(new double[]{p, p, p, p}, columnSize),null}, new Component[]{createValueStylePane(),null}, }; @@ -37,11 +38,17 @@ public class VanChartRadarXAxisPane extends VanChartBaseAxisPane { return TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); } + protected boolean showLabelDisplay() { + return false; + } + protected Component[][] getLineStylePaneComponents() { 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[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Type")), axisLineStyle}, + //TODO Bjorn 坐标轴面板回退 + //new Component[]{axisLineColor, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), axisLineColor}, }; } 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..cf4ffb3864 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 @@ -3,9 +3,9 @@ package com.fr.van.chart.designer.style.axis.radar; 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; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; - import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.axis.VanChartValueAxis; import com.fr.stable.CoreConstants; @@ -41,7 +41,7 @@ public class VanChartRadarYAxisPane extends VanChartValueAxisPane { double[] column = {f, s}; double[] rowSize = {p, p, p, p, p, p, p, p}; Component[][] components = new Component[][]{ - new Component[]{createLabelPane(new double[]{p, p}, column), null}, + new Component[]{createLabelPane(new double[]{p, p, p}, column), null}, new Component[]{createMinMaxValuePane(new double[]{p, p, p}, columnSize), null}, new Component[]{createLineStylePane(new double[]{p, p, p, p}, columnSize), null}, new Component[]{createValueStylePane(), null}, @@ -61,15 +61,15 @@ public class VanChartRadarYAxisPane extends VanChartValueAxisPane { double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double[] columnSize = {f, e}; - valueStyle = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Unified_Count"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Respectively_Specified")}); + valueStyle = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Axis_Unified_Count"), + Toolkit.i18nText("Fine-Design_Chart_Respectively_Specified")}); JPanel commenPane = createCommenValuePane(new double[]{p, p, p}, columnSize); tableDataPane = new RadarTableDataPane(); centerPane = new JPanel(new CardLayout()); - centerPane.add(commenPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Unified_Count")); - centerPane.add(tableDataPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Respectively_Specified")); + centerPane.add(commenPane, Toolkit.i18nText("Fine-Design_Chart_Axis_Unified_Count")); + centerPane.add(tableDataPane, Toolkit.i18nText("Fine-Design_Chart_Respectively_Specified")); JPanel contentPane = new JPanel(new BorderLayout()); contentPane.add(valueStyle, BorderLayout.NORTH); @@ -81,16 +81,18 @@ public class VanChartRadarYAxisPane extends VanChartValueAxisPane { } }); - JPanel panel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Value_Definition"), contentPane); - contentPane.setBorder(BorderFactory.createEmptyBorder(10,5,0,0)); + JPanel panel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Value_Definition"), contentPane); + contentPane.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0)); return panel; } protected Component[][] getLineStylePaneComponents() { 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[]{null, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Type")), axisLineStyle}, + //TODO Bjorn 坐标轴面板回退 + //new Component[]{axisLineColor, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), axisLineColor}, }; } @@ -102,9 +104,9 @@ public class VanChartRadarYAxisPane extends VanChartValueAxisPane { if (centerPane != null && valueStyle != null) { CardLayout cardLayout = (CardLayout) centerPane.getLayout(); if (valueStyle.getSelectedIndex() == 0) { - cardLayout.show(centerPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Unified_Count")); + cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Axis_Unified_Count")); } else { - cardLayout.show(centerPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Respectively_Specified")); + cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Respectively_Specified")); } } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java index b239583418..ca59824f69 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java @@ -205,7 +205,7 @@ public class VanChartAlertValuePane extends BasicBeanPane { } else { alertText.populateBean(GeneralUtils.objectToString(chartAlertValue.getAlertContentFormula())); } - fontName.setSelectedItem(chartAlertValue.getAlertFont().getName()); + fontName.setSelectedItem(chartAlertValue.getAlertFont().getFamily()); fontSize.setSelectedItem(chartAlertValue.getAlertFont().getSize()); fontColor.setSelectObject(chartAlertValue.getAlertFont().getForeground()); } 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..6cef622ebe 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 @@ -6,7 +6,6 @@ import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; 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; @@ -42,6 +41,12 @@ public class VanChartAreaBackgroundPane extends AbstractVanChartScrollPane { private LineTypeComboBox verticalLineType; private ColorSelectBox horizontalColorBox; private ColorSelectBox verticalColorBox; + //TODO Bjorn 背景坐标轴面板回退 + /* private ColorSelectBoxWithPreStyle horizontalColorBox; + private ColorSelectBoxWithPreStyle verticalColorBox;*/ private JPanel horizontalColorPane; private JPanel verticalColorPane; @@ -55,6 +58,9 @@ public class VanChartAxisAreaPane extends BasicBeanPane { private void initComponents() { horizontalColorBox = new ColorSelectBox(PREFERRED_WIDTH); verticalColorBox = new ColorSelectBox(PREFERRED_WIDTH); + //TODO Bjorn 背景坐标轴面板回退 + /* 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}); @@ -87,15 +93,18 @@ public class VanChartAxisAreaPane extends BasicBeanPane { } protected void initGridLineComponents() { + //TODO Bjorn 背景坐标轴面板回退 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 +152,7 @@ public class VanChartAxisAreaPane extends BasicBeanPane { return panel; } - protected AlertLineListControlPane getAlertLinePane () { + protected AlertLineListControlPane getAlertLinePane() { return new AlertLineListControlPane(); } @@ -153,7 +162,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(); @@ -219,12 +228,15 @@ public class VanChartAxisAreaPane extends BasicBeanPane { VanChartAxis defaultXAxis = rectanglePlot.getDefaultXAxis(); VanChartAxis defaultYAxis = rectanglePlot.getDefaultYAxis(); + //TODO Bjorn 背景坐标轴面板回退 if (defaultXAxis != null) { + //verticalColorBox.populate(defaultXAxis.getMainGridColorWithPreStyle()); verticalColorBox.setSelectObject(defaultXAxis.getMainGridColor()); verticalLineType.setSelectedItem(defaultXAxis.getGridLineType()); } if (defaultYAxis != null) { + //horizontalColorBox.populate(defaultYAxis.getMainGridColorWithPreStyle()); horizontalColorBox.setSelectObject(defaultYAxis.getMainGridColor()); horizonLineType.setSelectedItem(defaultYAxis.getGridLineType()); } @@ -252,12 +264,15 @@ public class VanChartAxisAreaPane extends BasicBeanPane { VanChartAxis defaultXAxis = rectanglePlot.getDefaultXAxis(); VanChartAxis defaultYAxis = rectanglePlot.getDefaultYAxis(); + //TODO Bjorn 背景坐标轴面板回退 if (defaultXAxis != null) { + //defaultXAxis.setMainGridColorWithPreStyle(verticalColorBox.update()); defaultXAxis.setMainGridColor(verticalColorBox.getSelectObject()); defaultXAxis.setGridLineType((LineType) verticalLineType.getSelectedItem()); } if (defaultYAxis != null) { + //defaultYAxis.setMainGridColorWithPreStyle(horizontalColorBox.update()); defaultYAxis.setMainGridColor(horizontalColorBox.getSelectObject()); 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..d6fa66bfb5 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; @@ -13,7 +12,6 @@ import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; 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; @@ -58,11 +56,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 +69,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 +78,40 @@ 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); + } + + //TODO Bjorn 数据表面板回退 + protected VanChartBorderPane createBorderPanePane() { + return new VanChartBorderPane(); + //return new VanChartBorderPaneWithPreStyle(); + } + + protected ChartTextAttrPane createChartTextAttrPane() { + return new ChartTextAttrPane(); + //return new ChartTextAttrPaneWithPreStyle(); } @Override @@ -119,11 +130,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 +144,7 @@ public class VanChartDataSheetPane extends AbstractVanChartScrollPane { plot.setDataSheet(dataSheet); } dataSheet.setVisible(isShowDataSheet.isSelected()); - if(isShowDataSheet.isSelected()){ + if (isShowDataSheet.isSelected()) { update(dataSheet); } @@ -144,14 +155,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 +184,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..3d6ad86e88 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,6 +49,7 @@ public class VanChartGaugeCateOrPercentLabelDetailPane extends VanChartGaugeLabe return getGaugeStyle() == GaugeStyle.RING || getGaugeStyle() == GaugeStyle.SLOT; } + //TODO Bjorn 仪表盘自动逻辑 protected boolean isFontColorAuto() { return getGaugeStyle() == GaugeStyle.RING || getGaugeStyle() == GaugeStyle.SLOT; } 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..17910d38a0 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 @@ -41,7 +41,7 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { private ChartTextAttrPane textFontPane; public VanChartGaugeLabelDetailPane(Plot plot, VanChartStylePane parent) { - super(plot, parent); + super(plot, parent, false); } protected void initLabelDetailPane(Plot plot) { @@ -80,8 +80,10 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { return false; } + //TODO Bjorn 仪表盘自动逻辑 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 1470951976..3047e608ff 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 @@ -58,13 +58,19 @@ public class VanChartPlotLabelDetailPane extends BasicPane { private VanChartStylePane parent; private Plot plot; + private boolean inCondition; - public VanChartPlotLabelDetailPane(Plot plot, VanChartStylePane parent) { + public VanChartPlotLabelDetailPane(Plot plot, VanChartStylePane parent, boolean inCondition) { + this.inCondition = inCondition; this.parent = parent; this.plot = plot; initLabelDetailPane(plot); } + public boolean isInCondition() { + return inCondition; + } + public BasicBeanPane getDataLabelContentPane() { return dataLabelContentPane; } @@ -77,11 +83,11 @@ public class VanChartPlotLabelDetailPane extends BasicPane { return parent; } - protected void initLabelDetailPane (Plot plot) { + protected void initLabelDetailPane(Plot plot) { this.setLayout(new BorderLayout()); initToolTipContentPane(plot); JPanel contentPane = createLabelPane(plot); - this.add(contentPane,BorderLayout.CENTER); + this.add(contentPane, BorderLayout.CENTER); } public Plot getPlot() { @@ -94,7 +100,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { //默认从factory中取 protected void initToolTipContentPane(Plot plot) { - dataLabelContentPane = PlotFactory.createPlotLabelContentPane(plot, parent, VanChartPlotLabelDetailPane.this); + dataLabelContentPane = PlotFactory.createPlotLabelContentPane(plot, parent, VanChartPlotLabelDetailPane.this, inCondition); } private JPanel createLabelPane(Plot plot) { @@ -109,12 +115,12 @@ public class VanChartPlotLabelDetailPane extends BasicPane { } protected Component[][] getLabelPaneComponents(Plot plot, double p, double[] columnSize) { - if(hasLabelPosition(plot)){ + if (hasLabelPosition(plot)) { // 仅饼图、柱形图、条形图、折线图、面积图含有边框和背景 if (hasBorderAndBackground(plot)) { return new Component[][]{ - new Component[]{dataLabelContentPane,null}, + new Component[]{dataLabelContentPane, null}, new Component[]{createLabelPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), plot), null}, new Component[]{createLabelBorderPane(), null}, new Component[]{createLabelBackgroundPane(), null} @@ -122,32 +128,32 @@ public class VanChartPlotLabelDetailPane extends BasicPane { } return new Component[][]{ - new Component[]{dataLabelContentPane,null}, + new Component[]{dataLabelContentPane, null}, new Component[]{createLabelPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), plot), null} }; } - return new Component[][]{ - new Component[]{dataLabelContentPane,null} + return new Component[][]{ + new Component[]{dataLabelContentPane, null} }; } private JPanel createLabelBorderPane() { - borderPane = new VanChartBorderWithShapePane(); + borderPane = new VanChartBorderWithShapePane(); borderPaneWithTitle = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane); return borderPaneWithTitle; } private JPanel createLabelBackgroundPane() { - backgroundPane = new VanChartBackgroundWithOutImagePane(){ + backgroundPane = new VanChartBackgroundWithOutImagePane() { protected Component[][] getPaneComponents() { return new Component[][]{ new Component[]{null, null}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Fill")), typeComboBox}, new Component[]{null, centerPane}, - new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Alpha")), transparent}, + new Component[]{getTransparentLabel(), transparent}, }; } }; @@ -162,7 +168,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { } protected double[] getLabelPaneRowSize(Plot plot, double p) { - return hasLabelPosition(plot) ? new double[]{p,p,p,p,p} : new double[]{p,p,p}; + return hasLabelPosition(plot) ? new double[]{p, p, p, p, p} : new double[]{p, p, p}; } protected boolean hasLabelPosition(Plot plot) { @@ -282,7 +288,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { } } - protected JPanel getLabelPositionPane (Component[][] comps, double[] row, double[] col){ + protected JPanel getLabelPositionPane(Component[][] comps, double[] row, double[] col) { return TableLayoutHelper.createTableLayoutPane(comps, row, col); } @@ -295,8 +301,8 @@ public class VanChartPlotLabelDetailPane extends BasicPane { }); } - protected ChartTextAttrPane initTextFontPane () { - return new ChartTextAttrPane(){ + protected ChartTextAttrPane initTextFontPane() { + return new ChartTextAttrPane() { protected Component[][] getComponents(JPanel buttonPane) { return new Component[][]{ new Component[]{null, null}, @@ -317,7 +323,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { } private void checkAllUse() { - if(tractionLine == null){ + if (tractionLine == null) { return; } checkPositionEnabled(); @@ -341,33 +347,33 @@ public class VanChartPlotLabelDetailPane extends BasicPane { tractionLinePane.setVisible(position.getSelectedItem() == Constants.OUTSIDE); } - protected void checkPane(){ + protected void checkPane() { checkPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Position")); } public void populate(AttrLabelDetail detail) { checkPane(); dataLabelContentPane.populateBean(detail.getContent()); - if(position != null){ + if (position != null) { position.setSelectedItem(detail.getPosition()); } - if(orientation != null){ + if (orientation != null) { orientation.setSelectedIndex(detail.isHorizontal() ? 0 : 1); } - if(tractionLine != null){ + if (tractionLine != null) { tractionLine.setSelected(detail.isShowGuidLine()); } - if(autoAdjust != null){ + if (autoAdjust != null) { autoAdjust.setSelectedIndex(detail.isAutoAdjust() ? 0 : 1); } - if(backgroundColor != null){ + if (backgroundColor != null) { backgroundColor.setSelectObject(detail.getBackgroundColor()); } - if(borderPane != null){ + if (borderPane != null) { borderPane.populate(detail.getBorder()); } - if(backgroundPane != null){ + if (backgroundPane != null) { backgroundPane.populate(detail.getBackground()); } @@ -379,30 +385,30 @@ public class VanChartPlotLabelDetailPane extends BasicPane { public void update(AttrLabelDetail detail) { detail.setContent(dataLabelContentPane.updateBean()); - if(position != null && position.getSelectedItem() != null){ + if (position != null && position.getSelectedItem() != null) { detail.setPosition(position.getSelectedItem()); - } else if(position != null){ + } else if (position != null) { position.setSelectedItem(detail.getPosition()); } detail.setAutoAdjust(autoAdjust != null && autoAdjust.getSelectedItem()); - if(orientation != null){ + if (orientation != null) { detail.setHorizontal(orientation.getSelectedIndex() == 0); } - if(tractionLine != null){ + if (tractionLine != null) { detail.setShowGuidLine(tractionLine.isSelected() && detail.getPosition() == Constants.OUTSIDE); } - if(backgroundColor != null){ + if (backgroundColor != null) { detail.setBackgroundColor(backgroundColor.getSelectObject()); } - if(borderPane != null){ + if (borderPane != null) { borderPane.update(detail.getBorder()); } - if(backgroundPane != null){ + if (backgroundPane != null) { backgroundPane.update(detail.getBackground()); } } -} +} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelNoCheckPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelNoCheckPane.java deleted file mode 100644 index beb89e5d78..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelNoCheckPane.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.fr.van.chart.designer.style.label; - -import com.fr.chart.chartattr.Plot; -import com.fr.plugin.chart.base.AttrLabel; -import com.fr.van.chart.designer.style.VanChartStylePane; - -import java.awt.BorderLayout; - -/** - * 条件属性中用到 - */ -public class VanChartPlotLabelNoCheckPane extends VanChartPlotLabelPane { - - private static final long serialVersionUID = 8124894034484334810L; - - public VanChartPlotLabelNoCheckPane(Plot plot,VanChartStylePane parent) { - super(plot, parent); - } - - protected void addComponents() { - this.setLayout(new BorderLayout()); - this.add(getLabelPane(),BorderLayout.CENTER); - } - - public void populate(AttrLabel attr) { - super.populate(attr); - getLabelShowCheckBox().setSelected(true); - getLabelPane().setVisible(true); - } -} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelPane.java index f1fa6f0f1a..71ad599fda 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelPane.java @@ -6,7 +6,6 @@ import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; - import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.AttrLabel; import com.fr.van.chart.designer.PlotFactory; @@ -29,19 +28,22 @@ public class VanChartPlotLabelPane extends BasicPane { private JPanel labelPane; + private boolean inCondition; + public VanChartPlotLabelPane(Plot plot, VanChartStylePane parent) { + this(plot, parent, false); + } + + public VanChartPlotLabelPane(Plot plot, VanChartStylePane parent, boolean inCondition) { this.parent = parent; this.plot = plot; + this.inCondition = inCondition; isLabelShow = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Use_Label")); labelPane = new JPanel(new BorderLayout(0, 4)); createLabelPane(); addComponents(); } - public UICheckBox getLabelShowCheckBox() { - return isLabelShow; - } - public VanChartPlotLabelDetailPane getLabelDetailPane() { return labelDetailPane; } @@ -67,31 +69,38 @@ public class VanChartPlotLabelPane extends BasicPane { } protected void createLabelPane() { - labelDetailPane = new VanChartPlotLabelDetailPane(this.plot, this.parent); + labelDetailPane = createPlotLabelDetailPane(); labelPane.add(labelDetailPane, BorderLayout.CENTER); } protected void addComponents() { + this.setLayout(new BorderLayout()); + this.add(getCenterPane(), BorderLayout.CENTER); + } + + private JPanel getCenterPane() { + if (inCondition) { + return labelPane; + } double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] columnSize = {f}; - double[] rowSize = {p,p}; + double[] rowSize = {p, p}; Component[][] components = new Component[][]{ new Component[]{isLabelShow}, new Component[]{labelPane} }; - - JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - this.setLayout(new BorderLayout()); - this.add(panel,BorderLayout.CENTER); - isLabelShow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { checkBoxUse(); } }); + + JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + return panel; } + @Override protected String title4PopupWindow() { return null; @@ -99,7 +108,7 @@ public class VanChartPlotLabelPane extends BasicPane { private void checkBoxUse() { labelPane.setVisible(isLabelShow.isSelected()); - if(checkEnabled4Large()) { + if (checkEnabled4Large()) { isLabelShow.setEnabled(!PlotFactory.largeDataModel(plot)); } } @@ -109,10 +118,11 @@ public class VanChartPlotLabelPane extends BasicPane { } public void populate(AttrLabel attr) { - if(attr == null) { - attr = ((VanChartPlot)this.plot).getDefaultAttrLabel(); + if (attr == null) { + attr = ((VanChartPlot) this.plot).getDefaultAttrLabel(); } - isLabelShow.setSelected(attr.isEnable()); + + isLabelShow.setSelected(inCondition ? true : attr.isEnable()); labelDetailPane.populate(attr.getAttrLabelDetail()); @@ -121,7 +131,7 @@ public class VanChartPlotLabelPane extends BasicPane { public AttrLabel update() { //刪除返回null,否則無法保存不顯示標籤的屬性 - AttrLabel attrLabel = ((VanChartPlot)this.plot).getDefaultAttrLabel(); + AttrLabel attrLabel = ((VanChartPlot) this.plot).getDefaultAttrLabel(); attrLabel.setEnable(isLabelShow.isSelected()); labelDetailPane.update(attrLabel.getAttrLabelDetail()); @@ -129,4 +139,7 @@ public class VanChartPlotLabelPane extends BasicPane { return attrLabel; } + public VanChartPlotLabelDetailPane createPlotLabelDetailPane() { + return PlotFactory.createPlotLabelDetailPane(plot, parent, inCondition); + } } \ 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..1ffb8fc2f5 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,14 +5,20 @@ 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; +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.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.mainframe.chart.gui.style.series.AbstractPlotSeriesPane; +import com.fr.design.widget.FRWidgetFactory; import com.fr.plugin.chart.VanChartAttrHelper; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; @@ -38,9 +44,11 @@ import com.fr.van.chart.pie.RadiusCardLayoutPane; import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.BorderLayout; +import java.awt.Component; /** * 图表样式-系列抽象界面 @@ -81,6 +89,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(); @@ -174,7 +190,16 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP //半径界面 protected JPanel createRadiusPane(String title) { radiusPane = initRadiusPane(); - radiusPaneWithTitle = TableLayout4VanChartHelper.createGapTableLayoutPane(title, radiusPane); + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {f, TableLayout4VanChartHelper.EDIT_AREA_WIDTH}; + double[] rowSize = {p}; + UILabel label = FRWidgetFactory.createLineWrapLabel(title); + label.setVerticalAlignment(SwingConstants.TOP); + Component[][] components = new Component[][]{ + new Component[]{label, radiusPane}, + }; + radiusPaneWithTitle = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, TableLayout4VanChartHelper.COMPONENT_INTERVAL, LayoutConstants.VGAP_LARGE); return ((VanChartPlot) plot).isInCustom() ? null : radiusPaneWithTitle; } @@ -246,6 +271,8 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP protected VanChartBorderPane createDiffBorderPane() { return new VanChartBorderPane(); + //TODO Bjorn 边框自动回退 + //return new VanChartBorderPane(true); } @@ -340,7 +367,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/drillmap/designer/other/VanChartDrillMapInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/other/VanChartDrillMapInteractivePane.java index cc912cf3fa..a5d441a750 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/other/VanChartDrillMapInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/other/VanChartDrillMapInteractivePane.java @@ -3,6 +3,7 @@ package com.fr.van.chart.drillmap.designer.other; import com.fr.chart.base.DrillMapTools; import com.fr.chart.chartattr.Chart; import com.fr.design.gui.ibutton.UIButtonGroup; +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; @@ -12,7 +13,6 @@ import com.fr.plugin.chart.vanchart.VanChart; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.background.VanChartBackgroundPaneWithOutImageAndShadow; import com.fr.van.chart.designer.other.VanChartInteractivePaneWithMapZoom; -import com.fr.design.i18n.Toolkit; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -74,6 +74,15 @@ public class VanChartDrillMapInteractivePane extends VanChartInteractivePaneWith }; } }; + + //TODO Bjorn 钻取地图钻取目录背景自动逻辑 + /*backgroundPane = new VanChartBackgroundPaneWithOutImageAndShadow(true) { + @Override + protected void initList() { + paneList.add(new ColorBackgroundQuickPane()); + } + };*/ + backgroundPane = new VanChartBackgroundPaneWithOutImageAndShadow(); selectBackgroundPane = new VanChartBackgroundPaneWithOutImageAndShadow(); catalogSuperLink = new VanChartCatalogHyperLinkPane(); 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 d7b9f9da47..a97225d55e 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 @@ -22,8 +22,8 @@ import java.awt.Component; * Created by Mitisky on 16/10/10. */ public class VanChartFunnelLabelContentPane extends VanChartLabelContentPane { - public VanChartFunnelLabelContentPane(VanChartStylePane parent, JPanel showOnPane) { - super(parent, showOnPane); + public VanChartFunnelLabelContentPane(VanChartStylePane parent, JPanel showOnPane, boolean inCondition) { + super(parent, showOnPane, inCondition); } protected double[] getRowSize(double p){ diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/other/VanChartGanttConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/other/VanChartGanttConditionPane.java index 09d7a4b817..fab646430c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/other/VanChartGanttConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/other/VanChartGanttConditionPane.java @@ -13,12 +13,13 @@ import com.fr.plugin.chart.gantt.attr.AttrGanttTooltip; import com.fr.plugin.chart.gantt.attr.AttrGanttTooltipContent; import com.fr.plugin.chart.type.ConditionKeyType; import com.fr.van.chart.designer.PlotFactory; +import com.fr.van.chart.designer.other.condition.item.VanChartLabelConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartSeriesColorConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartTooltipConditionPane; import com.fr.van.chart.designer.style.tooltip.VanChartPlotTooltipNoCheckPane; import com.fr.van.chart.designer.style.tooltip.VanChartPlotTooltipPane; -import com.fr.van.chart.gantt.designer.style.label.VanChartGanttLabelConditionPane; +import javax.swing.JPanel; import java.awt.Dimension; /** @@ -42,7 +43,7 @@ public class VanChartGanttConditionPane extends DataSeriesConditionPane { classPaneMap.put(AttrBackground.class, new VanChartSeriesColorConditionPane(this)); classPaneMap.put(AttrAlpha.class, new LabelAlphaPane(this)); if (!PlotFactory.largeDataModel(plot)) { - classPaneMap.put(AttrGanttLabel.class, new VanChartGanttLabelConditionPane(this, plot)); + classPaneMap.put(AttrGanttLabel.class, new VanChartLabelConditionPane(this, plot)); } classPaneMap.put(AttrGanttTooltip.class, new VanChartTooltipConditionPane(this, plot) { @@ -55,6 +56,11 @@ public class VanChartGanttConditionPane extends DataSeriesConditionPane { ((AttrGanttTooltipContent) attrGanttTooltip.getContent()).getDurationFormat().setEnable(true); return attrGanttTooltip; } + + @Override + protected JPanel createDisplayStrategy(Plot plot) { + return null; + } }; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/axis/GanttAxisStylePane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/axis/GanttAxisStylePane.java index 51e045edfb..8ff6786bad 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/axis/GanttAxisStylePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/axis/GanttAxisStylePane.java @@ -23,22 +23,28 @@ public class GanttAxisStylePane extends BasicBeanPane { private ColorSelectBoxWithOutTransparent colorSelectBox4button; private UINumberDragPane transparent; + public ChartTextAttrPane getTextAttrPane() { + return textAttrPane; + } + + public ColorSelectBoxWithOutTransparent getColorSelectBox4button() { + return colorSelectBox4button; + } + + public UINumberDragPane getTransparent() { + return transparent; + } + public GanttAxisStylePane() { - textAttrPane = new ChartTextAttrPane(); - colorSelectBox4button = new ColorSelectBoxWithOutTransparent(100); - transparent = new UINumberDragPane(0, 100); + initComponents(); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] row = {p,p,p}; + double[] row = {p, p, p, p}; double[] col = {f, e}; - Component[][] components = new Component[][]{ - new Component[]{textAttrPane, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")), colorSelectBox4button}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alpha")), transparent} - }; + Component[][] components = getUsedComponents(); JPanel content = TableLayoutHelper.createTableLayoutPane(components, row, col); @@ -46,6 +52,20 @@ public class GanttAxisStylePane extends BasicBeanPane { this.add(content, BorderLayout.CENTER); } + protected void initComponents() { + textAttrPane = new ChartTextAttrPane(); + colorSelectBox4button = new ColorSelectBoxWithOutTransparent(100); + transparent = new UINumberDragPane(0, 100); + } + + protected Component[][] getUsedComponents() { + return new Component[][]{ + new Component[]{textAttrPane, null}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")), colorSelectBox4button}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alpha")), transparent} + }; + } + @Override public void populateBean(GanttAxisStyleAttr contentAttr) { textAttrPane.populate(contentAttr.getTextAttr()); diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/axis/GanttAxisStylePaneWithPosition.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/axis/GanttAxisStylePaneWithPosition.java new file mode 100644 index 0000000000..102b0c2321 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/axis/GanttAxisStylePaneWithPosition.java @@ -0,0 +1,57 @@ +package com.fr.van.chart.gantt.designer.style.axis; + +import com.fr.base.BaseUtils; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.gantt.attr.GanttAxisStyleAttr; +import com.fr.plugin.chart.gantt.attr.GanttAxisStyleAttrWithPosition; +import com.fr.stable.Constants; + +import javax.swing.Icon; +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-10-27 + */ +public class GanttAxisStylePaneWithPosition extends GanttAxisStylePane { + + private UIButtonGroup alignmentPane; + + protected void initComponents() { + super.initComponents(); + Icon[] alignmentIconArray = {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[] alignment = new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT}; + alignmentPane = new UIButtonGroup<>(alignmentIconArray, alignment); + } + + protected Component[][] getUsedComponents() { + return new Component[][]{ + new Component[]{getTextAttrPane(), null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), getColorSelectBox4button()}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Alpha")), getTransparent()}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Form_BorderLayout_Constraints")), alignmentPane} + }; + } + + public void populateBean(GanttAxisStyleAttrWithPosition contentAttr) { + super.populateBean(contentAttr); + alignmentPane.setSelectedItem(contentAttr.getPosition()); + } + + public void updateBean(GanttAxisStyleAttrWithPosition contentAttr) { + super.updateBean(contentAttr); + contentAttr.setPosition(alignmentPane.getSelectedItem()); + } + + @Override + public GanttAxisStyleAttr updateBean() { + GanttAxisStyleAttrWithPosition styleAttr = new GanttAxisStyleAttrWithPosition(); + updateBean(styleAttr); + return styleAttr; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/axis/GanttProcessAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/axis/GanttProcessAxisPane.java index c642c3e130..c2461899b5 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/axis/GanttProcessAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/axis/GanttProcessAxisPane.java @@ -27,8 +27,8 @@ public class GanttProcessAxisPane extends AbstractVanChartScrollPane { private UISpinner horizontalProportion; private GanttAxisStylePane horizontalHeaderPane; - private GanttAxisStylePane verticalHeaderPane; - private GanttAxisStylePane bodyPane; + private GanttAxisStylePaneWithPosition verticalHeaderPane; + private GanttAxisStylePaneWithPosition bodyPane; @Override protected JPanel createContentPane() { @@ -54,7 +54,7 @@ public class GanttProcessAxisPane extends AbstractVanChartScrollPane { } private Component createBodyPane() { - bodyPane = new GanttAxisStylePane(); + bodyPane = new GanttAxisStylePaneWithPosition(); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content"), bodyPane); } @@ -66,7 +66,7 @@ public class GanttProcessAxisPane extends AbstractVanChartScrollPane { } private Component createVerticalHeaderPane() { - verticalHeaderPane = new GanttAxisStylePane(); + verticalHeaderPane = new GanttAxisStylePaneWithPosition(); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Vertical_Table"), verticalHeaderPane); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttLabelConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttLabelConditionPane.java deleted file mode 100644 index 86c3ba9429..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttLabelConditionPane.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.fr.van.chart.gantt.designer.style.label; - -import com.fr.chart.chartattr.Plot; -import com.fr.design.condition.ConditionAttributesPane; -import com.fr.van.chart.designer.other.condition.item.VanChartLabelConditionPane; -import com.fr.van.chart.designer.style.label.VanChartPlotLabelPane; - -public class VanChartGanttLabelConditionPane extends VanChartLabelConditionPane { - - public VanChartGanttLabelConditionPane(ConditionAttributesPane conditionAttributesPane, Plot plot) { - super(conditionAttributesPane, plot); - } - - protected VanChartPlotLabelPane createLabelPane() { - return new VanChartGanttPlotLabelNoCheckPane(getPlot(), null); - } -} 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 cfb1e63a8a..69409d34b4 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 @@ -24,8 +24,8 @@ public class VanChartGanttLabelContentPane extends VanChartLabelContentPane { private VanChartFormatComBoxWithCheckBox durationFormatPane; private VanChartFormatPaneWithCheckBox progressFormatPane; - public VanChartGanttLabelContentPane(VanChartStylePane parent, JPanel showOnPane) { - super(parent, showOnPane); + public VanChartGanttLabelContentPane(VanChartStylePane parent, JPanel showOnPane, boolean inCondition) { + super(parent, showOnPane, inCondition); } protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttPlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttPlotLabelDetailPane.java deleted file mode 100644 index e00e0afd4e..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttPlotLabelDetailPane.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.fr.van.chart.gantt.designer.style.label; - -import com.fr.chart.chartattr.Plot; -import com.fr.van.chart.designer.style.VanChartStylePane; -import com.fr.van.chart.designer.style.label.VanChartPlotLabelDetailPane; - -public class VanChartGanttPlotLabelDetailPane extends VanChartPlotLabelDetailPane { - - public VanChartGanttPlotLabelDetailPane(Plot plot, VanChartStylePane parent) { - super(plot, parent); - } - - protected void initToolTipContentPane(Plot plot) { - setDataLabelContentPane(new VanChartGanttLabelContentPane(getParentPane(), VanChartGanttPlotLabelDetailPane.this)); - } -} diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttPlotLabelNoCheckPane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttPlotLabelNoCheckPane.java deleted file mode 100644 index 4743a545d3..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttPlotLabelNoCheckPane.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.fr.van.chart.gantt.designer.style.label; - -import com.fr.chart.chartattr.Plot; -import com.fr.plugin.chart.base.AttrLabel; -import com.fr.van.chart.designer.style.VanChartStylePane; - -import java.awt.BorderLayout; - -public class VanChartGanttPlotLabelNoCheckPane extends VanChartGanttPlotLabelPane { - - public VanChartGanttPlotLabelNoCheckPane(Plot plot, VanChartStylePane parent) { - super(plot, parent); - } - - protected void addComponents() { - this.setLayout(new BorderLayout()); - this.add(getLabelPane(), BorderLayout.CENTER); - } - - public void populate(AttrLabel attr) { - super.populate(attr); - getLabelShowCheckBox().setSelected(true); - getLabelPane().setVisible(true); - } -} diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttPlotLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttPlotLabelPane.java deleted file mode 100644 index 546f772dd8..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttPlotLabelPane.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.fr.van.chart.gantt.designer.style.label; - -import com.fr.chart.chartattr.Plot; -import com.fr.van.chart.designer.style.VanChartStylePane; -import com.fr.van.chart.designer.style.label.VanChartPlotLabelPane; - -import java.awt.BorderLayout; - -public class VanChartGanttPlotLabelPane extends VanChartPlotLabelPane { - - public VanChartGanttPlotLabelPane(Plot plot, VanChartStylePane parent) { - super(plot, parent); - } - - protected void createLabelPane() { - VanChartGanttPlotLabelDetailPane labelDetailPane = new VanChartGanttPlotLabelDetailPane(getPlot(), getParentPane()); - setLabelDetailPane(labelDetailPane); - getLabelPane().add(labelDetailPane, BorderLayout.CENTER); - } -} diff --git a/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugePlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugePlotPane.java index 3d979119c3..d1a7650f51 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugePlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugePlotPane.java @@ -120,6 +120,8 @@ public class VanChartGaugePlotPane extends AbstractVanChartTypePane { cloneDetail.setInnerPaneBackgroundColor(newDetail.getInnerPaneBackgroundColor()); cloneDetail.setThermometerWidth(newDetail.getThermometerWidth()); cloneDetail.setChutePercent(newDetail.getChutePercent()); + cloneDetail.setPaneBackgroundColorAuto(newDetail.isPaneBackgroundColorAuto()); + cloneDetail.setSlotBackgroundColorAuto(newDetail.isSlotBackgroundColorAuto()); } protected void cloneOldConditionCollection(Plot oldPlot, Plot newPlot) throws CloneNotSupportedException { 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..8a48837cb3 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,8 @@ 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}; + //TODO Bjorn + double[] rowSize = {p,p,p,p,p,p,p}; Component[][] components = new Component[][]{ new Component[]{createGaugeLayoutPane()}, new Component[]{createGaugeStylePane(rowSize, new double[]{f,e})}, @@ -134,11 +141,14 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { private Component[][] getDiffComponentsWithGaugeStyle() { GaugeStyle style = plot == null ? GaugeStyle.POINTER : ((VanChartGaugePlot)plot).getGaugeStyle(); switch (style) { + //TODO Bjorn 仪表盘样式自动逻辑 case RING: 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() @@ -148,6 +158,8 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { new Component[]{null, null}, getNeedleColor(), getSlotBackgroundColor(), + /* getSlotBackgroundColorAuto(), + new Component[]{null, slotBackgroundColor},*/ new Component[]{createRadiusPane(Toolkit.i18nText("Fine-Design_Chart_Radius_Set")), null}, getChutePercent() }; @@ -156,6 +168,8 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { new Component[]{null, null}, getNeedleColor(), getSlotBackgroundColor(), + /*getSlotBackgroundColorAuto(), + new Component[]{null, slotBackgroundColor},*/ new Component[]{createRadiusPane(Toolkit.i18nText("Fine-Design_Chart_Length_Set")), null}, getThermometerWidth() }; @@ -163,9 +177,13 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { 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} }; } @@ -173,7 +191,21 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { private Component[] getHingeColor() { hingeColor = new ColorSelectBox(120); - return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Hinge")),hingeColor}; + return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Hinge")), hingeColor}; + } + + private Component[] getHingeColorAuto() { + hingeColor = new ColorSelectBox(120); + 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 +218,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 +280,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 +305,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 +361,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..00a847e2ec 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,8 +244,25 @@ 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() { + //TODO Bjorn 地图背景自动 + //borderWithAlphaPane = new VanChartBorderWithAlphaPane(true); borderWithAlphaPane = new VanChartBorderWithAlphaPane(); double p = TableLayout.PREFERRED; @@ -253,9 +279,43 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { } protected JPanel createNullValueColorPane() { + //TODO Bjorn 地图空值背景自动 + /* nullValueAuto = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Auto"), + Toolkit.i18nText("Fine-Design_Chart_Custom")}); + initNullValueListener(); + nullValueColorBox = new ColorSelectBox(80); + + 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);*/ + nullValueColorBox = new ColorSelectBox(80); + return TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_NULL_Value_Color"), nullValueColorBox); + } + + + private void initNullValueListener() { + nullValueAuto.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkNullValueButton(); + } + }); + } - return TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_NULL_Value_Color"), nullValueColorBox); + 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,6 +505,14 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { markerTypeCom.setSelectedItem(((VanChartMapPlot) plot).getMapMarkerType().toLocalString()); } if (nullValueColorBox != null) { + //TODO Bjorn 地图空值背景自动 + /* if (((VanChartMapPlot) plot).isAutoNullValue()) { + nullValueAuto.setSelectedIndex(0); + } else { + nullValueAuto.setSelectedIndex(1); + } + nullValueColorBox.setSelectObject(((VanChartMapPlot) plot).getNullValueColor()); + checkNullValueButton();*/ nullValueColorBox.setSelectObject(((VanChartMapPlot) plot).getNullValueColor()); } //大数据模式 恢复用注释。下面3行删除。 @@ -461,6 +529,8 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { ((VanChartMapPlot) plot).setMapMarkerType(MapMarkerType.parseInt(markerTypeCom.getSelectedIndex())); } if (nullValueColorBox != null) { + //TODO Bjorn 地图空值背景自动 + //((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/data/contentpane/table/VanMapTableDataContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanMapTableDataContentPane.java index 09d72a72e6..0006f5e22c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanMapTableDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanMapTableDataContentPane.java @@ -71,7 +71,7 @@ public abstract class VanMapTableDataContentPane extends AbstractTableDataConten @Override public void actionPerformed(ActionEvent e) { if (treeNodeAndItems == null) { - treeNodeAndItems = ChartGEOJSONHelper.getTreeNodeAndItems(plot.getGeoUrl(), level, plot.getMapType()); + treeNodeAndItems = ChartGEOJSONHelper.getTreeNodeAndItems(plot.getGeoUrl(), level, plot.getMapType(), true); } final MapAreaMatchPane pane = new MapAreaMatchPane(treeNodeAndItems); diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/VanChartMapStylePane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/VanChartMapStylePane.java index 68ec083e46..2083d9f120 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/VanChartMapStylePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/VanChartMapStylePane.java @@ -7,6 +7,8 @@ import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.map.VanChartMapPlot; import com.fr.plugin.chart.type.MapType; import com.fr.van.chart.designer.style.VanChartStylePane; +import com.fr.van.chart.designer.style.VanChartTitlePane; +import com.fr.van.chart.designer.style.VanChartTitleWithAutoBackground; import com.fr.van.chart.map.designer.style.label.VanChartMapLabelPane; import com.fr.van.chart.map.designer.style.tooltip.VanChartMapTooltipPane; @@ -20,6 +22,11 @@ public class VanChartMapStylePane extends VanChartStylePane { super(listener); } + + protected VanChartTitlePane createVanChartTitlePane() { + return new VanChartTitleWithAutoBackground(VanChartMapStylePane.this); + } + protected void createVanChartLabelPane(List paneList) { Plot plot = getChart().getPlot(); if(!isLineMapPlot(plot)) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java index 95e2864584..084953c996 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java @@ -21,8 +21,8 @@ import javax.swing.JPanel; * Created by Mitisky on 16/5/20. */ public class VanChartMapLabelContentPane extends VanChartLabelContentPane { - public VanChartMapLabelContentPane(VanChartStylePane parent, JPanel showOnPane) { - super(parent, showOnPane); + public VanChartMapLabelContentPane(VanChartStylePane parent, JPanel showOnPane, boolean inCondition) { + super(parent, showOnPane, inCondition); } @Override 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..bbe9d7dd44 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 @@ -645,6 +645,9 @@ public class VanChartMapSourceChoosePane extends JPanel implements UIObserver { } private void resetGisLayer(VanChartMapPlot mapPlot) { + //TODO Bjorn 地图gis图层自动逻辑 + /* mapPlot.getGisLayer().setGisLayerType(GISLayerType.AUTO); + mapPlot.getGisLayer().setLayerName(GISLayerType.getLocString(GISLayerType.AUTO));*/ String layerName = mapPlot.getDefaultGisLayerName(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieLabelContentPane.java index 09093b0993..73e766afc0 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieLabelContentPane.java @@ -16,8 +16,8 @@ import javax.swing.JPanel; * Created by Fangjie on 2016/6/15. */ public class VanChartMultiPieLabelContentPane extends VanChartLabelContentPane { - public VanChartMultiPieLabelContentPane(VanChartStylePane parent, JPanel showOnPane) { - super(parent, showOnPane); + public VanChartMultiPieLabelContentPane(VanChartStylePane parent, JPanel showOnPane, boolean inCondition) { + super(parent, showOnPane, inCondition); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterConditionPane.java index c1e7886c9c..4bd463c807 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterConditionPane.java @@ -17,11 +17,11 @@ import com.fr.plugin.chart.scatter.attr.ScatterAttrTooltip; import com.fr.van.chart.bubble.VanChartBubbleConditionSelectionPane; import com.fr.van.chart.designer.PlotFactory; import com.fr.van.chart.designer.other.condition.item.VanChartEffectConditionPane; +import com.fr.van.chart.designer.other.condition.item.VanChartLabelConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartSeriesColorConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartTrendLineConditionPane; import com.fr.van.chart.scatter.component.VanChartScatterLineTypeConditionPane; import com.fr.van.chart.scatter.component.VanChartScatterMarkerConditionPane; -import com.fr.van.chart.scatter.component.label.VanChartScatterLabelConditionPane; import com.fr.van.chart.scatter.component.tooltip.VanChartScatterTooltipConditionPane; import com.fr.van.chart.scatter.large.VanChartScatterLargeModelMarkerConditionPane; @@ -57,7 +57,7 @@ public class VanChartScatterConditionPane extends DataSeriesConditionPane { } else { classPaneMap.put(VanChartAttrLine.class, new VanChartScatterLineTypeConditionPane(this)); classPaneMap.put(VanChartAttrMarker.class, new VanChartScatterMarkerConditionPane(this)); - classPaneMap.put(ScatterAttrLabel.class, new VanChartScatterLabelConditionPane(this, plot)); + classPaneMap.put(ScatterAttrLabel.class, new VanChartLabelConditionPane(this, plot)); classPaneMap.put(AttrEffect.class, new VanChartEffectConditionPane(this, EffectHelper.getScatterPlotDefaultEffect())); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterLabelContentPane.java index 160cfb25ee..9c79f9b8cd 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterLabelContentPane.java @@ -12,8 +12,8 @@ import javax.swing.JPanel; public class VanChartScatterLabelContentPane extends VanChartScatterTooltipContentPane{ private static final long serialVersionUID = 5595016643808487922L; - public VanChartScatterLabelContentPane(VanChartStylePane parent, JPanel showOnPane) { - super(parent, showOnPane); + public VanChartScatterLabelContentPane(VanChartStylePane parent, JPanel showOnPane, boolean inCondition) { + super(parent, showOnPane, inCondition); } @Override @@ -21,4 +21,29 @@ public class VanChartScatterLabelContentPane extends VanChartScatterTooltipCont return new VanChartHtmlLabelPaneWithBackGroundLabel(); } + //TODO Bjorn 散点图标签预定义样式 + /* public JPanel createCommonStylePane() { + if (isInCondition()) { + return super.createCommonStylePane(); + } + setTextAttrPane(new ChartTextAttrPaneWithPreStyle()); + + JPanel stylePanel = new JPanel(new BorderLayout()); + stylePanel.add(getTextAttrPane(), BorderLayout.CENTER); + + return stylePanel; + } + + public void updateTextAttr(AttrTooltipContent attrTooltipContent) { + if (isInCondition()) { + super.updateTextAttr(attrTooltipContent); + return; + } + if (hasTextStylePane()) { + this.getTextAttrPane().update(attrTooltipContent.getTextAttr()); + if (!attrTooltipContent.getTextAttr().isPredefinedStyle()) { + attrTooltipContent.setCustom(true); + } + } + }*/ } 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 0933ce8a5c..39b20bedbd 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 @@ -58,6 +58,10 @@ public class VanChartScatterTooltipContentPane extends VanChartTooltipContentPa super(parent, showOnPane); } + public VanChartScatterTooltipContentPane(VanChartStylePane parent, JPanel showOnPane, boolean inCondition){ + super(parent, showOnPane, inCondition); + } + @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane){ diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterLabelConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterLabelConditionPane.java deleted file mode 100644 index 2ff71ee0cb..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterLabelConditionPane.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.fr.van.chart.scatter.component.label; - -import com.fr.chart.chartattr.Plot; -import com.fr.design.condition.ConditionAttributesPane; -import com.fr.van.chart.designer.other.condition.item.VanChartLabelConditionPane; -import com.fr.van.chart.designer.style.label.VanChartPlotLabelPane; - -public class VanChartScatterLabelConditionPane extends VanChartLabelConditionPane { - - public VanChartScatterLabelConditionPane(ConditionAttributesPane conditionAttributesPane, Plot plot) { - super(conditionAttributesPane, plot); - } - - @Override - protected VanChartPlotLabelPane createLabelPane() { - return new VanChartScatterPlotLabelNoCheckPane(getPlot(), null); - } -} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelDetailPane.java deleted file mode 100644 index a78261f655..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelDetailPane.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.fr.van.chart.scatter.component.label; - -import com.fr.chart.chartattr.Plot; -import com.fr.van.chart.designer.style.VanChartStylePane; -import com.fr.van.chart.designer.style.label.VanChartPlotLabelDetailPane; -import com.fr.van.chart.scatter.VanChartScatterLabelContentPane; - - - -/** - * 散点图的分类,多x、y标签 - */ -public class VanChartScatterPlotLabelDetailPane extends VanChartPlotLabelDetailPane { - - private static final long serialVersionUID = 5176535960949074940L; - public VanChartScatterPlotLabelDetailPane(Plot plot, VanChartStylePane parent) { - super(plot, parent); - } - - @Override - protected void initToolTipContentPane(Plot plot) { - setDataLabelContentPane(new VanChartScatterLabelContentPane(getParentPane(),VanChartScatterPlotLabelDetailPane.this)); - } -} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelNoCheckPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelNoCheckPane.java deleted file mode 100644 index a409180732..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelNoCheckPane.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.fr.van.chart.scatter.component.label; - -import com.fr.chart.chartattr.Plot; -import com.fr.plugin.chart.base.AttrLabel; -import com.fr.van.chart.designer.style.VanChartStylePane; - -import java.awt.BorderLayout; - -/** - * 条件属性中用到 - */ -public class VanChartScatterPlotLabelNoCheckPane extends VanChartScatterPlotLabelPane { - - private static final long serialVersionUID = 8124894034484334810L; - - public VanChartScatterPlotLabelNoCheckPane(Plot plot, VanChartStylePane parent) { - super(plot, parent); - } - - protected void addComponents() { - this.setLayout(new BorderLayout()); - this.add(getLabelPane(), BorderLayout.CENTER); - } - - public void populate(AttrLabel attr) { - super.populate(attr); - getLabelShowCheckBox().setSelected(true); - getLabelPane().setVisible(true); - } -} \ No newline at end of file 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 deleted file mode 100644 index fb8be90163..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelPane.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.fr.van.chart.scatter.component.label; - -import com.fr.chart.chartattr.Plot; -import com.fr.van.chart.designer.style.VanChartStylePane; -import com.fr.van.chart.designer.style.label.VanChartPlotLabelPane; - -import java.awt.BorderLayout; - -/** - * Created by Mitisky on 16/3/1. - */ -public class VanChartScatterPlotLabelPane extends VanChartPlotLabelPane { - private static final long serialVersionUID = 7405875523954797047L; - - public VanChartScatterPlotLabelPane(Plot plot, VanChartStylePane parent) { - super(plot, parent); - } - - @Override - protected void createLabelPane() { - VanChartScatterPlotLabelDetailPane labelDetailPane = new VanChartScatterPlotLabelDetailPane(getPlot(), getParentPane()); - setLabelDetailPane(labelDetailPane); - getLabelPane().add(labelDetailPane, BorderLayout.CENTER); - } -} diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/other/VanChartStructureConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/other/VanChartStructureConditionPane.java index 9a8cf4e453..7fac3034b7 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/other/VanChartStructureConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/other/VanChartStructureConditionPane.java @@ -11,10 +11,10 @@ import com.fr.plugin.chart.base.AttrTooltip; import com.fr.plugin.chart.structure.VanChartStructurePlot; import com.fr.plugin.chart.type.ConditionKeyType; import com.fr.van.chart.designer.other.condition.item.VanChartFloatColorConditionPane; +import com.fr.van.chart.designer.other.condition.item.VanChartLabelConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartSeriesColorConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartStructureNodeConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartTooltipConditionPane; -import com.fr.van.chart.structure.desinger.style.VanChartStructureLabelConditionPane; import java.awt.Dimension; @@ -47,7 +47,7 @@ public class VanChartStructureConditionPane extends DataSeriesConditionPane { protected void addBasicAction() { classPaneMap.put(AttrBackground.class, new VanChartSeriesColorConditionPane(this)); classPaneMap.put(AttrTooltip.class, new VanChartTooltipConditionPane(this, plot)); - classPaneMap.put(AttrLabel.class, new VanChartStructureLabelConditionPane(this, plot)); + classPaneMap.put(AttrLabel.class, new VanChartLabelConditionPane(this, plot)); classPaneMap.put(AttrFloatColor.class, new VanChartFloatColorConditionPane(this)); classPaneMap.put(AttrNode.class, new VanChartStructureNodeConditionPane(this)); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureLabelConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureLabelConditionPane.java deleted file mode 100644 index c5c9cf3203..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureLabelConditionPane.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.fr.van.chart.structure.desinger.style; - -import com.fr.chart.chartattr.Plot; -import com.fr.design.condition.ConditionAttributesPane; -import com.fr.van.chart.designer.other.condition.item.VanChartLabelConditionPane; -import com.fr.van.chart.designer.style.label.VanChartPlotLabelPane; - -public class VanChartStructureLabelConditionPane extends VanChartLabelConditionPane { - - public VanChartStructureLabelConditionPane(ConditionAttributesPane conditionAttributesPane, Plot plot) { - super(conditionAttributesPane, plot); - } - - protected VanChartPlotLabelPane createLabelPane() { - return new VanChartStructurePlotLabelNoCheckPane(getPlot(), null); - } -} 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 4e20364653..beeb7efe97 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 @@ -19,8 +19,8 @@ import java.awt.Component; * Created by shine on 2017/2/15. */ public class VanChartStructureLabelContentPane extends VanChartLabelContentPane { - public VanChartStructureLabelContentPane(VanChartStylePane parent, JPanel showOnPane) { - super(parent, showOnPane); + public VanChartStructureLabelContentPane(VanChartStylePane parent, JPanel showOnPane, boolean inCondition) { + super(parent, showOnPane, inCondition); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructurePlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructurePlotLabelDetailPane.java deleted file mode 100644 index 20e784c525..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructurePlotLabelDetailPane.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.fr.van.chart.structure.desinger.style; - -import com.fr.chart.chartattr.Plot; -import com.fr.van.chart.designer.style.VanChartStylePane; -import com.fr.van.chart.designer.style.label.VanChartPlotLabelDetailPane; - -public class VanChartStructurePlotLabelDetailPane extends VanChartPlotLabelDetailPane { - - public VanChartStructurePlotLabelDetailPane(Plot plot, VanChartStylePane parent) { - super(plot, parent); - } - - protected void initToolTipContentPane(Plot plot) { - setDataLabelContentPane(new VanChartStructureLabelContentPane(getParentPane(), VanChartStructurePlotLabelDetailPane.this)); - } -} diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructurePlotLabelNoCheckPane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructurePlotLabelNoCheckPane.java deleted file mode 100644 index e7dfb18734..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructurePlotLabelNoCheckPane.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.fr.van.chart.structure.desinger.style; - -import com.fr.chart.chartattr.Plot; -import com.fr.plugin.chart.base.AttrLabel; -import com.fr.van.chart.designer.style.VanChartStylePane; - -import java.awt.BorderLayout; - -public class VanChartStructurePlotLabelNoCheckPane extends VanChartStructurePlotLabelPane { - - public VanChartStructurePlotLabelNoCheckPane(Plot plot, VanChartStylePane parent) { - super(plot, parent); - } - - protected void addComponents() { - this.setLayout(new BorderLayout()); - this.add(getLabelPane(), BorderLayout.CENTER); - } - - public void populate(AttrLabel attr) { - super.populate(attr); - getLabelShowCheckBox().setSelected(true); - getLabelPane().setVisible(true); - } -} diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructurePlotLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructurePlotLabelPane.java deleted file mode 100644 index e4cdc99e19..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructurePlotLabelPane.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.fr.van.chart.structure.desinger.style; - -import com.fr.chart.chartattr.Plot; -import com.fr.van.chart.designer.style.VanChartStylePane; -import com.fr.van.chart.designer.style.label.VanChartPlotLabelPane; - -import java.awt.BorderLayout; - -public class VanChartStructurePlotLabelPane extends VanChartPlotLabelPane { - - public VanChartStructurePlotLabelPane(Plot plot, VanChartStylePane parent) { - super(plot, parent); - } - - protected void createLabelPane() { - VanChartStructurePlotLabelDetailPane labelDetailPane = new VanChartStructurePlotLabelDetailPane(getPlot(), getParentPane()); - setLabelDetailPane(labelDetailPane); - getLabelPane().add(labelDetailPane, BorderLayout.CENTER); - } -} diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java index 24c3a19dbc..c0eb392979 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java @@ -19,7 +19,12 @@ import com.fr.design.designer.creator.cardlayout.XWCardTitleLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.properties.FRFitLayoutConstraints; import com.fr.design.designer.properties.FRFitLayoutPropertiesGroupModel; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.fun.FormWidgetOptionProvider; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.JForm; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.utils.ComponentUtils; import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.container.WAbsoluteLayout; @@ -342,7 +347,15 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { //拖拽组件原大小、位置 Rectangle backupBound = creator.getBackupBound(); backupBound.x -= container.getX(); - backupBound.y -= container.getY(); + // REPORT-34739 对绝对画布块的backupBound.y的调整还需要考虑一下参数面板块的高度造成的偏移 + int paraHeight = 0; + if (creator.acceptType(XWAbsoluteLayout.class)) { + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jTemplate instanceof JForm) { + paraHeight = ((JForm) jTemplate).getFormDesign().getParaHeight(); + } + } + backupBound.y -= (container.getY() - paraHeight); //当前拖拽组件的位置 int x = creator.getX(); int y = creator.getY(); diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/StateModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/StateModel.java index c5150baa56..5045e13875 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/StateModel.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/StateModel.java @@ -301,12 +301,14 @@ public class StateModel { Rectangle bounds = createCurrentBounds(x, y); // 有参数面板时 要考虑下参数面板的高度影响 - int yOffset = 0; - XLayoutContainer paramComponent = designer.getParaComponent(); - if (paramComponent != null) { - yOffset = paramComponent.getHeight(); + if (!designer.isFormParaDesigner()) { + int yOffset = 0; + XLayoutContainer paramComponent = designer.getParaComponent(); + if (paramComponent != null) { + yOffset = paramComponent.getHeight(); + } + bounds.y = Math.max(bounds.y - yOffset, 0); } - bounds.y = Math.max(bounds.y - yOffset, 0); if ((x != currentX) || (y != currentY)) { ArrayList creators = getHotspotCreators(bounds, designer.getRootComponent()); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/CRPropertyDescriptorPane.java b/designer-form/src/main/java/com/fr/design/designer/creator/CRPropertyDescriptorPane.java index be4a81d4ec..ca7933e03a 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/CRPropertyDescriptorPane.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/CRPropertyDescriptorPane.java @@ -6,15 +6,18 @@ import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.xtable.TableUtils; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.widget.editors.ExtendedPropertyEditor; import com.fr.design.mainframe.widget.editors.StringEditor; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; import javax.swing.BorderFactory; +import javax.swing.JOptionPane; import javax.swing.JPanel; import java.awt.Component; import java.beans.PropertyChangeEvent; @@ -136,12 +139,37 @@ public class CRPropertyDescriptorPane { try { Object value = propertyEditor.getValue(); Method m = crPropertyDescriptor.getWriteMethod(); + if (ComparatorUtils.equals(m.getName(), "setWidgetName")) { + if (!isWidgetNameValid(value, widget)) { + value = widget.getWidgetName(); + } + } m.invoke(widget, value); - crPropertyDescriptor.firePropertyChanged(); } catch (Exception e) { } } + /** + * 设置控件名之前校验一下,不能为空,不能重名 + */ + private boolean isWidgetNameValid(Object value, Widget widget) { + String toSetWidgetName; + if (value != null) { + toSetWidgetName = value.toString(); + } else { + return false; + } + String currentWidgetName = widget.getWidgetName(); + boolean exist = designer.getTarget().isNameExist(toSetWidgetName) && !ComparatorUtils.equals(toSetWidgetName, currentWidgetName); + if (toSetWidgetName.isEmpty()) { + return false; + } else if (exist) { + //控件重名,弹出提示 + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Rename_Failure"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Joption_News"), JOptionPane.ERROR_MESSAGE, IOUtils.readIcon("com/fr/design/form/images/joption_failure.png")); + return false; + } + return true; + } } 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..c7c91d9aaf 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,11 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo return false; } - /** - * 是否支持置顶显示 - */ + public boolean isTopable() { return true; } + + } 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..14e0a65113 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 @@ -18,7 +18,6 @@ import com.fr.form.FormElementCaseProvider; import com.fr.form.FormProvider; import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.ElementCaseEditorProvider; - import com.fr.report.fit.ReportFitAttr; import com.fr.stable.ArrayUtils; import com.fr.stable.CoreGraphHelper; @@ -372,4 +371,6 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme return true; } + + } 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..a43ed01251 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 @@ -8,7 +8,6 @@ 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.container.WAbsoluteBodyLayout; - import com.fr.stable.core.PropertyChangeAdapter; import java.awt.Component; @@ -135,4 +134,5 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout { public boolean isTopable() { return false; } + } 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..6d55c658f2 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 @@ -23,7 +23,6 @@ import com.fr.general.FRLogger; import com.fr.general.FRScreen; import com.fr.stable.ArrayUtils; import com.fr.stable.AssistUtils; - import javax.swing.JOptionPane; import java.awt.Component; import java.awt.Dimension; @@ -1342,4 +1341,5 @@ public class XWFitLayout extends XLayoutContainer { } } } + } 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..d72a8f4fe3 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 @@ -8,15 +8,11 @@ import com.fr.design.designer.creator.CRPropertyDescriptor; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWFitLayout; -import com.fr.design.designer.properties.mobile.MobileBooKMarkUsePropertyUI; -import com.fr.design.designer.properties.mobile.MobileBookMarkPropertyUI; -import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormHierarchyTreePane; -import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.widget.editors.ButtonTypeEditor; import com.fr.design.mainframe.widget.editors.ImgBackgroundEditor; import com.fr.design.utils.gui.LayoutUtils; 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..c862ac76d7 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/FormPredefinedBackgroundPane.java @@ -0,0 +1,110 @@ +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.NameComponentBackground; +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(NameComponentBackground ob) { + this.setPopulating(true); + super.populate(ob); + this.backgroundPane.populateBean(ob.createRealStyle()); + this.previewPane.refresh(); + this.setPopulating(false); + } + + + @Override + public NameComponentBackground updateBean() { + if (this.predefinedRadioBtn.isSelected()) { + return NameFormBackground.createPredefinedStyle(getPredefinedStyleName()); + } else { + return NameFormBackground.createCustomStyle(this.backgroundPane.updateBean()); + } + } + + private BackgroundWithAlpha getCurrentValue() { + if (this.predefinedRadioBtn.isSelected()) { + return updatePredefinedStyle(); + } else { + return this.backgroundPane.updateBean(); + } + } + + private BackgroundWithAlpha updatePredefinedStyle(){ + NameComponentBackground componentBackground = NameFormBackground.createPredefinedStyle(getPredefinedStyleName()); + return componentBackground.createRealStyle(); + } + + protected void populateCustomPane(){ + this.backgroundPane.populateBean(updatePredefinedStyle()); + } + + @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..6e245b019c --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/PredefinedComponentStyleSettingPane.java @@ -0,0 +1,152 @@ +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.ComponentTitleStylePane; +import com.fr.design.mainframe.predefined.ui.preview.StyleSettingPreviewPane; +import com.fr.form.ui.LayoutBorderStyle; +import com.fr.form.ui.NameLayoutBorderStyle; +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(NameLayoutBorderStyle ob) { + this.setPopulating(true); + super.populate(ob); + this.formulaPane.populateBean(ob.getTitleText().toString()); + styleSettingPane.populateBean(ob); + this.previewPane.refresh(); + this.setPopulating(false); + } + + + @Override + public NameLayoutBorderStyle updateBean() { + if (predefinedRadioBtn.isSelected()) { + return updatePredefinedStyle(); + } + return styleSettingPane.updateBean(); + } + + private NameLayoutBorderStyle updatePredefinedStyle() { + NameLayoutBorderStyle layoutBorderStyle = NameLayoutBorderStyle.createPredefinedStyle(getPredefinedStyleName()); + layoutBorderStyle.setTitleText(formulaPane.updateBean()); + return layoutBorderStyle; + } + + protected void populateCustomPane() { + this.styleSettingPane.populateBean(updatePredefinedStyle()); + } + + @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; + + 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, 225)); + 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, 220)); + title.add(titleStylePane); + + this.add(frame, BorderLayout.NORTH); + this.add(title, BorderLayout.CENTER); + } + + @Override + public void populateBean(NameLayoutBorderStyle ob) { + PredefinedComponentStyle componentStyle = new PredefinedComponentStyle(); + componentStyle.setBorderStyle(ob.createRealStyle()); + frameStylePane.populate(componentStyle); + titleStylePane.populate(componentStyle); + } + + @Override + public NameLayoutBorderStyle updateBean() { + PredefinedComponentStyle componentStyle = update(); + NameLayoutBorderStyle nameLayoutBorderStyle = NameLayoutBorderStyle.createCustomStyle(componentStyle.getBorderStyle()); + return nameLayoutBorderStyle; + } + + public PredefinedComponentStyle update() { + PredefinedComponentStyle componentStyle = new PredefinedComponentStyle(); + frameStylePane.update(componentStyle); + titleStylePane.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() { + NameLayoutBorderStyle componentStyle = PredefinedComponentStyleSettingPane.this.updateBean(); + this.layoutBorderPreviewPane.repaint((LayoutBorderStyle) componentStyle.createRealStyle()); + } + + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java index ee667fd38c..c9ae03272f 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java @@ -2,15 +2,13 @@ package com.fr.design.mainframe; import com.fr.design.constants.UIConstants; import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XLayoutContainer; -import com.fr.design.designer.creator.XWAbsoluteBodyLayout; -import com.fr.design.designer.creator.XWFitLayout; -import com.fr.design.designer.creator.cardlayout.XCardSwitchButton; import com.fr.design.designer.treeview.ComponentTreeCellRenderer; import com.fr.design.designer.treeview.ComponentTreeModel; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.itree.UITreeUI; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import javax.swing.BorderFactory; @@ -19,9 +17,7 @@ import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JTree; import javax.swing.SwingUtilities; -import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreeCellRenderer; -import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; import java.awt.BorderLayout; @@ -37,8 +33,9 @@ import java.awt.image.BufferedImage; import java.io.IOException; import java.util.ArrayList; import java.util.Enumeration; +import java.util.HashMap; import java.util.List; -import java.util.Vector; +import java.util.Map; public class ComponentTree extends JTree { @@ -46,6 +43,8 @@ public class ComponentTree extends JTree { private ComponentTreeModel model; private UITreeUI uiTreeUI = new UITreeUI(); private PopupPreviewPane previewPane; + + private static final Map> treePathCache = new HashMap<>(); private static final int PADDING_LEFT = 5; private static final int PADDING_TOP = 5; @@ -85,6 +84,7 @@ public class ComponentTree extends JTree { public ComponentTree(FormDesigner designer, ComponentTreeModel model) { this(designer); this.setModel(model); + expandTree(); } public void setSelectionPath(TreePath path) { @@ -138,7 +138,6 @@ public class ComponentTree extends JTree { setSelectionPaths(treepath); if (treepath.length > 0) { scrollPathToVisible(treepath[0]); - //expandPath(treepath[0]); } } @@ -193,6 +192,20 @@ public class ComponentTree extends JTree { return paths; } + @Override + protected void setExpandedState(TreePath path, boolean state) { + super.setExpandedState(path, state); + saveTreePath(); + } + + /** + * 删除key对应的缓存展开路径 + */ + public void removeTreePath(String key) { + if (StringUtils.isNotEmpty(key)) { + treePathCache.remove(key); + } + } private void setSelectionPath() { @@ -232,6 +245,7 @@ public class ComponentTree extends JTree { public void refreshTreeRoot() { model = new ComponentTreeModel(designer, designer.getTopContainer()); setModel(model); + expandTree(); setDragEnabled(false); setDropMode(DropMode.ON_OR_INSERT); setTransferHandler(new TreeTransferHandler()); @@ -239,49 +253,55 @@ public class ComponentTree extends JTree { } /** - * 获得树的展开路径 - * */ - public void getExpandNodes(List searchList) { - getExpandNodes((XLayoutContainer)designer.getTopContainer(),searchList); + * 从缓存中获取展开路径并进行展开 + */ + public void expandTree() { + expandTree(loadTreePath()); } - public void getExpandNodes(XLayoutContainer container, List searchList) { - TreePath treePath = buildTreePath(container); - if (isExpanded(treePath)) { - searchList.add(treePath); - for (int i = 0, size = container.getXCreatorCount(); i < size; i++) { - XCreator creator = container.getXCreator(i); - if (creator.acceptType(XLayoutContainer.class) || creator.acceptType(XCardSwitchButton.class)) { - getExpandNodes((XLayoutContainer) creator.getXCreator(), searchList); - } - } + /** + * 按照传入参数展开组件树 + */ + private void expandTree(List list) { + if (list == null) { + return; } - //对绝对布局做特殊处理 - if (container.acceptType(XWFitLayout.class)) { - XWFitLayout bodyFitLayout = (XWFitLayout) container; - for (int j = 0; j < bodyFitLayout.getXCreatorCount(); j++) { - //类型是绝对布局并且还是body - if (bodyFitLayout.getXCreator(j).acceptType(XWAbsoluteBodyLayout.class)) { - container = (XLayoutContainer) bodyFitLayout.getXCreator(j); - getExpandNodes(container, searchList); - } - } + for (TreePath treePath : list) { + expandPath(treePath); } } /** - * 将树按照展开路径进行展开 - * */ - public void expandNodes(List list){ - for(TreePath treePath:list) { - if (treePath.getLastPathComponent() instanceof XLayoutContainer) { - XLayoutContainer creator= (XLayoutContainer) treePath.getLastPathComponent(); - if (XCreatorUtils.getParentXLayoutContainer(creator) == null) { - continue; - } - expandPath(treePath); + * 获得树的展开路径 + */ + private List getExpandTreePaths() { + List result = new ArrayList<>(); + TreePath rootTreePath = buildTreePath(designer.getTopContainer()); + Enumeration enumeration = getExpandedDescendants(rootTreePath); + if (enumeration != null) { + while (enumeration.hasMoreElements()) { + result.add(enumeration.nextElement()); } } + return result; + } + + private void saveTreePath() { + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jt instanceof JForm && jt.getTarget() == designer.getTarget()) { + String key = jt.getEditingFILE().getPath() + "-" + designer.getTarget().getTemplateID(); + treePathCache.put(key, getExpandTreePaths()); + } + } + + private List loadTreePath() { + List result = null; + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jt instanceof JForm) { + String key = jt.getEditingFILE().getPath() + "-" + designer.getTarget().getTemplateID(); + result = treePathCache.get(key); + } + return result == null ? new ArrayList<>() : result; } private TreePath buildTreePath(Component comp) { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormHierarchyTreePane.java b/designer-form/src/main/java/com/fr/design/mainframe/FormHierarchyTreePane.java index f94475a768..fdb8881c70 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormHierarchyTreePane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormHierarchyTreePane.java @@ -4,7 +4,6 @@ import com.fr.base.BaseUtils; import com.fr.design.actions.UndoableAction; import com.fr.design.constants.UIConstants; import com.fr.design.designer.beans.events.DesignerEditListener; -import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XWAbsoluteBodyLayout; import com.fr.design.designer.creator.XWParameterLayout; @@ -24,14 +23,12 @@ import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.SwingUtilities; -import javax.swing.tree.TreePath; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.util.ArrayList; -import java.util.List; /** @@ -48,6 +45,10 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree private ShortCut4JControlPane[] shorts; private ComponentTree componentTree; + private final DesignerEditListener designerEditListener = evt -> { + refreshComponentTree(); + }; + public static FormHierarchyTreePane getInstance() { return HOLDER.singleton; } @@ -94,10 +95,8 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree //TODO 太乱了,需要重写,监听器里加了监听器是什么意思,每次调用该方法都会添加一个新的监听器 public void refreshDockingView() { FormDesigner formDesigner = this.getEditingFormDesigner(); - List list = new ArrayList<>(); removeAll(); if (this.componentTree != null) { - componentTree.getExpandNodes(list); this.componentTree.removeAll(); } if (formDesigner == null) { @@ -106,13 +105,7 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree } componentTree = new ComponentTree(formDesigner); //保证删除组件后组件树不收起 - componentTree.expandNodes(list); - formDesigner.addDesignerEditListener(new DesignerEditListener() { - @Override - public void fireCreatorModified(DesignerEvent evt) { - refreshComponentTree(); - } - }); + formDesigner.addDesignerEditListener(designerEditListener); ComponentTreeModel treeModel = (ComponentTreeModel) componentTree.getModel(); XCreator root = (XCreator) treeModel.getRoot(); @@ -128,6 +121,38 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree refreshComponentTree(); } + public void removeTreePath(String key) { + componentTree.removeTreePath(key); + } + + /** + * 刷新树 + */ + public void refreshRoot() { + componentTree.refreshTreeRoot(); + } + + @Override + /** + * 位置 + * + * @return 位置 + */ + public Location preferredLocation() { + return Location.WEST_BELOW; + } + + protected ShortCut4JControlPane[] createShortcuts() { + ArrayList shortCutList = new ArrayList<>(); + FormDesigner designer = getEditingFormDesigner(); + + for (Action action : designer.getActions()) { + shortCutList.add(new WidgetEnableShortCut((UndoableAction) action)); + } + + return shortCutList.toArray(new ShortCut4JControlPane[shortCutList.size()]); + } + private void refreshComponentTree() { componentTree.setAndScrollSelectionPath(componentTree.getSelectedTreePath()); SwingUtilities.invokeLater(new Runnable() { @@ -178,17 +203,6 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree return toolBarPaneWrapper; } - protected ShortCut4JControlPane[] createShortcuts() { - ArrayList shortCutList = new ArrayList<>(); - FormDesigner designer = getEditingFormDesigner(); - - for (Action action : designer.getActions()) { - shortCutList.add(new WidgetEnableShortCut((UndoableAction) action)); - } - - return shortCutList.toArray(new ShortCut4JControlPane[shortCutList.size()]); - } - /** * 调整结构树para和body的位置 * @@ -212,26 +226,6 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree componentTree = new ComponentTree(formDesigner, treeModel); } - /** - * 刷新树 - */ - public void refreshRoot() { - if (componentTree == null) { - return; - } - componentTree.refreshTreeRoot(); - } - - @Override - /** - * 位置 - * - * @return 位置 - */ - public Location preferredLocation() { - return Location.WEST_BELOW; - } - private class WidgetEnableShortCut extends ShortCut4JControlPane { public WidgetEnableShortCut(ShortCut shortCut) { this.shortCut = shortCut; diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index 7cdd7fd600..43aa58d9b9 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -307,6 +307,16 @@ public class JForm extends JTemplate implements BaseJForm jt) { + if (jt == null) { + return; + } + String key = jt.getEditingFILE().getPath() + "-" + jt.getTarget().getTemplateID(); + FormHierarchyTreePane.getInstance().removeTreePath(key); + } + }); return tabCenterPane; } @@ -998,7 +1008,7 @@ public class JForm extends JTemplate implements BaseJForm all = wSortLayout.getNonContainerWidgetList(); List selected = wSortLayout.getFrozenWidgets(); + selected = fixRename(all, selected, wSortLayout); Map map = new LinkedHashMap<>(); for (String value : selected) { map.put(value, true); @@ -103,6 +104,24 @@ public class MobileComponentFrozenPane extends BasicPane { uiComboCheckBox.setSelectedValues(map); } + private List fixRename(List all, List selected, WSortLayout wSortLayout) { + // 存在重命名 + if (!selected.isEmpty() && !all.containsAll(selected)) { + // 清空原选中的 selected是Unmodifiable的 + selected = new ArrayList<>(); + for (String name : all) { + Widget widget = FormWidgetHelper.findWidgetWithBound(wSortLayout, name); + if (widget != null && widget.getMobileBookMark().isFrozen()) { + // 重新添加 + selected.add(name); + } + } + // 同时更新下 + wSortLayout.updateFrozenWidgets(selected); + } + return selected; + } + private List frozenWidgets() { Form form = WidgetPropertyPane.getInstance().getEditingFormDesigner().getTarget(); WLayout container = form.getContainer(); diff --git a/designer-realize/src/main/java/com/fr/design/actions/report/ReportBackgroundAction.java b/designer-realize/src/main/java/com/fr/design/actions/report/ReportBackgroundAction.java index 1a07b2a2d3..62a0e00ebb 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/report/ReportBackgroundAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/report/ReportBackgroundAction.java @@ -47,4 +47,4 @@ public class ReportBackgroundAction extends ReportComponentAction { if (hasParameterPane()) { parameterPane.populate(u.getApplyTarget()); setAutoHeightForCenterPane(); + reportComposite.setSelectedIndex(u.getSelectedReportIndex()); DesignModuleFactory.getFormHierarchyPane().refreshRoot(); } } else { + // REPORT-43022 即使没有处于编辑参数面板的状态,在经过有关参数面板的撤销后,也需要刷新一下参数面板 + if (hasParameterPane()) { + parameterPane.populate(u.getApplyTarget()); + setAutoHeightForCenterPane(); + } reportComposite.setSelectedIndex(u.getSelectedReportIndex()); u.getSelectedEditingState().revert(); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).refreshDockingView(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java index 66fed7afe2..9377c619a7 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java @@ -5,7 +5,7 @@ import com.fr.common.inputevent.InputEventBaseOnOS; import com.fr.design.designer.EditingState; import com.fr.design.event.RemoveListener; import com.fr.design.event.TargetModifiedListener; -import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.icontainer.UIModeControlContainer; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.grid.Grid; @@ -18,8 +18,6 @@ import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.BorderLayout; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelListener; import java.util.ArrayList; @@ -85,7 +83,10 @@ public class ReportComponentComposite extends JComponent implements RemoveListen value = value > MAX ? MAX : value; value = value < MIN ? MIN : value; int resolution = (int) (ScreenResolution.getScreenResolution() * value / HUND); - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setScale(resolution); + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template != null) { + template.setScale(resolution); + } } }; @@ -119,8 +120,12 @@ public class ReportComponentComposite extends JComponent implements RemoveListen templateStateList.add(null); } centerCardPane.editingComponet.setSelection(centerCardPane.editingComponet.getDefaultSelectElement()); - // Yvan: REPORT-37950 普通报表-多sheet-报表块缩放失效 - //jSliderContainer = JFormSliderPane.getInstance(); + // 这里jSliderContainer有可能为null,做个判断 + if (jSliderContainer == null) { + jSliderContainer = JFormSliderPane.getInstance(); + } + // 为新建的sheet的缩放条初始值置为100 + jSliderContainer.setShowValue(HUND); } if (centerCardPane.editingComponet.elementCasePane == null) { @@ -206,8 +211,9 @@ public class ReportComponentComposite extends JComponent implements RemoveListen hbarContainer = FRGUIPaneFactory.createBorderLayout_S_Pane(); hbarContainer.add(centerCardPane.editingComponet.getHorizontalScrollBar()); JPanel southPane = new JPanel(new BorderLayout()); - jSliderContainer = JFormSliderPane.getInstance(); - + if (jSliderContainer == null) { + jSliderContainer = JFormSliderPane.getInstance(); + } southPane.add(hbarContainer, BorderLayout.NORTH); southPane.add(sheetNameTab, BorderLayout.CENTER); southPane.add(jSliderContainer, BorderLayout.EAST); 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..4f38c8baa5 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CellPredefinedStyleSettingPane.java @@ -0,0 +1,257 @@ +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.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.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.predefined.PredefinedPatternStyleManager; +import com.fr.stable.Constants; +import com.fr.stable.StringUtils; +import com.fr.third.javax.annotation.Nonnull; + +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); +// PredefinedStyle currentStyle = PredefinedPatternStyleManager.INSTANCE.getStyleFromName(getPredefinedStyleName()); +// PredefinedCellStyleConfig config = currentStyle.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); + } + + + protected void populateCustomPane(){ + this.customPredefinedStylePane.populateBean(updatePredefinedStyle()); + } + + + + public void dealWithBorder(ElementCasePane ePane) { + + this.customPredefinedStylePane.dealWithBorder(ePane); + } + + public void updateBorder() { + this.customPredefinedStylePane.updateBorder(); + } + + @Override + @Nonnull + public NameStyle updateBean() { + Style style = updateStyle(); + if (!(style instanceof NameStyle)) { +// return NameStyle.createCustomStyle(style); + } + return (NameStyle) style; + } + + @Nonnull + public Style updateStyle() { + if (this.predefinedRadioBtn.isSelected()) { + return updatePredefinedStyle(); + } else { + return this.customPredefinedStylePane.updateBean(); + } + } + + private NameStyle updatePredefinedStyle() { + Object selectItem = this.applicationFormat.getSelectedItem(); +// return NameStyle.createPredefinedStyle(getPredefinedStyleName(), selectItem == null ? StringUtils.EMPTY : selectItem.toString(), Style.getInstance()); + return null; + } + + class CustomStylePane extends MultiTabPane