Browse Source

CHART-13666 图表类型自动匹配设计器面板

feature/big-screen
白岳 5 years ago
parent
commit
e6df73ae30
  1. 13
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java
  2. 8
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java
  3. 28
      designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java
  4. BIN
      designer-base/src/main/resources/com/fr/design/images/m_insert/auto_chart.png
  5. 17
      designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java
  6. 69
      designer-chart/src/main/java/com/fr/design/chart/AutoChartDialog.java
  7. 108
      designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java
  8. 230
      designer-chart/src/main/java/com/fr/design/chart/AutoChartTypePane.java
  9. 1
      designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java
  10. 38
      designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java
  11. 3
      designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java
  12. 41
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java
  13. BIN
      designer-chart/src/main/resources/com/fr/design/images/form/toolbar/auto_chart.png
  14. 113
      designer-form/src/main/java/com/fr/design/designer/creator/XAutoChartCreator.java
  15. 19
      designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java
  16. 2
      designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java
  17. 57
      designer-realize/src/main/java/com/fr/design/actions/insert/cell/AutoChartCellAction.java
  18. 53
      designer-realize/src/main/java/com/fr/design/actions/insert/flot/AutoChartFloatAction.java
  19. 11
      designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java
  20. 24
      designer-realize/src/main/java/com/fr/design/cell/editor/AutoChartCellEditor.java
  21. 18
      designer-realize/src/main/java/com/fr/design/cell/editor/AutoChartFloatEditor.java
  22. 18
      designer-realize/src/main/java/com/fr/design/cell/editor/ChartCellEditor.java
  23. 16
      designer-realize/src/main/java/com/fr/design/cell/editor/ChartFloatEditor.java
  24. 10
      designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java
  25. 49
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

13
designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java

