From 185f936457130e5e66ef29cf4271713597a5e7ab Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Mon, 17 Aug 2020 11:23:50 +0800 Subject: [PATCH] =?UTF-8?q?CHART-14983=20=E6=A0=B9=E6=8D=AE=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=B1=BB=E5=9E=8B=E8=B0=83=E6=95=B4=E7=AE=B1=E5=9E=8B?= =?UTF-8?q?=E5=9B=BE=E6=95=B0=E6=8D=AE=E7=82=B9=E6=8F=90=E7=A4=BA=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/box/VanChartBoxPlotTooltipPane.java | 8 +- .../box/VanChartBoxTooltipContentPane.java | 89 +++++++++++++++++-- .../van/chart/box/VanChartBoxTooltipPane.java | 18 ++++ .../component/VanChartTooltipContentPane.java | 16 +++- .../style/tooltip/VanChartTooltipPane.java | 12 ++- 5 files changed, 129 insertions(+), 14 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxPlotTooltipPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxPlotTooltipPane.java index 4ad21d0d86..a68eb55964 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxPlotTooltipPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxPlotTooltipPane.java @@ -2,6 +2,7 @@ package com.fr.van.chart.box; import com.fr.chart.chartattr.Plot; import com.fr.plugin.chart.base.AttrTooltip; +import com.fr.plugin.chart.box.VanChartBoxPlot; import com.fr.plugin.chart.box.attr.AttrBoxTooltip; import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.designer.style.tooltip.VanChartPlotTooltipPane; @@ -13,7 +14,8 @@ public class VanChartBoxPlotTooltipPane extends VanChartPlotTooltipPane { } protected void initTooltipContentPane(Plot plot) { - tooltipContentPane = new VanChartBoxTooltipContentPane(parent, VanChartBoxPlotTooltipPane.this); + boolean isDetailed = ((VanChartBoxPlot) plot).isDetailed(); + tooltipContentPane = new VanChartBoxTooltipContentPane(parent, VanChartBoxPlotTooltipPane.this, isDetailed); } protected AttrTooltip getAttrTooltip() { @@ -23,4 +25,8 @@ public class VanChartBoxPlotTooltipPane extends VanChartPlotTooltipPane { protected boolean hasTooltipSeriesType() { return false; } + + public void checkContentVisible(boolean isDetailed) { + ((VanChartBoxTooltipContentPane) tooltipContentPane).checkFormatVisible(isDetailed); + } } 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 2b449785ef..8831b50491 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 @@ -1,6 +1,8 @@ package com.fr.van.chart.box; import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.box.attr.AttrBoxTooltipContent; import com.fr.van.chart.designer.component.VanChartTooltipContentPane; @@ -10,10 +12,13 @@ import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithCheckBox import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; +import java.awt.BorderLayout; import java.awt.Component; public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { + private boolean detailed; + private VanChartFormatPaneWithCheckBox number; private VanChartFormatPaneWithCheckBox max; private VanChartFormatPaneWithCheckBox q3; @@ -22,8 +27,12 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { private VanChartFormatPaneWithCheckBox min; private VanChartFormatPaneWithCheckBox outlier; - public VanChartBoxTooltipContentPane(VanChartStylePane parent, JPanel showOnPane) { + private JPanel dataNumberPane; + private JPanel dataOutlierPane; + + public VanChartBoxTooltipContentPane(VanChartStylePane parent, JPanel showOnPane, boolean isDetailed) { super(parent, showOnPane); + this.detailed = isDetailed; } protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { @@ -67,22 +76,81 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { }; } + protected JPanel createCommonPanel() { + JPanel commonPanel = new JPanel(new BorderLayout()); + + commonPanel.add(createCateAndSeriesPane(), BorderLayout.NORTH); + commonPanel.add(createDataNumberPane(), BorderLayout.CENTER); + commonPanel.add(createDataDetailPane(), BorderLayout.SOUTH); + + checkFormatVisible(detailed); + + return commonPanel; + } + protected double[] getRowSize(double p) { - return new double[]{p, p, p, p, p, p, p, p, p}; + return new double[]{p, p, p, p, p, p, p, p, p, p, p, p}; } - protected Component[][] getPaneComponents() { - return new Component[][]{ + private JPanel createCateAndSeriesPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + + double[] columnSize = {f, p}; + double[] rowSize = {p, p}; + + Component[][] cateAndSeries = new Component[][]{ new Component[]{categoryNameFormatPane, null}, - new Component[]{seriesNameFormatPane, null}, + new Component[]{seriesNameFormatPane, null} + }; + + return TableLayoutHelper.createTableLayoutPane(cateAndSeries, rowSize, columnSize); + } + + private JPanel createDataNumberPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + + double[] columnSize = {f, p}; + double[] rowSize = {p, p}; + + Component[][] dataNumber = new Component[][]{ + new Component[]{null, null}, new Component[]{number, null}, + }; + + dataNumberPane = TableLayoutHelper.createTableLayoutPane(dataNumber, rowSize, columnSize); + + return dataNumberPane; + } + + private JPanel createDataDetailPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {f, p}; + + JPanel detailPane = new JPanel(new BorderLayout()); + + Component[][] dataDetail = new Component[][]{ + new Component[]{null, null}, new Component[]{max, null}, new Component[]{q3, null}, new Component[]{median, null}, new Component[]{q1, null}, - new Component[]{min, null}, - new Component[]{outlier, null} + new Component[]{min, null} }; + + Component[][] dataOutlier = new Component[][]{ + new Component[]{null, null}, + new Component[]{outlier, null}, + }; + + dataOutlierPane = TableLayoutHelper.createTableLayoutPane(dataOutlier, new double[]{p, p}, columnSize); + + detailPane.add(TableLayoutHelper.createTableLayoutPane(dataDetail, new double[]{p, p, p, p, p, p}, columnSize), BorderLayout.NORTH); + detailPane.add(dataOutlierPane, BorderLayout.CENTER); + + return detailPane; } public boolean isDirty() { @@ -146,4 +214,11 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { outlier.update(boxTooltipContent.getOutlier()); } } + + public void checkFormatVisible(boolean detailed) { + this.detailed = detailed; + + dataNumberPane.setVisible(detailed); + dataOutlierPane.setVisible(detailed); + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipPane.java index 5d485c31d2..955f974534 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipPane.java @@ -1,6 +1,10 @@ package com.fr.van.chart.box; +import com.fr.chart.base.DataSeriesCondition; import com.fr.chart.chartattr.Plot; +import com.fr.plugin.chart.attr.plot.VanChartPlot; +import com.fr.plugin.chart.base.AttrTooltip; +import com.fr.plugin.chart.box.VanChartBoxPlot; import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.designer.style.tooltip.VanChartPlotTooltipPane; import com.fr.van.chart.designer.style.tooltip.VanChartTooltipPane; @@ -14,4 +18,18 @@ public class VanChartBoxTooltipPane extends VanChartTooltipPane { protected VanChartPlotTooltipPane getTooltipPane(Plot plot) { return new VanChartBoxPlotTooltipPane(plot, parent); } + + public void populateTooltipPane(Plot plot) { + DataSeriesCondition attr = ((VanChartPlot) plot).getAttrTooltipFromConditionCollection(); + VanChartPlotTooltipPane tooltipPane = getPlotTooltipPane(); + + if (tooltipPane instanceof VanChartBoxPlotTooltipPane) { + tooltipPane.populate((AttrTooltip) attr); + + VanChartBoxPlotTooltipPane boxPlotTooltipPane = (VanChartBoxPlotTooltipPane) tooltipPane; + VanChartBoxPlot boxPlot = (VanChartBoxPlot) plot; + + boxPlotTooltipPane.checkContentVisible(boxPlot.isDetailed()); + } + } } 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 af03afbe91..5920dd969f 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 @@ -42,6 +42,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane { this.parent = parent; } + public VanChartPlotTooltipPane getPlotTooltipPane() { + return tooltipPane; + } + @Override protected JPanel createContentPane() { JPanel contentPane = new JPanel(new BorderLayout()); @@ -48,7 +53,10 @@ public class VanChartTooltipPane extends AbstractVanChartScrollPane { parent.initAllListeners(); } - Plot plot = this.chart.getPlot(); + populateTooltipPane(this.chart.getPlot()); + } + + public void populateTooltipPane(Plot plot) { DataSeriesCondition attr = ((VanChartPlot)plot).getAttrTooltipFromConditionCollection(); if(tooltipPane != null) { tooltipPane.populate((AttrTooltip)attr); @@ -74,7 +82,7 @@ public class VanChartTooltipPane extends AbstractVanChartScrollPane { @Override public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Tooltip"); + return Toolkit.i18nText("Fine-Design_Chart_Tooltip"); } protected VanChartPlotTooltipPane getTooltipPane(Plot plot) {