From db03f46adfa11505e510dbe539befdeaa93186fa Mon Sep 17 00:00:00 2001 From: shine Date: Tue, 25 May 2021 19:52:00 +0800 Subject: [PATCH] =?UTF-8?q?CHART-18787=20design=20refactor:=E5=9B=BE?= =?UTF-8?q?=E8=A1=A8=E7=B1=BB=E5=9E=8B=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/ChartTypeInterfaceManager.java | 213 +++++------------- .../chart/gui/ChartTypeButtonPane.java | 10 +- .../mainframe/chart/gui/ChartTypePane.java | 58 +++-- 3 files changed, 110 insertions(+), 171 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java index b50c740a3..eb3520852 100644 --- a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java @@ -8,7 +8,6 @@ import com.fr.chart.fun.ChartTypeProvider; import com.fr.chartx.attr.ChartProvider; import com.fr.common.annotations.Compatible; import com.fr.design.beans.BasicBeanPane; -import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.chart.fun.ChartTypeUIProvider; import com.fr.design.chart.gui.ChartWidgetOption; import com.fr.design.condition.ConditionAttributesPane; @@ -46,7 +45,6 @@ import com.fr.general.GeneralContext; import com.fr.general.IOUtils; import com.fr.invoke.Reflect; import com.fr.locale.InterProviderFactory; -import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.PiePlot4VanChart; import com.fr.plugin.chart.area.VanChartAreaPlot; import com.fr.plugin.chart.box.VanChartBoxPlot; @@ -75,7 +73,6 @@ import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEventListener; import com.fr.plugin.solution.closeable.CloseableContainedMap; import com.fr.stable.ArrayUtils; -import com.fr.stable.AssistUtils; import com.fr.stable.StringUtils; import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import com.fr.van.chart.area.AreaIndependentVanChartInterface; @@ -100,17 +97,7 @@ import com.fr.van.chart.treemap.TreeMapIndependentVanChartInterface; import com.fr.van.chart.wordcloud.designer.WordCloudIndependentVanChartInterface; import javax.swing.Icon; -import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.awt.event.ActionListener; - -import static com.fr.chart.charttypes.ChartTypeManager.DEFAULT_PRIORITY; -import static com.fr.chart.charttypes.ChartTypeManager.DEPRECATED_CHART_PRIORITY; -import static com.fr.chart.charttypes.ChartTypeManager.VAN_CHART_PRIORITY; /** * Created by eason on 14/12/29. @@ -120,10 +107,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr private static ChartTypeInterfaceManager classManager = new ChartTypeInterfaceManager(); - private static LinkedHashMap> chartTypeInterfaces = - new LinkedHashMap>(); - - private static Map idAndPriorityMap = new HashMap(); + private static CloseableContainedMap chartTypeUIs = new CloseableContainedMap<>(HashMap.class); public static final String TYPE_PANE_DEFAULT_TITLE = "DEFAULT_NAME"; @@ -185,127 +169,69 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr private static void readVanChart() { - addChartTypeInterface(VAN_CHART_PRIORITY, PiePlot4VanChart.VAN_CHART_PIE_PLOT, new PieIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID, new VanColumnChartTypeUI()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartColumnPlot.VAN_CHART_BAR_PLOT_ID, new BarIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartLinePlot.VAN_CHART_LINE_PLOT, new LineIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartAreaPlot.VAN_CHART_AREA_PLOT_ID, new AreaIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartGaugePlot.VAN_CHART_GAUGE_PLOT, new GaugeIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartRadarPlot.VAN_CHART_RADAR_PLOT, new RadarIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartScatterPlot.VAN_CHART_SCATTER_PLOT_ID, new ScatterIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartBubblePlot.VAN_CHART_BUBBLE_PLOT_ID, new BubbleIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartCustomPlot.VAN_CHART_CUSTOM_PLOT_ID, new CustomIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartMultiPiePlot.VAN_CHART_MULTILAYER_PLOT_ID, new MultiPieIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartMapPlot.VAN_CHART_MAP_ID, new VanMapChartTypeUI()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartDrillMapPlot.VAN_CHART_DRILL_MAP_ID, new VanDrillMapChartTypeUI()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartTreeMapPlot.VAN_CHART_TREE_MAP_PLOT_ID, new TreeMapIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartFunnelPlot.VAN_CHART_FUNNEL_PLOT_ID, new FunnelIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartHeatMapPlot.VAN_CHART_HEAT_MAP_ID, new VanHeatMapChartTypeUI()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartWordCloudPlot.WORD_CLOUD_PLOT_ID, new WordCloudIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartGanttPlot.VAN_CHART_GANTT_PLOT_ID, new GanttIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartStructurePlot.STRUCTURE_PLOT_ID, new VanStructureChartTypeUI()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartBoxPlot.VAN_CHART_BOX_PLOT_ID, new BoxIndependentVanChartInterface()); + addChartTypeInterface(PiePlot4VanChart.VAN_CHART_PIE_PLOT, new PieIndependentVanChartInterface()); + addChartTypeInterface(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID, new VanColumnChartTypeUI()); + addChartTypeInterface(VanChartColumnPlot.VAN_CHART_BAR_PLOT_ID, new BarIndependentVanChartInterface()); + addChartTypeInterface(VanChartLinePlot.VAN_CHART_LINE_PLOT, new LineIndependentVanChartInterface()); + addChartTypeInterface(VanChartAreaPlot.VAN_CHART_AREA_PLOT_ID, new AreaIndependentVanChartInterface()); + addChartTypeInterface(VanChartGaugePlot.VAN_CHART_GAUGE_PLOT, new GaugeIndependentVanChartInterface()); + addChartTypeInterface(VanChartRadarPlot.VAN_CHART_RADAR_PLOT, new RadarIndependentVanChartInterface()); + addChartTypeInterface(VanChartScatterPlot.VAN_CHART_SCATTER_PLOT_ID, new ScatterIndependentVanChartInterface()); + addChartTypeInterface(VanChartBubblePlot.VAN_CHART_BUBBLE_PLOT_ID, new BubbleIndependentVanChartInterface()); + addChartTypeInterface(VanChartCustomPlot.VAN_CHART_CUSTOM_PLOT_ID, new CustomIndependentVanChartInterface()); + addChartTypeInterface(VanChartMultiPiePlot.VAN_CHART_MULTILAYER_PLOT_ID, new MultiPieIndependentVanChartInterface()); + addChartTypeInterface(VanChartMapPlot.VAN_CHART_MAP_ID, new VanMapChartTypeUI()); + addChartTypeInterface(VanChartDrillMapPlot.VAN_CHART_DRILL_MAP_ID, new VanDrillMapChartTypeUI()); + addChartTypeInterface(VanChartTreeMapPlot.VAN_CHART_TREE_MAP_PLOT_ID, new TreeMapIndependentVanChartInterface()); + addChartTypeInterface(VanChartFunnelPlot.VAN_CHART_FUNNEL_PLOT_ID, new FunnelIndependentVanChartInterface()); + addChartTypeInterface(VanChartHeatMapPlot.VAN_CHART_HEAT_MAP_ID, new VanHeatMapChartTypeUI()); + addChartTypeInterface(VanChartWordCloudPlot.WORD_CLOUD_PLOT_ID, new WordCloudIndependentVanChartInterface()); + addChartTypeInterface(VanChartGanttPlot.VAN_CHART_GANTT_PLOT_ID, new GanttIndependentVanChartInterface()); + addChartTypeInterface(VanChartStructurePlot.STRUCTURE_PLOT_ID, new VanStructureChartTypeUI()); + addChartTypeInterface(VanChartBoxPlot.VAN_CHART_BOX_PLOT_ID, new BoxIndependentVanChartInterface()); } private static void readDefault() { - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.COLUMN_CHART, new ColumnChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.LINE_CHART, new LineChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.BAR_CHART, new BarChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.PIE_CHART, new PieChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.AREA_CHART, new AreaChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.SCATTER_CHART, new XYScatterChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.BUBBLE_CHART, new BubbleChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.RADAR_CHART, new RadarChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.STOCK_CHART, new StockChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.METER_CHART, new MeterChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.RANGE_CHART, new RangeChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.CUSTOM_CHART, new CustomChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.GANTT_CHART, new GanttChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.DONUT_CHART, new DonutChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.MAP_CHART, new MapChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.GIS_CHAER, new GisMapChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.FUNNEL_CHART, new FunnelChartTypeUI()); - } - - private static void addChartTypeInterface(String priority, String plotID, ChartTypeUIProvider provider) { - - if (chartTypeInterfaces != null) { - if (!chartTypeInterfaces.containsKey(priority)) { - //新建一个具体图表列表 - CloseableContainedMap chartUIList - = new CloseableContainedMap(LinkedHashMap.class); - chartUIList.put(plotID, provider); - chartTypeInterfaces.put(priority, chartUIList); - } else { - Map chartUIList = chartTypeInterfaces.get(priority); - if (!chartUIList.containsKey(plotID)) { - chartUIList.put(plotID, provider); - } - } - idAndPriorityMap.put(plotID, priority); + addChartTypeInterface(ChartConstants.COLUMN_CHART, new ColumnChartTypeUI()); + addChartTypeInterface(ChartConstants.LINE_CHART, new LineChartTypeUI()); + addChartTypeInterface(ChartConstants.BAR_CHART, new BarChartTypeUI()); + addChartTypeInterface(ChartConstants.PIE_CHART, new PieChartTypeUI()); + addChartTypeInterface(ChartConstants.AREA_CHART, new AreaChartTypeUI()); + addChartTypeInterface(ChartConstants.SCATTER_CHART, new XYScatterChartTypeUI()); + addChartTypeInterface(ChartConstants.BUBBLE_CHART, new BubbleChartTypeUI()); + addChartTypeInterface(ChartConstants.RADAR_CHART, new RadarChartTypeUI()); + addChartTypeInterface(ChartConstants.STOCK_CHART, new StockChartTypeUI()); + addChartTypeInterface(ChartConstants.METER_CHART, new MeterChartTypeUI()); + addChartTypeInterface(ChartConstants.RANGE_CHART, new RangeChartTypeUI()); + addChartTypeInterface(ChartConstants.CUSTOM_CHART, new CustomChartTypeUI()); + addChartTypeInterface(ChartConstants.GANTT_CHART, new GanttChartTypeUI()); + addChartTypeInterface(ChartConstants.DONUT_CHART, new DonutChartTypeUI()); + addChartTypeInterface(ChartConstants.MAP_CHART, new MapChartTypeUI()); + addChartTypeInterface(ChartConstants.GIS_CHAER, new GisMapChartTypeUI()); + addChartTypeInterface(ChartConstants.FUNNEL_CHART, new FunnelChartTypeUI()); + } + + private static void addChartTypeInterface(String id, ChartTypeUIProvider provider) { + + if (chartTypeUIs != null) { + chartTypeUIs.put(id, provider); } } - private ChartTypeUIProvider getChartTypeInterface(String plotID) { - if (idAndPriorityMap.containsKey(plotID)) { - String priority = idAndPriorityMap.get(plotID); - if (chartTypeInterfaces.containsKey(priority)) { - return chartTypeInterfaces.get(priority).get(plotID); - } + private ChartTypeUIProvider getChartTypeInterface(String id) { + if (chartTypeUIs.containsKey(id)) { + return chartTypeUIs.get(id); } return null; } - /** - * 把所有的pane加到list里 - * - * @param paneList pane容器 - */ - public void addPlotTypePaneList(List> paneList, - Map>> allChartTypePane, - ActionListener autoButtonListener) { - - List priorityList = getPriorityInOrder(); - for (Integer aPriorityList : priorityList) { - String priority = String.valueOf(aPriorityList); - addPlotTypePaneList(priority, paneList, allChartTypePane, autoButtonListener); - } - } - - - public void addPlotTypePaneList(String priority, List> paneList, - Map>> allChartTypePane, - ActionListener autoButtonListener) { - - if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority)) { - - Map chartUIList = chartTypeInterfaces.get(priority); - - Iterator> iterator = chartUIList.entrySet().iterator(); - while (iterator.hasNext()) { - try { - Map.Entry entry = iterator.next(); - String plotID = entry.getKey(); - - AbstractChartTypePane pane = entry.getValue().getPlotTypePane(); - if (AssistUtils.equals(pane.title4PopupWindow(), TYPE_PANE_DEFAULT_TITLE)) { - continue; - } - pane.reLayout(plotID); - pane.registerButtonListener(autoButtonListener); - paneList.add(pane); - - if (allChartTypePane.get(priority) == null) { - allChartTypePane.put(priority, new LinkedHashMap>()); - } - allChartTypePane.get(priority).put(plotID, pane); - } catch (Throwable e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } + public AbstractChartTypePane getPlotTypePane(String id) { + if (chartTypeUIs.containsKey(id)) { + return chartTypeUIs.get(id).getPlotTypePane(); } + return null; } @Compatible @@ -313,23 +239,9 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr return getName(plotID); } - private List getPriorityInOrder() { - - List priorityList = new ArrayList(); - if (chartTypeInterfaces != null) { - Iterator iterator = chartTypeInterfaces.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry entry = (Map.Entry) iterator.next(); - String priority = (String) entry.getKey(); - priorityList.add(Integer.valueOf(priority)); - } - } - return ChartTypeManager.orderInPriority(priorityList); - } - public String getIconPath(String plotID) { - if (chartTypeInterfaces != null) { + if (chartTypeUIs != null) { ChartTypeUIProvider provider = getChartTypeInterface(plotID); if (provider != null) { return provider.getIconPath(); @@ -340,7 +252,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr public String[] getDemoImagePath(String chartID) { - if (chartTypeInterfaces != null) { + if (chartTypeUIs != null) { ChartTypeUIProvider provider = getChartTypeInterface(chartID); if (provider != null) { String[] result = null; @@ -396,7 +308,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr } public String[] getSubName(String chartID) { - if (chartTypeInterfaces != null) { + if (chartTypeUIs != null) { ChartTypeUIProvider provider = getChartTypeInterface(chartID); if (provider != null) { String[] subNames = null; @@ -429,7 +341,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr } public String getName(String chartID) { - if (chartTypeInterfaces != null) { + if (chartTypeUIs != null) { ChartTypeUIProvider provider = getChartTypeInterface(chartID); if (provider != null) { String name = null; @@ -574,9 +486,8 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr if (StringUtils.isEmpty(id)) { id = injection.getAttribute("plotID"); } - String priority = injection.getAttribute("priority", DEFAULT_PRIORITY); ChartTypeUIProvider instance = (ChartTypeUIProvider) injection.getObject(); - addChartTypeInterface(priority, id, instance); + addChartTypeInterface(id, instance); } } @@ -585,22 +496,18 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr public void demount(PluginSingleInjection injection) { if (isChartTypeUIProvider(injection)) { - String priority = injection.getAttribute("priority", DEFAULT_PRIORITY); String id = injection.getAttribute("chartID"); if (StringUtils.isEmpty(id)) { id = injection.getAttribute("plotID"); } - removeChartTypeInterface(priority, id); + removeChartTypeInterface(id); } } - private void removeChartTypeInterface(String priority, String plotID) { + private void removeChartTypeInterface(String id) { - if (chartTypeInterfaces != null) { - if (chartTypeInterfaces.containsKey(priority)) { - Map chartUIList = chartTypeInterfaces.get(priority); - chartUIList.remove(plotID); - } + if (chartTypeUIs != null) { + chartTypeUIs.remove(id); } } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java index 4d7673b3e..34778a73b 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java @@ -6,7 +6,6 @@ import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.chartx.attr.ChartProvider; import com.fr.design.beans.BasicBeanPane; -import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.dialog.DialogActionListener; import com.fr.design.dialog.UIDialog; import com.fr.design.event.UIObserver; @@ -17,6 +16,7 @@ import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.imenutable.UIMenuNameableCreator; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.mainframe.chart.gui.ChartTypePane.ComboBoxPane; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.vanchart.VanChart; @@ -26,9 +26,6 @@ import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JPanel; import javax.swing.SwingUtilities; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.FlowLayout; @@ -45,6 +42,9 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; /** * 图表 类型 增删 控制按钮界面. @@ -180,7 +180,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen public ChartProvider getChangeStateNewChart() { ChartProvider chart = editingCollection.getSelectedChartProvider(ChartProvider.class); String chartID = chart.getID(); - String priority = ChartTypeManager.getInstanceWithCheck().getPriority(chartID); + int priority = ChartTypeManager.getInstanceWithCheck().getPriority(chartID); return ChartTypeManager.getInstanceWithCheck().getFirstChart(priority); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java index 1fa61298a..553895a18 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java @@ -20,20 +20,21 @@ import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.design.module.DesignModuleFactory; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; +import com.fr.stable.AssistUtils; import com.fr.stable.StringUtils; import javax.swing.JPanel; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; /** * 图表 属性表, 类型选择 界面. @@ -138,14 +139,45 @@ public class ChartTypePane extends AbstractChartAttrPane { } } + /** + * 把所有的pane加到list里 + * + * @param paneList pane容器 + */ + private static void addPlotTypePaneList(List> paneList, + Map>> allChartTypePane, + ActionListener autoButtonListener) { + + + String[] chartIDs = ChartTypeManager.getInstance().getAllChartIDs(); + + for (String id : chartIDs) { + + AbstractChartTypePane pane = ChartTypeInterfaceManager.getInstance().getPlotTypePane(id); + if (AssistUtils.equals(pane.title4PopupWindow(), ChartTypeInterfaceManager.TYPE_PANE_DEFAULT_TITLE)) { + continue; + } + pane.reLayout(id); + pane.registerButtonListener(autoButtonListener); + paneList.add(pane); + + Integer priority = ChartTypeManager.getInstance().getPriority(id); + if (allChartTypePane.get(priority) == null) { + allChartTypePane.put(priority, new LinkedHashMap>()); + } + allChartTypePane.get(priority).put(id, pane); + } + } + class ComboBoxPane extends UIComboBoxPane { - private Map>> allChartTypePane; + //todo:refactor 图表切换过滤不应该根据优先级priority,应该给旧版本图表和新特性图表的图表类型信息分别增加一个switchID之类的 + private Map>> allChartTypePane; @Override protected List> initPaneList() { List> paneList = new ArrayList>(); - allChartTypePane = new LinkedHashMap>>(); - ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(paneList, allChartTypePane, autoButtonListener); + allChartTypePane = new LinkedHashMap>>(); + addPlotTypePaneList(paneList, allChartTypePane, autoButtonListener); return paneList; } @@ -205,18 +237,18 @@ public class ChartTypePane extends AbstractChartAttrPane { } private void addAllCards() { - Iterator iterator = allChartTypePane.keySet().iterator(); + Iterator iterator = allChartTypePane.keySet().iterator(); while (iterator.hasNext()) { addOnePriorityCards(iterator.next(), false); } } - private void addOnePriorityCards(String priority) { + private void addOnePriorityCards(int priority) { addOnePriorityCards(priority, true); } - private void addOnePriorityCards(String priority, boolean ignore) { + private void addOnePriorityCards(int priority, boolean ignore) { Map> map = allChartTypePane.get(priority); @@ -232,7 +264,7 @@ public class ChartTypePane extends AbstractChartAttrPane { } - private void addOnePlotIDCards(String priority, String plotID) { + private void addOnePlotIDCards(int priority, String plotID) { cards.add(allChartTypePane.get(priority).get(plotID)); } @@ -242,7 +274,7 @@ public class ChartTypePane extends AbstractChartAttrPane { //重构需要重构下拉框选项和cardNames ChartProvider chart = collection.getSelectedChartProvider(ChartProvider.class); String chartID = chart.getID(); - String priority = ChartTypeManager.getInstanceWithCheck().getPriority(chartID); + int priority = ChartTypeManager.getInstanceWithCheck().getPriority(chartID); boolean enabledChart = ChartTypeManager.enabledChart(chartID); String item = ChartTypeInterfaceManager.getInstance().getName(chartID);