@ -11,6 +11,10 @@ import com.fr.general.IOUtils;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
@ -22,10 +26,6 @@ import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
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.List;
import java.util.Map;
public class UICheckListPopup extends UIPopupMenu { public class UICheckListPopup extends UIPopupMenu {
private List<ActionListener> listeners = new ArrayList<ActionListener>(); private List<ActionListener> listeners = new ArrayList<ActionListener>();
@ -68,6 +68,11 @@ public class UICheckListPopup extends UIPopupMenu {
addCheckboxValues(values); addCheckboxValues(values);
} }
public void refreshCheckboxValues(Object[] value){
this.values = value;
addCheckboxValues(values);
}
public void addCheckboxValues(Object[] value) { public void addCheckboxValues(Object[] value) {
checkboxPane.removeAll(); checkboxPane.removeAll();
checkBoxList.clear(); checkBoxList.clear();

8
designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java

@ -17,6 +17,9 @@ import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.event.PopupMenuEvent; import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener; import javax.swing.event.PopupMenuListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
@ -29,9 +32,6 @@ import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent; import java.awt.event.FocusEvent;
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.List;
import java.util.Map;
/** /**
* 设计器下拉复选框组件 * 设计器下拉复选框组件
@ -198,7 +198,7 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
*/ */
public void refreshCombo(Object[] value) { public void refreshCombo(Object[] value) {
this.values = value; this.values = value;
this.popup.addCheckboxValues(value); this.popup.refreshCheckboxValues(value);
} }
/** /**

28
designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java

@ -19,11 +19,10 @@ import com.fr.plugin.solution.sandbox.collection.PluginSandboxCollections;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Constructor;
import java.awt.Dialog; import java.awt.Dialog;
import java.awt.Frame; import java.awt.Frame;
import java.awt.Window; import java.awt.Window;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
/** /**
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
@ -45,6 +44,7 @@ public class DesignModuleFactory {
private Class<Widget> chartEditorClass; private Class<Widget> chartEditorClass;
private Class<MiddleChartComponent> chartComponentClass; private Class<MiddleChartComponent> chartComponentClass;
private Class<MiddleChartDialog> chartDialogClass; private Class<MiddleChartDialog> chartDialogClass;
private Class<MiddleChartDialog> autoChartDialogClass;
private Class<? extends BaseChartPropertyPane> chartPropertyPaneClass; private Class<? extends BaseChartPropertyPane> chartPropertyPaneClass;
private Class newFormAction; private Class newFormAction;
private Class formParaDesigner; private Class formParaDesigner;
@ -100,6 +100,10 @@ public class DesignModuleFactory {
instance.chartDialogClass = cd; instance.chartDialogClass = cd;
} }
public static void registerAutoChartDialogClass(Class autoChartDialogClass) {
instance.autoChartDialogClass = autoChartDialogClass;
}
public static void registerChartPropertyPaneClass(Class<? extends BaseChartPropertyPane> p) { public static void registerChartPropertyPaneClass(Class<? extends BaseChartPropertyPane> p) {
instance.chartPropertyPaneClass = p; instance.chartPropertyPaneClass = p;
} }
@ -205,6 +209,26 @@ public class DesignModuleFactory {
return null; return null;
} }
/**
* kunsnat: 初始化图表向导对话框, 调用静态方法showWindow, 参数window.
*
* @return 返回调出的图表自动推荐ChartDialog
*/
public static MiddleChartDialog getAutoChartDialog(Window window) {
try {
Constructor<MiddleChartDialog> c;
if (window instanceof Frame) {
c = instance.autoChartDialogClass.getConstructor(Frame.class);
} else {
c = instance.autoChartDialogClass.getConstructor(Dialog.class);
}
return c.newInstance(window);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return null;
}
/** /**
* kunsnat: 获取图表属性界面 * kunsnat: 获取图表属性界面
* *

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

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

@ -12,8 +12,10 @@ import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.chart.fun.ChartTypeUIProvider; import com.fr.design.chart.fun.ChartTypeUIProvider;
import com.fr.design.chart.gui.ChartWidgetOption; import com.fr.design.chart.gui.ChartWidgetOption;
import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.condition.ConditionAttributesPane;
import com.fr.design.gui.core.CustomWidgetOption;
import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.core.WidgetOption;
import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.i18n.Toolkit;
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.ChartsConfigPane; import com.fr.design.mainframe.chart.ChartsConfigPane;
@ -41,6 +43,7 @@ import com.fr.design.type.ui.RangeChartTypeUI;
import com.fr.design.type.ui.StockChartTypeUI; import com.fr.design.type.ui.StockChartTypeUI;
import com.fr.design.type.ui.XYScatterChartTypeUI; import com.fr.design.type.ui.XYScatterChartTypeUI;
import com.fr.extended.chart.AbstractChart; import com.fr.extended.chart.AbstractChart;
import com.fr.form.ui.ChartAutoEditor;
import com.fr.form.ui.ChartEditor; import com.fr.form.ui.ChartEditor;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
@ -162,8 +165,13 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
public static WidgetOption[] initWidgetOption() { public static WidgetOption[] initWidgetOption() {
String[] chartIDs = ChartTypeManager.getInstance().getAllChartIDs(); String[] chartIDs = ChartTypeManager.getInstance().getAllChartIDs();
ChartWidgetOption[] child = new ChartWidgetOption[chartIDs.length]; List<WidgetOption> child = new ArrayList<>();
int index = 0; if (ChartTypeManager.AUTO_CHART) {
//TODO @Bjorn 视觉样式优化icon
child.add(new CustomWidgetOption(Toolkit.i18nText("Fine-Design_Chart_M_Popup_Auto_Chart_Type"),
IOUtils.readIcon("com/fr/design/images/form/toolbar/auto_chart.png"), ChartAutoEditor.class));
}
for (String chartID : chartIDs) { for (String chartID : chartIDs) {
ChartProvider[] rowChart = ChartTypeManager.getInstance().getCharts(chartID); ChartProvider[] rowChart = ChartTypeManager.getInstance().getCharts(chartID);
if (ArrayUtils.isEmpty(rowChart) && !ChartTypeManager.innerChart(chartID)) { if (ArrayUtils.isEmpty(rowChart) && !ChartTypeManager.innerChart(chartID)) {
@ -172,11 +180,10 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
String name = ChartTypeInterfaceManager.getInstance().getName(chartID); String name = ChartTypeInterfaceManager.getInstance().getName(chartID);
String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(chartID); String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(chartID);
Icon icon = IOUtils.readIcon(iconPath); Icon icon = IOUtils.readIcon(iconPath);
child[index] = new ChartWidgetOption(name, icon, ChartEditor.class, chartID); child.add(new ChartWidgetOption(name, icon, ChartEditor.class, chartID));
index++;
} }
return child; return child.toArray(new WidgetOption[child.size()]);
} }
private static void readVanChart() { private static void readVanChart() {

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

@ -0,0 +1,69 @@
package com.fr.design.chart;
import com.fr.base.chart.BaseChartCollection;
import com.fr.base.chart.chartdata.TopDefinitionProvider;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.plugin.chart.vanchart.VanChart;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-28
*/
public class AutoChartDialog extends ChartDialog {
private AutoChartTypePane autoChartTypePane;
public AutoChartDialog(Frame owner) {
super(owner);
}
public AutoChartDialog(Dialog owner) {
super(owner);
}
protected Component initCenterPane() {
autoChartTypePane = new AutoChartTypePane();
return autoChartTypePane;
}
protected void addOkAction() {
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ChartCollection chartCollection = (ChartCollection) getChartCollection();
autoChartTypePane.update(chartCollection);
if (chartCollection.getChartCount() > 0) {
doOK();
} else {
doCancel();
}
}
});
}
/**
* 更新新建的图表 ChartCollection
*/
public void populate(BaseChartCollection 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;
}
String tableName = vanChart.getFilterDefinition().getTableName();
String[] dataFields = vanChart.getFilterDefinition().getDataFields();
autoChartTypePane.populate(tableName, dataFields);
}
}

108
designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java

@ -0,0 +1,108 @@
package com.fr.design.chart;
import com.fr.base.ScreenResolution;
import com.fr.base.chart.BaseChartPainter;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.base.chart.result.WebChartIDInfo;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.script.Calculator;
import javax.swing.Icon;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-29
*/
public class AutoChartIcon implements Icon {
private static final int WIDTH = 500;
private static final int HEIGHT = 281;
private ChartCollection chartCollection;
private CallbackEvent callbackEvent;
private String chartName;
public AutoChartIcon(ChartCollection chartCollection) {
this.chartCollection = chartCollection;
initChartName();
}
public ChartCollection getChartCollection() {
return chartCollection;
}
public String getChartName() {
return chartName;
}
private void initChartName() {
Chart chart = chartCollection.getSelectedChart(Chart.class);
String[] subName = ChartTypeInterfaceManager.getInstance().getSubName(chart.getPlot().getPlotID());
chartName = subName[0];
}
public void registerCallBackEvent(CallbackEvent callbackEvent) {
this.callbackEvent = callbackEvent;
}
/**
* 画出缩略图Icon
*
* @param g 图形的上下文
* @param c 所在的Component
* @param x 缩略图的起始坐标x
* @param y 缩略图的起始坐标y
*/
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
BaseChartPainter painter = chartCollection.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(),
WebChartIDInfo.createEmptyDesignerInfo(), getIconWidth(), getIconHeight());
int resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getJTemplateResolution();
if (resolution == 0) {
resolution = ScreenResolution.getScreenResolution();
}
Graphics2D g2d = (Graphics2D) g;
Paint oldPaint = g2d.getPaint();
g.translate(x, y);
g2d.setPaint(Color.white);
g2d.fillRect(0, 0, getIconWidth(), getIconHeight());
painter.paint(g2d, getIconWidth(), getIconHeight(), resolution, null, callbackEvent);
g.translate(-x, -y);
g2d.setPaint(oldPaint);
}
/**
* 返回缩略图的宽度
*
* @return int 缩略图宽度
*/
@Override
public int getIconWidth() {
return WIDTH;
}
/**
* 返回缩略图的高度
*
* @return int 缩略图高度
*/
@Override
public int getIconHeight() {
return HEIGHT;
}
}

