From 035d74bdafed8d060b2bbb515699c8550f9c26f7 Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Thu, 5 Nov 2020 16:45:16 +0800 Subject: [PATCH 1/2] =?UTF-8?q?CHART-16493=20=E5=8A=A0=E8=BD=BD=E5=9B=BE?= =?UTF-8?q?=E8=A1=A8=E6=A8=A1=E5=9D=97=E6=97=B6=EF=BC=8C=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E5=AF=8C=E6=96=87=E6=9C=AC=E7=BC=96=E8=BE=91=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/chart/ChartDesignerActivator.java | 3 ++ .../component/VanChartRichEditorPane.java | 36 ++++++++++++++++--- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java b/designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java index 0cd81f783..9b6f2e02e 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java @@ -18,6 +18,7 @@ import com.fr.plugin.chart.vanchart.export.ImagePainter; import com.fr.stable.bridge.StableFactory; import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import com.fr.van.chart.DownloadOnlineSourcesHelper; +import com.fr.van.chart.designer.component.VanChartRichEditorPane; /** * Created by juhaoyu on 2018/6/27. @@ -47,6 +48,8 @@ public class ChartDesignerActivator extends Activator implements Prepare { ImagePainter.registerDownloadSourcesEvent(new DownloadOnlineSourcesHelper()); ImagePainter.registerDefaultCallbackEvent(HistoryTemplateListCache.getInstance()); + VanChartRichEditorPane.initRichEditorPane(); + ChartTypeInterfaceManager.addPluginChangedListener(); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java index 622d2a0ee..1ccc146c1 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java @@ -1,6 +1,8 @@ package com.fr.van.chart.designer.component; +import com.fr.concurrent.NamedThreadFactory; import com.fr.design.ui.ModernUIPane; +import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.base.AttrTooltipRichText; import com.fr.plugin.chart.type.TextAlign; import com.fr.stable.StringUtils; @@ -10,6 +12,8 @@ import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; public class VanChartRichEditorPane { @@ -21,6 +25,25 @@ public class VanChartRichEditorPane { private static ModernUIPane richEditorPane; private static Browser browser; + public static void initRichEditorPane() { + ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor(new NamedThreadFactory("VanChartRichEditor")); + + try { + singleThreadExecutor.submit(new Runnable() { + @Override + public void run() { + try { + richEditorPane = initPane(new RichEditorModel()); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + }); + } finally { + singleThreadExecutor.shutdown(); + } + } + public static ModernUIPane createRichEditorPane(AttrTooltipRichText richEditor) { RichEditorModel model = getRichEditorModel(richEditor); @@ -88,11 +111,14 @@ public class VanChartRichEditorPane { } public static class RichEditorModel { - private String content; - private boolean auto; - private String params; - private String initParams; - private String align; + private String content = StringUtils.EMPTY; + private boolean auto = true; + private String params = StringUtils.EMPTY; + private String initParams = StringUtils.EMPTY; + private String align = TextAlign.LEFT.getAlign(); + + public RichEditorModel() { + } public RichEditorModel(String content, boolean auto, String params, String initParams, String align) { this.content = content; From d7ef3e180f631595a8bcb8e4ee4c9c08327506fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Thu, 5 Nov 2020 16:57:13 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=09CHART-16595=09=E8=A7=86=E8=A7=89?= =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=8C=E5=9C=B0=E5=9B=BE=E9=83=A8=E5=88=86?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=9A=84=E8=83=8C=E6=99=AF=E8=89=B2=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E5=85=81=E8=AE=B8=E8=AE=BE=E7=BD=AE=E4=B8=8D=E9=80=8F?= =?UTF-8?q?=E6=98=8E=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../background/VanChartBackgroundPane.java | 60 ++++++++++++++++--- ...rtBackgroundPaneWithOutImageAndShadow.java | 13 +++- .../VanChartBackgroundWithOutImagePane.java | 34 ----------- ...BackgroundWithOutShadowWithRadiusPane.java | 20 +++---- .../label/VanChartPlotLabelDetailPane.java | 2 +- .../VanChartDrillMapInteractivePane.java | 9 +-- 6 files changed, 75 insertions(+), 63 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundPane.java index a0d664fc0..9a81b6ece 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundPane.java @@ -7,6 +7,7 @@ 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.mainframe.backgroundpane.BackgroundQuickPane; import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane; @@ -39,6 +40,7 @@ public class VanChartBackgroundPane extends BasicPane { protected List paneList; protected UIComboBox typeComboBox; + private UILabel transparentLabel; protected UINumberDragPane transparent; protected UIButtonGroup shadow; @@ -46,6 +48,8 @@ public class VanChartBackgroundPane extends BasicPane { private boolean hasAuto; + private static final int AUTO = 0; + public VanChartBackgroundPane() { this(false); } @@ -58,6 +62,9 @@ public class VanChartBackgroundPane extends BasicPane { this.add(panel, BorderLayout.CENTER); } + public UILabel getTransparentLabel() { + return transparentLabel; + } public boolean isHasAuto() { return hasAuto; @@ -78,6 +85,7 @@ public class VanChartBackgroundPane extends BasicPane { final CardLayout cardlayout = new CardLayout(); paneList = new ArrayList<>(); + initAutoPane(); initList(); centerPane = new JPanel(cardlayout) { @@ -100,24 +108,43 @@ public class VanChartBackgroundPane extends BasicPane { public void itemStateChanged(ItemEvent e) { 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[][]{ 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()); @@ -158,7 +185,17 @@ public class VanChartBackgroundPane extends BasicPane { if (shadow != null) { shadow.setSelectedIndex(attr.isShadow() == true ? 0 : 1); } - populateBackground(attr, 0); + + if (isHasAuto()) { + if (attr.isAutoBackground()) { + typeComboBox.setSelectedIndex(AUTO); + checkTransparent(); + return; + } + populateBackground(attr, 1); + } else { + populateBackground(attr, 0); + } } public void populateBackground(GeneralInfo attr, int begin) { @@ -168,20 +205,29 @@ public class VanChartBackgroundPane extends BasicPane { if (pane.accept(background)) { pane.populateBean(background); typeComboBox.setSelectedIndex(i); + checkTransparent(); return; } } + checkTransparent(); } public void update(GeneralInfo attr) { if (attr == null) { attr = new GeneralInfo(); } - updateBackground(attr); attr.setAlpha((float) (transparent.updateBean() / ALPHA_V)); 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) { 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 202df532e..812dd5a09 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/VanChartBackgroundWithOutImagePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/background/VanChartBackgroundWithOutImagePane.java index 06c7aba70..d021640ff 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 @@ -1,7 +1,5 @@ package com.fr.van.chart.designer.component.background; -import com.fr.chart.chartglyph.GeneralInfo; -import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane; import com.fr.design.mainframe.backgroundpane.NullBackgroundQuickPane; import com.fr.design.mainframe.backgroundpane.VanChartGradientPane; @@ -13,8 +11,6 @@ import com.fr.design.mainframe.backgroundpane.VanChartGradientPane; public class VanChartBackgroundWithOutImagePane extends VanChartBackgroundPane { private static final long serialVersionUID = 1322979785605013853L; - private static final int AUTO = 0; - public VanChartBackgroundWithOutImagePane() { this(false); } @@ -24,38 +20,8 @@ public class VanChartBackgroundWithOutImagePane extends VanChartBackgroundPane { } protected void initList() { - if (isHasAuto()) { - paneList.add(new NullBackgroundQuickPane() { - public String title4PopupWindow() { - return Toolkit.i18nText("Fine-Design_Chart_Automatic"); - } - }); - } paneList.add(new NullBackgroundQuickPane()); paneList.add(new ColorBackgroundQuickPane()); paneList.add(new VanChartGradientPane()); } - - public void populateBackground(GeneralInfo attr, int begin) { - if (isHasAuto()) { - if (attr.isAutoBackground()) { - typeComboBox.setSelectedIndex(AUTO); - return; - } - super.populateBackground(attr, begin + 1); - } else { - super.populateBackground(attr, begin); - } - } - - public void updateBackground(GeneralInfo attr) { - if (isHasAuto()) { - if (typeComboBox.getSelectedIndex() == AUTO) { - attr.setAutoBackground(true); - return; - } - attr.setAutoBackground(false); - } - super.updateBackground(attr); - } } \ No newline at end of file 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 902d10ad7..807ee6216 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,27 +15,27 @@ public class VanChartBackgroundWithOutShadowWithRadiusPane extends VanChartBackg private UISpinner radius; - public VanChartBackgroundWithOutShadowWithRadiusPane(){ + public VanChartBackgroundWithOutShadowWithRadiusPane() { super(); } - public VanChartBackgroundWithOutShadowWithRadiusPane(boolean hasAuto){ + 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); @@ -48,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/style/label/VanChartPlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java index a245ce845..3047e608f 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 @@ -153,7 +153,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { 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}, }; } }; 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 f25802130..6886bae4d 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 @@ -7,7 +7,6 @@ import com.fr.design.i18n.Toolkit; 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 com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.drillmap.VanChartDrillMapPlot; @@ -77,15 +76,9 @@ public class VanChartDrillMapInteractivePane extends VanChartInteractivePaneWith } }; - backgroundPane = new VanChartBackgroundPaneWithOutImageAndShadow() { + backgroundPane = new VanChartBackgroundPaneWithOutImageAndShadow(true) { @Override protected void initList() { - paneList.add(new NullBackgroundQuickPane() { - @Override - public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Automatic"); - } - }); paneList.add(new ColorBackgroundQuickPane()); } };