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. 252
      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. 103
      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);
}
public FurtherBasicBeanPane<? extends T> getSelectedPane(){
return cards.get(jcb.getSelectedIndex());
}
protected void addItemChangeEvent() {
jcb.addItemListener(new ItemListener() {
@Override
@ -121,6 +126,8 @@ public abstract class UIComboBoxPane<T> extends BasicBeanPane<T> {
}
}
@Override
public T 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

252
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 javax.swing.*;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 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 ChartTypeInterfaceManager classManager = null;
//所有图表存储器
private static LinkedHashMap<String, IndependentChartUIProvider> chartTypeInterfaces = new LinkedHashMap<String, IndependentChartUIProvider>();
private static LinkedHashMap<String, LinkedHashMap<String, IndependentChartUIProvider>> chartTypeInterfaces = new LinkedHashMap<String, LinkedHashMap<String, IndependentChartUIProvider>>();
//private static LinkedHashMap<String, IndependentChartUIProvider> chartTypeInterfaces = new LinkedHashMap<String, IndependentChartUIProvider>();
public synchronized static ChartTypeInterfaceManager getInstance() {
if (classManager == null) {
@ -121,36 +117,64 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
}
private static void readDefault() {
chartTypeInterfaces.put(ChartConstants.COLUMN_CHART, new ColumnIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.LINE_CHART, new LineIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.BAR_CHART, new BarIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.PIE_CHART, new PieIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.AREA_CHART, new AreaIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.SCATTER_CHART, new XYScatterIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.BUBBLE_CHART, new BubbleIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.RADAR_CHART, new RadarIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.STOCK_CHART, new StockIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.METER_CHART, new MeterIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.RANGE_CHART, new RangeIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.CUSTOM_CHART, new CustomIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.GANTT_CHART, new GanttIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.DONUT_CHART, new DonutIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.MAP_CHART, new MapIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.GIS_CHAER, new GisMapIndependentChartInterface());
chartTypeInterfaces.put(ChartConstants.FUNNEL_CHART, new FunnelIndependentChartInterface());
LinkedHashMap<String, IndependentChartUIProvider> chartUIList = new LinkedHashMap<String, IndependentChartUIProvider>();
chartUIList.put(ChartConstants.COLUMN_CHART, new ColumnIndependentChartInterface());
chartUIList.put(ChartConstants.LINE_CHART, new LineIndependentChartInterface());
chartUIList.put(ChartConstants.BAR_CHART, new BarIndependentChartInterface());
chartUIList.put(ChartConstants.PIE_CHART, new PieIndependentChartInterface());
chartUIList.put(ChartConstants.AREA_CHART, new AreaIndependentChartInterface());
chartUIList.put(ChartConstants.SCATTER_CHART, new XYScatterIndependentChartInterface());
chartUIList.put(ChartConstants.BUBBLE_CHART, new BubbleIndependentChartInterface());
chartUIList.put(ChartConstants.RADAR_CHART, new RadarIndependentChartInterface());
chartUIList.put(ChartConstants.STOCK_CHART, new StockIndependentChartInterface());
chartUIList.put(ChartConstants.METER_CHART, new MeterIndependentChartInterface());
chartUIList.put(ChartConstants.RANGE_CHART, new RangeIndependentChartInterface());
chartUIList.put(ChartConstants.CUSTOM_CHART, new CustomIndependentChartInterface());
chartUIList.put(ChartConstants.GANTT_CHART, new GanttIndependentChartInterface());
chartUIList.put(ChartConstants.DONUT_CHART, new DonutIndependentChartInterface());
chartUIList.put(ChartConstants.MAP_CHART, new MapIndependentChartInterface());
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) {
if (chartTypeInterfaces.get(plotID) != null) {
return chartTypeInterfaces.get(plotID).getIconPath();
if (chartTypeInterfaces != null) {
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 {
return StringUtils.EMPTY;
}
}
public static void addChartTypeInterface(IndependentChartUIProvider provider, String plotID) {
if (chartTypeInterfaces != null && !chartTypeInterfaces.containsKey(plotID)) {
chartTypeInterfaces.put(plotID, provider);
public static void addChartTypeInterface(IndependentChartUIProvider provider, String chartID, String plotID) {
if (chartTypeInterfaces != null){
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 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)) {
try {
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)) {
PluginMessage.remindUpdate(className);
} else {
ChartTypeInterfaceManager.getInstance().addChartTypeInterface(provider, plotID);
ChartTypeInterfaceManager.getInstance().addChartTypeInterface(provider, chartID, plotID);
}
} catch (ClassNotFoundException e) {
FRLogger.getLogger().error("class not found:" + e.getMessage());
@ -193,56 +217,165 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
* @param paneList pane容器
*/
public void addPlotTypePaneList(List<FurtherBasicBeanPane<? extends Chart>> paneList) {
Iterator iterator = chartTypeInterfaces.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry) iterator.next();
IndependentChartUIProvider creator = (IndependentChartUIProvider) entry.getValue();
paneList.add(creator.getPlotTypePane());
String chartID = (String) entry.getKey();
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];
}
/**
* 把chartID的pane加到list里
*
* @param chartID 图表类型
* @param paneList pane容器
*/
public void addPlotTypePaneList(List<FurtherBasicBeanPane<? extends Chart>> paneList, String chartID) {
///////////////////////////待更改///////////////////////////////
private String[] getTitle4PopupWindow(){
int size = 0;
if (chartTypeInterfaces != null){
Iterator iterator = chartTypeInterfaces.entrySet().iterator();
while (iterator.hasNext()){
Map.Entry entry = (Map.Entry) iterator.next();
IndependentChartUIProvider creator = (IndependentChartUIProvider) entry.getValue();
paneList.add(creator.getPlotTypePane());
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) {
return chartTypeInterfaces.get(plotID).getChartDataPane(listener);
Iterator iterator = chartTypeInterfaces.entrySet().iterator();
while (iterator.hasNext()){
Map.Entry entry = (Map.Entry) iterator.next();
String chartID = (String) entry.getKey();
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);
}
/**
* 获取对应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) {
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) {
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) {
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) {
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) {
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 是否使用默认的界面
*/
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)) {
return chartTypeInterfaces.get(plotID).isUseDefaultPane();
if (chartTypeInterfaces.containsKey(chartID) && chartTypeInterfaces.get(chartID).containsKey(plotID)) {
return chartTypeInterfaces.get(chartID).get(plotID).isUseDefaultPane();
}
return true;
@ -272,7 +418,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
extraChartDesignInterfaceList.add(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.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.SwitchState;
import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.beans.FurtherBasicBeanPane;
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 UIButton addButton;
private UIButton configButton;
private ArrayList<ChartChangeButton> indexList = new ArrayList<ChartChangeButton>();
private JPanel buttonPane;
@ -79,6 +80,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
public ChartTypeButtonPane() {
this.setLayout(new BorderLayout());
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();
this.add(buttonPane, BorderLayout.CENTER);
@ -88,8 +90,13 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
eastPane.setLayout(new BorderLayout());
eastPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 20));
eastPane.add(addButton, BorderLayout.NORTH);
eastPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 15));
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.addActionListener(addListener);
@ -121,7 +128,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
//获取图表收集器的状态
SwitchState state = editingCollection.calculateMultiChartMode();
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);
checkAddButtonVisible();
checkConfigButtonVisible();
}
private void checkAddButtonVisible() {
private void checkConfigButtonVisible() {
addButton.setVisible(true);
configButton.setVisible(true);
//新建一个collection
if(editingCollection != null && editingCollection.getChartCount() == 1){
//vanChart 不支持图表切换 目前
if(!ComparatorUtils.equals(editingCollection.getSelectedChart().getClass(), Chart.class)){
addButton.setVisible(false);
}
if(editingCollection.getState() == SwitchState.CHANGE){
//Chart 不支持图表切换
configButton.setVisible(editingCollection.getSelectedChart().supportChange());
}
}
@ -381,12 +387,21 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
for (int i = 0; i < count; i++) {
if (ComparatorUtils.equals(getButtonName(), editingCollection.getChartName(i))) {
editingCollection.removeNameObject(i);
if (i <= editingCollection.getSelectedIndex()){
editingCollection.setSelectedIndex(editingCollection.getSelectedIndex()-1);
}
break;
}
}
}
}
//获取图表收集器的状态
SwitchState state = editingCollection.calculateMultiChartMode();
if (SwitchState.isDynamicState(state) && parent != null){
parent.reactorChartTypePane(editingCollection);
}
relayoutPane();
}

103
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.dialog.BasicScrollPane;
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.ChartEditPane;
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.general.ComparatorUtils;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.List;
@ -47,6 +54,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
@Override
protected void layoutContentPane() {
leftcontentPane = createContentPane();
this.add(leftcontentPane);
}
@ -67,10 +75,6 @@ public class ChartTypePane extends AbstractChartAttrPane{
return content;
}
public void reactorChartTypePane(SwitchState state, ChartCollection collection){
}
/**
* 界面做为按钮时的图片位置. design_base
*/
@ -90,12 +94,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
@Override
protected List<FurtherBasicBeanPane<? extends Chart>> initPaneList() {
List<FurtherBasicBeanPane<? extends Chart>> paneList = new ArrayList<FurtherBasicBeanPane<? extends Chart>>();
if (editingCollection.getState() == SwitchState.DEFAULT) {
ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(paneList);
}else {
Chart chart = editingCollection.getSelectedChart();
ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(paneList, chart.getChartID());
}
return paneList;
}
@ -108,7 +107,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
int lastSelectIndex = editPane.getSelectedChartIndex(chart);
try{
Chart newDefaultChart = (Chart)((AbstractChartTypePane)cards.get(jcb.getSelectedIndex())).getDefaultChart().clone();
Chart newDefaultChart = (Chart)((AbstractChartTypePane)getSelectedPane()).getDefaultChart().clone();
if(!chart.accept(newDefaultChart.getClass())){
//vanChart 和 chart 之间切换
editingCollection.removeNameObject(editingCollection.getSelectedIndex());
@ -120,7 +119,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
}
//这一步会替换plot
((AbstractChartTypePane) cards.get(jcb.getSelectedIndex())).updateBean(chart);
((AbstractChartTypePane)getSelectedPane()).updateBean(chart);
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