230
designer-chart/src/main/java/com/fr/design/chart/AutoChartTypePane.java

@ -0,0 +1,230 @@
package com.fr.design.chart;
import com.fr.base.chart.BaseChartCollection;
import com.fr.base.chart.BaseChartGetter;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chartx.attr.ChartProvider;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataComboBox;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombocheckbox.UIComboCheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.plugin.chart.area.VanChartAreaPlot;
import com.fr.plugin.chart.column.VanChartColumnPlot;
import com.fr.plugin.chart.line.VanChartLinePlot;
import com.fr.plugin.chart.vanchart.VanChart;
import javax.swing.BorderFactory;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.ListCellRenderer;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-29
*/
public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent {
private JList chartViewList;
private DefaultListModel chartResultModel;
private UIButton refreshButton;
private TableDataComboBox tableNameComboBox;
private UIComboCheckBox dataFieldBox;
public AutoChartTypePane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
initButtonGroup();
initRefreshLabel();
initDataFiledBox();
JPanel contentPane = createContentPane();
chartViewList = new JList();
chartResultModel = new DefaultListModel();
chartViewList.setModel(chartResultModel);
chartViewList.setVisibleRowCount(0);
chartViewList.setLayoutOrientation(JList.HORIZONTAL_WRAP);
chartViewList.setCellRenderer(iconCellRenderer);
JScrollPane subListPane = new JScrollPane(chartViewList);
JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, contentPane, subListPane);
splitPane.setDividerLocation(60);
splitPane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Chart_M_Popup_Auto_Chart_Type")));
this.add(splitPane);
}
ListCellRenderer iconCellRenderer = new DefaultListCellRenderer() {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
this.setText("");
AutoChartIcon chartIcon = (AutoChartIcon) value;
this.setIcon(chartIcon);
setHorizontalAlignment(UILabel.CENTER);
if (isSelected) {
// 深蓝色.
this.setBackground(new Color(57, 107, 181));
this.setBorder(GUICoreUtils.createTitledBorder(chartIcon.getChartName(), Color.WHITE));
} else {
this.setBorder(GUICoreUtils.createTitledBorder(chartIcon.getChartName()));
}
return this;
}
};
private JPanel createContentPane() {
JPanel panel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
JPanel tableDataPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
panel.add(tableDataPane);
tableDataPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Table_Data") + ":"));
tableNameComboBox.setPreferredSize(new Dimension(96, 20));
tableDataPane.add(tableNameComboBox);
JPanel areaNamePane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
panel.add(areaNamePane);
areaNamePane.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Data_Field") + ":"));
areaNamePane.add(dataFieldBox);
panel.add(refreshButton);
return panel;
}
private void initButtonGroup() {
dataFieldBox = new UIComboCheckBox(new Object[0]);
dataFieldBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkButtonState();
}
});
}
private void initDataFiledBox() {
tableNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource());
tableNameComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
refreshBox();
checkButtonState();
}
}
});
}
private void checkButtonState() {
if (tableNameComboBox.getSelectedItem() != null && dataFieldBox.getSelectedValues().length > 0) {
refreshButton.setEnabled(true);
} else {
refreshButton.setEnabled(false);
}
}
private void refreshBox() {
TableDataWrapper dataWrap = tableNameComboBox.getSelectedItem();
if (dataWrap == null) {
return;
}
dataFieldBox.clearText();
List<String> columnNameList = dataWrap.calculateColumnNameList();
dataFieldBox.refreshCombo(columnNameList.toArray());
}
private void initRefreshLabel() {
refreshButton = new UIButton(Toolkit.i18nText("Fine-Design_Chart_Recommend"));
refreshButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
calculateAutoChart();
}
});
refreshButton.setEnabled(false);
}
private void calculateAutoChart() {
chartResultModel.clear();
//TODO 使用以下模拟数据,计算规则待补充
BaseChartCollection chartCollection = BaseChartGetter.createChartCollection(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID);
VanChart selectedChart = ((ChartCollection) chartCollection).getSelectedChart(VanChart.class);
selectedChart.getTitle().setTextObject("自动图表标题");
BaseChartCollection chartCollection1 = BaseChartGetter.createChartCollection(VanChartLinePlot.VAN_CHART_LINE_PLOT);
VanChart selectedChart1 = ((ChartCollection) chartCollection1).getSelectedChart(VanChart.class);
selectedChart1.getTitle().setTextObject("自动图表标题");
BaseChartCollection chartCollection2 = BaseChartGetter.createChartCollection(VanChartAreaPlot.VAN_CHART_AREA_PLOT_ID);
VanChart selectedChart2 = ((ChartCollection) chartCollection2).getSelectedChart(VanChart.class);
selectedChart2.getTitle().setTextObject("自动图表标题");
AutoChartIcon autoChartIcon = new AutoChartIcon((ChartCollection) chartCollection);
autoChartIcon.registerCallBackEvent(this);
AutoChartIcon autoChartIcon1 = new AutoChartIcon((ChartCollection) chartCollection1);
autoChartIcon1.registerCallBackEvent(this);
AutoChartIcon autoChartIcon2 = new AutoChartIcon((ChartCollection) chartCollection2);
autoChartIcon2.registerCallBackEvent(this);
chartResultModel.addElement(autoChartIcon);
chartResultModel.addElement(autoChartIcon1);
chartResultModel.addElement(autoChartIcon2);
chartViewList.setSelectedIndex(0);
}
@Override
public void populate(ChartCollection cc) {
}
@Override
public void update(ChartCollection cc) {
if (chartViewList.getSelectedIndex() < 0) {
return;
}
AutoChartIcon chartIcon = (AutoChartIcon) chartViewList.getSelectedValue();
ChartProvider chartProvider = chartIcon.getChartCollection().getSelectedChartProvider(ChartProvider.class);
if (cc.getChartCount() > 0) {
cc.setSelectChart(chartProvider);
} else {
cc.addChart(chartProvider);
}
}
public void populate(String tableName, String[] dataFields) {
tableNameComboBox.setSelectedTableDataByName(tableName);
Map<Object, Boolean> map = new HashMap();
for (String dataField : dataFields) {
map.put(dataField, true);
}
dataFieldBox.setSelectedValues(map);
}
@Override
public void callback() {
this.repaint();
}
}

