Browse Source

CHART-13666 图表自动类型推荐

feature/big-screen
白岳 5 years ago
parent
commit
308bfc7e7f
  1. 37
      designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java
  2. 14
      designer-base/src/main/java/com/fr/design/fun/ChartWidgetOptionProvider.java
  3. 30
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractChartWidgetOptionProvider.java
  4. BIN
      designer-base/src/main/resources/com/fr/design/images/m_insert/auto_chart.png
  5. 12
      designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java
  6. 24
      designer-chart/src/main/java/com/fr/design/chart/AutoChartDialog.java
  7. 7
      designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java
  8. 72
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java
  9. 5
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java
  10. 3
      designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java
  11. 95
      designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java
  12. 1
      designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java
  13. 18
      designer-form/src/main/java/com/fr/design/designer/creator/XAutoChartCreator.java
  14. 3
      designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java
  15. 16
      designer-form/src/main/java/com/fr/design/mainframe/FormParaWidgetPane.java
  16. BIN
      designer-form/src/main/resources/com/fr/design/form/images/auto_chart_preview.png
  17. 3
      designer-realize/src/main/java/com/fr/design/actions/insert/cell/AutoChartCellAction.java
  18. 2
      designer-realize/src/main/java/com/fr/design/cell/editor/AutoChartCellEditor.java
  19. 7
      designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java
  20. 3
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

37
designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java

@ -8,6 +8,7 @@ import com.fr.base.BaseUtils;
import com.fr.common.annotations.Open; import com.fr.common.annotations.Open;
import com.fr.design.data.datapane.TableDataNameObjectCreator; import com.fr.design.data.datapane.TableDataNameObjectCreator;
import com.fr.design.fun.CellWidgetOptionProvider; import com.fr.design.fun.CellWidgetOptionProvider;
import com.fr.design.fun.ChartWidgetOptionProvider;
import com.fr.design.fun.FormWidgetOptionProvider; import com.fr.design.fun.FormWidgetOptionProvider;
import com.fr.design.fun.MobileWidgetStyleProvider; import com.fr.design.fun.MobileWidgetStyleProvider;
import com.fr.design.fun.ParameterWidgetOptionProvider; import com.fr.design.fun.ParameterWidgetOptionProvider;
@ -193,6 +194,42 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement
return result.toArray(new WidgetOption[result.size()]); return result.toArray(new WidgetOption[result.size()]);
} }
public Map<Class<? extends Widget>, Class<?>> getChartWidgetOptionsMap() {
Set<ChartWidgetOptionProvider> set = getArray(ChartWidgetOptionProvider.XML_TAG);
Map<Class<? extends Widget>, Class<?>> map = new HashMap<>();
for (ChartWidgetOptionProvider provider : set) {
map.put(provider.classForWidget(), provider.appearanceForWidget());
}
return map;
}
public WidgetOption[] getBeforeChartWidgetOptions() {
return getChartUnits(true);
}
public WidgetOption[] getAfterChartWidgetOptions() {
return getChartUnits(false);
}
private WidgetOption[] getChartUnits(boolean isBefore) {
Set<ChartWidgetOptionProvider> set = getArray(ChartWidgetOptionProvider.XML_TAG);
if (set.isEmpty()) {
return new WidgetOption[0];
}
Set<WidgetOption> result = new HashSet<>();
for (ChartWidgetOptionProvider provider : set) {
if (provider.isBefore() == isBefore) {
WidgetOption option = WidgetOptionFactory.createByWidgetClass(
provider.nameForWidget(),
BaseUtils.readIcon(provider.iconPathForWidget()),
provider.classForWidget()
);
result.add(option);
}
}
return result.toArray(new WidgetOption[result.size()]);
}
public WidgetOption[] getCellWidgetOptions() { public WidgetOption[] getCellWidgetOptions() {
Set<CellWidgetOptionProvider> set = getArray(CellWidgetOptionProvider.XML_TAG); Set<CellWidgetOptionProvider> set = getArray(CellWidgetOptionProvider.XML_TAG);

14
designer-base/src/main/java/com/fr/design/fun/ChartWidgetOptionProvider.java

@ -0,0 +1,14 @@
package com.fr.design.fun;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-06-12
*/
public interface ChartWidgetOptionProvider extends ParameterWidgetOptionProvider {
String XML_TAG = "ChartWidgetOptionProvider";
//在图表区域的开头还是结尾插入
boolean isBefore();
}

30
designer-base/src/main/java/com/fr/design/fun/impl/AbstractChartWidgetOptionProvider.java

@ -0,0 +1,30 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.ChartWidgetOptionProvider;
import com.fr.design.fun.FormWidgetOptionProvider;
import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-06-12
*/
@API(level = FormWidgetOptionProvider.CURRENT_LEVEL)
public abstract class AbstractChartWidgetOptionProvider extends AbstractProvider implements ChartWidgetOptionProvider {
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public String mark4Provider() {
return getClass().getName();
}
@Override
public boolean isBefore() {
return false;
}
}

BIN
designer-base/src/main/resources/com/fr/design/images/m_insert/auto_chart.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 135 B

After

Width:  |  Height:  |  Size: 423 B

12
designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java

@ -104,6 +104,7 @@ import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.awt.event.ActionListener;
import static com.fr.chart.charttypes.ChartTypeManager.DEFAULT_PRIORITY; import static com.fr.chart.charttypes.ChartTypeManager.DEFAULT_PRIORITY;
import static com.fr.chart.charttypes.ChartTypeManager.DEPRECATED_CHART_PRIORITY; import static com.fr.chart.charttypes.ChartTypeManager.DEPRECATED_CHART_PRIORITY;
@ -259,17 +260,21 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
* *
* @param paneList pane容器 * @param paneList pane容器
*/ */
public void addPlotTypePaneList(List<FurtherBasicBeanPane<? extends ChartProvider>> paneList, Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane) { public void addPlotTypePaneList(List<FurtherBasicBeanPane<? extends ChartProvider>> paneList,
Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane,
ActionListener autoButtonListener) {
List<Integer> priorityList = getPriorityInOrder(); List<Integer> priorityList = getPriorityInOrder();
for (Integer aPriorityList : priorityList) { for (Integer aPriorityList : priorityList) {
String priority = String.valueOf(aPriorityList); String priority = String.valueOf(aPriorityList);
addPlotTypePaneList(priority, paneList, allChartTypePane); addPlotTypePaneList(priority, paneList, allChartTypePane, autoButtonListener);
} }
} }
public void addPlotTypePaneList(String priority, List<FurtherBasicBeanPane<? extends ChartProvider>> paneList, Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane) { public void addPlotTypePaneList(String priority, List<FurtherBasicBeanPane<? extends ChartProvider>> paneList,
Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane,
ActionListener autoButtonListener) {
if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority)) { if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority)) {
@ -286,6 +291,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
continue; continue;
} }
pane.reLayout(plotID); pane.reLayout(plotID);
pane.registerButtonListener(autoButtonListener);
paneList.add(pane); paneList.add(pane);
if (allChartTypePane.get(priority) == null) { if (allChartTypePane.get(priority) == null) {

24
designer-chart/src/main/java/com/fr/design/chart/AutoChartDialog.java

@ -1,7 +1,11 @@
package com.fr.design.chart; package com.fr.design.chart;
import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartCollection;
import com.fr.base.chart.chartdata.TopDefinitionProvider;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.chartx.TwoTuple;
import com.fr.design.i18n.Toolkit;
import com.fr.plugin.chart.vanchart.VanChart;
import java.awt.Component; import java.awt.Component;
import java.awt.Dialog; import java.awt.Dialog;
@ -46,10 +50,30 @@ public class AutoChartDialog extends ChartDialog {
}; };
} }
protected String getDialogTitle() {
return Toolkit.i18nText("Fine-Design_Chart_M_Popup_Auto_Chart_Type");
}
/** /**
* 更新新建的图表 ChartCollection * 更新新建的图表 ChartCollection
*/ */
public void populate(BaseChartCollection cc) { public void populate(BaseChartCollection cc) {
super.populate(cc); super.populate(cc);
ChartCollection chartCollection = (ChartCollection) getChartCollection();
VanChart vanChart = chartCollection.getSelectedChartProvider(VanChart.class);
if (vanChart == null) {
return;
}
TopDefinitionProvider filterDefinition = vanChart.getFilterDefinition();
if (filterDefinition == null) {
return;
}
TwoTuple<String, String[]> tableNameAndDataFields = filterDefinition.getTableNameAndDataFields();
if (tableNameAndDataFields == null) {
return;
}
String tableName = tableNameAndDataFields.getFirst();
String[] dataFields = tableNameAndDataFields.getSecond();
autoChartTypePane.populate(tableName, dataFields);
} }
} }

