From 01eea4751a78b5a363606e4e773b43a0d9c3822d Mon Sep 17 00:00:00 2001 From: zheng Date: Wed, 25 Jul 2018 11:13:29 +0800 Subject: [PATCH] =?UTF-8?q?CHART-2611=20=E5=8E=BB=E6=8E=89=E6=96=B0?= =?UTF-8?q?=E7=89=B9=E6=80=A7=E8=BF=99=E5=87=A0=E4=B8=AA=E5=AD=97=20?= =?UTF-8?q?=E5=87=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/ChartTypeInterfaceManager.java | 29 ++++++------- .../chart/gui/ChartTypeButtonPane.java | 14 +++++-- .../mainframe/chart/gui/ChartTypePane.java | 42 ++++++++++++++++--- 3 files changed, 60 insertions(+), 25 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 ee6c5a8a7..55f6076d8 100644 --- a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java @@ -39,7 +39,6 @@ import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.form.ui.ChartEditor; import com.fr.general.IOUtils; - import com.fr.plugin.chart.PiePlot4VanChart; import com.fr.plugin.chart.area.VanChartAreaPlot; import com.fr.plugin.chart.bubble.VanChartBubblePlot; @@ -84,7 +83,7 @@ import com.fr.van.chart.structure.desinger.StructureIndependentVanChartInterface import com.fr.van.chart.treemap.TreeMapIndependentVanChartInterface; import com.fr.van.chart.wordcloud.designer.WordCloudIndependentVanChartInterface; -import javax.swing.*; +import javax.swing.Icon; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -92,7 +91,9 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import static com.fr.chart.charttypes.ChartTypeManager.*; +import static com.fr.chart.charttypes.ChartTypeManager.CHART_PRIORITY; +import static com.fr.chart.charttypes.ChartTypeManager.VAN_CHART_PRIORITY; +import static com.fr.chart.charttypes.ChartTypeManager.enabledChart; /** * Created by eason on 14/12/29. @@ -254,17 +255,17 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr * * @param paneList pane容器 */ - public void addPlotTypePaneList(List> paneList) { + public void addPlotTypePaneList(List> paneList, Map>> allChartTypePane) { List priorityList = getPriorityInOrder(); for (Integer aPriorityList : priorityList) { String priority = String.valueOf(aPriorityList); - addPlotTypePaneList(priority, paneList); + addPlotTypePaneList(priority, paneList, allChartTypePane); } } - public void addPlotTypePaneList(String priority, List> paneList) { + public void addPlotTypePaneList(String priority, List> paneList, Map>> allChartTypePane) { if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority)) { @@ -279,22 +280,16 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr AbstractChartTypePane pane = entry.getValue().getPlotTypePane(); pane.setPlotID(plotID); paneList.add(pane); + + if (allChartTypePane.get(priority) == null) { + allChartTypePane.put(priority, new LinkedHashMap>()); + } + allChartTypePane.get(priority).put(plotID, pane); } } } } - - public void addPlotTypePaneList(List> paneList, - String priority, String plotID) { - if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority) && chartTypeInterfaces.get(priority).containsKey(plotID)) { - IndependentChartUIProvider provider = chartTypeInterfaces.get(priority).get(plotID); - AbstractChartTypePane pane = provider.getPlotTypePane(); - pane.setPlotID(plotID); - paneList.add(pane); - } - } - private static String getChartName(String plotID, IndependentChartUIProvider provider) { String name = provider.getPlotTypeTitle4PopupWindow(); if (StringUtils.isEmpty(name)) { 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 48f20d31b..98c1d842e 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 @@ -18,12 +18,20 @@ 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.general.ComparatorUtils; - import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.BoxLayout; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.GridLayout; +import java.awt.Image; +import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.FocusEvent; 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 d5435cf02..99c0db27d 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 @@ -26,7 +26,10 @@ import java.awt.CardLayout; 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; /** * 图表 属性表, 类型选择 界面. @@ -121,10 +124,13 @@ public class ChartTypePane extends AbstractChartAttrPane{ } class ComboBoxPane extends UIComboBoxPane{ + private Map>> allChartTypePane; + @Override protected List> initPaneList() { List> paneList = new ArrayList>(); - ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(paneList); + allChartTypePane = new LinkedHashMap>>(); + ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(paneList, allChartTypePane); return paneList; } @@ -198,7 +204,33 @@ public class ChartTypePane extends AbstractChartAttrPane{ }); } - public void relayout(ChartCollection collection){ + private void addAllCards() { + Iterator iterator = allChartTypePane.keySet().iterator(); + + while (iterator.hasNext()) { + addOnePriorityCards(iterator.next()); + } + } + + private void addOnePriorityCards(String priority) { + + Map> map = allChartTypePane.get(priority); + + Iterator>> iterator = map.entrySet().iterator(); + + while (iterator.hasNext()) { + cards.add(iterator.next().getValue()); + } + + } + + private void addOnePlotIDCards(String priority, String plotID) { + cards.add(allChartTypePane.get(priority).get(plotID)); + } + + //因为饼图(新特性)把(新特性)去掉了,和老的饼图同名,下拉框选项和typePane不能一一对应了 + //处理办法:这边除了重构 下拉项选项和cardNames 还需要把cards重构下(不需要init pane,只需要我需要的拿出来就好了) + private void relayout(ChartCollection collection){ //重构需要重构下拉框选项和cardNames Chart chart = collection.getSelectedChart(); String priority = chart.getPriority(); @@ -210,12 +242,12 @@ public class ChartTypePane extends AbstractChartAttrPane{ cards.clear(); if (enabledChart) { if (collection.getState() == SwitchState.DEFAULT) { - ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(cards); + addAllCards(); } else { - ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(priority, cards); + addOnePriorityCards(priority); } } else { - ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(cards, priority, plotID); + addOnePlotIDCards(priority, plotID); } //下拉框重构开始。为了防止重构是触发update