1
designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java

@ -39,6 +39,7 @@ public class ChartDesignerActivator extends Activator implements Prepare {
DesignModuleFactory.registerChartComponentClass(ChartComponent.class); DesignModuleFactory.registerChartComponentClass(ChartComponent.class);
DesignModuleFactory.registerChartDialogClass(ChartDialog.class); DesignModuleFactory.registerChartDialogClass(ChartDialog.class);
DesignModuleFactory.registerAutoChartDialogClass(AutoChartDialog.class);
DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class); DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class);

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

@ -10,6 +10,7 @@ import com.fr.third.joda.time.DateTime;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dialog; import java.awt.Dialog;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.Frame; import java.awt.Frame;
@ -18,6 +19,7 @@ import java.awt.event.ActionListener;
/** /**
* 封装一层 图表新建的对话框, 配合属性表确定: 先单独只要一种图表类型的对话框. * 封装一层 图表新建的对话框, 配合属性表确定: 先单独只要一种图表类型的对话框.
*
* @author kunsnat E-mail:kunsnat@gmail.com * @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2013-1-7 下午07:29:15 * @version 创建时间2013-1-7 下午07:29:15
*/ */
@ -25,8 +27,9 @@ public class ChartDialog extends MiddleChartDialog {
private BaseChartCollection cc; private BaseChartCollection cc;
private UIButton ok; protected UIButton ok;
private UIButton cancel; protected UIButton cancel;
private ChartTypePane chartTypePane;
public ChartDialog(Frame owner) { public ChartDialog(Frame owner) {
super(owner); super(owner);
@ -39,43 +42,48 @@ public class ChartDialog extends MiddleChartDialog {
} }
private void initComponent() { private void initComponent() {
final String createTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
this.setModal(true); this.setModal(true);
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
final ChartTypePane chartTypePane = new ChartTypePane();
setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_M_Popup_Chart_Type")); setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_M_Popup_Chart_Type"));
this.applyClosingAction(); this.applyClosingAction();
this.applyEscapeAction(); this.applyEscapeAction();
this.setBasicDialogSize(BasicDialog.DEFAULT); this.setBasicDialogSize(BasicDialog.DEFAULT);
this.add(chartTypePane, BorderLayout.CENTER); this.add(initCenterPane(), BorderLayout.CENTER);
JPanel buttonPane = new JPanel(); JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
this.add(buttonPane, BorderLayout.SOUTH); this.add(buttonPane, BorderLayout.SOUTH);
ok = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_OK")); ok = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_OK"));
cancel = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cancel")); cancel = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cancel"));
addOkAction();
cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
doCancel();
}
});
buttonPane.add(ok); buttonPane.add(ok);
buttonPane.add(cancel); buttonPane.add(cancel);
GUICoreUtils.setWindowCenter(getOwner(), this);
}
protected Component initCenterPane() {
chartTypePane = new ChartTypePane();
return chartTypePane;
}
protected void addOkAction() {
final String createTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
ok.addActionListener(new ActionListener() { ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
chartTypePane.update((ChartCollection) cc, createTime); chartTypePane.update((ChartCollection) cc, createTime);
doOK(); doOK();
} }
}); });
cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
doCancel();
}
});
GUICoreUtils.setWindowCenter(getOwner(), this);
} }
/** /**

3
designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java

@ -140,6 +140,9 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
public void paintComponent(Graphics g) { // public void paintComponent(Graphics g) { //
super.paintComponent(g); super.paintComponent(g);
if(chartCollection4Design.getChartCount() == 0) {
return;
}
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;

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

@ -6,28 +6,36 @@ import com.fr.chartx.attr.ChartProvider;
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.dialog.DialogActionAdapter;
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.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.FlexibleComboBox;
import com.fr.design.mainframe.chart.gui.item.ItemEventType; 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.design.module.DesignModuleFactory;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; 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.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/** /**
* 图表 属性表, 类型选择 界面. * 图表 属性表, 类型选择 界面.
@ -39,6 +47,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
private ChartTypeButtonPane buttonPane; private ChartTypeButtonPane buttonPane;
private ChartEditPane editPane; private ChartEditPane editPane;
private ChartCollection editingCollection; private ChartCollection editingCollection;
private UIButton autoButton;
@Override @Override
protected JPanel createContentPane() { protected JPanel createContentPane() {
@ -79,6 +88,11 @@ 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;
} }
@ -97,6 +111,25 @@ public class ChartTypePane extends AbstractChartAttrPane{
return PaneTitleConstants.CHART_TYPE_TITLE; return PaneTitleConstants.CHART_TYPE_TITLE;
} }
private void initAutoButton(){
//TODO @Bjorn 视觉样式优化
autoButton = new UIButton(Toolkit.i18nText("Fine-Design_Chart_M_Popup_Auto_Chart_Type"));
autoButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final MiddleChartDialog autoChartDialog = DesignModuleFactory.getAutoChartDialog(DesignerContext.getDesignerFrame());
autoChartDialog.populate(editingCollection);
autoChartDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
populate(editingCollection);
}
});
autoChartDialog.setVisible(true);
}
});
}
class ComboBoxPane extends UIComboBoxPane<ChartProvider> { class ComboBoxPane extends UIComboBoxPane<ChartProvider> {
private Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane; private Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane;

BIN
designer-chart/src/main/resources/com/fr/design/images/form/toolbar/auto_chart.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

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

@ -0,0 +1,113 @@
package com.fr.design.designer.creator;
import com.fr.base.GraphHelper;
import com.fr.base.chart.BaseChartCollection;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.module.DesignModuleFactory;
import com.fr.form.ui.ChartAutoEditor;
import com.fr.stable.bridge.StableFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-26
*/
public class XAutoChartCreator extends XChartEditor {
private MiddleChartDialog autoChartDialog;
private EditingMouseListener editingMouseListener;
public XAutoChartCreator(ChartAutoEditor editor, Dimension size) {
super(editor, size);
}
/**
* 返回组件默认名
*
* @return 组件类名(小写)
*/
public String createDefaultName() {
return "auto_chart";
}
@Override
public ChartAutoEditor toData() {
return (ChartAutoEditor) data;
}
/**
* 点击选中的时候, 刷新界面
* 右键 reset之后, 触发事件 populate此方法
*
* @param jform 表单
* @param formDesigner 表单设计器
* @return 控件.
*/
public JComponent createToolPane(final BaseJForm jform, final FormDesigner formDesigner) {
if (toData().isChartSelect()) {
return super.createToolPane(jform, formDesigner);
}
if (isEditing) {
if (autoChartDialog != null && autoChartDialog.isVisible()) {
return new JPanel();
}
final BaseChartCollection chartCollection = (BaseChartCollection) StableFactory.createXmlObject(BaseChartCollection.XML_TAG);
autoChartDialog = DesignModuleFactory.getAutoChartDialog(DesignerContext.getDesignerFrame());
autoChartDialog.populate(chartCollection);
autoChartDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
initChart(autoChartDialog.getChartCollection());
formDesigner.fireTargetModified();
}
@Override
public void doCancel() {
editingMouseListener.stopEditing();
}
});
autoChartDialog.setVisible(true);
}
return toData().isChartSelect() ? super.createToolPane(jform, formDesigner) : new JPanel();
}
/**
* 响应点击事件
*
* @param editingMouseListener 鼠标点击位置处理器
* @param e 鼠标点击事件
*/
public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e) {
this.editingMouseListener = editingMouseListener;
super.respondClick(editingMouseListener, e);
}
public void paint(Graphics g) {
//TODO @Bjorn 视觉样式优化
g.setColor(Color.RED);
GraphHelper.fill(g, new Rectangle(0, 0, getWidth(), getHeight()));
super.paint(g);
}
private void initChart(BaseChartCollection chartCollection) {
((MiddleChartComponent) getDesignerEditor().getEditorTarget()).populate(chartCollection);
this.toData().resetChangeChartCollection(chartCollection);
this.toData().setChartSelect(true);
}
}