7
designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java

@ -5,6 +5,7 @@ import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.gui.chart.MiddleChartDialog; import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.third.joda.time.DateTime; import com.fr.third.joda.time.DateTime;
@ -46,7 +47,7 @@ public class ChartDialog extends MiddleChartDialog {
createTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); createTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
this.setModal(true); this.setModal(true);
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_M_Popup_Chart_Type")); setTitle(getDialogTitle());
this.applyClosingAction(); this.applyClosingAction();
this.applyEscapeAction(); this.applyEscapeAction();
@ -73,6 +74,10 @@ public class ChartDialog extends MiddleChartDialog {
GUICoreUtils.setWindowCenter(getOwner(), this); GUICoreUtils.setWindowCenter(getOwner(), this);
} }
protected String getDialogTitle() {
return Toolkit.i18nText("Fine-Design_Chart_M_Popup_Chart_Type");
}
protected Component initCenterPane() { protected Component initCenterPane() {
chartTypePane = new ChartTypePane(); chartTypePane = new ChartTypePane();
return chartTypePane; return chartTypePane;

72
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java

@ -9,9 +9,7 @@ import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.chart.MiddleChartDialog; import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.gui.frpane.UIComboBoxPane; import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
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;
@ -39,18 +37,20 @@ import java.awt.event.ItemListener;
/** /**
* 图表 属性表, 类型选择 界面. * 图表 属性表, 类型选择 界面.
* @author kunsnat E-mail:kunsnat@gmail.com *
* @version 创建时间2012-12-26 上午10:56:51 * @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2012-12-26 上午10:56:51
*/ */
public class ChartTypePane extends AbstractChartAttrPane{ public class ChartTypePane extends AbstractChartAttrPane {
private ComboBoxPane chartTypeComBox; private ComboBoxPane chartTypeComBox;
private ChartTypeButtonPane buttonPane; private ChartTypeButtonPane buttonPane;
private ChartEditPane editPane; private ChartEditPane editPane;
private ChartCollection editingCollection; private ChartCollection editingCollection;
private UIButton autoButton; private ActionListener autoButtonListener;
@Override @Override
protected JPanel createContentPane() { protected JPanel createContentPane() {
initButtonListener();
JPanel content = new JPanel(new BorderLayout()); JPanel content = new JPanel(new BorderLayout());
buttonPane = new ChartTypeButtonPane(this); buttonPane = new ChartTypeButtonPane(this);
@ -58,7 +58,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
if (editingCollection != null) { if (editingCollection != null) {
relayoutChartTypePane(editingCollection); relayoutChartTypePane(editingCollection);
}else { } else {
chartTypeComBox = new ComboBoxPane(); chartTypeComBox = new ComboBoxPane();
} }
@ -88,11 +88,6 @@ public class ChartTypePane extends AbstractChartAttrPane{
buttonPane.setEditingChartPane(chartTypeComBox); buttonPane.setEditingChartPane(chartTypeComBox);
if(ChartTypeManager.AUTO_CHART) {
initAutoButton();
content.add(autoButton, BorderLayout.SOUTH);
}
return content; return content;
} }
@ -105,16 +100,15 @@ public class ChartTypePane extends AbstractChartAttrPane{
/** /**
* 界面标题 * 界面标题
*
* @return 界面标题 * @return 界面标题
*/ */
public String title4PopupWindow() { public String title4PopupWindow() {
return PaneTitleConstants.CHART_TYPE_TITLE; return PaneTitleConstants.CHART_TYPE_TITLE;
} }
private void initAutoButton(){ public void initButtonListener() {
//TODO @Bjorn 视觉样式优化 autoButtonListener = new ActionListener() {
autoButton = new UIButton(Toolkit.i18nText("Fine-Design_Chart_M_Popup_Auto_Chart_Type"));
autoButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
final MiddleChartDialog autoChartDialog = DesignModuleFactory.getAutoChartDialog(DesignerContext.getDesignerFrame()); final MiddleChartDialog autoChartDialog = DesignModuleFactory.getAutoChartDialog(DesignerContext.getDesignerFrame());
@ -127,7 +121,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
}); });
autoChartDialog.setVisible(true); autoChartDialog.setVisible(true);
} }
}); };
} }
class ComboBoxPane extends UIComboBoxPane<ChartProvider> { class ComboBoxPane extends UIComboBoxPane<ChartProvider> {
@ -137,7 +131,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
protected List<FurtherBasicBeanPane<? extends ChartProvider>> initPaneList() { protected List<FurtherBasicBeanPane<? extends ChartProvider>> initPaneList() {
List<FurtherBasicBeanPane<? extends ChartProvider>> paneList = new ArrayList<FurtherBasicBeanPane<? extends ChartProvider>>(); List<FurtherBasicBeanPane<? extends ChartProvider>> paneList = new ArrayList<FurtherBasicBeanPane<? extends ChartProvider>>();
allChartTypePane = new LinkedHashMap<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>>(); allChartTypePane = new LinkedHashMap<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>>();
ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(paneList, allChartTypePane); ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(paneList, allChartTypePane, autoButtonListener);
return paneList; return paneList;
} }
@ -150,15 +144,16 @@ public class ChartTypePane extends AbstractChartAttrPane{
* 不同图表切换分同一个selected的不同图表切换和不同selected的不同图表切换 * 不同图表切换分同一个selected的不同图表切换和不同selected的不同图表切换
* 如果是切换图表的某个图表发生变化则collection的选择下标不会变 * 如果是切换图表的某个图表发生变化则collection的选择下标不会变
* 如果是切换图表的不同图表之间切换则collection的选择下标会改变 * 如果是切换图表的不同图表之间切换则collection的选择下标会改变
*
* @param chart * @param chart
*/ */
public void updateBean(ChartProvider chart) { public void updateBean(ChartProvider chart) {
String lastPlotID = chart.getID(); String lastPlotID = chart.getID();
try{ try {
AbstractChartTypePane selectedPane = (AbstractChartTypePane) getSelectedPane(); AbstractChartTypePane selectedPane = (AbstractChartTypePane) getSelectedPane();
ChartProvider newDefaultChart =(ChartProvider) ChartTypeManager.getInstanceWithCheck().getCharts(selectedPane.getPlotID())[0].clone(); ChartProvider newDefaultChart = (ChartProvider) ChartTypeManager.getInstanceWithCheck().getCharts(selectedPane.getPlotID())[0].clone();
if (!ComparatorUtils.equals(chart.getClass(), newDefaultChart.getClass())) { if (!ComparatorUtils.equals(chart.getClass(), newDefaultChart.getClass())) {
//vanChart 和 chart 之间切换 //vanChart 和 chart 之间切换
//不同chart之间切换 //不同chart之间切换
@ -166,11 +161,11 @@ public class ChartTypePane extends AbstractChartAttrPane{
editingCollection.addChart(newDefaultChart); editingCollection.addChart(newDefaultChart);
chart = newDefaultChart; chart = newDefaultChart;
} }
}catch (CloneNotSupportedException e){ } catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
//这一步会替换plot //这一步会替换plot
((AbstractChartTypePane)getSelectedPane()).updateBean(chart); ((AbstractChartTypePane) getSelectedPane()).updateBean(chart);
String chartID = chart.getID(); String chartID = chart.getID();
@ -194,12 +189,12 @@ public class ChartTypePane extends AbstractChartAttrPane{
jcb.addItemListener(new ItemListener() { jcb.addItemListener(new ItemListener() {
@Override @Override
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
FlexibleComboBox fcb = (FlexibleComboBox)jcb; FlexibleComboBox fcb = (FlexibleComboBox) jcb;
if (fcb.isReactor()){ if (fcb.isReactor()) {
return; return;
} }
comboBoxItemStateChanged(); comboBoxItemStateChanged();
CardLayout cl = (CardLayout)cardPane.getLayout(); CardLayout cl = (CardLayout) cardPane.getLayout();
cl.show(cardPane, cardNames[jcb.getSelectedIndex()]); cl.show(cardPane, cardNames[jcb.getSelectedIndex()]);
} }
}); });
@ -239,7 +234,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
//因为饼图(新特性)把(新特性)去掉了,和老的饼图同名,下拉框选项和typePane不能一一对应了 //因为饼图(新特性)把(新特性)去掉了,和老的饼图同名,下拉框选项和typePane不能一一对应了
//处理办法:这边除了重构 下拉项选项和cardNames 还需要把cards重构下(不需要init pane,只需要我需要的拿出来就好了) //处理办法:这边除了重构 下拉项选项和cardNames 还需要把cards重构下(不需要init pane,只需要我需要的拿出来就好了)
private void relayout(ChartCollection collection){ private void relayout(ChartCollection collection) {
//重构需要重构下拉框选项和cardNames //重构需要重构下拉框选项和cardNames
ChartProvider chart = collection.getSelectedChartProvider(ChartProvider.class); ChartProvider chart = collection.getSelectedChartProvider(ChartProvider.class);
String chartID = chart.getID(); String chartID = chart.getID();
@ -260,7 +255,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
} }
//下拉框重构开始。为了防止重构是触发update //下拉框重构开始。为了防止重构是触发update
((FlexibleComboBox)jcb).setItemEvenType(ItemEventType.REACTOR); ((FlexibleComboBox) jcb).setItemEvenType(ItemEventType.REACTOR);
//重构下拉框选项 //重构下拉框选项
cardNames = new String[cards.size()]; cardNames = new String[cards.size()];
cardPane.removeAll(); cardPane.removeAll();
@ -275,13 +270,13 @@ public class ChartTypePane extends AbstractChartAttrPane{
jcb.setSelectedItem(item); jcb.setSelectedItem(item);
jcb.setEnabled(enabledChart); jcb.setEnabled(enabledChart);
//下拉框重构结束 //下拉框重构结束
((FlexibleComboBox)jcb).setItemEvenType(ItemEventType.DEFAULT); ((FlexibleComboBox) jcb).setItemEvenType(ItemEventType.DEFAULT);
//重新选中 //重新选中
checkPlotPane(); checkPlotPane();
} }
private void checkPlotPane() { private void checkPlotPane() {
CardLayout cl = (CardLayout)cardPane.getLayout(); CardLayout cl = (CardLayout) cardPane.getLayout();
cl.show(cardPane, cardNames[jcb.getSelectedIndex()]); cl.show(cardPane, cardNames[jcb.getSelectedIndex()]);
} }
@ -310,8 +305,8 @@ public class ChartTypePane extends AbstractChartAttrPane{
@Override @Override
public FurtherBasicBeanPane<? extends ChartProvider> getSelectedPane() { public FurtherBasicBeanPane<? extends ChartProvider> getSelectedPane() {
Object item = jcb.getSelectedItem(); Object item = jcb.getSelectedItem();
for (int i = 0; i < cards.size(); i++){ for (int i = 0; i < cards.size(); i++) {
if (ComparatorUtils.equals(item, cards.get(i).title4PopupWindow())){ if (ComparatorUtils.equals(item, cards.get(i).title4PopupWindow())) {
return cards.get(i); return cards.get(i);
} }
} }
@ -323,10 +318,11 @@ public class ChartTypePane extends AbstractChartAttrPane{
/** /**
* 面板重构 * 面板重构
*
* @param lastPlotID * @param lastPlotID
* @param collection * @param collection
*/ */
public void reLayoutEditPane(String lastPlotID, ChartCollection collection){ public void reLayoutEditPane(String lastPlotID, ChartCollection collection) {
if (editPane == null) { if (editPane == null) {
return; return;
} }
@ -339,7 +335,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
} }
public void relayoutChartTypePane(ChartCollection collection){ public void relayoutChartTypePane(ChartCollection collection) {
chartTypeComBox.relayout(collection); chartTypeComBox.relayout(collection);
} }
@ -373,30 +369,34 @@ public class ChartTypePane extends AbstractChartAttrPane{
/** /**
* 所有图表的类型界面 * 所有图表的类型界面
*
* @return 类型界面 * @return 类型界面
*/ */
public FurtherBasicBeanPane[] getPaneList(){ public FurtherBasicBeanPane[] getPaneList() {
return chartTypeComBox.getCards().toArray(new FurtherBasicBeanPane[0]); return chartTypeComBox.getCards().toArray(new FurtherBasicBeanPane[0]);
} }
/** /**
* 当前选中的图表的index * 当前选中的图表的index
*
* @return 当前选中的图表的index * @return 当前选中的图表的index
*/ */
public int getSelectedIndex(){ public int getSelectedIndex() {
return chartTypeComBox.getSelectedIndex(); return chartTypeComBox.getSelectedIndex();
} }
/** /**
* 返回选中的图表的index * 返回选中的图表的index
*
* @return 选中的图标的序号 * @return 选中的图标的序号
*/ */
public int getSelectedChartIndex(){ public int getSelectedChartIndex() {
return chartTypeComBox.getSelectedIndex(); return chartTypeComBox.getSelectedIndex();
} }
/** /**
* 设置下编辑的面板 * 设置下编辑的面板
*
* @param currentEditPane 设置下编辑的面板 * @param currentEditPane 设置下编辑的面板
*/ */
public void registerChartEditPane(ChartEditPane currentEditPane) { public void registerChartEditPane(ChartEditPane currentEditPane) {

5
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java

@ -22,6 +22,7 @@ import java.util.List;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.event.ActionListener;
public abstract class AbstractChartTypePane<T extends ChartProvider> extends FurtherBasicBeanPane<T> { public abstract class AbstractChartTypePane<T extends ChartProvider> extends FurtherBasicBeanPane<T> {
@ -240,4 +241,8 @@ public abstract class AbstractChartTypePane<T extends ChartProvider> extends Fur
public ChartProvider getDefaultChart() { public ChartProvider getDefaultChart() {
return BarIndependentChart.barChartTypes[0]; return BarIndependentChart.barChartTypes[0];
} }
public void registerButtonListener(ActionListener autoButtonListener) {
}
} }

3
designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java

@ -61,7 +61,8 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane {
return new Component[][]{ return new Component[][]{
new Component[]{typePane}, new Component[]{typePane},
new Component[]{stylePane}, new Component[]{stylePane},
new Component[]{contentPane} new Component[]{contentPane},
new Component[]{buttonPane},
}; };
} }

95
designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java

@ -1,5 +1,6 @@
package com.fr.van.chart.designer.type; package com.fr.van.chart.designer.type;
import com.fr.base.BaseUtils;
import com.fr.chart.base.AttrFillStyle; import com.fr.chart.base.AttrFillStyle;
import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Legend; import com.fr.chart.chartattr.Legend;
@ -7,13 +8,16 @@ import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionAttr;
import com.fr.chart.chartglyph.ConditionCollection; import com.fr.chart.chartglyph.ConditionCollection;
import com.fr.chart.chartglyph.DataSheet; import com.fr.chart.chartglyph.DataSheet;
import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.chartx.data.AbstractDataDefinition; import com.fr.chartx.data.AbstractDataDefinition;
import com.fr.chartx.data.ChartDataDefinitionProvider; import com.fr.chartx.data.ChartDataDefinitionProvider;
import com.fr.chartx.data.field.AbstractColumnFieldCollection; import com.fr.chartx.data.field.AbstractColumnFieldCollection;
import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection;
import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.MultilineLabel; import com.fr.design.gui.ilable.MultilineLabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.design.mainframe.chart.gui.type.ChartImagePane; import com.fr.design.mainframe.chart.gui.type.ChartImagePane;
import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.mainframe.chart.info.ChartInfoCollector;
@ -25,21 +29,53 @@ import com.fr.plugin.chart.base.VanChartTools;
import com.fr.plugin.chart.base.VanChartZoom; import com.fr.plugin.chart.base.VanChartZoom;
import com.fr.plugin.chart.vanchart.VanChart; import com.fr.plugin.chart.vanchart.VanChart;
import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionListener;
public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Chart> { public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Chart> {
private static final long serialVersionUID = 7743244512351499265L; private static final long serialVersionUID = 7743244512351499265L;
private UICheckBox largeModelCheckBox; private UICheckBox largeModelCheckBox;
protected JPanel buttonPane;
protected UIButton autoButton;
private boolean samePlot; private boolean samePlot;
protected boolean isSamePlot() { protected boolean isSamePlot() {
return samePlot; return samePlot;
} }
public AbstractVanChartTypePane() {
buttonPane = new JPanel();
buttonPane.setLayout(new BorderLayout());
if (ChartTypeManager.AUTO_CHART) {
autoButton = new UIButton(Toolkit.i18nText("Fine-Design_Chart_M_Popup_Auto_Chart_Type"),
BaseUtils.readIcon("/com/fr/design/images/m_insert/auto_chart.png")) {
@Override
public Dimension getPreferredSize() {
return new Dimension((int) super.getPreferredSize().getWidth(), 25);
}
};
buttonPane.setBorder((BorderFactory.createEmptyBorder(5, 0, 0, 0)));
buttonPane.add(autoButton);
}
}
@Override
protected Component[][] getPaneComponents(JPanel typePane) {
return new Component[][]{
new Component[]{typePane},
new Component[]{buttonPane},
new Component[]{stylePane},
};
}
//新图表暂时还没有平面3d,渐变高光等布局。 //新图表暂时还没有平面3d,渐变高光等布局。
@Override @Override
protected String[] getTypeLayoutPath() { protected String[] getTypeLayoutPath() {
@ -66,7 +102,7 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Cha
return getPlotID(); return getPlotID();
} }
protected Component[][] getComponentsWithLargeData(JPanel typePane){ protected Component[][] getComponentsWithLargeData(JPanel typePane) {
largeModelCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open_Large_Data_Model")); largeModelCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open_Large_Data_Model"));
MultilineLabel prompt = new MultilineLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Large_Data_Model_Prompt")); MultilineLabel prompt = new MultilineLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Large_Data_Model_Prompt"));
prompt.setForeground(Color.red); prompt.setForeground(Color.red);
@ -84,7 +120,7 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Cha
* 更新界面内容 * 更新界面内容
*/ */
public void populateBean(Chart chart) { public void populateBean(Chart chart) {
for(ChartImagePane imagePane : typeDemo) { for (ChartImagePane imagePane : typeDemo) {
imagePane.isPressing = false; imagePane.isPressing = false;
} }
Plot plot = chart.getPlot(); Plot plot = chart.getPlot();
@ -100,13 +136,13 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Cha
VanChartPlot newPlot = getSelectedClonedPlot(); VanChartPlot newPlot = getSelectedClonedPlot();
checkTypeChange(oldPlot); checkTypeChange(oldPlot);
samePlot = accept(chart); samePlot = accept(chart);
if(typeChanged && samePlot){ if (typeChanged && samePlot) {
//同一中图表切换不同类型 //同一中图表切换不同类型
cloneOldPlot2New(oldPlot, newPlot); cloneOldPlot2New(oldPlot, newPlot);
chart.setPlot(newPlot); chart.setPlot(newPlot);
resetChartAttr4SamePlot(chart); resetChartAttr4SamePlot(chart);
ChartInfoCollector.getInstance().updateChartMiniType(chart); ChartInfoCollector.getInstance().updateChartMiniType(chart);
} else if(!samePlot){ } else if (!samePlot) {
//不同的图表类型切換 //不同的图表类型切換
resetChartAttr(chart, newPlot); resetChartAttr(chart, newPlot);
//切换图表时,数据配置不变,分类个数也不变 //切换图表时,数据配置不变,分类个数也不变
@ -114,55 +150,55 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Cha
//切换类型埋点 //切换类型埋点
ChartInfoCollector.getInstance().updateChartTypeTime(chart, oldPlot.getPlotID()); ChartInfoCollector.getInstance().updateChartTypeTime(chart, oldPlot.getPlotID());
} }
if(chart instanceof VanChart if (chart instanceof VanChart
&& !acceptDefinition(((VanChart) chart).getChartDataDefinition(), newPlot)) { && !acceptDefinition(((VanChart) chart).getChartDataDefinition(), newPlot)) {
((VanChart) chart).setChartDataDefinition(null); ((VanChart) chart).setChartDataDefinition(null);
} }
} }
protected boolean acceptDefinition(ChartDataDefinitionProvider definition, VanChartPlot vanChartPlot) { protected boolean acceptDefinition(ChartDataDefinitionProvider definition, VanChartPlot vanChartPlot) {
if(definition instanceof AbstractDataDefinition) { if (definition instanceof AbstractDataDefinition) {
AbstractColumnFieldCollection columnFieldCollection = ((AbstractDataDefinition) definition).getColumnFieldCollection(); AbstractColumnFieldCollection columnFieldCollection = ((AbstractDataDefinition) definition).getColumnFieldCollection();
return columnFieldCollection instanceof MultiCategoryColumnFieldCollection; return columnFieldCollection instanceof MultiCategoryColumnFieldCollection;
} }
return false; return false;
} }
protected void resetChartAttr4SamePlot(Chart chart){ protected void resetChartAttr4SamePlot(Chart chart) {
resetRefreshMoreLabelAttr((VanChart) chart); resetRefreshMoreLabelAttr((VanChart) chart);
} }
protected void resetChartAttr(Chart chart, Plot newPlot){ protected void resetChartAttr(Chart chart, Plot newPlot) {
chart.setPlot(newPlot); chart.setPlot(newPlot);
if(newPlot.isSupportZoomDirection() && !newPlot.isSupportZoomCategoryAxis()){ if (newPlot.isSupportZoomDirection() && !newPlot.isSupportZoomCategoryAxis()) {
//图表缩放新设计 恢复用注释。下面一行删除。 //图表缩放新设计 恢复用注释。下面一行删除。
((VanChart) chart).setVanChartZoom(new VanChartZoom()); ((VanChart) chart).setVanChartZoom(new VanChartZoom());
//图表缩放新设计 恢复用注释。下面一行取消注释。 //图表缩放新设计 恢复用注释。下面一行取消注释。
// ((VanChart) chart).setZoomAttribute(new ZoomAttribute()); // ((VanChart) chart).setZoomAttribute(new ZoomAttribute());
} }
//重置工具栏选项 //重置工具栏选项
((VanChart)chart).setVanChartTools(createVanChartTools()); ((VanChart) chart).setVanChartTools(createVanChartTools());
//重置标题选项 //重置标题选项
resetTitleAttr(chart); resetTitleAttr(chart);
//重置监控刷新选项 //重置监控刷新选项
resetRefreshMoreLabelAttr((VanChart)chart); resetRefreshMoreLabelAttr((VanChart) chart);
resetFilterDefinition(chart); resetFilterDefinition(chart);
} }
//默认有标题 //默认有标题
protected void resetTitleAttr(Chart chart){ protected void resetTitleAttr(Chart chart) {
VanChartPlot vanChartPlot = (VanChartPlot) chart.getPlot(); VanChartPlot vanChartPlot = (VanChartPlot) chart.getPlot();
chart.setTitle(vanChartPlot.getDefaultTitle()); chart.setTitle(vanChartPlot.getDefaultTitle());
} }
//重置数据配置 //重置数据配置
protected void resetFilterDefinition(Chart chart){ protected void resetFilterDefinition(Chart chart) {
} }
//重置监控刷新面板 //重置监控刷新面板
protected void resetRefreshMoreLabelAttr(VanChart chart){ protected void resetRefreshMoreLabelAttr(VanChart chart) {
chart.setRefreshMoreLabel(chart.getDefaultAutoAttrtooltip(chart)); chart.setRefreshMoreLabel(chart.getDefaultAutoAttrtooltip(chart));
} }
@ -170,9 +206,9 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Cha
return new VanChartTools(); return new VanChartTools();
} }
protected void checkTypeChange(Plot oldPlot){ protected void checkTypeChange(Plot oldPlot) {
for(int i = 0; i < typeDemo.size(); i++){ for (int i = 0; i < typeDemo.size(); i++) {
if(typeDemo.get(i).isPressing && i != oldPlot.getDetailType()){ if (typeDemo.get(i).isPressing && i != oldPlot.getDetailType()) {
typeChanged = true; typeChanged = true;
break; break;
} }
@ -193,15 +229,15 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Cha
cloneHotHyperLink(oldPlot, newPlot); cloneHotHyperLink(oldPlot, newPlot);
if (oldPlot.getPlotFillStyle() != null) { if (oldPlot.getPlotFillStyle() != null) {
newPlot.setPlotFillStyle((AttrFillStyle)oldPlot.getPlotFillStyle().clone()); newPlot.setPlotFillStyle((AttrFillStyle) oldPlot.getPlotFillStyle().clone());
} }
newPlot.setPlotStyle(oldPlot.getPlotStyle()); newPlot.setPlotStyle(oldPlot.getPlotStyle());
if (oldPlot.getDataSheet() != null) { if (oldPlot.getDataSheet() != null) {
newPlot.setDataSheet((DataSheet)oldPlot.getDataSheet().clone()); newPlot.setDataSheet((DataSheet) oldPlot.getDataSheet().clone());
} }
if (oldPlot.getBackground() != null) { if (oldPlot.getBackground() != null) {
newPlot.setBackground((Background)oldPlot.getBackground().clone()); newPlot.setBackground((Background) oldPlot.getBackground().clone());
} }
if (oldPlot.getBorderColor() != null) { if (oldPlot.getBorderColor() != null) {
newPlot.setBorderColor(oldPlot.getBorderColor()); newPlot.setBorderColor(oldPlot.getBorderColor());
@ -211,20 +247,20 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Cha
newPlot.setAlpha(oldPlot.getAlpha()); newPlot.setAlpha(oldPlot.getAlpha());
newPlot.setShadow(oldPlot.isShadow()); newPlot.setShadow(oldPlot.isShadow());
((VanChartPlot)newPlot).setCategoryNum( ((VanChartPlot)oldPlot).getCategoryNum()); ((VanChartPlot) newPlot).setCategoryNum(((VanChartPlot) oldPlot).getCategoryNum());
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error in change plot"); FineLoggerFactory.getLogger().error("Error in change plot");
} }
} }
protected void cloneHotHyperLink(Plot oldPlot, Plot newPlot) throws CloneNotSupportedException{ protected void cloneHotHyperLink(Plot oldPlot, Plot newPlot) throws CloneNotSupportedException {
if (oldPlot.getHotHyperLink() != null) { if (oldPlot.getHotHyperLink() != null) {
newPlot.setHotHyperLink((NameJavaScriptGroup)oldPlot.getHotHyperLink().clone()); newPlot.setHotHyperLink((NameJavaScriptGroup) oldPlot.getHotHyperLink().clone());
} }
} }
protected void cloneOldDefaultAttrConditionCollection(Plot oldPlot, Plot newPlot) throws CloneNotSupportedException{ protected void cloneOldDefaultAttrConditionCollection(Plot oldPlot, Plot newPlot) throws CloneNotSupportedException {
if (oldPlot.getConditionCollection() != null) { if (oldPlot.getConditionCollection() != null) {
ConditionCollection newCondition = new ConditionCollection(); ConditionCollection newCondition = new ConditionCollection();
newCondition.setDefaultAttr((ConditionAttr) oldPlot.getConditionCollection().getDefaultAttr().clone()); newCondition.setDefaultAttr((ConditionAttr) oldPlot.getConditionCollection().getDefaultAttr().clone());
@ -232,9 +268,16 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Cha
} }
} }
protected void cloneOldConditionCollection(Plot oldPlot, Plot newPlot) throws CloneNotSupportedException{ protected void cloneOldConditionCollection(Plot oldPlot, Plot newPlot) throws CloneNotSupportedException {
if (oldPlot.getConditionCollection() != null) { if (oldPlot.getConditionCollection() != null) {
newPlot.setConditionCollection((ConditionCollection)oldPlot.getConditionCollection().clone()); newPlot.setConditionCollection((ConditionCollection) oldPlot.getConditionCollection().clone());
}
}
@Override
public void registerButtonListener(ActionListener autoButtonListener) {
if (autoButton != null) {
autoButton.addActionListener(autoButtonListener);
} }
} }
} }

1
designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java

@ -42,6 +42,7 @@ public class VanChartMapPlotPane extends AbstractVanChartTypePane {
} }
return new Component[][]{ return new Component[][]{
new Component[]{typePane}, new Component[]{typePane},
new Component[]{buttonPane},
new Component[]{sourceChoosePane} new Component[]{sourceChoosePane}
}; };
} }

18
designer-form/src/main/java/com/fr/design/designer/creator/XAutoChartCreator.java

@ -2,6 +2,7 @@ package com.fr.design.designer.creator;
import com.fr.base.GraphHelper; import com.fr.base.GraphHelper;
import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartCollection;
import com.fr.common.annotations.Open;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.chart.MiddleChartComponent; import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.design.gui.chart.MiddleChartDialog; import com.fr.design.gui.chart.MiddleChartDialog;
@ -11,21 +12,23 @@ import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
import com.fr.form.ui.ChartAutoEditor; import com.fr.form.ui.ChartAutoEditor;
import com.fr.general.IOUtils;
import com.fr.stable.Constants;
import com.fr.stable.bridge.StableFactory; import com.fr.stable.bridge.StableFactory;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
/** /**
* @author Bjorn * @author Bjorn
* @version 10.0 * @version 10.0
* Created by Bjorn on 2020-05-26 * Created by Bjorn on 2020-05-26
*/ */
@Open
public class XAutoChartCreator extends XChartEditor { public class XAutoChartCreator extends XChartEditor {
private MiddleChartDialog autoChartDialog; private MiddleChartDialog autoChartDialog;
@ -76,6 +79,7 @@ public class XAutoChartCreator extends XChartEditor {
initChart(autoChartDialog.getChartCollection()); initChart(autoChartDialog.getChartCollection());
formDesigner.fireTargetModified(); formDesigner.fireTargetModified();
} }
@Override @Override
public void doCancel() { public void doCancel() {
editingMouseListener.stopEditing(); editingMouseListener.stopEditing();
@ -99,9 +103,13 @@ public class XAutoChartCreator extends XChartEditor {
public void paint(Graphics g) { public void paint(Graphics g) {
//TODO @Bjorn 视觉样式优化 BufferedImage bufferedImage = IOUtils.readImage("com/fr/design/form/images/auto_chart_preview.png");
g.setColor(Color.RED); GraphHelper.paintImage(
GraphHelper.fill(g, new Rectangle(0, 0, getWidth(), getHeight())); g, this.getWidth(), this.getHeight(), bufferedImage,
Constants.IMAGE_ADJUST,
0,
0, -1, -1
);
super.paint(g); super.paint(g);
} }

3
designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java

@ -19,7 +19,6 @@ import com.fr.form.parameter.FormSubmitButton;
import com.fr.form.ui.Button; import com.fr.form.ui.Button;
import com.fr.form.ui.CardAddButton; import com.fr.form.ui.CardAddButton;
import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.ChartAutoEditor;
import com.fr.form.ui.CheckBox; import com.fr.form.ui.CheckBox;
import com.fr.form.ui.CheckBoxGroup; import com.fr.form.ui.CheckBoxGroup;
import com.fr.form.ui.ComboBox; import com.fr.form.ui.ComboBox;
@ -170,12 +169,12 @@ public class XCreatorUtils {
extraObjectMap.clear(); extraObjectMap.clear();
extraObjectMap.putAll(ExtraDesignClassManager.getInstance().getParameterWidgetOptionsMap()); extraObjectMap.putAll(ExtraDesignClassManager.getInstance().getParameterWidgetOptionsMap());
extraObjectMap.putAll(ExtraDesignClassManager.getInstance().getFormWidgetOptionsMap()); extraObjectMap.putAll(ExtraDesignClassManager.getInstance().getFormWidgetOptionsMap());
extraObjectMap.putAll(ExtraDesignClassManager.getInstance().getChartWidgetOptionsMap());
} }
private static void putExtraEditor() { private static void putExtraEditor() {
if (DesignModuleFactory.getChartEditorClass() != null) { if (DesignModuleFactory.getChartEditorClass() != null) {
objectMap.put(DesignModuleFactory.getChartEditorClass(), XChartEditor.class); objectMap.put(DesignModuleFactory.getChartEditorClass(), XChartEditor.class);
objectMap.put(ChartAutoEditor.class, XAutoChartCreator.class);
} }
} }

16
designer-form/src/main/java/com/fr/design/mainframe/FormParaWidgetPane.java

@ -34,6 +34,10 @@ import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JSeparator; import javax.swing.JSeparator;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
@ -42,10 +46,6 @@ import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent; import java.awt.event.ComponentEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
/** /**
* @author null * @author null
@ -318,11 +318,11 @@ public class FormParaWidgetPane extends JPanel {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
initWidgetTypePopUp(); initWidgetTypePopUp();
if(jSeparatorChart != null) { if (jSeparatorChart != null) {
widgetTypePopupMenu.show(FormParaWidgetPane.this, widgetTypePopupMenu.show(FormParaWidgetPane.this,
(int) jSeparatorChart.getLocation().getX() + BORDER, (int) jSeparatorChart.getLocation().getX() + BORDER,
(int) jSeparatorChart.getLocation().getY()); (int) jSeparatorChart.getLocation().getY());
}else{ } else {
widgetTypePopupMenu.show(FormParaWidgetPane.this, widgetTypePopupMenu.show(FormParaWidgetPane.this,
(int) jSeparatorLayout.getLocation().getX() + BORDER, (int) jSeparatorLayout.getLocation().getX() + BORDER,
(int) jSeparatorLayout.getLocation().getY()); (int) jSeparatorLayout.getLocation().getY());
@ -440,7 +440,9 @@ public class FormParaWidgetPane extends JPanel {
private WidgetOption[] loadChartOptions() { private WidgetOption[] loadChartOptions() {
if (chartOptions == null) { if (chartOptions == null) {
chartOptions = DesignModuleFactory.getExtraWidgetOptions(); ExtraDesignClassManager instance = ExtraDesignClassManager.getInstance();
WidgetOption[] widgetOptions = ArrayUtils.addAll(instance.getBeforeChartWidgetOptions(), DesignModuleFactory.getExtraWidgetOptions());
chartOptions = ArrayUtils.addAll(widgetOptions, instance.getAfterChartWidgetOptions());
} }
return chartOptions; return chartOptions;
} }

BIN
designer-form/src/main/resources/com/fr/design/form/images/auto_chart_preview.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

3
designer-realize/src/main/java/com/fr/design/actions/insert/cell/AutoChartCellAction.java

@ -2,6 +2,7 @@ package com.fr.design.actions.insert.cell;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.chart.chartattr.AutoChartCollection; import com.fr.chart.chartattr.AutoChartCollection;
import com.fr.common.annotations.Open;
import com.fr.design.actions.core.WorkBookSupportable; import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
@ -14,6 +15,7 @@ import javax.swing.KeyStroke;
* @version 10.0 * @version 10.0
* Created by Bjorn on 2020-05-28 * Created by Bjorn on 2020-05-28
*/ */
@Open
public class AutoChartCellAction extends AbstractCellAction implements WorkBookSupportable { public class AutoChartCellAction extends AbstractCellAction implements WorkBookSupportable {
public AutoChartCellAction() { public AutoChartCellAction() {
@ -29,7 +31,6 @@ public class AutoChartCellAction extends AbstractCellAction implements WorkBookS
this.setMenuKeySet(INSERT_AUTO_CHART); this.setMenuKeySet(INSERT_AUTO_CHART);
this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
//TODO @Bjorn 视觉样式优化icon
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/auto_chart.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/auto_chart.png"));
} }

2
designer-realize/src/main/java/com/fr/design/cell/editor/AutoChartCellEditor.java

@ -1,5 +1,6 @@
package com.fr.design.cell.editor; package com.fr.design.cell.editor;
import com.fr.common.annotations.Open;
import com.fr.design.gui.chart.MiddleChartDialog; import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
@ -12,6 +13,7 @@ import java.awt.Window;
* @version 10.0 * @version 10.0
* Created by Bjorn on 2020-05-28 * Created by Bjorn on 2020-05-28
*/ */
@Open
public class AutoChartCellEditor extends ChartCellEditor { public class AutoChartCellEditor extends ChartCellEditor {
public AutoChartCellEditor(ElementCasePane<? extends TemplateElementCase> ePane) { public AutoChartCellEditor(ElementCasePane<? extends TemplateElementCase> ePane) {

7
designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java

@ -9,7 +9,6 @@ import com.fr.base.Formula;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.chart.chartattr.AutoChartCollection;
import com.fr.design.DesignState; import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
@ -53,8 +52,6 @@ import com.fr.design.cell.bar.DynamicScrollBar;
import com.fr.design.cell.clipboard.CellElementsClip; import com.fr.design.cell.clipboard.CellElementsClip;
import com.fr.design.cell.clipboard.ElementsTransferable; import com.fr.design.cell.clipboard.ElementsTransferable;
import com.fr.design.cell.clipboard.FloatElementsClip; import com.fr.design.cell.clipboard.FloatElementsClip;
import com.fr.design.cell.editor.AutoChartCellEditor;
import com.fr.design.cell.editor.AutoChartFloatEditor;
import com.fr.design.cell.editor.BiasTextPainterCellEditor; import com.fr.design.cell.editor.BiasTextPainterCellEditor;
import com.fr.design.cell.editor.CellEditor; import com.fr.design.cell.editor.CellEditor;
import com.fr.design.cell.editor.ChartCellEditor; import com.fr.design.cell.editor.ChartCellEditor;
@ -402,8 +399,6 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
grid.setDefaultFloatEditor(chartClass, new ChartFloatEditor()); grid.setDefaultFloatEditor(chartClass, new ChartFloatEditor());
} }
grid.setDefaultCellEditor(AutoChartCollection.class, new AutoChartCellEditor(this));
grid.setDefaultFloatEditor(AutoChartCollection.class, new AutoChartFloatEditor());
addExtraCellEditor(grid); addExtraCellEditor(grid);
@ -427,7 +422,7 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
editor = (CellEditor) c.newInstance(); editor = (CellEditor) c.newInstance();
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
try { try {
c = clazz.getConstructor(ElementCase.class); c = clazz.getConstructor(ElementCasePane.class);
editor = (CellEditor) c.newInstance(this); editor = (CellEditor) c.newInstance(this);
} catch (Exception e1) { } catch (Exception e1) {
FineLoggerFactory.getLogger().error(e1.getMessage(), e1); FineLoggerFactory.getLogger().error(e1.getMessage(), e1);

3
designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

@ -350,6 +350,9 @@ public class DesignerActivator extends Activator {
Set<ElementUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING); Set<ElementUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING);
for (ElementUIProvider provider : providers) { for (ElementUIProvider provider : providers) {
try { try {
if (provider.quickEditor() == null) {
continue;
}
ActionFactory.registerCellEditor(provider.targetObjectClass(), provider.quickEditor().newInstance()); ActionFactory.registerCellEditor(provider.targetObjectClass(), provider.quickEditor().newInstance());
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);

Loading…
Cancel
Save