From 2f68f0db7c323a482b3a79a56dcb4780fa4f5b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Tue, 29 Dec 2020 13:54:48 +0800 Subject: [PATCH] =?UTF-8?q?CHART-17661=20=E5=A4=9A=E5=B1=82=E9=A5=BC?= =?UTF-8?q?=E5=9B=BE=E9=9D=A2=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/van/chart/designer/PlotFactory.java | 19 +++++++++++++++---- .../label/VanChartGaugePlotLabelPane.java | 4 ++-- 2 files changed, 17 insertions(+), 6 deletions(-) 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 ab46f5526..0f9db09fa 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 @@ -166,6 +166,12 @@ public class PlotFactory { tooltipContentMap.put(VanChartStructurePlot.class, VanChartStructureTooltipContentPane.class); } + private static Map, Class> labelMap = new HashMap<>(); + + static { + labelMap.put(PiePlot4VanChart.class, VanChartPiePlotLabelPane.class); + labelMap.put(VanChartGaugePlot.class, VanChartGaugePlotLabelPane.class); + } /** * 监控刷新 自动数据点提示Map @@ -208,10 +214,15 @@ public class PlotFactory { } public static VanChartPlotLabelPane createPlotLabelPane(Plot plot, VanChartStylePane stylePane, boolean inCondition) { - if (plot instanceof VanChartGaugePlot) { - return new VanChartGaugePlotLabelPane(plot, stylePane); - } else if (plot instanceof PiePlot4VanChart) { - return new VanChartPiePlotLabelPane(plot, stylePane, inCondition); + Class key = plot.getClass(); + if (labelMap.containsKey(key)) { + try { + Class cl = labelMap.get(key); + Constructor constructor = cl.getConstructor(Plot.class, VanChartStylePane.class, boolean.class); + return constructor.newInstance(plot, stylePane, inCondition); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } } return new VanChartPlotLabelPane(plot, stylePane, inCondition); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugePlotLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugePlotLabelPane.java index 9bc21a044..5861bb0c2 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugePlotLabelPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugePlotLabelPane.java @@ -25,8 +25,8 @@ public class VanChartGaugePlotLabelPane extends VanChartPlotLabelPane { private VanChartPlotLabelDetailPane gaugeValueLabelPane; - public VanChartGaugePlotLabelPane(Plot plot, VanChartStylePane parent) { - super(plot, parent); + public VanChartGaugePlotLabelPane(Plot plot, VanChartStylePane parent, boolean inCondition) { + super(plot, parent, inCondition); } protected void createLabelPane() {