19
designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java

@ -28,13 +28,13 @@ import javax.swing.BorderFactory;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import java.beans.IntrospectionException;
import java.awt.Color; import java.awt.Color;
import java.awt.Cursor; import java.awt.Cursor;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.beans.IntrospectionException;
/** /**
* form中的图表按钮弹出的控件, 创建初始化图表内容. * form中的图表按钮弹出的控件, 创建初始化图表内容.
@ -52,7 +52,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
//marro:无奈的属性,暂时想不出好办法 //marro:无奈的属性,暂时想不出好办法
private boolean isRefreshing = false; private boolean isRefreshing = false;
private boolean isEditing = false; protected boolean isEditing = false;
private boolean isHovering = false; private boolean isHovering = false;
private static final Color OUTER_BORDER_COLOR = new Color(65, 155, 249, 30); private static final Color OUTER_BORDER_COLOR = new Color(65, 155, 249, 30);
@ -79,6 +79,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
/** /**
* 返回组件默认名 * 返回组件默认名
*
* @return 组件类名(小写) * @return 组件类名(小写)
*/ */
public String createDefaultName() { public String createDefaultName() {
@ -87,6 +88,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
/** /**
* 是否支持设置标题 * 是否支持设置标题
*
* @return 是返回true * @return 是返回true
*/ */
public boolean hasTitleStyle() { public boolean hasTitleStyle() {
@ -98,8 +100,10 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
isEditing = false; isEditing = false;
} }
/** /**
* 得到属性名 * 得到属性名
*
* @return 属性名 * @return 属性名
* @throws java.beans.IntrospectionException * @throws java.beans.IntrospectionException
*/ */
@ -111,7 +115,8 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
@Override @Override
public void propertyChange() { public void propertyChange() {
makeVisible(toData().isVisible());} makeVisible(toData().isVisible());
}
}), }),
new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass( new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass(
WLayoutBorderStyleEditor.class).setI18NName( WLayoutBorderStyleEditor.class).setI18NName(
@ -128,6 +133,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
/** /**
* 该组件是否可以拖入参数面板 * 该组件是否可以拖入参数面板
*
* @return 是则返回true * @return 是则返回true
*/ */
public boolean canEnterIntoParaPane() { public boolean canEnterIntoParaPane() {
@ -137,7 +143,6 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
/** /**
* 编辑状态的时候需要重新绘制下边框 * 编辑状态的时候需要重新绘制下边框
*
*/ */
@Override @Override
public void paintBorder(Graphics g, Rectangle bounds) { public void paintBorder(Graphics g, Rectangle bounds) {
@ -206,8 +211,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
} }
}); });
return (JComponent) propertyPane; return (JComponent) propertyPane;
} } else {
else{
return (JComponent) DesignModuleFactory.getWidgetPropertyPane(formDesigner); return (JComponent) DesignModuleFactory.getWidgetPropertyPane(formDesigner);
} }
} }
@ -305,6 +309,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
/** /**
* 是否展现覆盖的pane * 是否展现覆盖的pane
*
* @param display 是否 * @param display 是否
*/ */
public void displayCoverPane(boolean display) { public void displayCoverPane(boolean display) {
@ -329,7 +334,6 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
/** /**
* data属性改变触发其他操作 * data属性改变触发其他操作
*
*/ */
public void firePropertyChange() { public void firePropertyChange() {
initStyle(); initStyle();
@ -342,6 +346,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
/** /**
* 是否支持共享-现只支持报表块图表tab块绝对布局 * 是否支持共享-现只支持报表块图表tab块绝对布局
*
* @return * @return
*/ */
public boolean isSupportShared() { public boolean isSupportShared() {

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

@ -19,6 +19,7 @@ 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;
@ -174,6 +175,7 @@ public class XCreatorUtils {
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);
} }
} }

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

@ -0,0 +1,57 @@
package com.fr.design.actions.insert.cell;
import com.fr.base.BaseUtils;
import com.fr.chart.chartattr.AutoChartCollection;
import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.menu.MenuKeySet;
import javax.swing.KeyStroke;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-28
*/
public class AutoChartCellAction extends AbstractCellAction implements WorkBookSupportable {
public AutoChartCellAction() {
initAction();
}
public AutoChartCellAction(ElementCasePane t) {
super(t);
initAction();
}
private void initAction() {
this.setMenuKeySet(INSERT_AUTO_CHART);
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
//TODO @Bjorn 视觉样式优化icon
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/auto_chart.png"));
}
public static final MenuKeySet INSERT_AUTO_CHART = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'M';
}
@Override
public String getMenuName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_M_Insert_Auto_Chart");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
@Override
public Class getCellValueClass() {
return AutoChartCollection.class;
}
}

53
designer-realize/src/main/java/com/fr/design/actions/insert/flot/AutoChartFloatAction.java

@ -0,0 +1,53 @@
package com.fr.design.actions.insert.flot;
import com.fr.base.BaseUtils;
import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.menu.MenuKeySet;
import com.fr.design.module.DesignModuleFactory;
import javax.swing.KeyStroke;
import java.awt.Window;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-28
*/
public class AutoChartFloatAction extends ChartFloatAction {
/**
* 构造函数 图表插入悬浮元素
*/
public AutoChartFloatAction(ElementCasePane t) {
super(t);
}
protected void init() {
this.setMenuKeySet(FLOAT_INSERT_AUTO_CHART);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/auto_chart.png"));
}
public static final MenuKeySet FLOAT_INSERT_AUTO_CHART = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'M';
}
@Override
public String getMenuName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_M_Insert_Auto_Chart");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
protected MiddleChartDialog getMiddleChartDialog(Window window) {
return DesignModuleFactory.getAutoChartDialog(window);
}
}

