From 137adaaef28135d7b1b63d4258a5c86a3526af1b Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Fri, 22 Jan 2021 17:14:50 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=E7=AE=B1=E5=9E=8B=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ChartBoxRichTextDetailedFieldListPane.java | 135 ++++++++++ ...anChartBoxRichTextResultFieldListPane.java | 41 +++ .../box/VanChartBoxTooltipContentPane.java | 234 +++++++----------- 3 files changed, 259 insertions(+), 151 deletions(-) create mode 100644 designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxRichTextDetailedFieldListPane.java create mode 100644 designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxRichTextResultFieldListPane.java diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxRichTextDetailedFieldListPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxRichTextDetailedFieldListPane.java new file mode 100644 index 000000000..d780a44eb --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxRichTextDetailedFieldListPane.java @@ -0,0 +1,135 @@ +package com.fr.van.chart.box; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.ui.ModernUIPane; +import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; +import com.fr.plugin.chart.base.format.AttrTooltipDataMaxFormat; +import com.fr.plugin.chart.base.format.AttrTooltipDataMedianFormat; +import com.fr.plugin.chart.base.format.AttrTooltipDataMinFormat; +import com.fr.plugin.chart.base.format.AttrTooltipDataNumberFormat; +import com.fr.plugin.chart.base.format.AttrTooltipDataOutlierFormat; +import com.fr.plugin.chart.base.format.AttrTooltipDataQ1Format; +import com.fr.plugin.chart.base.format.AttrTooltipDataQ3Format; +import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; +import com.fr.plugin.chart.box.attr.AttrBoxTooltipContent; +import com.fr.van.chart.designer.component.richText.VanChartFieldAttrPane; +import com.fr.van.chart.designer.component.richText.VanChartFieldButton; +import com.fr.van.chart.designer.component.richText.VanChartFieldListPane; +import com.fr.van.chart.designer.component.richText.VanChartFieldListener; +import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel; + +import javax.swing.JPanel; +import java.util.ArrayList; +import java.util.List; + +public class VanChartBoxRichTextDetailedFieldListPane extends VanChartFieldListPane { + + private VanChartFieldButton richTextNumber; + private VanChartFieldButton richTextMax; + private VanChartFieldButton richTextQ3; + private VanChartFieldButton richTextMedian; + private VanChartFieldButton richTextQ1; + private VanChartFieldButton richTextMin; + private VanChartFieldButton richTextOutlier; + + public VanChartBoxRichTextDetailedFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditorPane) { + super(fieldAttrPane, richEditorPane); + } + + public VanChartFieldButton getRichTextMax() { + return richTextMax; + } + + public VanChartFieldButton getRichTextQ3() { + return richTextQ3; + } + + public VanChartFieldButton getRichTextMedian() { + return richTextMedian; + } + + public VanChartFieldButton getRichTextQ1() { + return richTextQ1; + } + + public VanChartFieldButton getRichTextMin() { + return richTextMin; + } + + protected void initDefaultFieldButton() { + VanChartFieldListener listener = getFieldListener(); + + setCategoryNameButton(new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Category_Use_Name"), new AttrTooltipCategoryFormat(), listener)); + setSeriesNameButton(new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Series_Name"), new AttrTooltipSeriesFormat(), listener)); + + richTextNumber = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Data_Number"), new AttrTooltipDataNumberFormat(), listener); + richTextMax = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Max_Value"), new AttrTooltipDataMaxFormat(), listener); + richTextQ3 = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Data_Q3"), new AttrTooltipDataQ3Format(), listener); + richTextMedian = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Data_Median"), new AttrTooltipDataMedianFormat(), listener); + richTextQ1 = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Data_Q1"), new AttrTooltipDataQ1Format(), listener); + richTextMin = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Min_Value"), new AttrTooltipDataMinFormat(), listener); + richTextOutlier = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Outlier_Value"), new AttrTooltipDataOutlierFormat(), listener); + } + + protected void addDefaultFieldButton(JPanel fieldPane) { + fieldPane.add(getCategoryNameButton()); + fieldPane.add(getSeriesNameButton()); + fieldPane.add(richTextNumber); + fieldPane.add(richTextMax); + fieldPane.add(richTextQ3); + fieldPane.add(richTextMedian); + fieldPane.add(richTextQ1); + fieldPane.add(richTextMin); + fieldPane.add(richTextOutlier); + } + + protected List getDefaultFieldButtonList() { + List fieldButtonList = new ArrayList<>(); + + fieldButtonList.add(getCategoryNameButton()); + fieldButtonList.add(getSeriesNameButton()); + fieldButtonList.add(richTextNumber); + fieldButtonList.add(richTextMax); + fieldButtonList.add(richTextQ3); + fieldButtonList.add(richTextMedian); + fieldButtonList.add(richTextQ1); + fieldButtonList.add(richTextMin); + fieldButtonList.add(richTextOutlier); + + return fieldButtonList; + } + + public void populateDefaultField(AttrTooltipContent tooltipContent) { + super.populateDefaultField(tooltipContent); + + if (tooltipContent instanceof AttrBoxTooltipContent) { + AttrBoxTooltipContent box = (AttrBoxTooltipContent) tooltipContent; + + populateButtonFormat(richTextNumber, box.getRichTextNumber()); + populateButtonFormat(richTextMax, box.getRichTextMax()); + populateButtonFormat(richTextQ3, box.getRichTextQ3()); + populateButtonFormat(richTextMedian, box.getRichTextMedian()); + populateButtonFormat(richTextQ1, box.getRichTextQ1()); + populateButtonFormat(richTextMin, box.getRichTextMin()); + populateButtonFormat(richTextOutlier, box.getRichTextOutlier()); + } + } + + public void updateDefaultField(AttrTooltipContent tooltipContent) { + super.updateDefaultField(tooltipContent); + + if (tooltipContent instanceof AttrBoxTooltipContent) { + AttrBoxTooltipContent box = (AttrBoxTooltipContent) tooltipContent; + + updateButtonFormat(richTextNumber, box.getRichTextNumber()); + updateButtonFormat(richTextMax, box.getRichTextMax()); + updateButtonFormat(richTextQ3, box.getRichTextQ3()); + updateButtonFormat(richTextMedian, box.getRichTextMedian()); + updateButtonFormat(richTextQ1, box.getRichTextQ1()); + updateButtonFormat(richTextMin, box.getRichTextMin()); + updateButtonFormat(richTextOutlier, box.getRichTextOutlier()); + } + } + +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxRichTextResultFieldListPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxRichTextResultFieldListPane.java new file mode 100644 index 000000000..9816967ff --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxRichTextResultFieldListPane.java @@ -0,0 +1,41 @@ +package com.fr.van.chart.box; + +import com.fr.design.ui.ModernUIPane; +import com.fr.van.chart.designer.component.richText.VanChartFieldAttrPane; +import com.fr.van.chart.designer.component.richText.VanChartFieldButton; +import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel; + +import javax.swing.JPanel; +import java.util.ArrayList; +import java.util.List; + +public class VanChartBoxRichTextResultFieldListPane extends VanChartBoxRichTextDetailedFieldListPane { + + public VanChartBoxRichTextResultFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditorPane) { + super(fieldAttrPane, richEditorPane); + } + + protected void addDefaultFieldButton(JPanel fieldPane) { + fieldPane.add(getCategoryNameButton()); + fieldPane.add(getSeriesNameButton()); + fieldPane.add(getRichTextMax()); + fieldPane.add(getRichTextQ3()); + fieldPane.add(getRichTextMedian()); + fieldPane.add(getRichTextQ1()); + fieldPane.add(getRichTextMin()); + } + + protected List getDefaultFieldButtonList() { + List fieldButtonList = new ArrayList<>(); + + fieldButtonList.add(getCategoryNameButton()); + fieldButtonList.add(getSeriesNameButton()); + fieldButtonList.add(getRichTextMax()); + fieldButtonList.add(getRichTextQ3()); + fieldButtonList.add(getRichTextMedian()); + fieldButtonList.add(getRichTextQ1()); + fieldButtonList.add(getRichTextMin()); + + return fieldButtonList; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java index 25eb587d8..64501bd9a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java @@ -4,8 +4,8 @@ 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.ui.ModernUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; -import com.fr.plugin.chart.base.AttrTooltipRichText; import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; import com.fr.plugin.chart.base.format.AttrTooltipDataMaxFormat; import com.fr.plugin.chart.base.format.AttrTooltipDataMedianFormat; @@ -25,12 +25,15 @@ import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckB import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.component.richText.VanChartFieldAttrPane; +import com.fr.van.chart.designer.component.richText.VanChartFieldListPane; +import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel; +import com.fr.van.chart.designer.component.richText.VanChartRichTextPane; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; -import java.util.Map; public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { @@ -55,9 +58,6 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { private JPanel dataNumberPane; private JPanel dataOutlierPane; - private JPanel richTextNumberPane; - private JPanel richTextOutlierPane; - public VanChartBoxTooltipContentPane(VanChartStylePane parent, JPanel showOnPane, boolean isDetailed) { super(parent, showOnPane); checkFormatVisible(isDetailed); @@ -155,14 +155,74 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { return commonPanel; } - protected JPanel createRichFormatPanel() { - JPanel richFormatPanel = new JPanel(new BorderLayout()); + protected VanChartRichTextPane createRichTextPane(ModernUIPane richEditorPane) { + + return new VanChartRichTextPane(richEditorPane) { + + protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditor) { + if (detailed) { + return new VanChartBoxRichTextDetailedFieldListPane(fieldAttrPane, richEditor); + } + + return new VanChartBoxRichTextResultFieldListPane(fieldAttrPane, richEditor); + } + + protected AttrTooltipContent getInitialTooltipContent() { + return createAttrTooltip(); + } + }; + } + + protected String[] getRichTextFieldNames() { + if (detailed) { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Category_Use_Name"), + Toolkit.i18nText("Fine-Design_Chart_Series_Name"), + Toolkit.i18nText("Fine-Design_Chart_Data_Number"), + Toolkit.i18nText("Fine-Design_Chart_Max_Value"), + Toolkit.i18nText("Fine-Design_Chart_Data_Q3"), + Toolkit.i18nText("Fine-Design_Chart_Data_Median"), + Toolkit.i18nText("Fine-Design_Chart_Data_Q1"), + Toolkit.i18nText("Fine-Design_Chart_Min_Value"), + Toolkit.i18nText("Fine-Design_Chart_Outlier_Value") + }; + } + + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Category_Use_Name"), + Toolkit.i18nText("Fine-Design_Chart_Series_Name"), + Toolkit.i18nText("Fine-Design_Chart_Max_Value"), + Toolkit.i18nText("Fine-Design_Chart_Data_Q3"), + Toolkit.i18nText("Fine-Design_Chart_Data_Median"), + Toolkit.i18nText("Fine-Design_Chart_Data_Q1"), + Toolkit.i18nText("Fine-Design_Chart_Min_Value") + }; + } - richFormatPanel.add(createRichTextCateAndSeriesPane(), BorderLayout.NORTH); - richFormatPanel.add(createRichTextDataNumberPane(), BorderLayout.CENTER); - richFormatPanel.add(createRichTextDataDetailPane(), BorderLayout.SOUTH); + protected AttrTooltipFormat[] getRichTextFieldFormats() { + if (detailed) { + return new AttrTooltipFormat[]{ + new AttrTooltipCategoryFormat(), + new AttrTooltipSeriesFormat(), + new AttrTooltipDataNumberFormat(), + new AttrTooltipDataMaxFormat(), + new AttrTooltipDataQ3Format(), + new AttrTooltipDataMedianFormat(), + new AttrTooltipDataQ1Format(), + new AttrTooltipDataMinFormat(), + new AttrTooltipDataOutlierFormat() + }; + } - return richFormatPanel; + return new AttrTooltipFormat[]{ + new AttrTooltipCategoryFormat(), + new AttrTooltipSeriesFormat(), + new AttrTooltipDataMaxFormat(), + new AttrTooltipDataQ3Format(), + new AttrTooltipDataMedianFormat(), + new AttrTooltipDataQ1Format(), + new AttrTooltipDataMinFormat() + }; } protected Component[][] getRichTextComponents() { @@ -249,72 +309,6 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { return detailPane; } - private JPanel createRichTextCateAndSeriesPane() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - - double[] columnSize = {f, e}; - double[] rowSize = {p, p, p}; - - Component[][] cateAndSeries = new Component[][]{ - new Component[]{null, null}, - new Component[]{null, getRichTextCategoryNameFormatPane()}, - new Component[]{null, getRichTextSeriesNameFormatPane()} - }; - - return TableLayoutHelper.createTableLayoutPane(cateAndSeries, rowSize, columnSize); - } - - private JPanel createRichTextDataNumberPane() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - - double[] columnSize = {f, e}; - double[] rowSize = {p, p}; - - Component[][] dataNumber = new Component[][]{ - new Component[]{null, null}, - new Component[]{null, richTextNumber}, - }; - - richTextNumberPane = TableLayoutHelper.createTableLayoutPane(dataNumber, rowSize, columnSize); - - return richTextNumberPane; - } - - private JPanel createRichTextDataDetailPane() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - - double[] columnSize = {f, e}; - - JPanel detailPane = new JPanel(new BorderLayout()); - - Component[][] richTextDetail = new Component[][]{ - new Component[]{null, null}, - new Component[]{null, richTextMax}, - new Component[]{new UILabel(getLabelContentTitle()), richTextQ3}, - new Component[]{null, richTextMedian}, - new Component[]{null, richTextQ1}, - new Component[]{null, richTextMin} - }; - - Component[][] dataOutlier = new Component[][]{ - new Component[]{null, null}, - new Component[]{null, richTextOutlier}, - }; - - richTextOutlierPane = TableLayoutHelper.createTableLayoutPane(dataOutlier, new double[]{p, p}, columnSize); - - detailPane.add(TableLayoutHelper.createTableLayoutPane(richTextDetail, new double[]{p, p, p, p, p, p}, columnSize), BorderLayout.NORTH); - detailPane.add(richTextOutlierPane, BorderLayout.CENTER); - - return detailPane; - } - public boolean isDirty() { return getCategoryNameFormatPane().isDirty() || getSeriesNameFormatPane().isDirty() @@ -362,63 +356,21 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { } } - protected void populateRichEditor(AttrTooltipContent attrTooltipContent) { - setRichTextAttr(new AttrTooltipRichText()); - Map params = getRichTextAttr().getParams(); - - AttrTooltipCategoryFormat categoryFormat = attrTooltipContent.getRichTextCategoryFormat(); - getRichTextCategoryNameFormatPane().populate(categoryFormat); - getRichTextCategoryNameFormatPane().updateFormatParams(params, categoryFormat.getJs()); - - AttrTooltipSeriesFormat seriesFormat = attrTooltipContent.getRichTextSeriesFormat(); - getRichTextSeriesNameFormatPane().populate(seriesFormat); - getRichTextSeriesNameFormatPane().updateFormatParams(params, seriesFormat.getJs()); - - if (attrTooltipContent instanceof AttrBoxTooltipContent) { - AttrBoxTooltipContent boxTooltipContent = (AttrBoxTooltipContent) attrTooltipContent; - - VanChartFormatPaneWithoutCheckBox[] formatPaneGroup = getFormatPaneGroup(); - AttrTooltipFormat[] formatGroup = getFormatGroup(boxTooltipContent); - - populateRichTextFormat(formatPaneGroup, formatGroup); - populateRichText(attrTooltipContent.getRichTextAttr()); - - checkRichEditorState(attrTooltipContent); - } - } - - private VanChartFormatPaneWithoutCheckBox[] getFormatPaneGroup() { - if (detailed) { - return new VanChartFormatPaneWithoutCheckBox[]{ - richTextNumber, richTextMax, richTextQ3, richTextMedian, - richTextQ1, richTextMin, richTextOutlier - }; - } - - return new VanChartFormatPaneWithoutCheckBox[]{ - richTextMax, richTextQ3, richTextMedian, richTextQ1, richTextMin - }; - } + protected void updateTooltipFormat(AttrTooltipContent target, AttrTooltipContent source) { + super.updateTooltipFormat(target, source); - private AttrTooltipFormat[] getFormatGroup(AttrBoxTooltipContent boxTooltipContent) { - AttrTooltipDataNumberFormat richTextNumber = boxTooltipContent.getRichTextNumber(); - AttrTooltipDataMaxFormat richTextMaxFormat = boxTooltipContent.getRichTextMax(); - AttrTooltipDataQ3Format richTextQ3Format = boxTooltipContent.getRichTextQ3(); - AttrTooltipDataMedianFormat richTextMedianFormat = boxTooltipContent.getRichTextMedian(); - AttrTooltipDataQ1Format richTextQ1Format = boxTooltipContent.getRichTextQ1(); - AttrTooltipDataMinFormat richTextMinFormat = boxTooltipContent.getRichTextMin(); - AttrTooltipDataOutlierFormat richTextOutlierFormat = boxTooltipContent.getRichTextOutlier(); + if (target instanceof AttrBoxTooltipContent && source instanceof AttrBoxTooltipContent) { + AttrBoxTooltipContent targetGantt = (AttrBoxTooltipContent) target; + AttrBoxTooltipContent sourceGantt = (AttrBoxTooltipContent) source; - if (detailed) { - return new AttrTooltipFormat[]{ - richTextNumber, richTextMaxFormat, richTextQ3Format, richTextMedianFormat, - richTextQ1Format, richTextMinFormat, richTextOutlierFormat - }; + targetGantt.setRichTextNumber(sourceGantt.getRichTextNumber()); + targetGantt.setRichTextMax(sourceGantt.getRichTextMax()); + targetGantt.setRichTextQ3(sourceGantt.getRichTextQ3()); + targetGantt.setRichTextMedian(sourceGantt.getRichTextMedian()); + targetGantt.setRichTextQ1(sourceGantt.getRichTextQ1()); + targetGantt.setRichTextMin(sourceGantt.getRichTextMin()); + targetGantt.setRichTextOutlier(sourceGantt.getRichTextOutlier()); } - - return new AttrTooltipFormat[]{ - richTextMaxFormat, richTextQ3Format, richTextMedianFormat, richTextQ1Format, richTextMinFormat - }; } protected void updateFormatPane(AttrTooltipContent attrTooltipContent) { @@ -440,30 +392,10 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { } } - protected void updateRichEditor(AttrTooltipContent attrTooltipContent) { - getRichTextCategoryNameFormatPane().update(attrTooltipContent.getRichTextCategoryFormat()); - getRichTextSeriesNameFormatPane().update(attrTooltipContent.getRichTextSeriesFormat()); - - if (attrTooltipContent instanceof AttrBoxTooltipContent) { - AttrBoxTooltipContent boxTooltipContent = (AttrBoxTooltipContent) attrTooltipContent; - - richTextNumber.update(boxTooltipContent.getRichTextNumber()); - richTextMax.update(boxTooltipContent.getRichTextMax()); - richTextQ3.update(boxTooltipContent.getRichTextQ3()); - richTextMedian.update(boxTooltipContent.getRichTextMedian()); - richTextQ1.update(boxTooltipContent.getRichTextQ1()); - richTextMin.update(boxTooltipContent.getRichTextMin()); - richTextOutlier.update(boxTooltipContent.getRichTextOutlier()); - } - } - public void checkFormatVisible(boolean detailed) { this.detailed = detailed; dataNumberPane.setVisible(detailed); dataOutlierPane.setVisible(detailed); - - richTextNumberPane.setVisible(detailed); - richTextOutlierPane.setVisible(detailed); } }