Browse Source

Merge pull request #392 in BA/design from ~XIAOHU/design:dev to dev

* commit '4c273165e5e329e379ceff9f718849c6f3f55ad7':
  update
  updae
  图标切换
  图表切换-设计器界面
  新老图表都做插件
  提升就图表级别,当做新图表
  切换结构设计
  重绘
  update
  update
  update
  图表切换-未完成
  uu
  update
  自定义属性
master
superman 8 years ago
parent
commit
5b29690188
  1. 1
      designer_base/src/com/fr/design/extra/PluginHelper.java
  2. 21
      designer_base/src/com/fr/design/gui/frpane/UIComboBoxPane.java
  3. 6
      designer_base/src/com/fr/design/gui/icombobox/UIComboBox.java
  4. BIN
      designer_base/src/com/fr/design/images/buttonicon/config.png
  5. 253
      designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java
  6. 2
      designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java
  7. 16
      designer_chart/src/com/fr/design/chart/gui/ChartComponent.java
  8. 50
      designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java
  9. 97
      designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java
  10. 54
      designer_chart/src/com/fr/design/mainframe/chart/gui/item/FlexibleComboBox.java
  11. 37
      designer_chart/src/com/fr/design/mainframe/chart/gui/item/ItemEventType.java

1
designer_base/src/com/fr/design/extra/PluginHelper.java