11
designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java

@ -27,6 +27,7 @@ import com.fr.stable.unit.OLDPIX;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import java.awt.Color; import java.awt.Color;
import java.awt.Window;
/** /**
* 图表插入悬浮元素的操作. * 图表插入悬浮元素的操作.
@ -40,6 +41,10 @@ public class ChartFloatAction extends ElementCaseAction {
*/ */
public ChartFloatAction(ElementCasePane t) { public ChartFloatAction(ElementCasePane t) {
super(t); super(t);
init();
}
protected void init() {
this.setMenuKeySet(FLOAT_INSERT_CHART); this.setMenuKeySet(FLOAT_INSERT_CHART);
this.setName(getMenuKeySet().getMenuKeySetName()); this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
@ -78,7 +83,7 @@ public class ChartFloatAction extends ElementCaseAction {
reportPane.stopEditing(); reportPane.stopEditing();
final BaseChartCollection cc = (BaseChartCollection) StableFactory.createXmlObject(BaseChartCollection.XML_TAG); final BaseChartCollection cc = (BaseChartCollection) StableFactory.createXmlObject(BaseChartCollection.XML_TAG);
final MiddleChartDialog chartDialog = DesignModuleFactory.getChartDialog(DesignerContext.getDesignerFrame()); final MiddleChartDialog chartDialog = getMiddleChartDialog(DesignerContext.getDesignerFrame());
chartDialog.populate(cc); chartDialog.populate(cc);
chartDialog.addDialogActionListener(new DialogActionAdapter() { chartDialog.addDialogActionListener(new DialogActionAdapter() {
@Override @Override
@ -124,4 +129,8 @@ public class ChartFloatAction extends ElementCaseAction {
chartDialog.setVisible(true); chartDialog.setVisible(true);
return isRecordNeeded; return isRecordNeeded;
} }
protected MiddleChartDialog getMiddleChartDialog(Window window) {
return DesignModuleFactory.getChartDialog(window);
}
} }

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

@ -0,0 +1,24 @@
package com.fr.design.cell.editor;
import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.module.DesignModuleFactory;
import com.fr.report.elementcase.TemplateElementCase;
import java.awt.Window;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-28
*/
public class AutoChartCellEditor extends ChartCellEditor {
public AutoChartCellEditor(ElementCasePane<? extends TemplateElementCase> ePane) {
super(ePane);
}
protected MiddleChartDialog getMiddleChartDialog(Window window) {
return DesignModuleFactory.getAutoChartDialog(window);
}
}

18
designer-realize/src/main/java/com/fr/design/cell/editor/AutoChartFloatEditor.java

@ -0,0 +1,18 @@
package com.fr.design.cell.editor;
import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.module.DesignModuleFactory;
import java.awt.Window;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-28
*/
public class AutoChartFloatEditor extends ChartFloatEditor {
protected MiddleChartDialog getMiddleChartDialog(Window window) {
return DesignModuleFactory.getAutoChartDialog(window);
}
}

18
designer-realize/src/main/java/com/fr/design/cell/editor/ChartCellEditor.java

@ -1,21 +1,21 @@
package com.fr.design.cell.editor; package com.fr.design.cell.editor;
import java.awt.Component;
import javax.swing.SwingUtilities;
import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartCollection;
import com.fr.design.dialog.DialogActionListener;
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;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.dialog.DialogActionListener;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.module.DesignModuleFactory;
import com.fr.grid.Grid; import com.fr.grid.Grid;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.bridge.StableFactory; import com.fr.stable.bridge.StableFactory;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.SwingUtilities;
import java.awt.Component;
import java.awt.Window;
/** /**
* CellEditor used to edit Chart object. * CellEditor used to edit Chart object.
*/ */
@ -67,7 +67,7 @@ public class ChartCellEditor extends AbstractCellEditor implements DialogActionL
this.chartCellEditorDialog = null; this.chartCellEditorDialog = null;
return glyphComponent; return glyphComponent;
} }
this.chartCellEditorDialog = DesignModuleFactory.getChartDialog(SwingUtilities.getWindowAncestor(grid)); this.chartCellEditorDialog = getMiddleChartDialog(SwingUtilities.getWindowAncestor(grid));
this.chartCellEditorDialog.addDialogActionListener(this); this.chartCellEditorDialog.addDialogActionListener(this);
BaseChartCollection cc = (BaseChartCollection)StableFactory.createXmlObject(BaseChartCollection.XML_TAG); BaseChartCollection cc = (BaseChartCollection)StableFactory.createXmlObject(BaseChartCollection.XML_TAG);
this.chartCellEditorDialog.populate(cc); this.chartCellEditorDialog.populate(cc);
@ -84,4 +84,8 @@ public class ChartCellEditor extends AbstractCellEditor implements DialogActionL
public void doCancel() { public void doCancel() {
cancelCellEditing(); cancelCellEditing();
} }
protected MiddleChartDialog getMiddleChartDialog(Window window) {
return DesignModuleFactory.getChartDialog(window);
}
} }

