Browse Source

图表切换-设计器界面

master
Fangjie Hu 8 years ago
parent
commit
e80e9ea05f
  1. 7
      designer_base/src/com/fr/design/gui/frpane/UIComboBoxPane.java
  2. BIN
      designer_base/src/com/fr/design/images/buttonicon/config.png
  3. 258
      designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java
  4. 1
      designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java
  5. 35
      designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java
  6. 105
      designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java
  7. 54
      designer_chart/src/com/fr/design/mainframe/chart/gui/item/FlexibleComboBox.java
  8. 37
      designer_chart/src/com/fr/design/mainframe/chart/gui/item/ItemEventType.java

7
designer_base/src/com/fr/design/gui/frpane/UIComboBoxPane.java

@ -56,6 +56,11 @@ public abstract class UIComboBoxPane<T> extends BasicBeanPane<T> {
jcb.setSelectedIndex(0); jcb.setSelectedIndex(0);
} }
public FurtherBasicBeanPane<? extends T> getSelectedPane(){
return cards.get(jcb.getSelectedIndex());
}
protected void addItemChangeEvent() { protected void addItemChangeEvent() {
jcb.addItemListener(new ItemListener() { jcb.addItemListener(new ItemListener() {
@Override @Override
@ -121,6 +126,8 @@ public abstract class UIComboBoxPane<T> extends BasicBeanPane<T> {
} }
} }
@Override @Override
public T updateBean() { public T updateBean() {
return cards.get(jcb.getSelectedIndex()).updateBean(); return cards.get(jcb.getSelectedIndex()).updateBean();

BIN
designer_base/src/com/fr/design/images/buttonicon/config.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 B

258
designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java

@ -38,10 +38,7 @@ import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import javax.swing.*; import javax.swing.*;
import java.util.Iterator; import java.util.*;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/** /**
* Created by eason on 14/12/29. * Created by eason on 14/12/29.
@ -54,9 +51,8 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
private static ClassLoader loader = Thread.currentThread().getContextClassLoader(); private static ClassLoader loader = Thread.currentThread().getContextClassLoader();
private static ChartTypeInterfaceManager classManager = null; private static ChartTypeInterfaceManager classManager = null;
private static LinkedHashMap<String, LinkedHashMap<String, IndependentChartUIProvider>> chartTypeInterfaces = new LinkedHashMap<String, LinkedHashMap<String, IndependentChartUIProvider>>();
//所有图表存储器 //private static LinkedHashMap<String, IndependentChartUIProvider> chartTypeInterfaces = new LinkedHashMap<String, IndependentChartUIProvider>();
private static LinkedHashMap<String, IndependentChartUIProvider> chartTypeInterfaces = new LinkedHashMap<String, IndependentChartUIProvider>();
public synchronized static ChartTypeInterfaceManager getInstance() { public synchronized static ChartTypeInterfaceManager getInstance() {
if (classManager == null) { if (classManager == null) {
@ -121,36 +117,64 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
} }
private static void readDefault() { private static void readDefault() {
chartTypeInterfaces.put(ChartConstants.COLUMN_CHART, new ColumnIndependentChartInterface()); LinkedHashMap<String, IndependentChartUIProvider> chartUIList = new LinkedHashMap<String, IndependentChartUIProvider>();
chartTypeInterfaces.put(ChartConstants.LINE_CHART, new LineIndependentChartInterface()); chartUIList.put(ChartConstants.COLUMN_CHART, new ColumnIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.BAR_CHART, new BarIndependentChartInterface()); chartUIList.put(ChartConstants.LINE_CHART, new LineIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.PIE_CHART, new PieIndependentChartInterface()); chartUIList.put(ChartConstants.BAR_CHART, new BarIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.AREA_CHART, new AreaIndependentChartInterface()); chartUIList.put(ChartConstants.PIE_CHART, new PieIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.SCATTER_CHART, new XYScatterIndependentChartInterface()); chartUIList.put(ChartConstants.AREA_CHART, new AreaIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.BUBBLE_CHART, new BubbleIndependentChartInterface()); chartUIList.put(ChartConstants.SCATTER_CHART, new XYScatterIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.RADAR_CHART, new RadarIndependentChartInterface()); chartUIList.put(ChartConstants.BUBBLE_CHART, new BubbleIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.STOCK_CHART, new StockIndependentChartInterface()); chartUIList.put(ChartConstants.RADAR_CHART, new RadarIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.METER_CHART, new MeterIndependentChartInterface()); chartUIList.put(ChartConstants.STOCK_CHART, new StockIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.RANGE_CHART, new RangeIndependentChartInterface()); chartUIList.put(ChartConstants.METER_CHART, new MeterIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.CUSTOM_CHART, new CustomIndependentChartInterface()); chartUIList.put(ChartConstants.RANGE_CHART, new RangeIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.GANTT_CHART, new GanttIndependentChartInterface()); chartUIList.put(ChartConstants.CUSTOM_CHART, new CustomIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.DONUT_CHART, new DonutIndependentChartInterface()); chartUIList.put(ChartConstants.GANTT_CHART, new GanttIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.MAP_CHART, new MapIndependentChartInterface()); chartUIList.put(ChartConstants.DONUT_CHART, new DonutIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.GIS_CHAER, new GisMapIndependentChartInterface()); chartUIList.put(ChartConstants.MAP_CHART, new MapIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.FUNNEL_CHART, new FunnelIndependentChartInterface()); chartUIList.put(ChartConstants.GIS_CHAER, new GisMapIndependentChartInterface());
chartUIList.put(ChartConstants.FUNNEL_CHART, new FunnelIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.CHART_ID, chartUIList);
} }
public String getIconPath(String plotID) { public String getIconPath(String plotID) {
if (chartTypeInterfaces.get(plotID) != null) { if (chartTypeInterfaces != null) {
return chartTypeInterfaces.get(plotID).getIconPath(); Iterator iterator = chartTypeInterfaces.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry) iterator.next();
String chartID = (String) entry.getKey();
String imagePath = getIconPath(chartID, plotID);
if (!StringUtils.isEmpty(imagePath)) {
return imagePath;
}
}
}
return StringUtils.EMPTY;
}
private String getIconPath(String chartID, String plotID) {
if (chartTypeInterfaces.get(chartID) != null && chartTypeInterfaces.get(chartID).get(plotID) != null) {
return chartTypeInterfaces.get(chartID).get(plotID).getIconPath();
}else { }else {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
} }
public static void addChartTypeInterface(IndependentChartUIProvider provider, String plotID) { public static void addChartTypeInterface(IndependentChartUIProvider provider, String chartID, String plotID) {
if (chartTypeInterfaces != null && !chartTypeInterfaces.containsKey(plotID)) { if (chartTypeInterfaces != null){
chartTypeInterfaces.put(plotID, provider); if (!chartTypeInterfaces.containsKey(chartID)){
//新建一个具体图表列表
LinkedHashMap<String, IndependentChartUIProvider> chartUIList = new LinkedHashMap<String, IndependentChartUIProvider>();
chartUIList.put(plotID, provider);
chartTypeInterfaces.put(chartID, chartUIList);
}else {
LinkedHashMap<String, IndependentChartUIProvider> chartUIList = chartTypeInterfaces.get(chartID);
if (!chartUIList.containsKey(plotID)) {
chartUIList.put(plotID, provider);
}
}
} }
} }
@ -160,7 +184,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
* @param className 类名 * @param className 类名
* @param plotID 标志ID * @param plotID 标志ID
*/ */
public void addChartInterface(String className, String plotID, PluginSimplify simplify) { public void addChartInterface(String className, String chartID, String plotID, PluginSimplify simplify) {
if (StringUtils.isNotBlank(className)) { if (StringUtils.isNotBlank(className)) {
try { try {
Class<?> clazz = Class.forName(className); Class<?> clazz = Class.forName(className);
@ -172,7 +196,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
if (PluginCollector.getCollector().isError(provider, IndependentChartUIProvider.CURRENT_API_LEVEL, simplify.getPluginName()) || !containsChart(plotID)) { if (PluginCollector.getCollector().isError(provider, IndependentChartUIProvider.CURRENT_API_LEVEL, simplify.getPluginName()) || !containsChart(plotID)) {
PluginMessage.remindUpdate(className); PluginMessage.remindUpdate(className);
} else { } else {
ChartTypeInterfaceManager.getInstance().addChartTypeInterface(provider, plotID); ChartTypeInterfaceManager.getInstance().addChartTypeInterface(provider, chartID, plotID);
} }
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
FRLogger.getLogger().error("class not found:" + e.getMessage()); FRLogger.getLogger().error("class not found:" + e.getMessage());
@ -193,56 +217,165 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
* @param paneList pane容器 * @param paneList pane容器
*/ */
public void addPlotTypePaneList(List<FurtherBasicBeanPane<? extends Chart>> paneList) { public void addPlotTypePaneList(List<FurtherBasicBeanPane<? extends Chart>> paneList) {
Iterator iterator = chartTypeInterfaces.entrySet().iterator(); Iterator iterator = chartTypeInterfaces.entrySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry) iterator.next(); Map.Entry entry = (Map.Entry) iterator.next();
IndependentChartUIProvider creator = (IndependentChartUIProvider) entry.getValue(); String chartID = (String) entry.getKey();
paneList.add(creator.getPlotTypePane()); Iterator chartUIIterator = chartTypeInterfaces.get(chartID).entrySet().iterator();
while (chartUIIterator.hasNext()) {
Map.Entry chartUIEntry = (Map.Entry) chartUIIterator.next();
IndependentChartUIProvider provider = (IndependentChartUIProvider) chartUIEntry.getValue();
paneList.add(provider.getPlotTypePane());
}
} }
}
public String[] getTitle4PopupWindow(String chartID){
if (chartID.isEmpty()){
return getTitle4PopupWindow();
}
String[] names = new String[getChartSize(chartID)];
if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(chartID)){
HashMap<String, IndependentChartUIProvider> chartUIList = chartTypeInterfaces.get(chartID);
Iterator iterator = chartUIList.entrySet().iterator();
int i = 0;
while (iterator.hasNext()){
Map.Entry entry = (Map.Entry) iterator.next();
IndependentChartUIProvider provider = (IndependentChartUIProvider) entry.getValue();
names[i++] = provider.getPlotTypePane().title4PopupWindow();
}
return names;
}
return new String[0];
} }
/** private String[] getTitle4PopupWindow(){
* 把chartID的pane加到list里 int size = 0;
* if (chartTypeInterfaces != null){
* @param chartID 图表类型 Iterator iterator = chartTypeInterfaces.entrySet().iterator();
* @param paneList pane容器 while (iterator.hasNext()){
*/ Map.Entry entry = (Map.Entry) iterator.next();
public void addPlotTypePaneList(List<FurtherBasicBeanPane<? extends Chart>> paneList, String chartID) { String chartID = (String) entry.getKey();
///////////////////////////待更改/////////////////////////////// size += getChartSize(chartID);
}
String[] names = new String[size];
int index = 0;
Iterator i = chartTypeInterfaces.entrySet().iterator();
while (i.hasNext()){
Map.Entry entry = (Map.Entry) i.next();
String chartID = (String) entry.getKey();
Iterator chartUI = chartTypeInterfaces.get(chartID).entrySet().iterator();
while (chartUI.hasNext()){
Map.Entry chartUIEntry = (Map.Entry) chartUI.next();
IndependentChartUIProvider provider = (IndependentChartUIProvider) chartUIEntry.getValue();
names[index++] = provider.getPlotTypePane().title4PopupWindow();
}
}
return names;
}
return new String[0];
}
public ChartDataPane getChartDataPane(String plotID, AttributeChangeListener listener) {
Iterator iterator = chartTypeInterfaces.entrySet().iterator(); Iterator iterator = chartTypeInterfaces.entrySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()){
Map.Entry entry = (Map.Entry) iterator.next(); Map.Entry entry = (Map.Entry) iterator.next();
IndependentChartUIProvider creator = (IndependentChartUIProvider) entry.getValue(); String chartID = (String) entry.getKey();
paneList.add(creator.getPlotTypePane()); return getChartDataPane(chartID, plotID, listener);
} }
return getChartDataPane(ChartConstants.DEFAULT_CHART_ID, plotID, listener);
} }
private ChartDataPane getChartDataPane(String chartID, String plotID, AttributeChangeListener listener) {
return chartTypeInterfaces.get(chartID).get(plotID).getChartDataPane(listener);
}
public ChartDataPane getChartDataPane(String plotID, AttributeChangeListener listener) { /**
return chartTypeInterfaces.get(plotID).getChartDataPane(listener); * 获取对应ID的图表数量
* @param chartID
* @return
*/
private int getChartSize(String chartID){
if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(chartID)){
return chartTypeInterfaces.get(chartID).size();
}
return 0;
} }
public AbstractChartAttrPane[] getAttrPaneArray(String plotID, AttributeChangeListener listener) { public AbstractChartAttrPane[] getAttrPaneArray(String plotID, AttributeChangeListener listener) {
return chartTypeInterfaces.get(plotID).getAttrPaneArray(listener); Iterator iterator = chartTypeInterfaces.entrySet().iterator();
while (iterator.hasNext()){
Map.Entry entry = (Map.Entry) iterator.next();
String chartID = (String) entry.getKey();
return getAttrPaneArray(chartID, plotID, listener);
}
return getAttrPaneArray(ChartConstants.DEFAULT_CHART_ID, plotID, listener);
}
private AbstractChartAttrPane[] getAttrPaneArray(String chartID, String plotID, AttributeChangeListener listener) {
return chartTypeInterfaces.get(chartID).get(plotID).getAttrPaneArray(listener);
} }
public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) {
return chartTypeInterfaces.get(plot.getPlotID()).getTableDataSourcePane(plot, parent); Iterator iterator = chartTypeInterfaces.entrySet().iterator();
while (iterator.hasNext()){
Map.Entry entry = (Map.Entry) iterator.next();
String chartID = (String) entry.getKey();
return getTableDataSourcePane(chartID, plot, parent);
}
return getTableDataSourcePane(ChartConstants.DEFAULT_CHART_ID, plot, parent);
}
private AbstractTableDataContentPane getTableDataSourcePane(String chartID, Plot plot, ChartDataPane parent) {
return chartTypeInterfaces.get(chartID).get(plot.getPlotID()).getTableDataSourcePane(plot, parent);
} }
public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) { public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) {
return chartTypeInterfaces.get(plot.getPlotID()).getReportDataSourcePane(plot, parent); Iterator iterator = chartTypeInterfaces.entrySet().iterator();
while (iterator.hasNext()){
Map.Entry entry = (Map.Entry) iterator.next();
String chartID = (String) entry.getKey();
return getReportDataSourcePane(chartID, plot, parent);
}
return getReportDataSourcePane(ChartConstants.DEFAULT_CHART_ID, plot, parent);
}
private AbstractReportDataContentPane getReportDataSourcePane(String chartID, Plot plot, ChartDataPane parent) {
return chartTypeInterfaces.get(chartID).get(plot.getPlotID()).getReportDataSourcePane(plot, parent);
} }
public ConditionAttributesPane getPlotConditionPane(Plot plot) { public ConditionAttributesPane getPlotConditionPane(Plot plot) {
return chartTypeInterfaces.get(plot.getPlotID()).getPlotConditionPane(plot); Iterator iterator = chartTypeInterfaces.entrySet().iterator();
while (iterator.hasNext()){
Map.Entry entry = (Map.Entry) iterator.next();
String chartID = (String) entry.getKey();
return getPlotConditionPane(chartID, plot);
}
return getPlotConditionPane(ChartConstants.DEFAULT_CHART_ID, plot);
}
private ConditionAttributesPane getPlotConditionPane(String chartID, Plot plot) {
return chartTypeInterfaces.get(chartID).get(plot.getPlotID()).getPlotConditionPane(plot);
} }
public BasicBeanPane<Plot> getPlotSeriesPane(ChartStylePane parent, Plot plot) { public BasicBeanPane<Plot> getPlotSeriesPane(ChartStylePane parent, Plot plot) {
return chartTypeInterfaces.get(plot.getPlotID()).getPlotSeriesPane(parent, plot); Iterator iterator = chartTypeInterfaces.entrySet().iterator();
while (iterator.hasNext()){
Map.Entry entry = (Map.Entry) iterator.next();
String chartID = (String) entry.getKey();
return getPlotSeriesPane(chartID, parent, plot);
}
return getPlotSeriesPane(ChartConstants.DEFAULT_CHART_ID, parent, plot);
}
private BasicBeanPane<Plot> getPlotSeriesPane(String chartID, ChartStylePane parent, Plot plot) {
return chartTypeInterfaces.get(chartID).get(plot.getPlotID()).getPlotSeriesPane(parent, plot);
} }
/** /**
@ -252,9 +385,22 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
* @return 是否使用默认的界面 * @return 是否使用默认的界面
*/ */
public boolean isUseDefaultPane(String plotID) { public boolean isUseDefaultPane(String plotID) {
Iterator iterator = chartTypeInterfaces.entrySet().iterator();
while (iterator.hasNext()){
Map.Entry entry = (Map.Entry) iterator.next();
String chartID = (String) entry.getKey();
if (chartTypeInterfaces.get(chartID).containsKey(plotID)){
return isUseDefaultPane(chartID, plotID);
}
}
return true;
}
private boolean isUseDefaultPane(String chartID, String plotID){
if (chartTypeInterfaces.containsKey(plotID)) { if (chartTypeInterfaces.containsKey(chartID) && chartTypeInterfaces.get(chartID).containsKey(plotID)) {
return chartTypeInterfaces.get(plotID).isUseDefaultPane(); return chartTypeInterfaces.get(chartID).get(plotID).isUseDefaultPane();
} }
return true; return true;
@ -272,7 +418,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
extraChartDesignInterfaceList.add(tagName); extraChartDesignInterfaceList.add(tagName);
} }
if (IndependentChartUIProvider.XML_TAG.equals(tagName)) { if (IndependentChartUIProvider.XML_TAG.equals(tagName)) {
addChartInterface(reader.getAttrAsString("class", ""), reader.getAttrAsString("plotID", ""), simplify); addChartInterface(reader.getAttrAsString("class", ""), reader.getAttrAsString("chartID", ChartConstants.DEFAULT_CHART_ID),reader.getAttrAsString("plotID", ""), simplify);
} }
} }
} }