@ -153,7 +153,6 @@ public class PluginHelper {
installDependenceOnline(currentID, needInstallDependence); installDependenceOnline(currentID, needInstallDependence);
} }
/** /**
* 构造一个下载UI * 构造一个下载UI
* @param currentID * @param currentID

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

@ -25,7 +25,7 @@ public abstract class UIComboBoxPane<T> extends BasicBeanPane<T> {
protected JPanel cardPane; protected JPanel cardPane;
protected List<FurtherBasicBeanPane<? extends T>> cards; protected List<FurtherBasicBeanPane<? extends T>> cards;
private String[] cardNames; protected String[] cardNames;
public UIComboBoxPane() { public UIComboBoxPane() {
cards = initPaneList(); cards = initPaneList();
@ -49,6 +49,19 @@ public abstract class UIComboBoxPane<T> extends BasicBeanPane<T> {
addComboBoxItem(cards, i); addComboBoxItem(cards, i);
} }
addItemChangeEvent();
initLayout();
jcb.setSelectedIndex(0);
}
public FurtherBasicBeanPane<? extends T> getSelectedPane(){
return cards.get(jcb.getSelectedIndex());
}
protected void addItemChangeEvent() {
jcb.addItemListener(new ItemListener() { jcb.addItemListener(new ItemListener() {
@Override @Override
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
@ -57,10 +70,6 @@ public abstract class UIComboBoxPane<T> extends BasicBeanPane<T> {
cl.show(cardPane, cardNames[jcb.getSelectedIndex()]); cl.show(cardPane, cardNames[jcb.getSelectedIndex()]);
} }
}); });
initLayout();
jcb.setSelectedIndex(0);
} }
protected UIComboBox createComboBox() { protected UIComboBox createComboBox() {
@ -117,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();

6
designer_base/src/com/fr/design/gui/icombobox/UIComboBox.java

@ -37,7 +37,7 @@ public class UIComboBox extends JComboBox implements UIObserver, GlobalNameObser
private static final int SIZE5 = 5; private static final int SIZE5 = 5;
private UIObserverListener uiObserverListener; protected UIObserverListener uiObserverListener;
private String comboBoxName = ""; private String comboBoxName = "";
@ -71,7 +71,7 @@ public class UIComboBox extends JComboBox implements UIObserver, GlobalNameObser
initListener(); initListener();
} }
private void initListener() { protected void initListener() {
if (shouldResponseChangeListener()) { if (shouldResponseChangeListener()) {
this.addFocusListener(new FocusAdapter() { this.addFocusListener(new FocusAdapter() {
@Override @Override
@ -94,7 +94,7 @@ public class UIComboBox extends JComboBox implements UIObserver, GlobalNameObser
} }
} }
private void fireSetGlobalName() { protected void fireSetGlobalName() {
if (globalNameListener != null && shouldResponseNameListener()) { if (globalNameListener != null && shouldResponseNameListener()) {
globalNameListener.setGlobalName(comboBoxName); globalNameListener.setGlobalName(comboBoxName);
} }

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 B

253
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,8 +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) {
@ -77,7 +74,9 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
GeneralContext.addPluginReadListener(new PluginReadListener() { GeneralContext.addPluginReadListener(new PluginReadListener() {
@Override @Override
public void success() { public void success() {
ChartTypeInterfaceManager.getInstance().readDefault(); if (chartTypeInterfaces.size() == 0) {
ChartTypeInterfaceManager.getInstance().readDefault();
}
//重新注册designModuleFactory //重新注册designModuleFactory
DesignModuleFactory.registerExtraWidgetOptions(initWidgetOption()); DesignModuleFactory.registerExtraWidgetOptions(initWidgetOption());
} }
@ -118,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);
}
}
} }
} }
@ -157,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);
@ -169,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());
@ -190,38 +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(){
int size = 0;
if (chartTypeInterfaces != null){
Iterator iterator = chartTypeInterfaces.entrySet().iterator();
while (iterator.hasNext()){
Map.Entry entry = (Map.Entry) iterator.next();
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) { 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) { 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);
} }
/** /**
@ -231,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;
@ -251,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);
} }
} }
} }

2
designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java

@ -15,7 +15,7 @@ import com.fr.general.ComparatorUtils;
* Created by Mitisky on 16/3/7. * Created by Mitisky on 16/3/7.
*/ */
public abstract class AbstractIndependentChartUIWithAPILevel implements IndependentChartUIProvider { public abstract class AbstractIndependentChartUIWithAPILevel implements IndependentChartUIProvider {
private static final int OLD_PLUGIN_LEVEL = -2; private static final int OLD_PLUGIN_LEVEL = 3;
@Override @Override
//以前的插件没有覆写这个方法,所以始终获取到-2,比当前level低,提示更新. //以前的插件没有覆写这个方法,所以始终获取到-2,比当前level低,提示更新.

16
designer_chart/src/com/fr/design/chart/gui/ChartComponent.java

@ -5,6 +5,7 @@ import com.fr.base.ScreenResolution;
import com.fr.base.chart.BaseChart; import com.fr.base.chart.BaseChart;
import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartCollection;
import com.fr.base.chart.BaseChartGlyph; import com.fr.base.chart.BaseChartGlyph;
import com.fr.base.chart.chartdata.ChartDataEvent;
import com.fr.chart.base.ChartConstants; import com.fr.chart.base.ChartConstants;
import com.fr.chart.chartattr.Axis; import com.fr.chart.chartattr.Axis;
import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Chart;
@ -31,7 +32,7 @@ import java.util.List;
* 类说明: 事件说明: 工具栏编辑--> 是刷新ChartComponent 然后响应整个设计块的改变事件 * 类说明: 事件说明: 工具栏编辑--> 是刷新ChartComponent 然后响应整个设计块的改变事件
右键编辑 ---> 刷新ChartCompment 刷新对应的工具栏(加入事件) 然后响应整个设计块的改变事件 右键编辑 ---> 刷新ChartCompment 刷新对应的工具栏(加入事件) 然后响应整个设计块的改变事件
*/ */
public class ChartComponent extends MiddleChartComponent implements MouseListener, MouseMotionListener { public class ChartComponent extends MiddleChartComponent implements MouseListener, MouseMotionListener, ChartDataEvent {
private static final long serialVersionUID = 744164838619052097L; private static final long serialVersionUID = 744164838619052097L;
private final List<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>(); private final List<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>();
private ChartCollection chartCollection4Design; private ChartCollection chartCollection4Design;
@ -309,13 +310,24 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
} else { } else {
chartGlyph.setBounds(new Rectangle2D.Double(0, 0, chartWidth, chartHeight)); chartGlyph.setBounds(new Rectangle2D.Double(0, 0, chartWidth, chartHeight));
} }
// chartGlyph.draw(g2d, ScreenResolution.getScreenResolution());
//不直接画chartGlyph而画image的原因是表单的柱形图会溢出表单 //不直接画chartGlyph而画image的原因是表单的柱形图会溢出表单
//其他图都ok,其实感觉应该是柱形图画的不对,应该也可以改那边 //其他图都ok,其实感觉应该是柱形图画的不对,应该也可以改那边
//注册获取图片后续事件
registerChartDataEvent(chartGlyph);
Image chartImage = chartGlyph.toImage(chartWidth,chartHeight,ScreenResolution.getScreenResolution()); Image chartImage = chartGlyph.toImage(chartWidth,chartHeight,ScreenResolution.getScreenResolution());
g2d.drawImage(chartImage, 0, 0, null); g2d.drawImage(chartImage, 0, 0, null);
} }
} }
@Override
public void registerChartDataEvent(BaseChartGlyph glyph) {
glyph.addChartDataEvent(this);
}
@Override
public void fire() {
this.repaint();
}
} }

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