16
designer-realize/src/main/java/com/fr/design/cell/editor/ChartFloatEditor.java

@ -1,20 +1,20 @@
package com.fr.design.cell.editor; package com.fr.design.cell.editor;
import java.awt.Component;
import javax.swing.SwingUtilities;
import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartCollection;
import com.fr.design.dialog.DialogActionListener;
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;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
import com.fr.design.dialog.DialogActionListener;
import com.fr.grid.Grid; import com.fr.grid.Grid;
import com.fr.report.cell.FloatElement; import com.fr.report.cell.FloatElement;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.bridge.StableFactory; import com.fr.stable.bridge.StableFactory;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.SwingUtilities;
import java.awt.Component;
import java.awt.Window;
public class ChartFloatEditor extends AbstractFloatEditor implements DialogActionListener { public class ChartFloatEditor extends AbstractFloatEditor implements DialogActionListener {
private MiddleChartDialog chartFloatEditorDialog = null; private MiddleChartDialog chartFloatEditorDialog = null;
@ -65,7 +65,7 @@ public class ChartFloatEditor extends AbstractFloatEditor implements DialogActio
} }
return glyphComponent; return glyphComponent;
} }
this.chartFloatEditorDialog = DesignModuleFactory.getChartDialog(SwingUtilities.getWindowAncestor(grid)); this.chartFloatEditorDialog = getMiddleChartDialog(SwingUtilities.getWindowAncestor(grid));
this.chartFloatEditorDialog.addDialogActionListener(this); this.chartFloatEditorDialog.addDialogActionListener(this);
BaseChartCollection cc = (BaseChartCollection)StableFactory.createXmlObject(BaseChartCollection.XML_TAG); BaseChartCollection cc = (BaseChartCollection)StableFactory.createXmlObject(BaseChartCollection.XML_TAG);
this.chartFloatEditorDialog.populate(cc); this.chartFloatEditorDialog.populate(cc);
@ -82,4 +82,8 @@ public class ChartFloatEditor extends AbstractFloatEditor implements DialogActio
public void doCancel() { public void doCancel() {
cancelFloatEditing(); cancelFloatEditing();
} }
protected MiddleChartDialog getMiddleChartDialog(Window window) {
return DesignModuleFactory.getChartDialog(window);
}
} }

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