1
designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java

@ -4,6 +4,7 @@ package com.fr.design.mainframe.chart;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.SwitchState;
import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;

35
designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java

@ -36,6 +36,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
private static final int COL_COUNT = 3; private static final int COL_COUNT = 3;
private UIButton addButton; private UIButton addButton;
private UIButton configButton;
private ArrayList<ChartChangeButton> indexList = new ArrayList<ChartChangeButton>(); private ArrayList<ChartChangeButton> indexList = new ArrayList<ChartChangeButton>();
private JPanel buttonPane; private JPanel buttonPane;
@ -79,6 +80,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
public ChartTypeButtonPane() { public ChartTypeButtonPane() {
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png"));
configButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/config.png"));
buttonPane = new JPanel(); buttonPane = new JPanel();
this.add(buttonPane, BorderLayout.CENTER); this.add(buttonPane, BorderLayout.CENTER);
@ -88,8 +90,13 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
eastPane.setLayout(new BorderLayout()); eastPane.setLayout(new BorderLayout());
eastPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 20)); eastPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 15));
eastPane.add(addButton, BorderLayout.NORTH); JPanel button = new JPanel();
button.setPreferredSize(new Dimension(45, 20));
button.setLayout(new GridLayout(1, 2, 5, 0));
button.add(addButton);
button.add(configButton);
eastPane.add(button, BorderLayout.NORTH);
addButton.setPreferredSize(new Dimension(20, 20)); addButton.setPreferredSize(new Dimension(20, 20));
addButton.addActionListener(addListener); addButton.addActionListener(addListener);
@ -121,7 +128,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
//获取图表收集器的状态 //获取图表收集器的状态
SwitchState state = editingCollection.calculateMultiChartMode(); SwitchState state = editingCollection.calculateMultiChartMode();
if (SwitchState.isDynamicState(state) && parent != null){ if (SwitchState.isDynamicState(state) && parent != null){
parent.reactorChartTypePane(state, editingCollection); parent.reactorChartTypePane(editingCollection);
} }
} }
@ -260,17 +267,16 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
} }
layoutPane(buttonPane); layoutPane(buttonPane);
checkAddButtonVisible(); checkConfigButtonVisible();
} }
private void checkAddButtonVisible() { private void checkConfigButtonVisible() {
addButton.setVisible(true); addButton.setVisible(true);
configButton.setVisible(true);
//新建一个collection //新建一个collection
if(editingCollection != null && editingCollection.getChartCount() == 1){ if(editingCollection.getState() == SwitchState.CHANGE){
//vanChart 不支持图表切换 目前 //Chart 不支持图表切换
if(!ComparatorUtils.equals(editingCollection.getSelectedChart().getClass(), Chart.class)){ configButton.setVisible(editingCollection.getSelectedChart().supportChange());
addButton.setVisible(false);
}
} }
} }
@ -381,12 +387,21 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
if (ComparatorUtils.equals(getButtonName(), editingCollection.getChartName(i))) { if (ComparatorUtils.equals(getButtonName(), editingCollection.getChartName(i))) {
editingCollection.removeNameObject(i); editingCollection.removeNameObject(i);
if (i <= editingCollection.getSelectedIndex()){
editingCollection.setSelectedIndex(editingCollection.getSelectedIndex()-1);
}
break; break;
} }
} }
} }
} }
//获取图表收集器的状态
SwitchState state = editingCollection.calculateMultiChartMode();
if (SwitchState.isDynamicState(state) && parent != null){
parent.reactorChartTypePane(editingCollection);
}
relayoutPane(); relayoutPane();
} }