@ -3,6 +3,7 @@ package com.fr.design.mainframe.chart.gui;
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.chart.charttypes.ColumnIndependentChart; import com.fr.chart.charttypes.ColumnIndependentChart;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserver;
@ -35,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;
@ -43,6 +45,8 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
private ComboBoxPane editChartType; private ComboBoxPane editChartType;
private UITextField currentEditingEditor = null; private UITextField currentEditingEditor = null;
private ChartTypePane parent = null;
private boolean mouseOnChartTypeButtonPane = false; private boolean mouseOnChartTypeButtonPane = false;
/** /**
@ -68,9 +72,15 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
} }
}; };
public ChartTypeButtonPane(ChartTypePane chartTypePane){
this();
parent = chartTypePane;
}
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);
@ -80,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);
@ -101,14 +116,20 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
indexList.add(button); indexList.add(button);
if (editingCollection != null) { if (editingCollection != null) {
Chart[] barChart = ColumnIndependentChart.columnChartTypes; //点击添加按钮,则会触发切换状态
Chart chart = editingCollection.getChangeStateNewChart();
try { try {
Chart newChart = (Chart) barChart[0].clone(); Chart newChart = (Chart) chart.clone();
editingCollection.addNamedChart(name, newChart); editingCollection.addNamedChart(name, newChart);
editingCollection.addFunctionRecord(newChart); editingCollection.addFunctionRecord(newChart);
} catch (CloneNotSupportedException e1) { } catch (CloneNotSupportedException e1) {
FRLogger.getLogger().error("Error in Clone"); FRLogger.getLogger().error("Error in Clone");
} }
//获取图表收集器的状态
SwitchState state = editingCollection.calculateMultiChartMode();
if (SwitchState.isDynamicState(state) && parent != null){
parent.reactorChartTypePane(editingCollection);
}
} }
layoutPane(buttonPane); layoutPane(buttonPane);
@ -246,17 +267,15 @@ 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);
//新建一个collection //新建一个collection
if(editingCollection != null && editingCollection.getChartCount() == 1){ if(editingCollection.getState() == SwitchState.DEFAULT){
//vanChart 不支持图表切换 目前 //Chart 不支持图表切换
if(!ComparatorUtils.equals(editingCollection.getSelectedChart().getClass(), Chart.class)){ configButton.setVisible(editingCollection.getSelectedChart().supportChange());
addButton.setVisible(false);
}
} }
} }
@ -367,12 +386,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();
} }

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

@ -4,18 +4,26 @@ import com.fr.base.FRContext;
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.Plot; import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartattr.SwitchState;
import com.fr.chart.charttypes.ChartTypeManager; import com.fr.chart.charttypes.ChartTypeManager;
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.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;
@ -34,7 +42,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
protected JPanel createContentPane() { protected JPanel createContentPane() {
JPanel content = new JPanel(new BorderLayout()); JPanel content = new JPanel(new BorderLayout());
buttonPane = new ChartTypeButtonPane(); buttonPane = new ChartTypeButtonPane(this);
content.add(buttonPane, BorderLayout.NORTH); content.add(buttonPane, BorderLayout.NORTH);
chartTypePane = new ComboBoxPane(); chartTypePane = new ComboBoxPane();
@ -46,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);
} }
@ -98,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());
@ -110,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();
@ -130,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