@ -9,6 +9,7 @@ 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;
@ -52,6 +53,8 @@ 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;
@ -118,6 +121,8 @@ import javax.swing.JPanel;
import javax.swing.JPopupMenu; import javax.swing.JPopupMenu;
import javax.swing.JScrollBar; import javax.swing.JScrollBar;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import java.lang.reflect.Constructor;
import java.util.Set;
import java.awt.AWTEvent; import java.awt.AWTEvent;
import java.awt.Adjustable; import java.awt.Adjustable;
import java.awt.Dimension; import java.awt.Dimension;
@ -131,8 +136,6 @@ import java.awt.event.ActionListener;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.lang.reflect.Constructor;
import java.util.Set;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
@ -399,6 +402,9 @@ 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);
grid.setDefaultFloatEditor(Formula.class, new FormulaFloatEditor()); grid.setDefaultFloatEditor(Formula.class, new FormulaFloatEditor());

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

@ -7,12 +7,14 @@ import com.fr.base.passport.FinePassportListenerAdapter;
import com.fr.base.passport.FinePassportManager; import com.fr.base.passport.FinePassportManager;
import com.fr.base.process.ProcessOperator; import com.fr.base.process.ProcessOperator;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
import com.fr.decision.update.backup.RecoverManager; import com.fr.decision.update.backup.RecoverManager;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.NewFormAction; import com.fr.design.actions.NewFormAction;
import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.insert.cell.AutoChartCellAction;
import com.fr.design.actions.insert.cell.BiasCellAction; import com.fr.design.actions.insert.cell.BiasCellAction;
import com.fr.design.actions.insert.cell.ChartCellAction; import com.fr.design.actions.insert.cell.ChartCellAction;
import com.fr.design.actions.insert.cell.DSColumnCellAction; import com.fr.design.actions.insert.cell.DSColumnCellAction;
@ -21,6 +23,7 @@ import com.fr.design.actions.insert.cell.GeneralCellAction;
import com.fr.design.actions.insert.cell.ImageCellAction; import com.fr.design.actions.insert.cell.ImageCellAction;
import com.fr.design.actions.insert.cell.RichTextCellAction; import com.fr.design.actions.insert.cell.RichTextCellAction;
import com.fr.design.actions.insert.cell.SubReportCellAction; import com.fr.design.actions.insert.cell.SubReportCellAction;
import com.fr.design.actions.insert.flot.AutoChartFloatAction;
import com.fr.design.actions.insert.flot.ChartFloatAction; import com.fr.design.actions.insert.flot.ChartFloatAction;
import com.fr.design.actions.insert.flot.FormulaFloatAction; import com.fr.design.actions.insert.flot.FormulaFloatAction;
import com.fr.design.actions.insert.flot.ImageFloatAction; import com.fr.design.actions.insert.flot.ImageFloatAction;
@ -112,11 +115,11 @@ import com.fr.start.BBSGuestPaneProvider;
import com.fr.task.Once; import com.fr.task.Once;
import com.fr.xml.ReportXMLUtils; import com.fr.xml.ReportXMLUtils;
import java.awt.*;
import java.awt.image.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.awt.Image;
import java.awt.image.BufferedImage;
/** /**
* Created by juhaoyu on 2018/1/31. * Created by juhaoyu on 2018/1/31.
@ -222,16 +225,21 @@ public class DesignerActivator extends Activator {
classes.add(provider.actionForInsertCellElement()); classes.add(provider.actionForInsertCellElement());
} }
return ArrayUtils.addAll(new Class<?>[]{ List<Class<?>> baseClasses = new ArrayList<>();
DSColumnCellAction.class, baseClasses.add(DSColumnCellAction.class);
GeneralCellAction.class, baseClasses.add(GeneralCellAction.class);
RichTextCellAction.class, baseClasses.add(RichTextCellAction.class);
FormulaCellAction.class, baseClasses.add(FormulaCellAction.class);
ChartCellAction.class, baseClasses.add(ChartCellAction.class);
ImageCellAction.class, if(ChartTypeManager.AUTO_CHART) {
BiasCellAction.class, baseClasses.add(AutoChartCellAction.class);
SubReportCellAction.class }
}, classes.toArray(new Class<?>[classes.size()])); baseClasses.add(ImageCellAction.class);
baseClasses.add(BiasCellAction.class);
baseClasses.add(SubReportCellAction.class);
return ArrayUtils.addAll(baseClasses.toArray(new Class<?>[baseClasses.size()]),
classes.toArray(new Class<?>[classes.size()]));
} }
private static Class<?>[] actionsForInsertFloatElement() { private static Class<?>[] actionsForInsertFloatElement() {
@ -240,12 +248,17 @@ public class DesignerActivator extends Activator {
for (ElementUIProvider provider : providers) { for (ElementUIProvider provider : providers) {
classes.add(provider.actionForInsertFloatElement()); classes.add(provider.actionForInsertFloatElement());
} }
return ArrayUtils.addAll(new Class<?>[]{
TextBoxFloatAction.class, List<Class<?>> baseClasses = new ArrayList<>();
FormulaFloatAction.class, baseClasses.add(TextBoxFloatAction.class);
ChartFloatAction.class, baseClasses.add(FormulaFloatAction.class);
ImageFloatAction.class baseClasses.add(ChartFloatAction.class);
}, classes.toArray(new Class<?>[classes.size()])); if(ChartTypeManager.AUTO_CHART) {
baseClasses.add(AutoChartFloatAction.class);
}
baseClasses.add(ImageFloatAction.class);
return ArrayUtils.addAll(baseClasses.toArray(new Class<?>[baseClasses.size()]),
classes.toArray(new Class<?>[classes.size()]));
} }
private static NameableCreator[] hyperlinkTypes() { private static NameableCreator[] hyperlinkTypes() {

Loading…
Cancel
Save