105
designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java

@ -10,13 +10,20 @@ import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.dialog.BasicScrollPane; import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.gui.frpane.UIComboBoxPane; import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.AbstractChartAttrPane;
import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.mainframe.chart.gui.item.FlexibleComboBox;
import com.fr.design.mainframe.chart.gui.item.ItemEventType;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -47,6 +54,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
@Override @Override
protected void layoutContentPane() { protected void layoutContentPane() {
leftcontentPane = createContentPane(); leftcontentPane = createContentPane();
this.add(leftcontentPane); this.add(leftcontentPane);
} }
@ -67,10 +75,6 @@ public class ChartTypePane extends AbstractChartAttrPane{
return content; return content;
} }
public void reactorChartTypePane(SwitchState state, ChartCollection collection){
}
/** /**
* 界面做为按钮时的图片位置. design_base * 界面做为按钮时的图片位置. design_base
*/ */
@ -90,12 +94,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
@Override @Override
protected List<FurtherBasicBeanPane<? extends Chart>> initPaneList() { protected List<FurtherBasicBeanPane<? extends Chart>> initPaneList() {
List<FurtherBasicBeanPane<? extends Chart>> paneList = new ArrayList<FurtherBasicBeanPane<? extends Chart>>(); List<FurtherBasicBeanPane<? extends Chart>> paneList = new ArrayList<FurtherBasicBeanPane<? extends Chart>>();
if (editingCollection.getState() == SwitchState.DEFAULT) { ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(paneList);
ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(paneList);
}else {
Chart chart = editingCollection.getSelectedChart();
ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(paneList, chart.getChartID());
}
return paneList; return paneList;
} }
@ -108,7 +107,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
int lastSelectIndex = editPane.getSelectedChartIndex(chart); int lastSelectIndex = editPane.getSelectedChartIndex(chart);
try{ try{
Chart newDefaultChart = (Chart)((AbstractChartTypePane)cards.get(jcb.getSelectedIndex())).getDefaultChart().clone(); Chart newDefaultChart = (Chart)((AbstractChartTypePane)getSelectedPane()).getDefaultChart().clone();
if(!chart.accept(newDefaultChart.getClass())){ if(!chart.accept(newDefaultChart.getClass())){
//vanChart 和 chart 之间切换 //vanChart 和 chart 之间切换
editingCollection.removeNameObject(editingCollection.getSelectedIndex()); editingCollection.removeNameObject(editingCollection.getSelectedIndex());
@ -120,7 +119,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
} }
//这一步会替换plot //这一步会替换plot
((AbstractChartTypePane) cards.get(jcb.getSelectedIndex())).updateBean(chart); ((AbstractChartTypePane)getSelectedPane()).updateBean(chart);
Plot plot = chart.getPlot(); Plot plot = chart.getPlot();
@ -140,6 +139,88 @@ public class ChartTypePane extends AbstractChartAttrPane{
} }
} }
} }
protected UIComboBox createComboBox() {
return new FlexibleComboBox();
}
@Override
protected void addItemChangeEvent() {
jcb.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
FlexibleComboBox fcb = (FlexibleComboBox)jcb;
if (fcb.isReactor()){
return;
}
comboBoxItemStateChanged();
CardLayout cl = (CardLayout)cardPane.getLayout();
cl.show(cardPane, cardNames[jcb.getSelectedIndex()]);
}
});
}
public void reactor(ChartCollection collection){
//重构前存储所选择的下拉选项
Object item = jcb.getSelectedItem();
//重构需要重构下拉框选项和cardNames
Chart chart = collection.getSelectedChart();
String chartID = chart.getChartID();
if (collection.getState() == SwitchState.DEFAULT){
chartID = StringUtils.EMPTY;
}
//第一步就是重构cardNames
cardNames = ChartTypeInterfaceManager.getInstance().getTitle4PopupWindow(chartID);
//重构下拉框选项
FlexibleComboBox fcb = (FlexibleComboBox)jcb;
fcb.setItemEvenType(ItemEventType.REACTOR);
fcb.removeAllItems();
for (int i = 0; i < this.cardNames.length; i++) {
fcb.addItem(cardNames[i]);
}
//重新选择选中的下拉项
jcb.setSelectedItem(item);
fcb.setItemEvenType(ItemEventType.DEFAULT);
}
@Override
public void populateBean(Chart ob) {
for (int i = 0; i < this.cards.size(); i++) {
FurtherBasicBeanPane pane = cards.get(i);
if (pane.accept(ob)) {
pane.populateBean(ob);
Object item = pane.title4PopupWindow();
for (int j = 0; j < cardNames.length; j++) {
if (ComparatorUtils.equals(item, cardNames[j])) {
jcb.setSelectedIndex(j);
}
}
return;
}
}
}
@Override
public Chart updateBean() {
return getSelectedPane().updateBean();
}
@Override
public FurtherBasicBeanPane<? extends Chart> getSelectedPane(){
Object item = jcb.getSelectedItem();
for (int i = 0; i < cards.size(); i++){
if (ComparatorUtils.equals(item, cards.get(i).title4PopupWindow())){
return cards.get(i);
}
}
return cards.get(0);
}
}
public void reactorChartTypePane(ChartCollection collection){
chartTypePane.reactor(collection);
} }
/** /**

54
designer_chart/src/com/fr/design/mainframe/chart/gui/item/FlexibleComboBox.java

@ -0,0 +1,54 @@
package com.fr.design.mainframe.chart.gui.item;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.gui.icombobox.UIComboBox;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* Created by hufan on 2016/10/11.
*/
public class FlexibleComboBox extends UIComboBox {
//当前下拉框处理的事件类型
private ItemEventType itemEvenType = ItemEventType.DEFAULT;
public boolean isReactor(){
return itemEvenType == ItemEventType.REACTOR;
}
public ItemEventType getItemEvenType() {
return itemEvenType;
}
public void setItemEvenType(ItemEventType itemEvenType) {
this.itemEvenType = itemEvenType;
}
@Override
protected void initListener() {
if (shouldResponseChangeListener()) {
this.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
fireSetGlobalName();
}
});
this.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (uiObserverListener == null) {
return;
}
fireSetGlobalName();
//只有不在重构状态才会触发下拉框选择时的改变事件
if (e.getStateChange() == ItemEvent.SELECTED && !isReactor()) {
uiObserverListener.doChange();
}
}
});
}
}
}

37
designer_chart/src/com/fr/design/mainframe/chart/gui/item/ItemEventType.java

@ -0,0 +1,37 @@
package com.fr.design.mainframe.chart.gui.item;
import com.fr.general.ComparatorUtils;
/**
* Created by hufan on 2016/10/11.
*/
public enum ItemEventType {
REACTOR("reactor"),//重构选项
DEFAULT("default")//默认选项操作
;
//这个String会存起来的,不能随意更改。
private String type;
private ItemEventType(String type){
this.type = type;
}
public String getType() {
return this.type;
}
private static ItemEventType[] types;
public static ItemEventType parse(String type){
if(types == null){
types = ItemEventType.values();
}
for(ItemEventType itemEventType : types){
if(ComparatorUtils.equals(itemEventType.getType(), type)){
return itemEventType;
}
}
return DEFAULT;
}
}
Loading…
Cancel
Save