Browse Source

Merging in latest from upstream (DESIGN/design:refs/heads/feature/10.0)

* commit '376cc491e49fb854ba31cbcc35ae066d80e479b5': (33 commits)
  KERNEL-896 修改VcsFolderManagerActivator位置
  KERNEL-896 修改vcs目录位置
  CHART-9141 filter界面&xml、processor不合理改成枚举、result流程一部分
  CHART-4798 数据集数据源
  REPORT-19083 设计器内删除当前模板时,未自动退回到最后一张已打开的模板
  无JIRA任务 数据收集,为了规避获取username要在启动之后,写了个中转文件
  REPORT-18422 图片控件插件问题 设计器部分漏提交
  CHART-9141 删除图表设计器相关代码
  CHART-9141 replace chart with chartProvider(eg:typePane) && 图表公式相关接口 && 删除图表内部对datamodel的cache(和engine确认过)
  CHART-9783 地图相关操作慢
  REPORT-18570 fr连接bi 数据分析预览单元格没有过滤设置
  限制文件大小
  REPORT-19059 环境切换同名程序数据集还是使用上一个环境的sql
  换个名字
  REPORT-18855 加下单元测试
  REPORT-19058 环境切换暂存文件为保存提示
  REPORT-18855 & REPORT-18857 jpg图片持久化遗漏了一些场景
  CHART-9576 远程设计 设计器中用实时的
  内存配置推荐:设计器安装插件随lic显示状态不对
  REPORT-18955 填报属性配置,提交条件的删除按钮没有灰色化
  ...
research/11.0
vito 5 years ago
parent
commit
4628bc9400
  1. 15
      designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java
  2. 2
      designer-base/src/main/java/com/fr/design/extra/PluginUtils.java
  3. 2
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  4. 15
      designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java
  5. 3
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java
  6. 18
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCacheFileNodeFile.java
  7. 8
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java
  8. 7
      designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java
  9. 5
      designer-base/src/main/java/com/fr/file/StashedFILE.java
  10. 102
      designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java
  11. 23
      designer-base/src/test/java/com/fr/file/StashedFILETest.java
  12. 19
      designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java
  13. 14
      designer-chart/src/main/java/com/fr/design/chart/ChartCommonWizardPane.java
  14. 128
      designer-chart/src/main/java/com/fr/design/chart/ChartControlPane.java
  15. 86
      designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java
  16. 4
      designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java
  17. 10
      designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java
  18. 12
      designer-chart/src/main/java/com/fr/design/chart/gui/active/action/ChartComponentAction.java
  19. 8
      designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java
  20. 58
      designer-chart/src/main/java/com/fr/design/chartx/AbstractChartDataPane.java
  21. 39
      designer-chart/src/main/java/com/fr/design/chartx/GanttChartDataPane.java
  22. 43
      designer-chart/src/main/java/com/fr/design/chartx/MultiCategoryChartDataPane.java
  23. 21
      designer-chart/src/main/java/com/fr/design/chartx/MultiPieChartDataPane.java
  24. 20
      designer-chart/src/main/java/com/fr/design/chartx/WordCloudChartDataPane.java
  25. 252
      designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java
  26. 168
      designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java
  27. 150
      designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPaneWithUISpinner.java
  28. 171
      designer-chart/src/main/java/com/fr/design/chartx/component/AbstractSingleFilterPane.java
  29. 56
      designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueCorrelationPane.java
  30. 40
      designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java
  31. 40
      designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPaneWithUISpinner.java
  32. 31
      designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java
  33. 25
      designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPaneWithUISpinner.java
  34. 107
      designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java
  35. 130
      designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractCorrelationPane.java
  36. 19
      designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractEditorComponent.java
  37. 45
      designer-chart/src/main/java/com/fr/design/chartx/component/correlation/CalculateComboBoxEditorComponent.java
  38. 20
      designer-chart/src/main/java/com/fr/design/chartx/component/correlation/FieldEditorComponentWrapper.java
  39. 56
      designer-chart/src/main/java/com/fr/design/chartx/component/correlation/TinyFormulaPaneEditorComponent.java
  40. 55
      designer-chart/src/main/java/com/fr/design/chartx/component/correlation/UIComboBoxEditorComponent.java
  41. 41
      designer-chart/src/main/java/com/fr/design/chartx/component/correlation/UITextFieldEditorComponent.java
  42. 97
      designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java
  43. 149
      designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractDataSetFieldsPane.java
  44. 41
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java
  45. 60
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java
  46. 115
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java
  47. 116
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java
  48. 67
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieCellDataFieldsPane.java
  49. 94
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieDataSetFieldsPane.java
  50. 70
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/WordCloudCellDataFieldsPane.java
  51. 74
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/WordCloudDataSetFieldsPane.java
  52. 56
      designer-chart/src/main/java/com/fr/design/chartx/single/CellDataPane.java
  53. 121
      designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java
  54. 90
      designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java
  55. 43
      designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java
  56. 65
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDesignerOtherPane.java
  57. 72
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java
  58. 110
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java
  59. 33
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/StylePane4Chart.java
  60. 94
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/other/ChartSwitchPane.java
  61. 6
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractBarPane.java
  62. 397
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java
  63. 409
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractDeprecatedChartTypePane.java
  64. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AreaPlotPane.java
  65. 4
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/BubblePlotPane.java
  66. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/CustomPlotPane.java
  67. 8
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/DonutPlotPane.java
  68. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/FunnelPlotPane.java
  69. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GanttPlotPane.java
  70. 6
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GisMapPlotPane.java
  71. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/LinePlotPane.java
  72. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MapPlotPane.java
  73. 6
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MeterPlotPane.java
  74. 4
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/PiePlotPane.java
  75. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/RadarPlotPane.java
  76. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/RangePlotPane.java
  77. 4
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/StockPlotPane.java
  78. 4
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/UserDefinedChartTypePane.java
  79. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/XYScatterPlotPane.java
  80. 13
      designer-chart/src/main/java/com/fr/design/module/ChartPreStylePane.java
  81. 331
      designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java
  82. 10
      designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java
  83. 8
      designer-chart/src/main/java/com/fr/van/chart/column/ColumnIndependentVanChartInterface.java
  84. 5
      designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java
  85. 6
      designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java
  86. 15
      designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java
  87. 21
      designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java
  88. 8
      designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java
  89. 2
      designer-realize/src/main/java/com/fr/design/actions/insert/flot/ImageFloatAction.java
  90. 2
      designer-realize/src/main/java/com/fr/design/headerfooter/ImagePane.java
  91. 3
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java
  92. 26
      designer-realize/src/main/java/com/fr/design/report/SelectImagePane.java
  93. 7
      designer-realize/src/main/java/com/fr/design/webattr/ViewToolBarPane.java
  94. 1
      designer-realize/src/main/java/com/fr/grid/Grid.java
  95. 9
      designer-realize/src/main/java/com/fr/poly/PolyComponentsBar.java
  96. 24
      designer-realize/src/main/java/com/fr/poly/PolyUtils.java
  97. 133
      designer-realize/src/main/java/com/fr/poly/creator/ChartBlockEditor.java
  98. 6
      designer-realize/src/main/java/com/fr/poly/hanlder/PolyDesignerDropTarget.java
  99. 15
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java
  100. 69
      designer-realize/src/test/java/com.fr/design/mainframe/JFileTest.java

15
designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java

@ -41,7 +41,7 @@ import javax.swing.event.ChangeListener;
import java.io.ByteArrayOutputStream;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
@ -123,6 +123,7 @@ public abstract class DesignTableDataManager {
* @param dsNameChangedMap 改变名字的数据集
*/
public static void fireDSChanged(Map<String, String> dsNameChangedMap) {
clearGlobalDs();
if (!dsNameChangedMap.isEmpty()) {
setDsNameChangedMap(dsNameChangedMap);
}
@ -334,15 +335,9 @@ public abstract class DesignTableDataManager {
private static void addStoreProcedureData(java.util.Map<String, TableDataWrapper> resMap) {
ProcedureConfig procedureConfig = ProcedureConfig.getInstance();
String[] namearray = new String[0];
@SuppressWarnings("unchecked")
java.util.Iterator<String> nameIt = procedureConfig.getProcedures().keySet().iterator();
while (nameIt.hasNext()) {
namearray = (String[]) ArrayUtils.add(namearray, nameIt.next());
}
Arrays.sort(namearray, Collator.getInstance(java.util.Locale.CHINA));
for (String name : namearray) {
List<String> names = new ArrayList<>(procedureConfig.getProcedures().keySet());
Collections.sort(names, Collator.getInstance(java.util.Locale.CHINA));
for (String name : names) {
StoreProcedure storeProcedure = procedureConfig.getProcedure(name);
if (globalDsCache.containsKey(name)) {
resMap.put(name, globalDsCache.get(name));

2
designer-base/src/main/java/com/fr/design/extra/PluginUtils.java

@ -233,6 +233,8 @@ public class PluginUtils {
jo.put("onTrial", pluginContext.isOnTrial());
jo.put("deadline", getDeadline(pluginContext));
jo.put("registerFailed", pluginContext.isRegisterFailed());
jo.put("selfState", pluginContext.getSelfState());
jo.put("switchedReason", pluginContext.getSwitchedReason());
ja.put(jo);
}
}catch (Exception e){

2
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java

@ -263,9 +263,9 @@ public class HistoryTemplateListCache implements CallbackEvent {
JTemplate<?, ?> template = iterator.next();
String tPath = template.getPath();
if (isDir ? tPath.startsWith(path) : tPath.equals(path)) {
int size = getHistoryCount();
iterator.remove();
int index = iterator.nextIndex();
int size = getHistoryCount();
if (size == index + 1 && index > 0) {
//如果删除的是后一个Tab,则定位到前一个
MutilTempalteTabPane.getInstance().setSelectedIndex(index - 1);

15
designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java

@ -1,12 +1,11 @@
package com.fr.design.gui.chart;
import javax.swing.JComponent;
import com.fr.base.chart.BaseChart;
import com.fr.base.chart.BaseChartCollection;
import com.fr.stable.core.PropertyChangeAdapter;
import com.fr.chartx.attr.ChartProvider;
import com.fr.stable.core.PropertyChangeListener;
import javax.swing.JComponent;
/**
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2013-7-10 上午09:19:36
@ -18,8 +17,8 @@ public abstract class MiddleChartComponent extends JComponent {
public abstract BaseChartCollection update();
public abstract void reset();
public abstract BaseChart getEditingChart();
public abstract void addStopEditingListener(PropertyChangeListener list);
public abstract ChartProvider getEditingChart();
public abstract void addStopEditingListener(PropertyChangeListener list);
}

3
designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java

@ -36,6 +36,7 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter {
private static final String XML_TEMPLATE_INFO_LIST = "TemplateInfoList";
private static final String XML_FILE_NAME = "tpl.info";
private static TemplateInfoCollector instance;
private static final int MAX_SIZE = 512 * 1024 * 1024;
private Map<String, TemplateInfo> templateInfoMap;
private DesignerOpenHistory designerOpenHistory;
@ -167,7 +168,7 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter {
}
private boolean shouldCollectInfo() {
return DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv();
return FileUtils.sizeOf(getInfoFile()) <= MAX_SIZE && DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv();
}
/**

18
designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCacheFileNodeFile.java

@ -8,6 +8,7 @@ import com.fr.stable.StableUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.resource.WorkResourceOutputStream;
import com.fr.workspace.server.lock.TplOperator;
import com.fr.workspace.server.vcs.filesystem.VcsFileSystem;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@ -34,16 +35,15 @@ public class VcsCacheFileNodeFile extends FileNodeFILE {
if (node == null) {
return null;
}
String vcsCacheDir = VcsFileSystem.getInstance().getVcsCacheRelativePath();
String envPath = node.getEnvPath();
// envPath必须以vcs开头
if (!envPath.startsWith(VcsHelper.VCS_CACHE_DIR)) {
// envPath必须以VcsCacheRelativePath开头
if (!envPath.startsWith(vcsCacheDir)) {
return null;
}
InputStream in = new ByteArrayInputStream(
WorkContext.getCurrent().get(TplOperator.class).readAndLockFile(
StableUtils.pathJoin(VcsHelper.VCS_CACHE_DIR, envPath.substring(VcsHelper.VCS_CACHE_DIR.length() + 1))
StableUtils.pathJoin(vcsCacheDir, envPath.substring(vcsCacheDir.length() + 1))
)
);
@ -63,13 +63,13 @@ public class VcsCacheFileNodeFile extends FileNodeFILE {
if (ComparatorUtils.equals(node, null)) {
return null;
}
String vcsCacheDir = VcsFileSystem.getInstance().getVcsCacheRelativePath();
String envPath = node.getEnvPath();
// envPath必须以reportLets开头
if (!envPath.startsWith(VcsHelper.VCS_CACHE_DIR)) {
// envPath必须以VcsCacheRelativePath开头
if (!envPath.startsWith(vcsCacheDir)) {
return null;
}
return new WorkResourceOutputStream(StableUtils.pathJoin(VcsHelper.VCS_CACHE_DIR, envPath.substring(VcsHelper.VCS_CACHE_DIR.length() + 1)));
return new WorkResourceOutputStream(StableUtils.pathJoin(vcsCacheDir, envPath.substring(vcsCacheDir.length() + 1)));
}
}

8
designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java

@ -19,6 +19,7 @@ import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator;
import com.fr.workspace.server.vcs.filesystem.VcsFileSystem;
import javax.swing.Icon;
import javax.swing.border.EmptyBorder;
@ -45,8 +46,6 @@ public class VcsHelper implements JTemplateActionListener {
public final static Icon VCS_USER_PNG = IOUtils.readIcon("/com/fr/design/images/vcs/icon_user@1x.png");
public final static Icon VCS_REVERT = IOUtils.readIcon("/com/fr/design/images/vcs/icon_revert.png");
public final static int OFFSET = 2;
private final static String VCS_DIR = "vcs";
public final static String VCS_CACHE_DIR = pathJoin(VCS_DIR, "cache");
private static final int MINUTE = 60 * 1000;
private final static String VCS_PLUGIN_ID = "com.fr.plugin.vcs.v10";
private static final VcsHelper instance = new VcsHelper();
@ -89,12 +88,13 @@ public class VcsHelper implements JTemplateActionListener {
}
private String getEditingFilename() {
String vcsCacheDir = VcsFileSystem.getInstance().getVcsCacheRelativePath();
JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
String editingFilePath = jt.getEditingFILE().getPath();
if (editingFilePath.startsWith(ProjectConstants.REPORTLETS_NAME)) {
editingFilePath = editingFilePath.replaceFirst(ProjectConstants.REPORTLETS_NAME, StringUtils.EMPTY);
} else if (editingFilePath.startsWith(VcsHelper.VCS_CACHE_DIR)) {
editingFilePath = editingFilePath.replaceFirst(VcsHelper.VCS_CACHE_DIR, StringUtils.EMPTY);
} else if (editingFilePath.startsWith(vcsCacheDir)) {
editingFilePath = editingFilePath.replaceFirst(vcsCacheDir, StringUtils.EMPTY);
}
if (editingFilePath.startsWith("/")) {
editingFilePath = editingFilePath.substring(1);

7
designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java

@ -279,7 +279,12 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
addSubmitConditionButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final DSColumnLiteConditionPane conditionPane = new DSColumnLiteConditionPane();
final DSColumnLiteConditionPane conditionPane = new DSColumnLiteConditionPane() {
@Override
protected boolean isNeedDoWithCondition(Condition liteCondition) {
return liteCondition != null;
}
};
String[] columns = chooseTable.currentColumnNames();
if (columns != null && columns.length > 0) {
conditionPane.populateColumns(chooseTable.currentColumnNames());

5
designer-base/src/main/java/com/fr/file/StashedFILE.java

@ -71,4 +71,9 @@ public class StashedFILE extends AbstractFILE {
public boolean isEnvFile() {
return false;
}
@Override
public String toString() {
return FILEFactory.MEM_PREFIX + getName();
}
}

102
designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java

@ -0,0 +1,102 @@
package com.fr.design.data;
import com.fr.base.TableData;
import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.design.data.tabledata.wrapper.TableDataFactory;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.file.ProcedureConfig;
import com.fr.file.TableDataConfig;
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.HashMap;
import java.util.Map;
@RunWith(PowerMockRunner.class)
@PrepareForTest({TableDataFactory.class, StoreProcedure.class, TableDataConfig.class, ProcedureConfig.class})
@SuppressStaticInitializationFor({"com.fr.design.data.tabledata.wrapper.TableDataFactory"})
public class DesignTableDataManagerTest {
@Test
public void testFireDataChange() {
DesignTableDataManager.envChange();
PowerMock.mockStatic(TableDataConfig.class);
TableDataConfig config = EasyMock.mock(TableDataConfig.class);
TableDataConfig config2 = EasyMock.mock(TableDataConfig.class);
TableData td1 = EasyMock.mock(TableData.class);
TableData td2 = EasyMock.mock(TableData.class);
TableData td3 = EasyMock.mock(TableData.class);
TableData td4 = EasyMock.mock(TableData.class);
EasyMock.expect(config.getTableData("firstData")).andReturn(td1).once();
EasyMock.expect(config.getTableData("secondData")).andReturn(td2).once();
EasyMock.expect(config2.getTableData("firstData")).andReturn(td3).once();
EasyMock.expect(config2.getTableData("secondData")).andReturn(td4).once();
EasyMock.expect(TableDataConfig.getInstance()).andReturn(config).once().andReturn(config2).once();
PowerMock.mockStatic(TableDataFactory.class);
EasyMock.expect(TableDataFactory.getSortOfChineseNameOfServerData(config))
.andReturn(new String[]{"firstData", "secondData"}).once();
EasyMock.expect(TableDataFactory.getSortOfChineseNameOfServerData(config2))
.andReturn(new String[]{"firstData", "secondData"}).once();
ProcedureConfig proConfig = EasyMock.mock(ProcedureConfig.class);
StoreProcedure pc1 = PowerMock.createMock(StoreProcedure.class);
StoreProcedure pc2 = PowerMock.createMock(StoreProcedure.class);
ProcedureConfig proConfig2 = EasyMock.mock(ProcedureConfig.class);
StoreProcedure pc3 = PowerMock.createMock(StoreProcedure.class);
StoreProcedure pc4 = PowerMock.createMock(StoreProcedure.class);
Map<String, StoreProcedure> procedureMap = new HashMap<>();
procedureMap.put("firstPRO", pc1);
procedureMap.put("secondPRO", pc2);
EasyMock.expect(proConfig.getProcedure("firstPRO")).andReturn(pc1).once();
EasyMock.expect(proConfig.getProcedure("secondPRO")).andReturn(pc2).once();
Map<String, StoreProcedure> procedureMap2 = new HashMap<>();
procedureMap2.put("firstPRO", pc3);
procedureMap2.put("secondPRO", pc4);
EasyMock.expect(proConfig2.getProcedure("firstPRO")).andReturn(pc3).once();
EasyMock.expect(proConfig2.getProcedure("secondPRO")).andReturn(pc4).once();
EasyMock.expect(proConfig.getProcedures()).andReturn(procedureMap).once();
EasyMock.expect(proConfig2.getProcedures()).andReturn(procedureMap2).once();
PowerMock.mockStatic(ProcedureConfig.class);
EasyMock.expect(ProcedureConfig.getInstance()).andReturn(proConfig).once().andReturn(proConfig2).once();
EasyMock.replay(proConfig, config, config2, proConfig2);
PowerMock.replay(TableDataFactory.class, TableDataConfig.class, ProcedureConfig.class);
Map<String, TableDataWrapper> map = DesignTableDataManager.getAllEditingDataSet(null);
Assert.assertEquals(4, map.size());
Assert.assertSame(pc1, map.get("firstPRO").getTableData());
Assert.assertSame(pc2, map.get("secondPRO").getTableData());
Assert.assertSame(td1, map.get("firstData").getTableData());
Assert.assertSame(td2, map.get("secondData").getTableData());
DesignTableDataManager.fireDSChanged(new HashMap<String, String>());
Map<String, TableDataWrapper> map2 = DesignTableDataManager.getAllEditingDataSet(null);
Assert.assertEquals(4, map2.size());
Assert.assertSame(pc3, map2.get("firstPRO").getTableData());
Assert.assertSame(pc4, map2.get("secondPRO").getTableData());
Assert.assertSame(td3, map2.get("firstData").getTableData());
Assert.assertSame(td4, map2.get("secondData").getTableData());
}
}

23
designer-base/src/test/java/com/fr/file/StashedFILETest.java

@ -0,0 +1,23 @@
package com.fr.file;
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Test;
public class StashedFILETest {
/**
* 用于测试暂存文件未保存时的提示
*/
@Test
public void testToString() {
FILE file = EasyMock.mock(FILE.class);
String name = "getA.cpt";
EasyMock.expect(file.getName()).andReturn(name).once();
EasyMock.replay(file);
FILE stashedFILE = new StashedFILE(file, new byte[0]);
String expectString = FILEFactory.MEM_PREFIX + name;
Assert.assertEquals(expectString, stashedFILE + "");
EasyMock.verify(file);
}
}

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

@ -2,9 +2,9 @@ package com.fr.design;
import com.fr.chart.base.ChartConstants;
import com.fr.chart.base.ChartInternationalNameContentBean;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.chartx.attr.ChartProvider;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.chart.fun.IndependentChartUIProvider;
@ -160,8 +160,8 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
ChartWidgetOption[] child = new ChartWidgetOption[typeName.length];
int index = 0;
for (ChartInternationalNameContentBean bean : typeName) {
String plotID = bean.getPlotID();
Chart[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID);
String plotID = bean.getChartID();
ChartProvider[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID);
if (ArrayUtils.isEmpty(rowChart) && !ChartTypeManager.innerChart(plotID)) {
continue;
}
@ -253,7 +253,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
*
* @param paneList pane容器
*/
public void addPlotTypePaneList(List<FurtherBasicBeanPane<? extends Chart>> paneList, Map<String, Map<String, FurtherBasicBeanPane<? extends Chart>>> allChartTypePane) {
public void addPlotTypePaneList(List<FurtherBasicBeanPane<? extends ChartProvider>> paneList, Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane) {
List<Integer> priorityList = getPriorityInOrder();
for (Integer aPriorityList : priorityList) {
@ -263,7 +263,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
}
public void addPlotTypePaneList(String priority, List<FurtherBasicBeanPane<? extends Chart>> paneList, Map<String, Map<String, FurtherBasicBeanPane<? extends Chart>>> allChartTypePane) {
public void addPlotTypePaneList(String priority, List<FurtherBasicBeanPane<? extends ChartProvider>> paneList, Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane) {
if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority)) {
@ -282,7 +282,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
paneList.add(pane);
if (allChartTypePane.get(priority) == null) {
allChartTypePane.put(priority, new LinkedHashMap<String, FurtherBasicBeanPane<? extends Chart>>());
allChartTypePane.put(priority, new LinkedHashMap<String, FurtherBasicBeanPane<? extends ChartProvider>>());
}
allChartTypePane.get(priority).put(plotID, pane);
}
@ -449,9 +449,10 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
return true;
}
public boolean needChartChangePane(Chart chart) {
if (chart != null && chart.getPlot() != null) {
IndependentChartUIProvider provider = getChartTypeInterface(chart.getPlot().getPlotID());
public boolean needChartChangePane(ChartProvider chart) {
if (chart != null) {
String chartID = chart.getID();
IndependentChartUIProvider provider = getChartTypeInterface(chartID);
if (provider != null) {
return provider.needChartChangePane();
}

14
designer-chart/src/main/java/com/fr/design/chart/ChartCommonWizardPane.java

@ -1,7 +1,7 @@
package com.fr.design.chart;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chartx.attr.ChartProvider;
public abstract class ChartCommonWizardPane extends ChartWizardPane {
private static final long serialVersionUID = 2467967841657570498L;
@ -11,12 +11,12 @@ public abstract class ChartCommonWizardPane extends ChartWizardPane {
if (cc == null) {
return;
}
populate(cc.getSelectedChart());
populate(cc.getSelectedChartProvider());
}
public abstract void populate(Chart chart);
public abstract void update(Chart oldChart);
public abstract void populate(ChartProvider chart);
public abstract void update(ChartProvider oldChart);
}

128
designer-chart/src/main/java/com/fr/design/chart/ChartControlPane.java

@ -1,128 +0,0 @@
package com.fr.design.chart;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.NameObject;
import com.fr.stable.Nameable;
import java.awt.*;
import java.util.HashMap;
/**
* 管理图表类型Pane
* @author kunsnat: ChartComponent移出.
*/
public class ChartControlPane extends JListControlPane {
private static final long serialVersionUID = 7336270815128413184L;
public ChartControlPane() {
super();
// 重新设定大小. 因为JControlPane默认的(450,450) 不适合图表这边 @ChartSize
// this.setPreferredSize(new Dimension(770, 520));
}
@Override
public NameableCreator[] createNameableCreators() {
return new NameableCreator[] {
new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Chart"), Chart.class, ChartTypeUpdatePane.class)
};
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Manage_Chart_Type");
}
public void populate(ChartCollection cc) {
if(cc == null)return;
NameObject[] nameObjects = new NameObject[cc.getChartCount()];
for (int i = 0; i < nameObjects.length; i++) {
nameObjects[i] = new NameObject(cc.getChartName(i), cc.getChart(i));
}
populate(nameObjects);
// kunsnat: 选中当前图表选中的name
String chartSelectedName = cc.getChartName(cc.getSelectedIndex() < cc.getChartCount() ? cc.getSelectedIndex() : 0);
setSelectedName(chartSelectedName);
}
public void update(ChartCollection cc) {
HashMap namesChart = new HashMap();// 暂存判断是否有必要更新
for(int i = 0; i < cc.getChartCount(); i++) {
try {
namesChart.put(cc.getChartName(i), cc.getChart(i).clone());
} catch (CloneNotSupportedException e) {
}
}
Nameable[] nameables = update();
if (nameables.length == 0 || cc == null) {
return;
}
cc.removeAllNameObject();
String select = getSelectedName();
for (int i = 0; i < nameables.length; i++) {
if (nameables[i] instanceof NameObject && ((NameObject)nameables[i]).getObject() instanceof Chart) {
NameObject no = (NameObject)nameables[i];
String name = no.getName();
Chart chart = (Chart)no.getObject();
if(namesChart.containsKey(name)) {
Chart tmpChart = (Chart)namesChart.get(name);
if(chart.getPlot() != null && tmpChart.getPlot() != null
&& chart.getPlot().match4GUI(tmpChart.getPlot())) {
chart = tmpChart;// 代替之前做过编辑的Chart
}
}
cc.addNamedChart(name, chart);
if(no.getName().equals(select)) {
cc.setSelectedIndex(i);
}
}
}
}
/*
* alex:继承UpdatePane的ChartTypePane
*/
public static class ChartTypeUpdatePane extends BasicBeanPane<Chart> {
private static final long serialVersionUID = -7058348930816218415L;
private Chart editing;
private ChartTypePane typePane;
public ChartTypeUpdatePane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
typePane = new ChartTypePane();
this.add(typePane, BorderLayout.CENTER);
}
@Override
protected String title4PopupWindow() {
return "Chart Type";
}
@Override
public void populateBean(Chart ob) {
editing = ob;
typePane.populate(ob);
}
@Override
public Chart updateBean() {
typePane.update(editing);
return editing;
}
}
}

86
designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java

@ -5,17 +5,13 @@ package com.fr.design.chart;
*/
import com.fr.chart.base.ChartInternationalNameContentBean;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.ChartIcon;
import com.fr.chart.chartattr.MapPlot;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.chartx.attr.ChartProvider;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.license.exception.RegistEditionException;
import com.fr.license.function.VT4FR;
import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory;
@ -23,7 +19,6 @@ import javax.swing.BorderFactory;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.ListCellRenderer;
@ -36,21 +31,22 @@ public class ChartTypePane extends ChartCommonWizardPane {
private static final long serialVersionUID = -1175602484968520546L;
private ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstanceWithCheck().getAllChartBaseNames();
private Chart[][] charts4Icon = null;
private ChartProvider[][] charts4Icon = null;
{
charts4Icon = new Chart[this.typeName.length][];
charts4Icon = new ChartProvider[this.typeName.length][];
for (int i = 0; i < this.typeName.length; i++) {
Chart[] rowCharts = ChartTypeManager.getInstanceWithCheck().getChartTypes(this.typeName[i].getPlotID());
ChartProvider[] rowCharts = ChartTypeManager.getInstanceWithCheck().getChartTypes(this.typeName[i].getChartID());
int rowChartsCount = rowCharts.length;
charts4Icon[i] = new Chart[rowChartsCount];
charts4Icon[i] = new ChartProvider[rowChartsCount];
for (int j = 0; j < rowChartsCount; j++) {
try {
charts4Icon[i][j] = (Chart) rowCharts[j].clone();
charts4Icon[i][j].setTitle(null);
if(charts4Icon[i][j].getPlot() != null){
charts4Icon[i][j].getPlot().setLegend(null);
}
charts4Icon[i][j] = (ChartProvider) rowCharts[j].clone();
//todo@shinerefactor 老图表也是提供一张图片 这边就不用setTitle(null) 然后实时去画
// charts4Icon[i][j].setTitle(null);
// if(charts4Icon[i][j].getPlot() != null){
// charts4Icon[i][j].getPlot().setLegend(null);
// }
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
@ -121,7 +117,7 @@ public class ChartTypePane extends ChartCommonWizardPane {
protected ListSelectionListener listSelectionListener = new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
int main_index = mainTypeList.getSelectedIndex();
Chart[] sub_charts = ChartTypePane.this.charts4Icon[main_index];
ChartProvider[] sub_charts = ChartTypePane.this.charts4Icon[main_index];
ChartTypePane.this.iconListModel.clear();
for (int i = 0; i < sub_charts.length; i++) {
ChartTypePane.this.iconListModel.addElement(new ChartIcon(sub_charts[i]));
@ -131,56 +127,14 @@ public class ChartTypePane extends ChartCommonWizardPane {
};
public String getChartName(ChartIcon chartIcon) {
Chart chart = (Chart)chartIcon.getChart();
return chart.getChartName();
ChartProvider chart = chartIcon.getChart();
return ChartTypeManager.getInstanceWithCheck().getChartName(chart.getID());
}
public void populate(Chart chart) {
if (chart == null) {
return;
}
Plot plot = chart.getPlot();
int mainIndex = 0;
int subIndex = 0;
for (int i = 0; i < typeName.length; i++) {
Chart[] charts = ChartTypeManager.getInstanceWithCheck().getChartTypes(typeName[i].getPlotID());
for (int j = 0; j < charts.length; j++) {
if (charts[j].getPlot().match4GUI(plot)) {
mainIndex = i;
subIndex = j;
// 一旦匹配 立马中断
break;
}
}
}
mainTypeList.setSelectedIndex(mainIndex);
iconViewList.setSelectedIndex(subIndex);
}
public void update(Chart oldChart) {
String plotID = typeName[mainTypeList.getSelectedIndex()].getPlotID();
Chart chart = ChartTypeManager.getInstanceWithCheck().getChartTypes(plotID)[iconViewList.getSelectedIndex()];
if(chart.getPlot() != null){
if(chart.getPlot() instanceof MapPlot && !supportMap()){
JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Not_Supported"));
throw new RegistEditionException(VT4FR.ChartMap);
}
if (chart.getPlot() != null) {
try {
oldChart.changePlotInNewType((Plot) chart.getPlot().clone());
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
public void populate(ChartProvider chart) {
}
private boolean supportMap() {
return VT4FR.ChartMap.isSupport();
public void update(ChartProvider oldChart) {
}
public void update(ChartCollection cc) {
@ -188,12 +142,12 @@ public class ChartTypePane extends ChartCommonWizardPane {
return;
}
Chart chart4Update = cc.getSelectedChart();
ChartProvider chart4Update = cc.getSelectedChartProvider();
if (chart4Update == null) {
String plotID = typeName[mainTypeList.getSelectedIndex()].getPlotID();
Chart chart = ChartTypeManager.getInstance().getChartTypes(plotID)[iconViewList.getSelectedIndex()];
String plotID = typeName[mainTypeList.getSelectedIndex()].getChartID();
ChartProvider chart = ChartTypeManager.getInstance().getChartTypes(plotID)[iconViewList.getSelectedIndex()];
try{
chart4Update = (Chart)chart.clone();
chart4Update = (ChartProvider) chart.clone();
cc.addChart(chart4Update);
}catch (CloneNotSupportedException ex){
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);

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

@ -1,7 +1,6 @@
package com.fr.design.chart.gui;
import com.fr.base.ScreenResolution;
import com.fr.base.chart.BaseChart;
import com.fr.base.chart.BaseChartCollection;
import com.fr.base.chart.BaseChartGlyph;
import com.fr.base.chart.chartdata.CallbackEvent;
@ -10,6 +9,7 @@ import com.fr.chart.chartattr.Axis;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartglyph.AxisGlyph;
import com.fr.chartx.attr.ChartProvider;
import com.fr.design.chart.gui.active.ActiveGlyph;
import com.fr.design.chart.gui.active.ChartActiveGlyph;
import com.fr.design.file.HistoryTemplateListPane;
@ -162,7 +162,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
return (this.chartCollection4Design == null) ? 0 : this.chartCollection4Design.getChartCount();
}
public BaseChart getEditingChart() {
public ChartProvider getEditingChart() {
return editingChart;
}

10
designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java

@ -1,7 +1,6 @@
package com.fr.design.chart.gui;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.base.chart.BaseChartGetter;
import com.fr.design.gui.core.WidgetOption;
import com.fr.form.ui.ChartEditor;
import com.fr.form.ui.Widget;
@ -38,14 +37,11 @@ public class ChartWidgetOption extends WidgetOption {
Class<? extends ChartEditor> clz = widgetClass();
try {
ChartEditor widget = clz.newInstance();
Chart chart = ChartTypeManager.getInstanceWithCheck().getChartTypes(this.chartID)[0];
widget.addChart((Chart) chart.clone());
widget.setChartCollection(BaseChartGetter.createChartCollection(this.chartID));
return widget;
} catch (InstantiationException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (IllegalAccessException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}

12
designer-chart/src/main/java/com/fr/design/chart/gui/active/action/ChartComponentAction.java

@ -1,11 +1,9 @@
package com.fr.design.chart.gui.active.action;
import com.fr.base.chart.BaseChart;
import com.fr.chart.chartattr.Axis;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartglyph.AxisGlyph;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.actions.UpdateAction;
import com.fr.design.chart.gui.ChartComponent;
/**
* Created by IntelliJ IDEA.
@ -29,18 +27,10 @@ public abstract class ChartComponentAction extends UpdateAction {
chartComponent.repaint();
}
public BaseChart getEditingChart() {
return chartComponent.getEditingChart();
}
public ChartCollection getChartCollection() {
return chartComponent.getChartCollection();
}
public Axis getActiveAxis() {
return chartComponent.getActiveAxis();
}
public AxisGlyph getActiveAxisGlyph() {
return chartComponent.getActiveAxisGlyph();
}

8
designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java

@ -1,11 +1,11 @@
package com.fr.design.chart.series.SeriesCondition.impl;
import com.fr.base.chart.BaseChartCollection;
import com.fr.chart.chartattr.Bar2DPlot;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.chart.web.ChartHyperPoplink;
import com.fr.chartx.attr.ChartProvider;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.hyperlink.AbstractHyperLinkPane;
@ -66,10 +66,10 @@ public class ChartHyperPoplinkPane extends AbstractHyperLinkPane<ChartHyperPopli
private ChartCollection createChartCollection() {
ChartCollection cc = new ChartCollection();
Chart chart = ChartTypeManager.getInstanceWithCheck().getFirstChart();
ChartProvider chart = ChartTypeManager.getInstanceWithCheck().getFirstChart();
if (chart != null) {
try {
cc.addChart((Chart) chart.clone());
cc.addChart((ChartProvider) chart.clone());
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
@ -91,7 +91,7 @@ public class ChartHyperPoplinkPane extends AbstractHyperLinkPane<ChartHyperPopli
this.itemNameTextField.setText(chartHyperlink.getItemName());
}
BaseChartCollection cc = chartHyperlink.getChartCollection();
ChartCollection cc = (ChartCollection) chartHyperlink.getChartCollection();
if (cc == null || cc.getChartCount() < 1) {
cc = createChartCollection();
chartHyperlink.setChartCollection(cc);

58
designer-chart/src/main/java/com/fr/design/chartx/AbstractChartDataPane.java

@ -0,0 +1,58 @@
package com.fr.design.chartx;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chartx.data.ChartDataDefinitionProvider;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.plugin.chart.vanchart.VanChart;
import java.awt.BorderLayout;
/**
* Created by shine on 2019/4/15.
*/
public abstract class AbstractChartDataPane<T extends ChartDataDefinitionProvider> extends ChartDataPane {
public AbstractChartDataPane(AttributeChangeListener listener) {
super(listener);
}
protected abstract void populate(T t);
protected abstract T update();
@Override
public void populate(ChartCollection collection) {
if (collection == null) {
return;
}
VanChart chart = collection.getSelectedChart(VanChart.class);
if (chart == null) {
return;
}
this.removeAll();
this.add(createContentPane(), BorderLayout.CENTER);
ChartDataDefinitionProvider dataSetCollection = chart.getChartDataDefinition();
populate((T) dataSetCollection);
this.initAllListeners();
this.validate();
}
@Override
public void update(ChartCollection collection) {
if (collection == null) {
return;
}
VanChart chart = collection.getSelectedChart(VanChart.class);
if (chart == null) {
return;
}
chart.setChartDataDefinition(update());
}
}

39
designer-chart/src/main/java/com/fr/design/chartx/GanttChartDataPane.java

@ -0,0 +1,39 @@
package com.fr.design.chartx;
import com.fr.chartx.data.GanttChartDataDefinition;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.van.chart.map.designer.VanChartGroupPane;
import javax.swing.JPanel;
/**
* Created by shine on 2019/5/22.
*/
public class GanttChartDataPane extends AbstractChartDataPane<GanttChartDataDefinition> {
private MultiCategoryChartDataPane dataPane;
private MultiCategoryChartDataPane linkPane;
@Override
protected JPanel createContentPane() {
dataPane = new MultiCategoryChartDataPane(listener);
linkPane = new MultiCategoryChartDataPane(listener);
return new VanChartGroupPane(new String[]{"data", "link"}, new JPanel[]{dataPane, linkPane}) {
};
}
public GanttChartDataPane(AttributeChangeListener listener) {
super(listener);
}
@Override
protected void populate(GanttChartDataDefinition ganttChartDataDefinition) {
dataPane.populate(ganttChartDataDefinition.getDataDefinition());
linkPane.populate(ganttChartDataDefinition.getLinkDefinition());
}
@Override
protected GanttChartDataDefinition update() {
return null;
}
}

43
designer-chart/src/main/java/com/fr/design/chartx/MultiCategoryChartDataPane.java

@ -0,0 +1,43 @@
package com.fr.design.chartx;
import com.fr.chartx.data.AbstractDataDefinition;
import com.fr.design.chartx.fields.diff.MultiCategoryCellDataFieldsPane;
import com.fr.design.chartx.fields.diff.MultiCategoryDataSetFieldsPane;
import com.fr.design.chartx.single.SingleDataPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import javax.swing.JPanel;
/**
* Created by shine on 2019/5/22.
*/
public class MultiCategoryChartDataPane extends AbstractChartDataPane<AbstractDataDefinition> {
private SingleDataPane singleDataPane;
public MultiCategoryChartDataPane(AttributeChangeListener listener) {
super(listener);
}
@Override
protected void populate(AbstractDataDefinition dataDefinition) {
singleDataPane.populateBean(dataDefinition);
}
@Override
protected AbstractDataDefinition update() {
return singleDataPane.updateBean();
}
@Override
protected JPanel createContentPane() {
singleDataPane = createSingleDataPane();
return singleDataPane;
}
protected SingleDataPane createSingleDataPane() {
return new SingleDataPane(new MultiCategoryDataSetFieldsPane(), new MultiCategoryCellDataFieldsPane());
}
}

21
designer-chart/src/main/java/com/fr/design/chartx/MultiPieChartDataPane.java

@ -0,0 +1,21 @@
package com.fr.design.chartx;
import com.fr.design.chartx.fields.diff.MultiPieCellDataFieldsPane;
import com.fr.design.chartx.fields.diff.MultiPieDataSetFieldsPane;
import com.fr.design.chartx.single.SingleDataPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
/**
* Created by shine on 2019/6/18.
*/
public class MultiPieChartDataPane extends MultiCategoryChartDataPane {
public MultiPieChartDataPane(AttributeChangeListener listener) {
super(listener);
}
@Override
protected SingleDataPane createSingleDataPane() {
return new SingleDataPane(new MultiPieDataSetFieldsPane(), new MultiPieCellDataFieldsPane());
}
}

20
designer-chart/src/main/java/com/fr/design/chartx/WordCloudChartDataPane.java

@ -0,0 +1,20 @@
package com.fr.design.chartx;
import com.fr.design.chartx.fields.diff.WordCloudCellDataFieldsPane;
import com.fr.design.chartx.fields.diff.WordCloudDataSetFieldsPane;
import com.fr.design.chartx.single.SingleDataPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
/**
* Created by shine on 2019/5/22.
*/
public class WordCloudChartDataPane extends MultiCategoryChartDataPane {
public WordCloudChartDataPane(AttributeChangeListener listener) {
super(listener);
}
@Override
protected SingleDataPane createSingleDataPane() {
return new SingleDataPane(new WordCloudDataSetFieldsPane(), new WordCloudCellDataFieldsPane());
}
}

252
designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java

@ -0,0 +1,252 @@
package com.fr.design.chartx.component;
import com.fr.data.util.function.AbstractDataFunction;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.chartx.component.correlation.AbstractCorrelationPane;
import com.fr.design.chartx.component.correlation.CalculateComboBoxEditorComponent;
import com.fr.design.chartx.component.correlation.FieldEditorComponentWrapper;
import com.fr.design.chartx.component.correlation.UIComboBoxEditorComponent;
import com.fr.design.chartx.component.correlation.UITextFieldEditorComponent;
import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox;
import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper;
import com.fr.extended.chart.UIComboBoxWithNone;
import com.fr.general.GeneralUtils;
import com.fr.stable.StringUtils;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.List;
/**
* Created by shine on 2018/9/12.
* 系列名使用字段名or字段值的抽象的pane 支持多种属性结构的存取
*/
public abstract class AbstractCustomFieldComboBoxPane<T> extends UIComboBoxPane<T> {
private AbstractUseFieldValuePane useFieldValuePane;
private AbstractCustomFieldNamePane customFieldNamePane;
private List<String> fieldList = new ArrayList<String>();
@Override
protected void initLayout() {
this.setLayout(new BorderLayout(0, 6));
JPanel northPane = new JPanel(new BorderLayout());
northPane.add(jcb, BorderLayout.CENTER);
UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name_From"));
label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, 20));
northPane.add(label, BorderLayout.WEST);
this.add(northPane, BorderLayout.NORTH);
this.add(cardPane, BorderLayout.CENTER);
}
@Override
protected List<FurtherBasicBeanPane<? extends T>> initPaneList() {
useFieldValuePane = createUseFieldValuePane();
customFieldNamePane = createCustomFieldNamePane();
List<FurtherBasicBeanPane<? extends T>> list = new ArrayList<FurtherBasicBeanPane<? extends T>>();
list.add(useFieldValuePane);
list.add(paneWrapper());
return list;
}
private FurtherBasicBeanPane<? extends T> paneWrapper() {
FurtherBasicBeanPane pane = new FurtherBasicBeanPane() {
@Override
public String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Name");
}
@Override
public boolean accept(Object ob) {
return false;
}
@Override
public void reset() {
}
@Override
public void populateBean(Object ob) {
}
@Override
public Object updateBean() {
return null;
}
};
pane.setLayout(new BorderLayout(0, 6));
pane.add(customFieldNamePane, BorderLayout.CENTER);
return pane;
}
protected abstract AbstractUseFieldValuePane createUseFieldValuePane();
protected abstract AbstractCustomFieldNamePane createCustomFieldNamePane();
@Override
protected String title4PopupWindow() {
return StringUtils.EMPTY;
}
protected boolean valueComboBoxHasNone() {
return false;
}
public void checkBoxUse(boolean hasUse) {
jcb.setEnabled(hasUse);
useFieldValuePane.checkBoxUse(hasUse);
}
public void clearAllBoxList() {
useFieldValuePane.clearAllBoxList();
fieldList.clear();
}
public void refreshBoxListWithSelectTableData(List columnNameList) {
useFieldValuePane.refreshBoxListWithSelectTableData(columnNameList);
fieldList = columnNameList;
}
protected void populateCustomFieldNamePane(T t) {
customFieldNamePane.populateBean(t);
}
protected void updateCustomFieldNamePane(T t) {
customFieldNamePane.updateBean(t);
}
protected void populateUseFieldValuePane(T t) {
useFieldValuePane.populateBean(t);
}
protected void updateUseFieldValuePane(T t) {
useFieldValuePane.updateBean(t);
}
protected abstract class AbstractUseFieldValuePane extends FurtherBasicBeanPane<T> {
private UIComboBox series;
private UIComboBox value;
private CalculateComboBox function;
public AbstractUseFieldValuePane() {
initComponents();
}
private void initComponents() {
series = new UIComboBox();
value = valueComboBoxHasNone() ? new UIComboBoxWithNone() : new UIComboBox();
function = new CalculateComboBox();
Component[][] components = new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Series_Name"), SwingConstants.LEFT), series},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Use_Value"), SwingConstants.LEFT), value},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Summary_Method"), SwingConstants.LEFT), function},
};
double p = TableLayout.PREFERRED;
double[] columnSize = {78, 122};
double[] rowSize = {p, p, p};
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
this.setLayout(new BorderLayout(0, 6));
this.add(panel, BorderLayout.CENTER);
}
public void checkBoxUse(boolean hasUse) {
series.setEnabled(hasUse);
value.setEnabled(hasUse);
function.setEnabled(hasUse);
}
public void clearAllBoxList() {
DataPaneHelper.clearBoxItems(series);
DataPaneHelper.clearBoxItems(value);
}
public void refreshBoxListWithSelectTableData(List columnNameList) {
DataPaneHelper.refreshBoxItems(series, columnNameList);
DataPaneHelper.refreshBoxItems(value, columnNameList);
}
protected void populateSeries(String item) {
series.setSelectedItem(item);
}
protected void populateValue(String item) {
value.setSelectedItem(item);
}
protected void populateFunction(AbstractDataFunction _function) {
function.populateBean(_function);
}
protected String updateSeries() {
return GeneralUtils.objectToString(series.getSelectedItem());
}
protected String updateValue() {
return GeneralUtils.objectToString(value.getSelectedItem());
}
protected AbstractDataFunction updateFunction() {
return function.updateBean();
}
@Override
public boolean accept(Object ob) {
return true;
}
@Override
public void reset() {
}
@Override
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Value");
}
@Override
public T updateBean() {
return null;
}
}
protected abstract class AbstractCustomFieldNamePane extends AbstractCorrelationPane<T> {
@Override
protected FieldEditorComponentWrapper[] createFieldEditorComponentWrappers() {
return new FieldEditorComponentWrapper[]{
new UIComboBoxEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Field_Name")) {
@Override
protected List<String> items() {
return fieldList;
}
},
new UITextFieldEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Name")),
new CalculateComboBoxEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Summary_Method"))
};
}
@Override
protected Object[] createLine() {
return new String[]{StringUtils.EMPTY, StringUtils.EMPTY, Toolkit.i18nText("Fine-Design_Chart_Use_None")};
}
}
}

168
designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java

@ -0,0 +1,168 @@
package com.fr.design.chartx.component;
import com.fr.chartx.data.field.ColumnField;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.general.IOUtils;
import javax.swing.BoxLayout;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
/**
* Created by shine on 2019/4/10.
* 一列组件<T extends JComponent> 可增可删通过JComponent后面的加减button增删
*/
public abstract class AbstractMultiComponentPane<T extends JComponent> extends JPanel {
private static final int COM_W = 96;
private static final int H = 20;
private static final int ICON_W = 20;
private JPanel boxPane;
private UIButton addButton;
private T firstFieldComponent;
private List<T> categoryComponentList = new ArrayList<T>();
protected abstract T createFirstFieldComponent();
protected abstract T createOtherFieldComponent();
protected abstract void populateField(T component, ColumnField field);
protected abstract void updateField(T component, ColumnField field);
public AbstractMultiComponentPane() {
UILabel label = new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Category"));
label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT));
firstFieldComponent = createFirstFieldComponent();
firstFieldComponent.setPreferredSize(new Dimension(COM_W, H));
addButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/buttonicon/add.png"));
addButton.setPreferredSize(new Dimension(ICON_W, H));
addButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (canAdd()) {
addNewComboBox();
}
}
});
final JPanel panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2));
panel.add(label);
panel.add(firstFieldComponent);
panel.add(addButton);
boxPane = new JPanel();
boxPane.setLayout(new BoxLayout(boxPane, BoxLayout.Y_AXIS));
this.setLayout(new BorderLayout(4, 0));
this.add(panel, BorderLayout.NORTH);
this.add(boxPane, BorderLayout.CENTER);
}
private JPanel addComboBoxAndButtonToBox(T uiComboBox, UIButton uiButton) {
final JPanel panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2));
panel.add(uiComboBox);
panel.add(uiButton);
boxPane.add(panel);
categoryComponentList.add(uiComboBox);
return panel;
}
private void addNewComboBox() {
final T comboBox = createOtherFieldComponent();
comboBox.setPreferredSize(new Dimension(COM_W, H));
UIButton delButton = new UIButton(IOUtils.readIcon("com/fr/design/images/toolbarbtn/close.png"));
delButton.setPreferredSize(new Dimension(ICON_W, H));
final JPanel panel = addComboBoxAndButtonToBox(comboBox, delButton);
delButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boxPane.remove(panel);
categoryComponentList.remove(comboBox);
checkAddButton();
relayoutPane();
}
});
relayoutPane();
checkAddButton();
}
private void relayoutPane() {
this.revalidate();
}
private void checkAddButton() {
addButton.setEnabled(canAdd());
}
private boolean canAdd() {
return categoryComponentList.size() < 3;
}
public List<T> componentList() {
List<T> list = new ArrayList<>(categoryComponentList);
list.add(firstFieldComponent);
return list;
}
public void populate(List<ColumnField> categoryList) {
int comboBoxSize = categoryComponentList.size(),
len = categoryList.size();
if (len > 0) {
populateField(firstFieldComponent, categoryList.get(0));
}
for (int i = 1; i < len; i++) {
if (i > comboBoxSize) {
addNewComboBox();
}
T comboBox = categoryComponentList.get(i - 1);
populateField(comboBox, categoryList.get(i));
}
checkAddButton();
relayoutPane();
}
public void update(List<ColumnField> categoryList) {
categoryList.clear();
ColumnField temp1 = new ColumnField();
categoryList.add(temp1);
updateField(firstFieldComponent, temp1);
for (T comboBox : categoryComponentList) {
ColumnField temp = new ColumnField();
categoryList.add(temp);
updateField(comboBox, temp);
}
}
}

150
designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPaneWithUISpinner.java

@ -0,0 +1,150 @@
package com.fr.design.chartx.component;
import com.fr.chartx.data.field.ColumnField;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.util.ArrayList;
import java.util.List;
/**
* Created by shine on 2019/6/18.
* 一列组件<T extends JComponent> 可增可删通过UISpinner增删
*/
public abstract class AbstractMultiComponentPaneWithUISpinner<T extends JComponent> extends JPanel {
private UISpinner levelNumSpinner;
private List<T> levelComponentList = new ArrayList<T>();
private JPanel levelPane;
private int currentNum = 3;
public AbstractMultiComponentPaneWithUISpinner() {
initComps();
}
public List<T> getComponentList() {
return levelComponentList;
}
protected abstract T createJComponent();
protected abstract void populateField(T component, ColumnField field);
protected abstract void updateField(T component, ColumnField field);
protected void initComps() {
this.setLayout(new BorderLayout(0, 6));
levelNumSpinner = new UISpinner(1, 15, 1, currentNum) {
@Override
protected void fireStateChanged() {
//先处理自身的空间布局
refreshLevelPane();
//然后更新数据
super.fireStateChanged();
}
@Override
public void setTextFieldValue(double value) {
//如果为0,则没有改变值
if (value == 0) {
return;
}
super.setTextFieldValue(value);
}
};
Component[][] components = new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Level_Number")), levelNumSpinner},
};
JPanel northPane = TableLayoutHelper.createGapTableLayoutPane(components, new double[]{TableLayout.PREFERRED}, new double[]{ChartDataPane.LABEL_WIDTH, 122}, 0, 6);
this.add(northPane, BorderLayout.NORTH);
initLevelPane();
}
private void initLevelPane() {
double[] rows = new double[currentNum];
Component[][] components = new Component[currentNum][2];
List<T> newList = new ArrayList<T>();
int maxSize = levelComponentList.size();
for (int i = 0; i < currentNum; i++) {
rows[i] = TableLayout.PREFERRED;
T component = i < maxSize ? levelComponentList.get(i) : createJComponent();
newList.add(component);
components[i] = new Component[]{
new UILabel(Toolkit.i18nText("Fine-Design_Chart_Level") + String.valueOf(i + 1)),
component
};
}
levelComponentList = newList;
levelPane = TableLayoutHelper.createGapTableLayoutPane(components, rows, new double[]{ChartDataPane.LABEL_WIDTH, 122}, 0, 6);
this.add(levelPane, BorderLayout.CENTER);
}
private void refreshLevelPane() {
if (levelNumSpinner == null) {
return;
}
int newNum = (int) levelNumSpinner.getValue();
if (newNum != currentNum) {
currentNum = newNum;
this.remove(levelPane);
this.initLevelPane();
}
refreshPane();
}
private void refreshPane() {
this.validate();
this.repaint();
this.revalidate();
}
public void populate(List<ColumnField> categoryList) {
int len = categoryList.size();
levelNumSpinner.setValue(len);
refreshLevelPane();
for (int i = 0; i < len; i++) {
ColumnField columnField = categoryList.get(i);
T component = levelComponentList.get(i);
populateField(component, columnField);
}
}
public void update(List<ColumnField> categoryList) {
categoryList.clear();
for (T comboBox : levelComponentList) {
ColumnField temp = new ColumnField();
categoryList.add(temp);
updateField(comboBox, temp);
}
}
}

171
designer-chart/src/main/java/com/fr/design/chartx/component/AbstractSingleFilterPane.java

@ -0,0 +1,171 @@
package com.fr.design.chartx.component;
import com.fr.base.Utils;
import com.fr.chartx.data.field.DataFilterProperties;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout;
import com.fr.design.mainframe.chart.gui.data.PresentComboBox;
import com.fr.design.mainframe.chart.gui.style.AbstractChartTabPane;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
/**
* Created by shine on 2019/07/18.
*/
public abstract class AbstractSingleFilterPane extends AbstractChartTabPane<DataFilterProperties> {
private static final int FIL_HEIGHT = 150;
private UICheckBox useTopCheckBox;
private UITextField topNumTextField;
private UICheckBox hideNullCheckBox;
private UICheckBox mergeOtherCheckBox;
private PresentComboBox present;
private AbstractAttrNoScrollPane parent;
private JPanel topPane;
public AbstractSingleFilterPane() {
super(true);
//todo@shinerefactor present的时候这边可以整理下
// this.parent = parent;
}
@Override
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
dim.height = FIL_HEIGHT;
return dim;
}
protected void layoutContentPane() {
super.layoutContentPane();
leftcontentPane.setBorder(BorderFactory.createEmptyBorder());
}
public void reloaPane(JPanel pane) {
super.reloaPane(pane);
leftcontentPane.setBorder(BorderFactory.createEmptyBorder());
}
@Override
protected JPanel createContentPane() {
this.setLayout(new BorderLayout());
JPanel pane = initPane();
this.add(pane, BorderLayout.NORTH);
return pane;
}
private JPanel initPane() {
useTopCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Only_Use_Before_Records"));
JPanel panel1 = new JPanel(new BorderLayout());
JPanel panel2 = new JPanel(new BorderLayout());
panel1.add(useTopCheckBox, BorderLayout.NORTH);
topNumTextField = new UITextField();
UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Records_Num"));
mergeOtherCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_CombineOther"));
mergeOtherCheckBox.setSelected(true);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f};
double[] rowSize = {p, p};
Component[][] components = new Component[][]{
new Component[]{label, topNumTextField},
new Component[]{mergeOtherCheckBox, null}
};
topPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize);
topPane.setBorder(BorderFactory.createEmptyBorder(10, 15, 0, 0));
//默认不显示
topPane.setVisible(false);
panel1.add(topPane, BorderLayout.CENTER);
hideNullCheckBox = new UICheckBox(title4PopupWindow() + " is null, hidden");
panel2.add(hideNullCheckBox, BorderLayout.NORTH);
useTopCheckBox.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
checkBoxUse();
}
});
present = new PresentComboBox() {
protected void fireChange() {
fire();
}
};
JPanel presentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Present"), present);
panel2.add(presentPane, BorderLayout.SOUTH);
double[] column = {f};
double[] row = {p, p};
Component[][] coms = new Component[][]{
new Component[]{panel1},
new Component[]{panel2}
};
return TableLayout4VanChartHelper.createGapTableLayoutPane(coms, row, column);
}
private void fire() {
if (this.parent != null) {
parent.attributeChanged();
}
}
/**
* 检查Box是否可用
*/
public void checkBoxUse() {
topPane.setVisible(useTopCheckBox.isSelected());
}
@Override
public void populateBean(DataFilterProperties ob) {
useTopCheckBox.setSelected(ob.isUseTop());
topNumTextField.setText(String.valueOf(ob.getTop()));
hideNullCheckBox.setSelected(ob.isHideNull());
mergeOtherCheckBox.setSelected(ob.isMerge());
present.populate(ob.getPresent());
checkBoxUse();
}
@Override
public DataFilterProperties updateBean() {
DataFilterProperties dataFilterProperties = new DataFilterProperties();
dataFilterProperties.setUseTop(useTopCheckBox.isSelected());
Number number = Utils.objectToNumber(topNumTextField.getText(), true);
if (number != null) {
dataFilterProperties.setTop(number.intValue());
}
dataFilterProperties.setHideNull(hideNullCheckBox.isSelected());
dataFilterProperties.setMerge(mergeOtherCheckBox.isSelected());
dataFilterProperties.setPresent(present.update());
return dataFilterProperties;
}
}

56
designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueCorrelationPane.java

@ -0,0 +1,56 @@
package com.fr.design.chartx.component;
import com.fr.chartx.data.field.ColumnField;
import com.fr.chartx.data.field.SeriesValueCorrelationDefinition;
import com.fr.chartx.data.field.SeriesValueField;
import com.fr.design.chartx.component.correlation.AbstractCorrelationPane;
import com.fr.design.chartx.component.correlation.FieldEditorComponentWrapper;
import com.fr.design.chartx.component.correlation.TinyFormulaPaneEditorComponent;
import com.fr.design.i18n.Toolkit;
import com.fr.general.GeneralUtils;
import java.util.ArrayList;
import java.util.List;
/**
* Created by shine on 2019/6/4.
*/
public class CellDataSeriesValueCorrelationPane extends AbstractCorrelationPane<SeriesValueCorrelationDefinition> {
@Override
protected FieldEditorComponentWrapper[] createFieldEditorComponentWrappers() {
return new FieldEditorComponentWrapper[]{
new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Name")),
new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Value"))
};
}
@Override
protected List<Object[]> covertTBeanToTableModelList(SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) {
List<Object[]> result = new ArrayList<Object[]>();
List<SeriesValueField> seriesValueFieldList = seriesValueCorrelationDefinition.getSeriesValueFieldList();
for (SeriesValueField seriesValueField : seriesValueFieldList) {
Object[] array = new Object[]{seriesValueField.getSeries().getFieldName(), seriesValueField.getValue().getFieldName()};
result.add(array);
}
return result;
}
@Override
protected void setTableModelListToTBean(List<Object[]> tableValues, SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) {
List<SeriesValueField> seriesValueFieldList = new ArrayList<SeriesValueField>();
for (Object[] oneLine : tableValues) {
SeriesValueField seriesValueField = new SeriesValueField();
ColumnField series = new ColumnField(GeneralUtils.objectToString(oneLine[0]));
ColumnField value = new ColumnField(GeneralUtils.objectToString(oneLine[1]));
seriesValueField.setSeries(series);
seriesValueField.setValue(value);
seriesValueFieldList.add(seriesValueField);
}
seriesValueCorrelationDefinition.setSeriesValueFieldList(seriesValueFieldList);
}
}

40
designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java

@ -0,0 +1,40 @@
package com.fr.design.chartx.component;
import com.fr.chartx.data.field.ColumnField;
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.extended.chart.UIComboBoxWithNone;
import java.util.ArrayList;
import java.util.List;
/**
* Created by shine on 2019/4/12.
*/
public class MultiComboBoxPane extends AbstractMultiComponentPane<UIComboBox> {
private List currentBoxItems = new ArrayList();
public void setCurrentBoxItems(List currentBoxItems) {
this.currentBoxItems = currentBoxItems;
}
@Override
protected UIComboBox createFirstFieldComponent() {
return new UIComboBoxWithNone();
}
@Override
protected UIComboBox createOtherFieldComponent() {
return new UIComboBox(currentBoxItems.toArray(new Object[currentBoxItems.size()]));
}
@Override
protected void populateField(UIComboBox component, ColumnField field) {
AbstractDataSetFieldsPane.populateField(component, field);
}
@Override
protected void updateField(UIComboBox component, ColumnField field) {
AbstractDataSetFieldsPane.updateField(component, field);
}
}

40
designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPaneWithUISpinner.java

@ -0,0 +1,40 @@
package com.fr.design.chartx.component;
import com.fr.chartx.data.field.ColumnField;
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane;
import com.fr.design.gui.icombobox.UIComboBox;
import java.util.ArrayList;
import java.util.List;
/**
* Created by shine on 2019/6/18.
*/
public class MultiComboBoxPaneWithUISpinner extends AbstractMultiComponentPaneWithUISpinner<UIComboBox> {
private List currentBoxList = new ArrayList();
@Override
protected void initComps() {
currentBoxList = new ArrayList();
super.initComps();
}
public void setCurrentBoxList(List currentBoxList) {
this.currentBoxList = currentBoxList;
}
@Override
protected UIComboBox createJComponent() {
return new UIComboBox(currentBoxList.toArray(new Object[currentBoxList.size()]));
}
@Override
protected void populateField(UIComboBox component, ColumnField field) {
AbstractDataSetFieldsPane.populateField(component, field);
}
@Override
protected void updateField(UIComboBox component, ColumnField field) {
AbstractDataSetFieldsPane.updateField(component, field);
}
}

31
designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java

@ -0,0 +1,31 @@
package com.fr.design.chartx.component;
import com.fr.chartx.data.field.ColumnField;
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane;
import com.fr.design.formula.TinyFormulaPane;
/**
* Created by shine on 2019/4/12.
*/
public class MultiTinyFormulaPane extends AbstractMultiComponentPane<TinyFormulaPane> {
@Override
protected TinyFormulaPane createFirstFieldComponent() {
return new TinyFormulaPane();
}
@Override
protected TinyFormulaPane createOtherFieldComponent() {
return new TinyFormulaPane();
}
@Override
protected void populateField(TinyFormulaPane component, ColumnField field) {
AbstractCellDataFieldsPane.populateField(component, field);
}
@Override
protected void updateField(TinyFormulaPane component, ColumnField field) {
AbstractCellDataFieldsPane.updateField(component, field);
}
}

25
designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPaneWithUISpinner.java

@ -0,0 +1,25 @@
package com.fr.design.chartx.component;
import com.fr.chartx.data.field.ColumnField;
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane;
import com.fr.design.formula.TinyFormulaPane;
/**
* Created by shine on 2019/6/19.
*/
public class MultiTinyFormulaPaneWithUISpinner extends AbstractMultiComponentPaneWithUISpinner<TinyFormulaPane> {
@Override
protected TinyFormulaPane createJComponent() {
return new TinyFormulaPane();
}
@Override
protected void populateField(TinyFormulaPane component, ColumnField field) {
AbstractCellDataFieldsPane.populateField(component, field);
}
@Override
protected void updateField(TinyFormulaPane component, ColumnField field) {
AbstractCellDataFieldsPane.updateField(component, field);
}
}

107
designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java

@ -0,0 +1,107 @@
package com.fr.design.chartx.component;
import com.fr.chartx.data.field.ColumnField;
import com.fr.chartx.data.field.SeriesValueCorrelationDefinition;
import com.fr.chartx.data.field.SeriesValueField;
import com.fr.data.util.function.AbstractDataFunction;
import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper;
import com.fr.general.GeneralUtils;
import java.util.ArrayList;
import java.util.List;
/**
* Created by shine on 2019/5/17.
*/
public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPane<SeriesValueCorrelationDefinition> {
@Override
protected AbstractUseFieldValuePane createUseFieldValuePane() {
return new UseFieldValuePane();
}
@Override
protected AbstractCustomFieldNamePane createCustomFieldNamePane() {
return new CustomFieldNamePane();
}
@Override
public void populateBean(SeriesValueCorrelationDefinition ob) {
if (ob.isCustomFieldValue()) {
populateCustomFieldNamePane(ob);
jcb.setSelectedIndex(1);
} else {
populateUseFieldValuePane(ob);
jcb.setSelectedIndex(0);
}
}
@Override
public void updateBean(SeriesValueCorrelationDefinition ob) {
if (jcb.getSelectedIndex() == 0) {
ob.setCustomFieldValue(false);
updateUseFieldValuePane(ob);
} else {
ob.setCustomFieldValue(true);
updateCustomFieldNamePane(ob);
}
}
private class UseFieldValuePane extends AbstractUseFieldValuePane {
@Override
public void populateBean(SeriesValueCorrelationDefinition ob) {
List<SeriesValueField> list = ob.getSeriesValueFieldList();
if (list != null && list.size() > 0) {
populateSeries(list.get(0).getSeries().getFieldName());
populateValue(list.get(0).getValue().getFieldName());
populateFunction((AbstractDataFunction) list.get(0).getValue().getDataFunction());
}
}
@Override
public void updateBean(SeriesValueCorrelationDefinition ob) {
List<SeriesValueField> list = new ArrayList<SeriesValueField>();
SeriesValueField seriesValueField = new SeriesValueField();
ColumnField series = new ColumnField(updateSeries());
ColumnField value = new ColumnField(updateValue());
value.setDataFunction(updateFunction());
seriesValueField.setValue(value);
seriesValueField.setSeries(series);
list.add(seriesValueField);
ob.setSeriesValueFieldList(list);
}
}
private class CustomFieldNamePane extends AbstractCustomFieldNamePane {
@Override
protected List<Object[]> covertTBeanToTableModelList(SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) {
List<Object[]> list = new ArrayList<Object[]>();
for (SeriesValueField seriesValueField : seriesValueCorrelationDefinition.getSeriesValueFieldList()) {
Object[] array = new Object[]{
seriesValueField.getValue().getFieldName(),
seriesValueField.getSeries().getFieldName(),
DataPaneHelper.getFunctionString(seriesValueField.getValue().getDataFunction())
};
list.add(array);
}
return list;
}
@Override
protected void setTableModelListToTBean(List<Object[]> tableValues, SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) {
List<SeriesValueField> seriesValueFields = new ArrayList<SeriesValueField>();
for (Object[] line : tableValues) {
ColumnField value = new ColumnField(GeneralUtils.objectToString(line[0]));
ColumnField series = new ColumnField(GeneralUtils.objectToString(line[1]));
value.setDataFunction(DataPaneHelper.getFunctionByName(GeneralUtils.objectToString(line[2])));
SeriesValueField seriesValueField = new SeriesValueField();
seriesValueField.setValue(value);
seriesValueField.setSeries(series);
seriesValueFields.add(seriesValueField);
}
seriesValueCorrelationDefinition.setSeriesValueFieldList(seriesValueFields);
}
}
}

130
designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractCorrelationPane.java

@ -0,0 +1,130 @@
package com.fr.design.chartx.component.correlation;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.frpane.UICorrelationPane;
import com.fr.design.gui.itable.UITable;
import com.fr.design.gui.itable.UITableEditor;
import com.fr.stable.StringUtils;
import javax.swing.JTable;
import javax.swing.event.ChangeEvent;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
/**
* Created by shine on 2019/6/4.
* 自定义editorComponent + 支持多种数据格式
*/
public abstract class AbstractCorrelationPane<T> extends BasicBeanPane<T> {
private FieldEditorComponentWrapper[] editorComponents;
private UICorrelationPane correlationPane;
public AbstractCorrelationPane() {
this.editorComponents = createFieldEditorComponentWrappers();
String[] headers = new String[editorComponents.length];
for (int i = 0, len = editorComponents.length; i < len; i++) {
headers[i] = editorComponents[i].headerName();
}
initComps(headers);
}
protected abstract FieldEditorComponentWrapper[] createFieldEditorComponentWrappers();
@Override
public void populateBean(T ob) {
correlationPane.populateBean(covertTBeanToTableModelList(ob));
}
@Override
public void updateBean(T ob) {
setTableModelListToTBean(correlationPane.updateBean(), ob);
}
@Override
public T updateBean() {
return null;
}
protected abstract List<Object[]> covertTBeanToTableModelList(T t);
protected abstract void setTableModelListToTBean(List<Object[]> tableValues, T t);
private void initComps(String[] headers) {
correlationPane = new UICorrelationPane(headers) {
public UITableEditor createUITableEditor() {
return new Editor();
}
protected UITable initUITable() {
return new UITable(columnCount) {
public UITableEditor createTableEditor() {
return createUITableEditor();
}
public void tableCellEditingStopped(ChangeEvent e) {
stopPaneEditing(e);
}
};
}
protected ActionListener getAddButtonListener() {
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
tablePane.addLine(createLine());
fireTargetChanged();
}
};
}
};
this.setLayout(new BorderLayout());
this.add(correlationPane, BorderLayout.CENTER);
}
protected Object[] createLine() {
return new Object[this.editorComponents.length];
}
private class Editor extends UITableEditor {
private Component currentComponent;
private FieldEditorComponentWrapper currentEditorWrapper;
public Object getCellEditorValue() {
return currentEditorWrapper.getValue(currentComponent);
}
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
if (column == table.getModel().getColumnCount()) {
return null;
}
correlationPane.stopCellEditing();
currentEditorWrapper = AbstractCorrelationPane.this.editorComponents[column];
currentComponent = currentEditorWrapper.getTableCellEditorComponent(correlationPane, table, isSelected, row, column);
currentEditorWrapper.setValue(currentComponent, value);
return currentComponent;
}
}
@Override
protected String title4PopupWindow() {
return StringUtils.EMPTY;
}
}

19
designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractEditorComponent.java

@ -0,0 +1,19 @@
package com.fr.design.chartx.component.correlation;
import java.awt.Component;
/**
* Created by shine on 2019/6/10.
*/
public abstract class AbstractEditorComponent<T extends Component> implements FieldEditorComponentWrapper<T> {
private String header;
public AbstractEditorComponent(String header) {
this.header = header;
}
@Override
public String headerName() {
return this.header;
}
}

45
designer-chart/src/main/java/com/fr/design/chartx/component/correlation/CalculateComboBoxEditorComponent.java

@ -0,0 +1,45 @@
package com.fr.design.chartx.component.correlation;
import com.fr.design.gui.frpane.UICorrelationPane;
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox;
import javax.swing.JTable;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* Created by shine on 2019/6/10.
*/
public class CalculateComboBoxEditorComponent extends AbstractEditorComponent<CalculateComboBox> {
public CalculateComboBoxEditorComponent(String header) {
super(header);
}
@Override
public CalculateComboBox getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, int row, int column) {
CalculateComboBox calculateComboBox = new CalculateComboBox();
calculateComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
parent.stopCellEditing();
parent.fireTargetChanged();
}
});
return calculateComboBox;
}
@Override
public Object getValue(CalculateComboBox calculateComboBox) {
return calculateComboBox.getSelectedItem();
}
@Override
public void setValue(CalculateComboBox calculateComboBox, Object o) {
if (o != null) {
calculateComboBox.setSelectedItem(o);
}
}
}

20
designer-chart/src/main/java/com/fr/design/chartx/component/correlation/FieldEditorComponentWrapper.java

@ -0,0 +1,20 @@
package com.fr.design.chartx.component.correlation;
import com.fr.design.gui.frpane.UICorrelationPane;
import javax.swing.JTable;
import java.awt.Component;
/**
* Created by shine on 2019/6/4.
*/
public interface FieldEditorComponentWrapper<T extends Component> {
String headerName();
T getTableCellEditorComponent(UICorrelationPane parent, JTable table, boolean isSelected, final int row, int column);
Object getValue(T t);
void setValue(T t, Object o);
}

56
designer-chart/src/main/java/com/fr/design/chartx/component/correlation/TinyFormulaPaneEditorComponent.java

@ -0,0 +1,56 @@
package com.fr.design.chartx.component.correlation;
import com.fr.base.BaseFormula;
import com.fr.base.Utils;
import com.fr.design.constants.UIConstants;
import com.fr.design.event.UIObserverListener;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.frpane.UICorrelationPane;
import javax.swing.JTable;
/**
* Created by shine on 2019/6/4.
*/
public class TinyFormulaPaneEditorComponent extends AbstractEditorComponent<TinyFormulaPane> {
public TinyFormulaPaneEditorComponent(String header) {
super(header);
}
@Override
public TinyFormulaPane getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, final int row, int column) {
TinyFormulaPane editorComponent = new TinyFormulaPane() {
@Override
public void okEvent() {
parent.stopCellEditing();
parent.fireTargetChanged();
}
@Override
protected void populateTextField(BaseFormula fm) {
formulaTextField.setText(fm.getContent());
}
};
editorComponent.setBackground(UIConstants.FLESH_BLUE);
editorComponent.getUITextField().registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
parent.fireTargetChanged();
}
});
return editorComponent;
}
@Override
public Object getValue(TinyFormulaPane formulaPane) {
return formulaPane.getUITextField().getText();
}
@Override
public void setValue(TinyFormulaPane formulaPane, Object o) {
formulaPane.getUITextField().setText(Utils.objectToString(o));
}
}

55
designer-chart/src/main/java/com/fr/design/chartx/component/correlation/UIComboBoxEditorComponent.java

@ -0,0 +1,55 @@
package com.fr.design.chartx.component.correlation;
import com.fr.design.gui.frpane.UICorrelationPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.itable.UITable;
import javax.swing.JTable;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.List;
/**
* Created by shine on 2019/6/10.
*/
public class UIComboBoxEditorComponent extends AbstractEditorComponent<UIComboBox> {
public UIComboBoxEditorComponent(String header) {
super(header);
}
protected List<String> items() {
return new ArrayList<String>();
}
@Override
public UIComboBox getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, final int row, int column) {
UIComboBox uiComboBox = new UIComboBox(items().toArray());
uiComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
parent.stopCellEditing();
parent.fireTargetChanged();
UITable table = parent.getTable();
Object object = table.getValueAt(row, 0);
if (object != null) {
table.setValueAt(object, row, 1);
}
}
});
return uiComboBox;
}
@Override
public Object getValue(UIComboBox uiComboBox) {
return uiComboBox.getSelectedItem();
}
@Override
public void setValue(UIComboBox uiComboBox, Object o) {
uiComboBox.getModel().setSelectedItem(o);
}
}

41
designer-chart/src/main/java/com/fr/design/chartx/component/correlation/UITextFieldEditorComponent.java

@ -0,0 +1,41 @@
package com.fr.design.chartx.component.correlation;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.frpane.UICorrelationPane;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.general.GeneralUtils;
import javax.swing.JTable;
/**
* Created by shine on 2019/6/10.
*/
public class UITextFieldEditorComponent extends AbstractEditorComponent<UITextField> {
public UITextFieldEditorComponent(String header) {
super(header);
}
@Override
public UITextField getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, int row, int column) {
UITextField uiTextField = new UITextField();
uiTextField.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
parent.fireTargetChanged();
}
});
return uiTextField;
}
@Override
public Object getValue(UITextField uiTextField) {
return uiTextField.getText();
}
@Override
public void setValue(UITextField uiTextField, Object o) {
uiTextField.setText(GeneralUtils.objectToString(o));
}
}

97
designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java

@ -0,0 +1,97 @@
package com.fr.design.chartx.fields;
import com.fr.chartx.data.field.AbstractColumnFieldCollection;
import com.fr.chartx.data.field.ColumnField;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
import java.util.Arrays;
/**
* Created by shine on 2019/5/16.
* 单元格数据源 具体有哪些字段的一个抽象pane
*/
public abstract class AbstractCellDataFieldsPane<T extends AbstractColumnFieldCollection> extends BasicBeanPane<T> {
public AbstractCellDataFieldsPane() {
initComponents();
}
protected void initComponents() {
this.setLayout(new BorderLayout(0, 6));
this.add(createNorthPane(), BorderLayout.NORTH);
this.add(createCenterPane(), BorderLayout.CENTER);
this.add(createSouthPane(), BorderLayout.SOUTH);
this.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 8));
}
protected JPanel createCenterPane() {
String[] labels = fieldLabels();
Component[] formulaPanes = fieldComponents();
int len = Math.min(labels.length, formulaPanes.length);
if (len == 0) {
return null;
}
Component[][] components = new Component[len][2];
for (int i = 0; i < len; i++) {
components[i] = new Component[]{new UILabel(labels[i], SwingConstants.LEFT), formulaPanes[i]};
}
double p = TableLayout.PREFERRED;
double[] columnSize = {ChartDataPane.LABEL_WIDTH, 124};
double[] rowSize = new double[len];
Arrays.fill(rowSize, p);
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 6);
}
protected JPanel createNorthPane() {
return new JPanel();
}
protected JPanel createSouthPane() {
return new JPanel();
}
protected Component[] fieldComponents() {
return formulaPanes();
}
protected abstract String[] fieldLabels();
protected abstract TinyFormulaPane[] formulaPanes();
@Override
public abstract T updateBean();
public static void populateField(TinyFormulaPane formulaPane, ColumnField field) {
formulaPane.populateBean(field.getFieldName());
}
public static void updateField(TinyFormulaPane formulaPane, ColumnField field) {
field.setFieldName(formulaPane.updateBean());
}
@Override
protected String title4PopupWindow() {
return StringUtils.EMPTY;
}
}

149
designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractDataSetFieldsPane.java

@ -0,0 +1,149 @@
package com.fr.design.chartx.fields;
import com.fr.chartx.data.field.AbstractColumnFieldCollection;
import com.fr.chartx.data.field.ColumnField;
import com.fr.data.util.function.AbstractDataFunction;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox;
import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper;
import com.fr.general.GeneralUtils;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
import java.util.Arrays;
import java.util.List;
import static com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper.refreshBoxItems;
/**
* Created by shine on 2019/5/16.
* 数据集数据源 具体有哪些字段的一个抽象pane
*/
public abstract class AbstractDataSetFieldsPane<T extends AbstractColumnFieldCollection> extends BasicBeanPane<T> {
public AbstractDataSetFieldsPane() {
initComponents();
}
protected void initComponents() {
this.setLayout(new BorderLayout(0, 4));
this.setBorder(BorderFactory.createEmptyBorder(2, 24, 0, 15));
JPanel north = createNorthPane(),
center = createCenterPane(),
south = createSouthPane();
if (north != null) {
this.add(north, BorderLayout.NORTH);
}
if (center != null) {
this.add(center, BorderLayout.CENTER);
}
if (south != null) {
this.add(south, BorderLayout.SOUTH);
}
}
protected JPanel createNorthPane() {
return null;
}
protected JPanel createCenterPane() {
String[] labels = fieldLabels();
Component[] fieldComponents = fieldComponents();
int len = Math.min(labels.length, fieldComponents.length);
if (len == 0) {
return null;
}
Component[][] components = new Component[len][2];
for (int i = 0; i < len; i++) {
components[i] = new Component[]{new UILabel(labels[i], SwingConstants.LEFT), fieldComponents[i]};
}
double p = TableLayout.PREFERRED;
double[] columnSize = {ChartDataPane.LABEL_WIDTH, 122};
double[] rowSize = new double[len];
Arrays.fill(rowSize, p);
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 6);
}
protected JPanel createSouthPane() {
return null;
}
protected Component[] fieldComponents() {
return filedComboBoxes();
}
protected abstract String[] fieldLabels();
protected abstract UIComboBox[] filedComboBoxes();
public void checkBoxUse(boolean hasUse) {
for (Component component : fieldComponents()) {
component.setEnabled(hasUse);
}
}
public void clearAllBoxList() {
for (UIComboBox comboBox : filedComboBoxes()) {
DataPaneHelper.clearBoxItems(comboBox);
}
}
public void refreshBoxListWithSelectTableData(List columnNameList) {
for (UIComboBox comboBox : filedComboBoxes()) {
refreshBoxItems(comboBox, columnNameList);
}
}
@Override
public abstract T updateBean();
public static void populateField(UIComboBox comboBox, ColumnField field) {
populateFunctionField(comboBox, null, field);
}
public static void updateField(UIComboBox comboBox, ColumnField field) {
updateFunctionField(comboBox, null, field);
}
protected static void populateFunctionField(UIComboBox comboBox, CalculateComboBox calculateComboBox, ColumnField field) {
comboBox.setSelectedItem(field.getFieldName());
if (calculateComboBox != null) {
calculateComboBox.populateBean((AbstractDataFunction) field.getDataFunction());
}
}
protected static void updateFunctionField(UIComboBox comboBox, CalculateComboBox calculateComboBox, ColumnField field) {
field.setFieldName(GeneralUtils.objectToString(comboBox.getSelectedItem()));
if (calculateComboBox != null) {
field.setDataFunction(calculateComboBox.updateBean());
} else {
field.setDataFunction(null);
}
}
@Override
protected String title4PopupWindow() {
return StringUtils.EMPTY;
}
}

41
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java

@ -0,0 +1,41 @@
package com.fr.design.chartx.fields.diff;
import com.fr.chartx.data.field.diff.AbstractColumnFieldCollectionWithSeriesValue;
import com.fr.design.chartx.component.CellDataSeriesValueCorrelationPane;
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane;
import javax.swing.JPanel;
import java.awt.BorderLayout;
/**
* Created by shine on 2019/6/4.
*/
public abstract class AbstractCellDataFieldsWithSeriesValuePane<T extends AbstractColumnFieldCollectionWithSeriesValue>
extends AbstractCellDataFieldsPane<T> {
private CellDataSeriesValueCorrelationPane seriesValueFieldsPane;
@Override
protected JPanel createCenterPane() {
JPanel normalCenter = super.createCenterPane();
seriesValueFieldsPane = new CellDataSeriesValueCorrelationPane();
if (normalCenter != null) {
JPanel panel = new JPanel(new BorderLayout());
panel.add(normalCenter, BorderLayout.CENTER);
panel.add(seriesValueFieldsPane, BorderLayout.SOUTH);
return panel;
} else {
return seriesValueFieldsPane;
}
}
protected void populateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue fieldCollectionWithSeriesValue) {
seriesValueFieldsPane.populateBean(fieldCollectionWithSeriesValue.getSeriesValueCorrelationDefinition());
}
protected void updateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue fieldCollectionWithSeriesValue) {
seriesValueFieldsPane.updateBean(fieldCollectionWithSeriesValue.getSeriesValueCorrelationDefinition());
}
}

60
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java

@ -0,0 +1,60 @@
package com.fr.design.chartx.fields.diff;
import com.fr.chartx.data.field.diff.AbstractColumnFieldCollectionWithSeriesValue;
import com.fr.design.chartx.component.SeriesValueFieldComboBoxPane;
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.util.List;
/**
* Created by shine on 2019/5/16.
* 带有 自定义系列名fr表现为 系列名使用字段名 的字段集合 的一个pane
*/
public abstract class AbstractDataSetFieldsWithSeriesValuePane<T extends AbstractColumnFieldCollectionWithSeriesValue>
extends AbstractDataSetFieldsPane<T> {
private SeriesValueFieldComboBoxPane seriesValueFieldComboBoxPane;
@Override
protected JPanel createCenterPane() {
JPanel normalCenter = super.createCenterPane();
seriesValueFieldComboBoxPane = new SeriesValueFieldComboBoxPane();
if (normalCenter != null) {
JPanel panel = new JPanel(new BorderLayout());
panel.add(normalCenter, BorderLayout.CENTER);
panel.add(seriesValueFieldComboBoxPane, BorderLayout.SOUTH);
return panel;
} else {
return seriesValueFieldComboBoxPane;
}
}
@Override
public void checkBoxUse(boolean hasUse) {
super.checkBoxUse(hasUse);
seriesValueFieldComboBoxPane.checkBoxUse(hasUse);
}
@Override
public void clearAllBoxList() {
super.clearAllBoxList();
seriesValueFieldComboBoxPane.clearAllBoxList();
}
@Override
public void refreshBoxListWithSelectTableData(List columnNameList) {
super.refreshBoxListWithSelectTableData(columnNameList);
seriesValueFieldComboBoxPane.refreshBoxListWithSelectTableData(columnNameList);
}
protected void populateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue fieldCollectionWithSeriesValue) {
seriesValueFieldComboBoxPane.populateBean(fieldCollectionWithSeriesValue.getSeriesValueCorrelationDefinition());
}
protected void updateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue fieldCollectionWithSeriesValue) {
seriesValueFieldComboBoxPane.updateBean(fieldCollectionWithSeriesValue.getSeriesValueCorrelationDefinition());
}
}

115
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java

@ -0,0 +1,115 @@
package com.fr.design.chartx.fields.diff;
import com.fr.chartx.data.field.ColumnField;
import com.fr.chartx.data.field.SeriesValueCorrelationDefinition;
import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection;
import com.fr.design.chartx.component.AbstractSingleFilterPane;
import com.fr.design.chartx.component.MultiTinyFormulaPane;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.van.chart.map.designer.VanChartGroupPane;
import javax.swing.JPanel;
import java.util.List;
/**
* Created by shine on 2019/4/12.
*/
public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithSeriesValuePane<MultiCategoryColumnFieldCollection> {
private MultiTinyFormulaPane multiCategoryPane;
private AbstractSingleFilterPane seriesFilterPane;
private AbstractSingleFilterPane categoryFilterPane;
private void createMultiFormulaPane() {
if (multiCategoryPane == null) {
multiCategoryPane = new MultiTinyFormulaPane();
}
}
@Override
protected JPanel createNorthPane() {
createMultiFormulaPane();
return multiCategoryPane;
}
@Override
protected JPanel createSouthPane() {
if (seriesFilterPane == null) {
seriesFilterPane = new AbstractSingleFilterPane() {
@Override
public String title4PopupWindow() {
//todo@shinerefactor
return "series";
}
};
categoryFilterPane = new AbstractSingleFilterPane() {
@Override
public String title4PopupWindow() {
return "category";
}
};
}
return new VanChartGroupPane(new String[]{seriesFilterPane.title4PopupWindow(), categoryFilterPane.title4PopupWindow()}
, new JPanel[]{seriesFilterPane, categoryFilterPane}) {
};
}
@Override
protected String[] fieldLabels() {
return new String[0];
}
@Override
protected TinyFormulaPane[] formulaPanes() {
createMultiFormulaPane();
List<TinyFormulaPane> list = multiCategoryPane.componentList();
return list.toArray(new TinyFormulaPane[list.size()]);
}
@Override
public void populateBean(MultiCategoryColumnFieldCollection multiCategoryColumnFieldCollection) {
List<ColumnField> categoryList = multiCategoryColumnFieldCollection.getCategoryList();
multiCategoryPane.populate(categoryList);
populateSeriesValuePane(multiCategoryColumnFieldCollection);
SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = multiCategoryColumnFieldCollection.getSeriesValueCorrelationDefinition();
if (seriesValueCorrelationDefinition != null) {
seriesFilterPane.populateBean(seriesValueCorrelationDefinition.getFilterProperties());
}
if (categoryList != null && !categoryList.isEmpty()) {
categoryFilterPane.populateBean(categoryList.get(0).getFilterProperties());
}
}
@Override
public MultiCategoryColumnFieldCollection updateBean() {
MultiCategoryColumnFieldCollection fieldCollection = new MultiCategoryColumnFieldCollection();
List<ColumnField> categoryList = fieldCollection.getCategoryList();
multiCategoryPane.update(categoryList);
updateSeriesValuePane(fieldCollection);
SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = fieldCollection.getSeriesValueCorrelationDefinition();
if (seriesValueCorrelationDefinition != null) {
seriesValueCorrelationDefinition.setFilterProperties(seriesFilterPane.updateBean());
}
if (categoryList != null && !categoryList.isEmpty()) {
categoryList.get(0).setFilterProperties(categoryFilterPane.updateBean());
}
return fieldCollection;
}
}

116
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java

@ -0,0 +1,116 @@
package com.fr.design.chartx.fields.diff;
import com.fr.chartx.data.field.ColumnField;
import com.fr.chartx.data.field.SeriesValueCorrelationDefinition;
import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection;
import com.fr.design.chartx.component.AbstractSingleFilterPane;
import com.fr.design.chartx.component.MultiComboBoxPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.van.chart.map.designer.VanChartGroupPane;
import javax.swing.JPanel;
import java.util.List;
/**
* Created by shine on 2019/4/10.
*/
public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSeriesValuePane<MultiCategoryColumnFieldCollection> {
private MultiComboBoxPane multiCategoryPane;
private AbstractSingleFilterPane seriesFilterPane;
private AbstractSingleFilterPane categoryFilterPane;
@Override
protected String[] fieldLabels() {
return new String[0];
}
@Override
protected UIComboBox[] filedComboBoxes() {
List<UIComboBox> list = initMultiCategoryPane().componentList();
return list.toArray(new UIComboBox[list.size()]);
}
private MultiComboBoxPane initMultiCategoryPane() {
if (multiCategoryPane == null) {
multiCategoryPane = new MultiComboBoxPane();
}
return multiCategoryPane;
}
@Override
protected JPanel createNorthPane() {
return initMultiCategoryPane();
}
@Override
protected JPanel createSouthPane() {
if (seriesFilterPane == null) {
seriesFilterPane = new AbstractSingleFilterPane() {
@Override
public String title4PopupWindow() {
//todo@shinerefactor
return "series";
}
};
categoryFilterPane = new AbstractSingleFilterPane() {
@Override
public String title4PopupWindow() {
return "category";
}
};
}
return new VanChartGroupPane(new String[]{seriesFilterPane.title4PopupWindow(), categoryFilterPane.title4PopupWindow()}
, new JPanel[]{seriesFilterPane, categoryFilterPane}) {
};
}
@Override
public void refreshBoxListWithSelectTableData(List columnNameList) {
super.refreshBoxListWithSelectTableData(columnNameList);
multiCategoryPane.setCurrentBoxItems(columnNameList);
}
@Override
public void populateBean(MultiCategoryColumnFieldCollection multiCategoryColumnFieldCollection) {
List<ColumnField> categoryList = multiCategoryColumnFieldCollection.getCategoryList();
multiCategoryPane.populate(categoryList);
populateSeriesValuePane(multiCategoryColumnFieldCollection);
SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = multiCategoryColumnFieldCollection.getSeriesValueCorrelationDefinition();
if (seriesValueCorrelationDefinition != null) {
seriesFilterPane.populateBean(seriesValueCorrelationDefinition.getFilterProperties());
}
if (categoryList != null && !categoryList.isEmpty()) {
categoryFilterPane.populateBean(categoryList.get(0).getFilterProperties());
}
}
@Override
public MultiCategoryColumnFieldCollection updateBean() {
MultiCategoryColumnFieldCollection columnFieldCollection = new MultiCategoryColumnFieldCollection();
List<ColumnField> categoryList = columnFieldCollection.getCategoryList();
multiCategoryPane.update(categoryList);
updateSeriesValuePane(columnFieldCollection);
SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = columnFieldCollection.getSeriesValueCorrelationDefinition();
if (seriesValueCorrelationDefinition != null) {
seriesValueCorrelationDefinition.setFilterProperties(seriesFilterPane.updateBean());
}
if (categoryList != null && !categoryList.isEmpty()) {
categoryList.get(0).setFilterProperties(categoryFilterPane.updateBean());
}
return columnFieldCollection;
}
}

67
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieCellDataFieldsPane.java

@ -0,0 +1,67 @@
package com.fr.design.chartx.fields.diff;
import com.fr.chartx.data.field.diff.MultiPieColumnFieldCollection;
import com.fr.design.chartx.component.MultiTinyFormulaPaneWithUISpinner;
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import javax.swing.JPanel;
/**
* Created by shine on 2019/6/18.
*/
public class MultiPieCellDataFieldsPane extends AbstractCellDataFieldsPane<MultiPieColumnFieldCollection> {
private UITextField nameField;//指标名称
private MultiTinyFormulaPaneWithUISpinner levelPane;
private TinyFormulaPane value;
@Override
protected void initComponents() {
nameField = new UITextField();
levelPane = new MultiTinyFormulaPaneWithUISpinner();
value = new TinyFormulaPane();
super.initComponents();
}
@Override
protected JPanel createNorthPane() {
return levelPane;
}
@Override
protected String[] fieldLabels() {
return new String[]{
Toolkit.i18nText("Fine-Design_Chart_Use_Value"),
};
}
@Override
protected TinyFormulaPane[] formulaPanes() {
return new TinyFormulaPane[]{
value
};
}
@Override
public void populateBean(MultiPieColumnFieldCollection ob) {
nameField.setText(ob.getTargetName());
levelPane.populate(ob.getLevels());
populateField(value, ob.getValue());
}
@Override
public MultiPieColumnFieldCollection updateBean() {
MultiPieColumnFieldCollection result = new MultiPieColumnFieldCollection();
result.setTargetName(nameField.getText());
levelPane.update(result.getLevels());
updateField(value, result.getValue());
return result;
}
}

94
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieDataSetFieldsPane.java

@ -0,0 +1,94 @@
package com.fr.design.chartx.fields.diff;
import com.fr.chartx.data.field.diff.MultiPieColumnFieldCollection;
import com.fr.design.chartx.component.MultiComboBoxPaneWithUISpinner;
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox;
import javax.swing.JPanel;
import java.awt.Component;
import java.util.List;
/**
* Created by shine on 2019/6/18.
*/
public class MultiPieDataSetFieldsPane extends AbstractDataSetFieldsPane<MultiPieColumnFieldCollection> {
private UITextField nameField;
private MultiComboBoxPaneWithUISpinner levelComboBoxPane;
private UIComboBox value;
private CalculateComboBox function;
@Override
protected void initComponents() {
nameField = new UITextField();
levelComboBoxPane = new MultiComboBoxPaneWithUISpinner();
value = new UIComboBox();
function = new CalculateComboBox();
super.initComponents();
}
@Override
protected JPanel createNorthPane() {
return levelComboBoxPane;
}
@Override
protected String[] fieldLabels() {
return new String[]{
Toolkit.i18nText("Fine-Design_Chart_Use_Value"),
Toolkit.i18nText("Fine-Design_Chart_Summary_Method")
};
}
@Override
protected Component[] fieldComponents() {
return new UIComboBox[]{
value,
function
};
}
@Override
protected UIComboBox[] filedComboBoxes() {
List<UIComboBox> list = levelComboBoxPane.getComponentList();
int len = list.size();
UIComboBox[] result = new UIComboBox[len + 1];
for (int i = 0; i < len; i++) {
result[i] = list.get(i);
}
result[len] = value;
return result;
}
@Override
public void refreshBoxListWithSelectTableData(List columnNameList) {
super.refreshBoxListWithSelectTableData(columnNameList);
levelComboBoxPane.setCurrentBoxList(columnNameList);
}
@Override
public void populateBean(MultiPieColumnFieldCollection ob) {
levelComboBoxPane.populate(ob.getLevels());
populateFunctionField(value, function, ob.getValue());
}
@Override
public MultiPieColumnFieldCollection updateBean() {
MultiPieColumnFieldCollection result = new MultiPieColumnFieldCollection();
levelComboBoxPane.update(result.getLevels());
updateFunctionField(value, function, result.getValue());
return result;
}
}

70
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/WordCloudCellDataFieldsPane.java

@ -0,0 +1,70 @@
package com.fr.design.chartx.fields.diff;
import com.fr.chartx.data.field.diff.WordCloudColumnFieldCollection;
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import java.awt.Component;
/**
* Created by shine on 2019/6/18.
*/
public class WordCloudCellDataFieldsPane extends AbstractCellDataFieldsPane<WordCloudColumnFieldCollection> {
private UITextField name;
private TinyFormulaPane wordName;
private TinyFormulaPane wordValue;
@Override
protected void initComponents() {
name = new UITextField();
wordName = new TinyFormulaPane();
wordValue = new TinyFormulaPane();
super.initComponents();
}
@Override
protected String[] fieldLabels() {
return new String[]{
Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"),
Toolkit.i18nText("Fine-Design_Chart_Word_Name"),
Toolkit.i18nText("Fine-Design_Chart_Word_Value")
};
}
@Override
protected TinyFormulaPane[] formulaPanes() {
return new TinyFormulaPane[]{
wordName,
wordValue
};
}
@Override
protected Component[] fieldComponents() {
return new Component[]{
name,
wordName,
wordValue
};
}
@Override
public void populateBean(WordCloudColumnFieldCollection ob) {
name.setText(ob.getTargetName());
populateField(wordName, ob.getWordName());
populateField(wordValue, ob.getWordValue());
}
@Override
public WordCloudColumnFieldCollection updateBean() {
WordCloudColumnFieldCollection result = new WordCloudColumnFieldCollection();
result.setTargetName(name.getText());
updateField(wordName, result.getWordName());
populateField(wordValue, result.getWordValue());
return result;
}
}

74
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/WordCloudDataSetFieldsPane.java

@ -0,0 +1,74 @@
package com.fr.design.chartx.fields.diff;
import com.fr.chartx.data.field.diff.WordCloudColumnFieldCollection;
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox;
import java.awt.Component;
/**
* Created by shine on 2019/6/18.
*/
public class WordCloudDataSetFieldsPane extends AbstractDataSetFieldsPane<WordCloudColumnFieldCollection> {
private UITextField name;
private UIComboBox wordName;
private UIComboBox wordValue;
private CalculateComboBox calculateCombox;
@Override
protected void initComponents() {
name = new UITextField();
wordName = new UIComboBox();
wordValue = new UIComboBox();
calculateCombox = new CalculateComboBox();
super.initComponents();
}
@Override
protected String[] fieldLabels() {
return new String[]{
Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"),
Toolkit.i18nText("Fine-Design_Chart_Word_Name"),
Toolkit.i18nText("Fine-Design_Chart_Word_Value"),
Toolkit.i18nText("Fine-Design_Chart_Summary_Method")
};
}
@Override
protected UIComboBox[] filedComboBoxes() {
return new UIComboBox[]{
wordName,
wordValue
};
}
@Override
protected Component[] fieldComponents() {
return new Component[]{
name,
wordName,
wordValue,
calculateCombox
};
}
@Override
public void populateBean(WordCloudColumnFieldCollection ob) {
name.setText(ob.getTargetName());
populateField(wordName, ob.getWordName());
populateFunctionField(wordValue, calculateCombox, ob.getWordValue());
}
@Override
public WordCloudColumnFieldCollection updateBean() {
WordCloudColumnFieldCollection result = new WordCloudColumnFieldCollection();
result.setTargetName(name.getText());
updateField(wordName, result.getWordName());
updateFunctionField(wordValue, calculateCombox, result.getWordValue());
return result;
}
}

56
designer-chart/src/main/java/com/fr/design/chartx/single/CellDataPane.java

@ -0,0 +1,56 @@
package com.fr.design.chartx.single;
import com.fr.chartx.data.CellDataDefinition;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane;
import com.fr.design.i18n.Toolkit;
import java.awt.BorderLayout;
/**
* Created by shine on 2019/5/21.
*/
public class CellDataPane extends FurtherBasicBeanPane<CellDataDefinition> {
private AbstractCellDataFieldsPane cellDataFieldsPane;
public CellDataPane(AbstractCellDataFieldsPane cellDataFieldsPane) {
initComps(cellDataFieldsPane);
}
private void initComps(AbstractCellDataFieldsPane cellDataFieldsPane) {
this.cellDataFieldsPane = cellDataFieldsPane;
this.setLayout(new BorderLayout());
this.add(cellDataFieldsPane, BorderLayout.CENTER);
}
@Override
public String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Chart_Cell_Data");
}
@Override
public boolean accept(Object ob) {
return ob instanceof CellDataDefinition;
}
@Override
public void reset() {
this.removeAll();
}
@Override
public void populateBean(CellDataDefinition ob) {
cellDataFieldsPane.populateBean(ob.getColumnFieldCollection());
}
@Override
public CellDataDefinition updateBean() {
CellDataDefinition cellDataDefinition = new CellDataDefinition();
cellDataDefinition.setColumnFieldCollection(cellDataFieldsPane.updateBean());
return cellDataDefinition;
}
}

121
designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java

@ -0,0 +1,121 @@
package com.fr.design.chartx.single;
import com.fr.chartx.data.DataSetDefinition;
import com.fr.data.impl.NameTableData;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.DatabaseTableDataPane;
import com.fr.design.utils.gui.UIComponentUtils;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.List;
/**
* Created by shine on 2019/5/21.
*/
public class DataSetPane extends FurtherBasicBeanPane<DataSetDefinition> {
private static final int TABLE_DATA_LABEL_LINE_WRAP_WIDTH = 65;
private static final int TABLE_DATA_PANE_WIDTH = 246;
private DatabaseTableDataPane tableDataPane;
private AbstractDataSetFieldsPane dataSetFieldsPane;
public DataSetPane(AbstractDataSetFieldsPane dataSetFieldsPane) {
initComps(dataSetFieldsPane);
}
private void initComps(AbstractDataSetFieldsPane dataSetFieldsPane) {
UILabel label = new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Table_Data"));
UIComponentUtils.setLineWrap(label, TABLE_DATA_LABEL_LINE_WRAP_WIDTH);
UIComponentUtils.setPreferedWidth(label, ChartDataPane.LABEL_WIDTH);
tableDataPane = new DatabaseTableDataPane(label) {
@Override
protected void userEvent() {
refreshBoxList();
checkBoxUse();
}
};
tableDataPane.setPreferredSize(new Dimension(TABLE_DATA_PANE_WIDTH, tableDataPane.getPreferredSize().height));
this.dataSetFieldsPane = dataSetFieldsPane;
this.setLayout(new BorderLayout());
this.add(tableDataPane, BorderLayout.NORTH);
this.add(dataSetFieldsPane, BorderLayout.CENTER);
}
/**
* 检查box是否可用.
*/
public void checkBoxUse() {
TableDataWrapper dataWrap = tableDataPane.getTableDataWrapper();
if (dataSetFieldsPane != null) {
dataSetFieldsPane.checkBoxUse(dataWrap != null);
}
}
/**
* 刷新字段下拉列表
*/
private void refreshBoxList() {
TableDataWrapper dataWrap = tableDataPane.getTableDataWrapper();
if (dataWrap == null) {
return;
}
List<String> columnNameList = dataWrap.calculateColumnNameList();
if (dataSetFieldsPane != null) {
dataSetFieldsPane.refreshBoxListWithSelectTableData(columnNameList);
}
}
@Override
public boolean accept(Object ob) {
return ob instanceof DataSetDefinition;
}
@Override
public String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Chart_TableData");
}
@Override
public void reset() {
this.removeAll();
}
@Override
public void populateBean(DataSetDefinition ob) {
refreshBoxList();
checkBoxUse();
tableDataPane.populateBean(ob.getNameTableData());
dataSetFieldsPane.populateBean(ob.getColumnFieldCollection());
}
@Override
public DataSetDefinition updateBean() {
DataSetDefinition dataSetDefinition = new DataSetDefinition();
TableDataWrapper tableDataWrapper = tableDataPane.getTableDataWrapper();
if (tableDataWrapper != null) {
dataSetDefinition.setNameTableData(new NameTableData(tableDataWrapper.getTableDataName()));
}
dataSetDefinition.setColumnFieldCollection(dataSetFieldsPane.updateBean());
return dataSetDefinition;
}
}

90
designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java

@ -0,0 +1,90 @@
package com.fr.design.chartx.single;
import com.fr.chartx.data.AbstractDataDefinition;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane;
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.List;
/**
* Created by shine on 2019/5/21.
*/
public class SingleDataPane extends BasicBeanPane<AbstractDataDefinition> {
private UIComboBoxPane<AbstractDataDefinition> comboBoxPane;
private DataSetPane dataSetPane;
private CellDataPane cellDataPane;
public SingleDataPane(AbstractDataSetFieldsPane dataSetFieldsPane, AbstractCellDataFieldsPane cellDataFieldsPane) {
initComps(dataSetFieldsPane, cellDataFieldsPane);
}
private void initComps(AbstractDataSetFieldsPane dataSetFieldsPane, AbstractCellDataFieldsPane cellDataFieldsPane) {
cellDataPane = new CellDataPane(cellDataFieldsPane);
dataSetPane = new DataSetPane(dataSetFieldsPane);
comboBoxPane = new UIComboBoxPane<AbstractDataDefinition>() {
@Override
protected List<FurtherBasicBeanPane<? extends AbstractDataDefinition>> initPaneList() {
List<FurtherBasicBeanPane<? extends AbstractDataDefinition>> list = new ArrayList<FurtherBasicBeanPane<? extends AbstractDataDefinition>>();
list.add(dataSetPane);
list.add(cellDataPane);
return list;
}
protected void initLayout() {
this.setLayout(new BorderLayout(LayoutConstants.HGAP_LARGE, 6));
JPanel northPane = new JPanel(new BorderLayout(LayoutConstants.HGAP_LARGE, 0));
northPane.add(jcb, BorderLayout.CENTER);
UILabel label1 = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Source"));
label1.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT));
northPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{jcb, null, null, label1, null}));
northPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 8));
this.add(northPane, BorderLayout.NORTH);
this.add(cardPane, BorderLayout.CENTER);
}
@Override
protected String title4PopupWindow() {
return null;
}
};
this.setLayout(new BorderLayout());
this.add(comboBoxPane, BorderLayout.CENTER);
}
@Override
public void populateBean(AbstractDataDefinition ob) {
comboBoxPane.populateBean(ob);
}
@Override
public AbstractDataDefinition updateBean() {
return comboBoxPane.updateBean();
}
@Override
protected String title4PopupWindow() {
return null;
}
}

43
designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java

@ -1,8 +1,8 @@
package com.fr.design.mainframe.chart;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chartx.attr.ChartProvider;
import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.data.DesignTableDataManager;
@ -20,6 +20,7 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.ChartTypePane;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.vanchart.VanChart;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
@ -109,12 +110,14 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4
if (!ComparatorUtils.equals(collection, lastCollection)) {
//此处画图
Chart chart = collection.getSelectedChart();
chart.demoImgEvent(true);
VanChart vanChart = collection.getSelectedChart(VanChart.class);
if (vanChart != null) {
//此处画图
vanChart.demoImgEvent(true);
}
try {
lastCollection = (ChartCollection) collection.clone();
lastCollection = collection.clone();
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("error in clone ChartEditPane");
}
@ -131,7 +134,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4
* 重新构造面板
* @param currentChart 图表
*/
public void reLayout(Chart currentChart){
public void reLayout(ChartProvider currentChart) {
if(currentChart != null){
int chartIndex = getSelectedChartIndex(currentChart);
this.removeAll();
@ -139,12 +142,8 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4
paneList = new ArrayList<AbstractChartAttrPane>();
addTypePane();
boolean isDefault = true;
String plotID = "";
if(currentChart.getPlot() != null){
plotID = currentChart.getPlot().getPlotID();
isDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID);
}
String chartID = currentChart.getID();
boolean isDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(chartID);
if(isDefault){
paneList.add(dataPane4SupportCell);
@ -152,11 +151,11 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4
paneList.add(otherPane);
this.isDefaultPane = true;
}else{
ChartDataPane chartDataPane = createChartDataPane(plotID);
ChartDataPane chartDataPane = createChartDataPane(chartID);
if (chartDataPane != null) {
paneList.add(chartDataPane);
}
AbstractChartAttrPane[] otherPaneList = ChartTypeInterfaceManager.getInstance().getAttrPaneArray(plotID, listener);
AbstractChartAttrPane[] otherPaneList = ChartTypeInterfaceManager.getInstance().getAttrPaneArray(chartID, listener);
for(int i = 0; i < otherPaneList.length; i++){
otherPaneList[i].addAttributeChangeListener(listener);
paneList.add(otherPaneList[i]);
@ -226,8 +225,8 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4
return;
}
if(checkNeedsReLayout(collection.getSelectedChart())){
reLayout(collection.getSelectedChart());
if (checkNeedsReLayout(collection.getSelectedChartProvider())) {
reLayout(collection.getSelectedChartProvider());
}
this.collection = collection;
@ -253,7 +252,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4
}
}
public int getSelectedChartIndex(Chart chart){
public int getSelectedChartIndex(ChartProvider chart) {
int index = 0;
if(typePane != null){
FurtherBasicBeanPane[] paneList = typePane.getPaneList();
@ -267,15 +266,13 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4
}
//populate的时候看看要不要重构面板
private boolean checkNeedsReLayout(Chart chart){
private boolean checkNeedsReLayout(ChartProvider chart) {
if(chart != null){
int lastIndex = typePane.getSelectedIndex();
int currentIndex = getSelectedChartIndex(chart);
boolean currentPane = true;
if(chart.getPlot() != null){
String plotID = chart.getPlot().getPlotID();
currentPane = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID);
}
String chartID = chart.getID();
boolean currentPane = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(chartID);
return (currentPane != isDefaultPane) || (!currentPane && lastIndex != currentIndex);
}
return false;

65
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDesignerOtherPane.java

@ -1,65 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe.chart.gui;
import com.fr.design.mainframe.chart.gui.other.ChartDesignerConditionAttrPane;
import com.fr.design.mainframe.chart.gui.other.ChartDesignerInteractivePane;
import com.fr.design.dialog.BasicPane;
import javax.swing.*;
import java.awt.*;
import java.util.*;
/**
* 图表设计器的图标属性表高级tab
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-16
* Time: 下午2:04
*/
public class ChartDesignerOtherPane extends ChartOtherPane {
@Override
protected JPanel createContentPane() {
JPanel content = new JPanel(new BorderLayout());
otherPane = new ChartTabPane();
content.add(otherPane, BorderLayout.CENTER);
return content;
}
/**
* 界面标题
*
* @return 返回标题.
*/
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Advanced");
}
private boolean isHaveCondition() {
return hasCondition;
}
private class ChartTabPane extends TabPane {
@Override
protected java.util.List<BasicPane> initPaneList() {
java.util.List<BasicPane> paneList = new ArrayList<BasicPane>();
interactivePane = new ChartDesignerInteractivePane(ChartDesignerOtherPane.this);
paneList.add(interactivePane);
if (ChartDesignerOtherPane.this.isHaveCondition()) {
conditionAttrPane = new ChartDesignerConditionAttrPane();
paneList.add(conditionAttrPane);
}
return paneList;
}
}
}

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

@ -2,10 +2,10 @@ package com.fr.design.mainframe.chart.gui;
import com.fr.base.BaseUtils;
import com.fr.chart.base.AttrChangeConfig;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.SwitchState;
import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.chartx.attr.ChartProvider;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.DialogActionListener;
import com.fr.design.dialog.UIDialog;
@ -19,6 +19,7 @@ import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.mainframe.chart.gui.ChartTypePane.ComboBoxPane;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
@ -42,6 +43,8 @@ import java.awt.event.MouseListener;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
/**
* 图表 类型 增删 控制按钮界面.
@ -56,6 +59,12 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
private static final int P_W = 300;
private static final int P_H = 400;
private static Set<Class<? extends ChartProvider>> supportChangeConfigChartClassSet = new HashSet<Class<? extends ChartProvider>>();
static {
registerSupportChangeConfigChartClass(VanChart.class);
}
private UIButton addButton;
private UIButton configButton;
private ArrayList<ChartChangeButton> indexList = new ArrayList<ChartChangeButton>();
@ -109,6 +118,10 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
// Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK);
}
public static void registerSupportChangeConfigChartClass(Class<? extends ChartProvider> cls) {
supportChangeConfigChartClassSet.add(cls);
}
private void initConfigCreator() {
configCreator = new UIMenuNameableCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Change_Config_Attributes"), new AttrChangeConfig(), ChangeConfigPane.class);
}
@ -135,9 +148,9 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
if (editingCollection != null) {
//点击添加按钮,则会触发切换状态
Chart chart = editingCollection.getChangeStateNewChart();
ChartProvider chart = getChangeStateNewChart();
try {
Chart newChart = (Chart) chart.clone();
ChartProvider newChart = (ChartProvider) chart.clone();
editingCollection.addNamedChart(name, newChart);
} catch (CloneNotSupportedException e1) {
FineLoggerFactory.getLogger().error("Error in Clone");
@ -150,12 +163,51 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
//获取图表收集器的状态
private void checkoutChange(){
editingCollection.calculateMultiChartMode();
calculateMultiChartMode();
if (parent != null){
parent.relayoutChartTypePane(editingCollection);
}
//检查是否可以配置切换
configButton.setEnabled(editingCollection.changeEnable());
configButton.setEnabled(changeEnable());
}
/**
* 获取切花状态下的图表
*
* @return
*/
public ChartProvider getChangeStateNewChart() {
ChartProvider chart = editingCollection.getSelectedChartProvider();
String priority = ChartTypeManager.VAN_CHART_PRIORITY;
//todo@shinerefactor
// chart.getPriority();
return ChartTypeManager.getInstanceWithCheck().getFirstChart(priority);
}
//图表收集器模式状态改变
private void calculateMultiChartMode() {
//设置切换功能是否可用
editingCollection.getChangeConfigAttr().setEnable(changeEnable());
//多图表切换模式
if (editingCollection.getChartCount() > 1) {
editingCollection.setState(SwitchState.CHANGE);
} else {
editingCollection.setState(SwitchState.DEFAULT);
}
}
/**
* 是否支持图表切换的配置
*
* @return
*/
private boolean changeEnable() {
return editingCollection.getChartCount() > 1
&& supportChange();
}
private boolean supportChange() {
return supportChangeConfigChartClassSet.contains(editingCollection.getSelectedChartProvider().getClass());
}
ActionListener configListener = new ActionListener() {
@ -310,11 +362,11 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
}
private void checkConfigButtonVisible() {
addButton.setVisible(ChartTypeManager.enabledChart(editingCollection.getSelectedChart().getPlot().getPlotID()));
addButton.setVisible(ChartTypeManager.enabledChart(editingCollection.getSelectedChartProvider().getID()));
//新建一个collection
if(editingCollection.getState() == SwitchState.DEFAULT && editingCollection.getSelectedChart() != null){
if (editingCollection.getState() == SwitchState.DEFAULT && editingCollection.getSelectedChartProvider() != null) {
//Chart 不支持图表切换
configButton.setVisible(editingCollection.getSelectedChart().supportChange());
configButton.setVisible(supportChange());
}
}
@ -440,7 +492,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
private void deleteAButton() {
//先重构属性,在重构面板,否则面板在重构过程中,会重新将属性中的切换图表加到indexList中,导致面板无法删除
//记录改变前的plotID
String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChart().getPlot().getPlotID();
String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChartProvider().getID();
if (editingCollection != null) {
int count = editingCollection.getChartCount();
for (int i = 0; i < count; i++) {
@ -520,7 +572,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
if (isEnabled()) {
noSelected();
//记录改变前的plotID
String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChart().getPlot().getPlotID();
String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChartProvider().getID();
changeCollectionSelected(getButtonName());
setSelectedWithFireListener(true);
fireSelectedChanged();

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

@ -2,9 +2,9 @@ package com.fr.design.mainframe.chart.gui;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartattr.SwitchState;
import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.chartx.attr.ChartProvider;
import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.dialog.BasicScrollPane;
@ -41,30 +41,6 @@ public class ChartTypePane extends AbstractChartAttrPane{
private ChartTypeButtonPane buttonPane;
private ChartEditPane editPane;
private ChartCollection editingCollection;
private PaneState paneState = new PaneState();
private class PaneState{
//记录面板所处状态
private SwitchState paneState = SwitchState.DEFAULT;
//记录当前面板是谁在使用切换状态
private String chartID = StringUtils.EMPTY;
public SwitchState getPaneState() {
return paneState;
}
public void setPaneState(SwitchState paneState) {
this.paneState = paneState;
}
public String getChartID() {
return chartID;
}
public void setChartID(String chartID) {
this.chartID = chartID;
}
}
@Override
protected JPanel createContentPane() {
@ -122,14 +98,14 @@ public class ChartTypePane extends AbstractChartAttrPane{
public String title4PopupWindow() {
return PaneTitleConstants.CHART_TYPE_TITLE;
}
class ComboBoxPane extends UIComboBoxPane<Chart>{
private Map<String, Map<String, FurtherBasicBeanPane<? extends Chart>>> allChartTypePane;
class ComboBoxPane extends UIComboBoxPane<ChartProvider> {
private Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane;
@Override
protected List<FurtherBasicBeanPane<? extends Chart>> initPaneList() {
List<FurtherBasicBeanPane<? extends Chart>> paneList = new ArrayList<FurtherBasicBeanPane<? extends Chart>>();
allChartTypePane = new LinkedHashMap<String, Map<String, FurtherBasicBeanPane<? extends Chart>>>();
protected List<FurtherBasicBeanPane<? extends ChartProvider>> initPaneList() {
List<FurtherBasicBeanPane<? extends ChartProvider>> paneList = new ArrayList<FurtherBasicBeanPane<? extends ChartProvider>>();
allChartTypePane = new LinkedHashMap<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>>();
ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(paneList, allChartTypePane);
return paneList;
}
@ -145,13 +121,12 @@ public class ChartTypePane extends AbstractChartAttrPane{
* 如果是切换图表的不同图表之间切换则collection的选择下标会改变
* @param chart
*/
public void updateBean(Chart chart) {
public void updateBean(ChartProvider chart) {
Plot oldPlot = chart.getPlot();
String lastPlotID = oldPlot == null ? StringUtils.EMPTY : oldPlot.getPlotID();
String lastPlotID = chart.getID();
try{
Chart newDefaultChart = (Chart)((AbstractChartTypePane)getSelectedPane()).getDefaultChart().clone();
ChartProvider newDefaultChart = (ChartProvider) ((AbstractChartTypePane) getSelectedPane()).getDefaultChart().clone();
if (!ComparatorUtils.equals(chart.getClass(), newDefaultChart.getClass())) {
//vanChart 和 chart 之间切换
//不同chart之间切换
@ -166,20 +141,20 @@ public class ChartTypePane extends AbstractChartAttrPane{
//这一步会替换plot
((AbstractChartTypePane)getSelectedPane()).updateBean(chart);
Plot plot = chart.getPlot();
if(plot != null){
String plotID = plot.getPlotID();
//plot改变的话图表类型就算改变了
String chartID = chart.getID();
chart.setWrapperName(ChartTypeManager.getInstanceWithCheck().getWrapperName(plotID));
//chartID改变的话图表类型就算改变了
if (StringUtils.isNotEmpty(chartID)) {
chart.setChartImagePath(ChartTypeManager.getInstanceWithCheck().getChartImagePath(plotID));
if (chart instanceof Chart) {
//todo@shinerefactor: 这边看下是否可以删除
((Chart) chart).setWrapperName(ChartTypeManager.getInstanceWithCheck().getWrapperName(chartID));
((Chart) chart).setChartImagePath(ChartTypeManager.getInstanceWithCheck().getChartImagePath(chartID));
}
boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID);
boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(chartID);
if(editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, plotID))){
if (editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, chartID))) {
editPane.reLayout(chart);
}
}
@ -219,12 +194,12 @@ public class ChartTypePane extends AbstractChartAttrPane{
private void addOnePriorityCards(String priority, boolean ignore) {
Map<String, FurtherBasicBeanPane<? extends Chart>> map = allChartTypePane.get(priority);
Map<String, FurtherBasicBeanPane<? extends ChartProvider>> map = allChartTypePane.get(priority);
Iterator<Map.Entry<String, FurtherBasicBeanPane<? extends Chart>>> iterator = map.entrySet().iterator();
Iterator<Map.Entry<String, FurtherBasicBeanPane<? extends ChartProvider>>> iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, FurtherBasicBeanPane<? extends Chart>> entry = iterator.next();
Map.Entry<String, FurtherBasicBeanPane<? extends ChartProvider>> entry = iterator.next();
String plotID = entry.getKey();
if (ignore || ChartTypeManager.enabledChart(plotID)) {
cards.add(entry.getValue());
@ -241,9 +216,11 @@ public class ChartTypePane extends AbstractChartAttrPane{
//处理办法:这边除了重构 下拉项选项和cardNames 还需要把cards重构下(不需要init pane,只需要我需要的拿出来就好了)
private void relayout(ChartCollection collection){
//重构需要重构下拉框选项和cardNames
Chart chart = collection.getSelectedChart();
String priority = chart.getPriority();
String plotID = chart.getPlot().getPlotID();
ChartProvider chart = collection.getSelectedChartProvider();
String priority = ChartTypeManager.VAN_CHART_PRIORITY;
//TODO@shinerefactor
// chart.getPriority();
String plotID = chart.getID();
boolean enabledChart = ChartTypeManager.enabledChart(plotID);
String item = ChartTypeInterfaceManager.getInstance().getTitle4PopupWindow(priority, plotID);
@ -286,7 +263,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
}
@Override
public void populateBean(Chart ob) {
public void populateBean(ChartProvider ob) {
for (int i = 0; i < this.cards.size(); i++) {
FurtherBasicBeanPane pane = cards.get(i);
if (pane.accept(ob)) {
@ -303,12 +280,12 @@ public class ChartTypePane extends AbstractChartAttrPane{
}
@Override
public Chart updateBean() {
public ChartProvider updateBean() {
return getSelectedPane().updateBean();
}
@Override
public FurtherBasicBeanPane<? extends Chart> getSelectedPane(){
public FurtherBasicBeanPane<? extends ChartProvider> getSelectedPane() {
Object item = jcb.getSelectedItem();
for (int i = 0; i < cards.size(); i++){
if (ComparatorUtils.equals(item, cards.get(i).title4PopupWindow())){
@ -327,8 +304,8 @@ public class ChartTypePane extends AbstractChartAttrPane{
* @param collection
*/
public void reLayoutEditPane(String lastPlotID, ChartCollection collection){
Chart chart = collection.getSelectedChart();
String plotID = chart.getPlot().getPlotID();
ChartProvider chart = collection.getSelectedChartProvider();
String plotID = chart.getID();
boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID);
if (editPane != null && editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, plotID))){
editPane.reLayout(chart);
@ -337,22 +314,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
public void relayoutChartTypePane(ChartCollection collection){
if (needRelayout(collection)) {
chartTypeComBox.relayout(collection);
//设置面板切换状态
updatePaneState(collection);
}
}
private void updatePaneState(ChartCollection collection) {
paneState.setChartID(collection.getRepresentChartID());
paneState.setPaneState(collection.getState());
}
// TODO: 2016/11/17 因为现在populate面板时会重新构造面板,所以每次都需要重构
private boolean needRelayout(ChartCollection collection) {
/*return paneState.getChartID() != collection.getRepresentChartID() || paneState.getPaneState() != collection.getState();*/
return true;
chartTypeComBox.relayout(collection);
}
/**
@ -361,7 +323,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
public void populate(ChartCollection collection) {
editingCollection = collection;
Chart chart = collection.getSelectedChart();
ChartProvider chart = collection.getSelectedChartProvider();
this.remove(leftContentPane);
initContentPane();
@ -379,7 +341,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
public void update(ChartCollection collection) {
editingCollection = collection;
buttonPane.update(collection);// 内部操作时 已经做过处理.
Chart chart = collection.getSelectedChart();
ChartProvider chart = collection.getSelectedChartProvider();
chartTypeComBox.updateBean(chart);
}

33
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/StylePane4Chart.java

@ -1,33 +0,0 @@
package com.fr.design.mainframe.chart.gui;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.chart.gui.style.series.ChartSeriesPane;
import com.fr.design.mainframe.chart.gui.style.series.SeriesPane4ChartDesigner;
/**
* 图表设计器的样式面板
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-25
* Time: 下午6:56
*/
public class StylePane4Chart extends ChartStylePane {
public StylePane4Chart(AttributeChangeListener listener, boolean isNeedFormula) {
super(listener, isNeedFormula);
}
public void update(ChartCollection collection) {
int selectIndex = collection.getSelectedIndex();
super.update(collection);
collection.getSelectedChart().setStyleGlobal(false);
collection.setChartName(selectIndex, collection.getSelectedChart().getTitle().getTextObject().toString());
}
protected ChartSeriesPane createChartSeriesPane(){
return new SeriesPane4ChartDesigner(StylePane4Chart.this);
}
}

94
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/other/ChartSwitchPane.java

@ -1,94 +0,0 @@
package com.fr.design.mainframe.chart.gui.other;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import com.fr.design.chart.ChartControlPane;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
public class ChartSwitchPane extends AbstractAttrNoScrollPane{
private UIButton changeButton;
private ChartCollection editingChartCollection;
private ChartEditPane currentChartEditPane;
public ChartSwitchPane() {
}
@Override
protected JPanel createContentPane() {
JPanel pane = new JPanel();
pane.setLayout(new BorderLayout());
changeButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Switch"));
pane.add(changeButton, BorderLayout.NORTH);
changeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final ChartControlPane chartTypeManager = new ChartControlPane();
chartTypeManager.populate(editingChartCollection);
BasicDialog dlg = chartTypeManager.showWindow4ChartType(SwingUtilities.getWindowAncestor(new JPanel()), new DialogActionAdapter() {
public void doOk() {
chartTypeManager.update(editingChartCollection);//kunsnat: 确定刷新"chartSelectIndex"
if(currentChartEditPane != null) {
currentChartEditPane.populate(editingChartCollection);// 选中新Plot之后 刷新对应界面, 比如超级链接等, 然后才能update.
currentChartEditPane.gotoPane(PaneTitleConstants.CHART_TYPE_TITLE);
currentChartEditPane.gotoPane(PaneTitleConstants.CHART_OTHER_TITLE, PaneTitleConstants.CHART_OTHER_TITLE_CHANGE);
currentChartEditPane.fire();
}
}
});
dlg.setVisible(true);
}
});
return pane;
}
/**
* 注册 切换事件的改变 和超链不同.
* @param listener
*/
public void registerChartEditPane(ChartEditPane currentChartEditPane) {
this.currentChartEditPane = currentChartEditPane;
}
public void populateBean(ChartCollection c) {
this.editingChartCollection = c;
}
public void updateBean(ChartCollection c) {
}
/**
* 界面标题
* @param 返回标题
*/
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Switch_Chart");
}
@Override
public String getIconPath() {
return null;
}
}

6
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractBarPane.java

@ -9,9 +9,9 @@ import com.fr.chart.chartattr.Chart;
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2012-12-25 下午04:55:05
*/
public abstract class AbstractBarPane extends AbstractChartTypePane {
protected static final int COLOMN_CHART = 0;
public abstract class AbstractBarPane extends AbstractDeprecatedChartTypePane {
protected static final int COLOMN_CHART = 0;
protected static final int STACK_COLOMN_CHART = 1;
protected static final int PERCENT_STACK_COLOMN_CHART = 2;
protected static final int THREE_D_COLOMN_CHART = 3;

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

@ -1,22 +1,11 @@
package com.fr.design.mainframe.chart.gui.type;
import com.fr.base.ChartColorMatching;
import com.fr.base.ChartPreStyleConfig;
import com.fr.base.background.ColorBackground;
import com.fr.chart.base.AttrContents;
import com.fr.chart.base.AttrFillStyle;
import com.fr.chart.base.ChartConstants;
import com.fr.chart.base.ChartUtils;
import com.fr.chart.base.DataSeriesCondition;
import com.fr.chart.base.TextAttr;
import com.fr.chart.chartattr.Axis;
import com.fr.chart.chartattr.CategoryPlot;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Legend;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartattr.Title;
import com.fr.chart.chartglyph.ConditionAttr;
import com.fr.chart.charttypes.BarIndependentChart;
import com.fr.chartx.attr.ChartProvider;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.chart.series.PlotStyle.ChartSelectDemoPane;
import com.fr.design.gui.ilable.BoldFontTextLabel;
@ -24,9 +13,6 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont;
import com.fr.js.NameJavaScriptGroup;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants;
import javax.swing.JPanel;
@ -34,12 +20,11 @@ import javax.swing.JSeparator;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.util.ArrayList;
import java.util.List;
public abstract class AbstractChartTypePane extends FurtherBasicBeanPane<Chart>{
public abstract class AbstractChartTypePane<T extends ChartProvider> extends FurtherBasicBeanPane<T> {
private static final int ONE_LINE_NUM = 4;
@ -162,50 +147,6 @@ public abstract class AbstractChartTypePane extends FurtherBasicBeanPane<Chart>{
}
}
}
/**
* 更新界面属性
*/
public void populateBean(Chart chart) {
for(ChartImagePane imagePane : typeDemo) {
imagePane.isPressing = false;
}
for(ChartImagePane imagePane : styleList) {
imagePane.isPressing = false;
}
if(styleList != null && !styleList.isEmpty()){
int plotStyle = chart.getPlot().getPlotStyle();
String styleName = chart.getPlot().getPlotFillStyle().getFillStyleName();
switch (plotStyle){
case ChartConstants.STYLE_SHADE: if(ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Retro"), styleName)){
styleList.get(STYLE_SHADE).isPressing = true;
lastStyleIndex = STYLE_SHADE;
}
break;
case ChartConstants.STYLE_TRANSPARENT:if(ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Fresh"), styleName)){
styleList.get(STYLE_TRANSPARENT).isPressing = true;
lastStyleIndex = STYLE_TRANSPARENT;
}
break;
case ChartConstants.STYLE_3D: if(ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"), styleName)){
styleList.get(STYLE_PLANE3D).isPressing = true;
lastStyleIndex = STYLE_PLANE3D;
}
break;
case ChartConstants.STYLE_OUTER:if(ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"), styleName)){
styleList.get(STYLE_HIGHLIGHT).isPressing = true;
lastStyleIndex = STYLE_HIGHLIGHT;
}
break;
default:
lastStyleIndex = -1;
break;
}
stylePane.setVisible(!(chart.getPlot().isSupport3D()));
this.repaint();
}
}
protected void checkDemosBackground() {
if(this.styleList != null && !styleList.isEmpty()){
@ -221,119 +162,10 @@ public abstract class AbstractChartTypePane extends FurtherBasicBeanPane<Chart>{
}
}
private void setPlotFillStyle(Chart chart){
ChartPreStyleConfig manager = ChartPreStyleConfig.getInstance();
Plot plot = chart.getPlot();
Object preStyle = null;
String name = "";
if(styleList.get(STYLE_SHADE).isPressing){
name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Retro");
preStyle = manager.getPreStyle(name);
}else if(styleList.get(STYLE_TRANSPARENT).isPressing){
name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Fresh");
preStyle = manager.getPreStyle(name);
}else if(styleList.get(STYLE_PLANE3D).isPressing){
name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright");
preStyle = manager.getPreStyle(name);
}else if(styleList.get(STYLE_HIGHLIGHT).isPressing){
name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright");
preStyle = manager.getPreStyle(name);
}
if(preStyle == null){
plot.getPlotFillStyle().setColorStyle(ChartConstants.COLOR_DEFAULT);
}else{
AttrFillStyle fillStyle = ChartUtils.chartColorMatching2AttrFillStyle((ChartColorMatching) preStyle);
fillStyle.setFillStyleName(name);
plot.setPlotFillStyle(fillStyle);
}
}
/**
* 保存风格,对选中的风格做设置
*/
public void updateBean(Chart chart) {
Plot oldPlot = chart.getPlot();
Plot newPlot = this.setSelectedClonedPlotWithCondition(oldPlot);
checkTypeChange(oldPlot);//判断图表的类型是否发生变化
if(styleList != null && !styleList.isEmpty()){
if(styleList.get(STYLE_SHADE).isPressing && lastStyleIndex != STYLE_SHADE){
lastStyleIndex = STYLE_SHADE;
chart.setPlot(newPlot);
chart.getPlot().setPlotStyle(ChartConstants.STYLE_SHADE);
resetChart(chart);
createCondition4Shade(chart);
setPlotFillStyle(chart);
}else if(styleList.get(STYLE_TRANSPARENT).isPressing && lastStyleIndex != STYLE_TRANSPARENT){
lastStyleIndex = STYLE_TRANSPARENT;
chart.setPlot(newPlot);
chart.getPlot().setPlotStyle(ChartConstants.STYLE_TRANSPARENT);
resetChart(chart);
createCondition4Transparent(chart);
setPlotFillStyle(chart);
}else if(styleList.get(STYLE_PLANE3D).isPressing && lastStyleIndex != STYLE_PLANE3D){
lastStyleIndex = STYLE_PLANE3D;
chart.setPlot(newPlot);
chart.getPlot().setPlotStyle(ChartConstants.STYLE_3D);
resetChart(chart);
createCondition4Plane3D(chart);
setPlotFillStyle(chart);
}else if(styleList.get(STYLE_HIGHLIGHT).isPressing && lastStyleIndex != STYLE_HIGHLIGHT){
lastStyleIndex = STYLE_HIGHLIGHT;
chart.setPlot(newPlot);
chart.getPlot().setPlotStyle(ChartConstants.STYLE_OUTER);
resetChart(chart);
createCondition4HighLight(chart);
setPlotFillStyle(chart);
}else if(lastStyleIndex >= STYLE_SHADE && lastStyleIndex <= STYLE_HIGHLIGHT){
if(styleList.get(lastStyleIndex).isDoubleClicked || typeChanged){
chart.setPlot(newPlot);
resetChart(chart);
styleList.get(lastStyleIndex).isPressing = false;
checkDemosBackground();
lastStyleIndex = -1;
}
}
stylePane.setVisible(!(chart.getPlot().isSupport3D()));
this.repaint();
}
}
private Plot setSelectedClonedPlotWithCondition(Plot oldPlot){
Plot newPlot = getSelectedClonedPlot();
if(oldPlot != null && ComparatorUtils.equals(newPlot.getClass(), oldPlot.getClass())){
if(oldPlot.getHotHyperLink() != null){
NameJavaScriptGroup hotHyper = oldPlot.getHotHyperLink();
try {
newPlot.setHotHyperLink((NameJavaScriptGroup)hotHyper.clone());
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error in Hyperlink, Please Check it.", e);
}
}
newPlot.setConditionCollection(oldPlot.getConditionCollection());
newPlot.setSeriesDragEnable(oldPlot.isSeriesDragEnable());
if(newPlot.isSupportZoomCategoryAxis() && newPlot.getxAxis() != null) {
newPlot.getxAxis().setZoom(oldPlot.getxAxis().isZoom());
}
if(newPlot.isSupportTooltipInInteractivePane()) {
newPlot.setHotTooltipStyle(oldPlot.getHotTooltipStyle());
}
if(newPlot.isSupportAutoRefresh()) {
newPlot.setAutoRefreshPerSecond(oldPlot.getAutoRefreshPerSecond());
}
if (newPlot.isSupportAxisTip()) {
newPlot.setInteractiveAxisTooltip(oldPlot.isInteractiveAxisTooltip());
}
}
return newPlot;
}
/**
* 更新整个新的Chart类型
*/
public Chart updateBean() {
public T updateBean() {
return null;
}
@ -345,14 +177,6 @@ public abstract class AbstractChartTypePane extends FurtherBasicBeanPane<Chart>{
chart.setBackground(null);
}
protected void changePlotWithClone(Chart chart, Plot plot) {
try {
chart.switchPlot((Plot)plot.clone());
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error in change plot");
}
}
/**
* 重置
*/
@ -393,219 +217,6 @@ public abstract class AbstractChartTypePane extends FurtherBasicBeanPane<Chart>{
return false;
}
//高光渐变的默认属性设置
private void createCondition4HighLight(Chart chart){
if(chart != null){
//标题
Title title = new Title(chart.getTitle().getTextObject());
chart.setTitle(title);
title.setTitleVisible(true);
TextAttr textAttr = title.getTextAttr();
if (textAttr == null) {
textAttr = new TextAttr();
title.setTextAttr(textAttr);
}
title.setPosition(Constants.LEFT);
textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(51, 51, 51)));
//图例
Legend legend = new Legend();
legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(138,140,139)));
legend.setPosition(Constants.RIGHT_TOP);
chart.getPlot().setLegend(legend);
//分类轴,现在只有柱形图,条形图,面积图
if(chart.getPlot() instanceof CategoryPlot){
CategoryPlot plot = (CategoryPlot)chart.getPlot();
//分类轴设置
Axis cateAxis = plot.getxAxis();
cateAxis.setAxisStyle(Constants.LINE_THICK);
cateAxis.setAxisColor(new Color(204, 220, 228));
cateAxis.setTickMarkType(Constants.TICK_MARK_INSIDE);
cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE);
cateAxis.setShowAxisLabel(true);
cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(138,140,139)));
//值轴
Axis valueAxis = plot.getyAxis();
valueAxis.setAxisStyle(Constants.NONE);
valueAxis.setAxisColor(null);
valueAxis.setTickMarkType(Constants.TICK_MARK_INSIDE);
valueAxis.setSecTickMarkType(Constants.TICK_MARK_NONE);
valueAxis.setShowAxisLabel(true);
valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(138,140,139)));
//绘图区
plot.setBorderStyle(Constants.LINE_THIN);
plot.setBorderColor(new Color(204, 220, 228));
plot.setBackground(ColorBackground.getInstance(new Color(248, 247, 245)));
plot.getyAxis().setMainGridStyle(Constants.LINE_THIN);
plot.getyAxis().setMainGridColor(new Color(192,192,192));
}
}
}
//平面3D的默认属性设置
private void createCondition4Plane3D(Chart chart){
if(chart != null){
//标题
Title title = new Title(chart.getTitle().getTextObject());
chart.setTitle(title);
title.setTitleVisible(true);
TextAttr textAttr = title.getTextAttr();
if (textAttr == null) {
textAttr = new TextAttr();
title.setTextAttr(textAttr);
}
title.setPosition(Constants.CENTER);
textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 16f, new Color(51,51,51)));
//图例
Legend legend = new Legend();
legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(128,128,128)));
legend.setPosition(Constants.TOP);
chart.getPlot().setLegend(legend);
//分类轴,现在只有柱形图,条形图,面积图
if(chart.getPlot() instanceof CategoryPlot){
CategoryPlot plot = (CategoryPlot)chart.getPlot();
//分类轴设置
Axis cateAxis = plot.getxAxis();
cateAxis.setAxisStyle(Constants.LINE_THICK);
cateAxis.setAxisColor(new Color(57, 57, 57));
cateAxis.setTickMarkType(Constants.TICK_MARK_NONE);
cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE);
cateAxis.setShowAxisLabel(true);
cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(57,57,57)));
//值轴设置
Axis valueAxis = plot.getyAxis();
valueAxis.setAxisStyle(Constants.LINE_NONE);
valueAxis.setTickMarkType(Constants.TICK_MARK_NONE);
valueAxis.setSecTickMarkType(Constants.TICK_MARK_NONE);
valueAxis.setShowAxisLabel(false);
//绘图区
plot.getyAxis().setMainGridStyle(Constants.LINE_THIN);
plot.getyAxis().setMainGridColor(new Color(192,192,192));
chart.setBorderStyle(Constants.LINE_NONE);
//数据标签
ConditionAttr attrList = plot.getConditionCollection().getDefaultAttr();
DataSeriesCondition attr = attrList.getExisted(AttrContents.class);
if(attr != null) {
attrList.remove(attr);
}
AttrContents attrContents = new AttrContents();
attrContents.setPosition(Constants.OUTSIDE);
attrContents.setSeriesLabel(ChartConstants.VALUE_PARA);
attrContents.setTextAttr(new TextAttr(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(51,51,51))));
attrList.addDataSeriesCondition(attrContents);
}
}
}
//透明风格的默认属性设置
private void createCondition4Transparent(Chart chart){
if(chart != null){
//标题
Title title = new Title(chart.getTitle().getTextObject());
chart.setTitle(title);
title.setTitleVisible(true);
TextAttr textAttr = title.getTextAttr();
if (textAttr == null) {
textAttr = new TextAttr();
title.setTextAttr(textAttr);
}
title.setPosition(Constants.LEFT);
textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(192,192,192)));
//图例
Legend legend = new Legend();
legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(138,140,139)));
legend.setPosition(Constants.RIGHT_TOP);
chart.getPlot().setLegend(legend);
Plot plot = chart.getPlot();
//绘图区
chart.setBackground(ColorBackground.getInstance(new Color(51,51,51)));
//分类轴,现在只有柱形图,条形图,面积图
if(plot instanceof CategoryPlot){
//边框
plot.setBorderStyle(Constants.LINE_THIN);
plot.setBorderColor(new Color(65,65,65));
//分类轴设置
Axis cateAxis = plot.getxAxis();
cateAxis.setAxisStyle(Constants.LINE_THICK);
cateAxis.setAxisColor(new Color(192,192,192));
cateAxis.setTickMarkType(Constants.TICK_MARK_NONE);
cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE);
cateAxis.setShowAxisLabel(true);
cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(150,150,150)));
//值轴
Axis valueAxis = plot.getyAxis();
valueAxis.setShowAxisLabel(true);
valueAxis.setAxisStyle(Constants.LINE_NONE);
valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(150,150,150)));
valueAxis.setMainGridStyle(Constants.LINE_THIN);
valueAxis.setMainGridColor(new Color(63, 62, 62));
}
}
}
//渐变的默认属性设置
private void createCondition4Shade(Chart chart){
if(chart != null){
//标题
Title title = new Title(chart.getTitle().getTextObject());
chart.setTitle(title);
title.setTitleVisible(true);
TextAttr textAttr = title.getTextAttr();
if (textAttr == null) {
textAttr = new TextAttr();
title.setTextAttr(textAttr);
}
title.setPosition(Constants.CENTER);
textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(0,51,102)));
//图例
Legend legend = new Legend();
legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(128,128,128)));
legend.setPosition(Constants.BOTTOM);
chart.getPlot().setLegend(legend);
//分类轴,现在只有柱形图,条形图,面积图
if(chart.getPlot() instanceof CategoryPlot){
CategoryPlot plot = (CategoryPlot)chart.getPlot();
//分类轴设置
Axis cateAxis = plot.getxAxis();
cateAxis.setAxisStyle(Constants.LINE_THICK);
cateAxis.setAxisColor(new Color(73, 100, 117));
cateAxis.setTickMarkType(Constants.TICK_MARK_NONE);
cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE);
cateAxis.setShowAxisLabel(true);
cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(128,128,128)));
//值轴
Axis valueAxis = plot.getyAxis();
valueAxis.setShowAxisLabel(true);
valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(128,128,128)));
valueAxis.setAxisStyle(Constants.LINE_NONE);
//绘图区
plot.getyAxis().setMainGridStyle(Constants.LINE_THIN);
plot.getyAxis().setMainGridColor(new Color(192,192,192));
plot.setHorizontalIntervalBackgroundColor(new Color(243,243,243));
}
}
}
protected boolean needsResetChart(Chart chart){
return chart != null
&&chart.getPlot() != null
@ -616,7 +227,7 @@ public abstract class AbstractChartTypePane extends FurtherBasicBeanPane<Chart>{
return typePane;
}
public Chart getDefaultChart() {
public ChartProvider getDefaultChart() {
return BarIndependentChart.barChartTypes[0];
}
}

409
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractDeprecatedChartTypePane.java

@ -0,0 +1,409 @@
package com.fr.design.mainframe.chart.gui.type;
import com.fr.base.ChartColorMatching;
import com.fr.base.ChartPreStyleConfig;
import com.fr.base.background.ColorBackground;
import com.fr.chart.base.AttrContents;
import com.fr.chart.base.AttrFillStyle;
import com.fr.chart.base.ChartConstants;
import com.fr.chart.base.ChartUtils;
import com.fr.chart.base.DataSeriesCondition;
import com.fr.chart.base.TextAttr;
import com.fr.chart.chartattr.Axis;
import com.fr.chart.chartattr.CategoryPlot;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Legend;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartattr.Title;
import com.fr.chart.chartglyph.ConditionAttr;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont;
import com.fr.js.NameJavaScriptGroup;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants;
import java.awt.Color;
import java.awt.Font;
/**
* Created by shine on 2019/7/1.
*/
public abstract class AbstractDeprecatedChartTypePane extends AbstractChartTypePane<Chart> {
protected void changePlotWithClone(Chart chart, Plot plot) {
try {
chart.switchPlot((Plot) plot.clone());
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error in change plot");
}
}
/**
* 更新界面属性
*/
public void populateBean(Chart chart) {
for (ChartImagePane imagePane : typeDemo) {
imagePane.isPressing = false;
}
for (ChartImagePane imagePane : styleList) {
imagePane.isPressing = false;
}
if (styleList != null && !styleList.isEmpty()) {
int plotStyle = chart.getPlot().getPlotStyle();
String styleName = chart.getPlot().getPlotFillStyle().getFillStyleName();
switch (plotStyle) {
case ChartConstants.STYLE_SHADE:
if (ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Retro"), styleName)) {
styleList.get(STYLE_SHADE).isPressing = true;
lastStyleIndex = STYLE_SHADE;
}
break;
case ChartConstants.STYLE_TRANSPARENT:
if (ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Fresh"), styleName)) {
styleList.get(STYLE_TRANSPARENT).isPressing = true;
lastStyleIndex = STYLE_TRANSPARENT;
}
break;
case ChartConstants.STYLE_3D:
if (ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"), styleName)) {
styleList.get(STYLE_PLANE3D).isPressing = true;
lastStyleIndex = STYLE_PLANE3D;
}
break;
case ChartConstants.STYLE_OUTER:
if (ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"), styleName)) {
styleList.get(STYLE_HIGHLIGHT).isPressing = true;
lastStyleIndex = STYLE_HIGHLIGHT;
}
break;
default:
lastStyleIndex = -1;
break;
}
stylePane.setVisible(!(chart.getPlot().isSupport3D()));
this.repaint();
}
}
public void updateBean(Chart chart) {
Plot oldPlot = chart.getPlot();
Plot newPlot = this.setSelectedClonedPlotWithCondition(oldPlot);
checkTypeChange(oldPlot);//判断图表的类型是否发生变化
if (styleList != null && !styleList.isEmpty()) {
if (styleList.get(STYLE_SHADE).isPressing && lastStyleIndex != STYLE_SHADE) {
lastStyleIndex = STYLE_SHADE;
chart.setPlot(newPlot);
chart.getPlot().setPlotStyle(ChartConstants.STYLE_SHADE);
resetChart(chart);
createCondition4Shade(chart);
setPlotFillStyle(chart);
} else if (styleList.get(STYLE_TRANSPARENT).isPressing && lastStyleIndex != STYLE_TRANSPARENT) {
lastStyleIndex = STYLE_TRANSPARENT;
chart.setPlot(newPlot);
chart.getPlot().setPlotStyle(ChartConstants.STYLE_TRANSPARENT);
resetChart(chart);
createCondition4Transparent(chart);
setPlotFillStyle(chart);
} else if (styleList.get(STYLE_PLANE3D).isPressing && lastStyleIndex != STYLE_PLANE3D) {
lastStyleIndex = STYLE_PLANE3D;
chart.setPlot(newPlot);
chart.getPlot().setPlotStyle(ChartConstants.STYLE_3D);
resetChart(chart);
createCondition4Plane3D(chart);
setPlotFillStyle(chart);
} else if (styleList.get(STYLE_HIGHLIGHT).isPressing && lastStyleIndex != STYLE_HIGHLIGHT) {
lastStyleIndex = STYLE_HIGHLIGHT;
chart.setPlot(newPlot);
chart.getPlot().setPlotStyle(ChartConstants.STYLE_OUTER);
resetChart(chart);
createCondition4HighLight(chart);
setPlotFillStyle(chart);
} else if (lastStyleIndex >= STYLE_SHADE && lastStyleIndex <= STYLE_HIGHLIGHT) {
if (styleList.get(lastStyleIndex).isDoubleClicked || typeChanged) {
chart.setPlot(newPlot);
resetChart(chart);
styleList.get(lastStyleIndex).isPressing = false;
checkDemosBackground();
lastStyleIndex = -1;
}
}
stylePane.setVisible(!(chart.getPlot().isSupport3D()));
this.repaint();
}
}
private Plot setSelectedClonedPlotWithCondition(Plot oldPlot) {
Plot newPlot = getSelectedClonedPlot();
if (oldPlot != null && ComparatorUtils.equals(newPlot.getClass(), oldPlot.getClass())) {
if (oldPlot.getHotHyperLink() != null) {
NameJavaScriptGroup hotHyper = oldPlot.getHotHyperLink();
try {
newPlot.setHotHyperLink((NameJavaScriptGroup) hotHyper.clone());
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error in Hyperlink, Please Check it.", e);
}
}
newPlot.setConditionCollection(oldPlot.getConditionCollection());
newPlot.setSeriesDragEnable(oldPlot.isSeriesDragEnable());
if (newPlot.isSupportZoomCategoryAxis() && newPlot.getxAxis() != null) {
newPlot.getxAxis().setZoom(oldPlot.getxAxis().isZoom());
}
if (newPlot.isSupportTooltipInInteractivePane()) {
newPlot.setHotTooltipStyle(oldPlot.getHotTooltipStyle());
}
if (newPlot.isSupportAutoRefresh()) {
newPlot.setAutoRefreshPerSecond(oldPlot.getAutoRefreshPerSecond());
}
if (newPlot.isSupportAxisTip()) {
newPlot.setInteractiveAxisTooltip(oldPlot.isInteractiveAxisTooltip());
}
}
return newPlot;
}
//平面3D的默认属性设置
private void createCondition4Plane3D(Chart chart) {
if (chart != null) {
//标题
Title title = new Title(chart.getTitle().getTextObject());
chart.setTitle(title);
title.setTitleVisible(true);
TextAttr textAttr = title.getTextAttr();
if (textAttr == null) {
textAttr = new TextAttr();
title.setTextAttr(textAttr);
}
title.setPosition(Constants.CENTER);
textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 16f, new Color(51, 51, 51)));
//图例
Legend legend = new Legend();
legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(128, 128, 128)));
legend.setPosition(Constants.TOP);
chart.getPlot().setLegend(legend);
//分类轴,现在只有柱形图,条形图,面积图
if (chart.getPlot() instanceof CategoryPlot) {
CategoryPlot plot = (CategoryPlot) chart.getPlot();
//分类轴设置
Axis cateAxis = plot.getxAxis();
cateAxis.setAxisStyle(Constants.LINE_THICK);
cateAxis.setAxisColor(new Color(57, 57, 57));
cateAxis.setTickMarkType(Constants.TICK_MARK_NONE);
cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE);
cateAxis.setShowAxisLabel(true);
cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(57, 57, 57)));
//值轴设置
Axis valueAxis = plot.getyAxis();
valueAxis.setAxisStyle(Constants.LINE_NONE);
valueAxis.setTickMarkType(Constants.TICK_MARK_NONE);
valueAxis.setSecTickMarkType(Constants.TICK_MARK_NONE);
valueAxis.setShowAxisLabel(false);
//绘图区
plot.getyAxis().setMainGridStyle(Constants.LINE_THIN);
plot.getyAxis().setMainGridColor(new Color(192, 192, 192));
chart.setBorderStyle(Constants.LINE_NONE);
//数据标签
ConditionAttr attrList = plot.getConditionCollection().getDefaultAttr();
DataSeriesCondition attr = attrList.getExisted(AttrContents.class);
if (attr != null) {
attrList.remove(attr);
}
AttrContents attrContents = new AttrContents();
attrContents.setPosition(Constants.OUTSIDE);
attrContents.setSeriesLabel(ChartConstants.VALUE_PARA);
attrContents.setTextAttr(new TextAttr(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(51, 51, 51))));
attrList.addDataSeriesCondition(attrContents);
}
}
}
//透明风格的默认属性设置
private void createCondition4Transparent(Chart chart) {
if (chart != null) {
//标题
Title title = new Title(chart.getTitle().getTextObject());
chart.setTitle(title);
title.setTitleVisible(true);
TextAttr textAttr = title.getTextAttr();
if (textAttr == null) {
textAttr = new TextAttr();
title.setTextAttr(textAttr);
}
title.setPosition(Constants.LEFT);
textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(192, 192, 192)));
//图例
Legend legend = new Legend();
legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(138, 140, 139)));
legend.setPosition(Constants.RIGHT_TOP);
chart.getPlot().setLegend(legend);
Plot plot = chart.getPlot();
//绘图区
chart.setBackground(ColorBackground.getInstance(new Color(51, 51, 51)));
//分类轴,现在只有柱形图,条形图,面积图
if (plot instanceof CategoryPlot) {
//边框
plot.setBorderStyle(Constants.LINE_THIN);
plot.setBorderColor(new Color(65, 65, 65));
//分类轴设置
Axis cateAxis = plot.getxAxis();
cateAxis.setAxisStyle(Constants.LINE_THICK);
cateAxis.setAxisColor(new Color(192, 192, 192));
cateAxis.setTickMarkType(Constants.TICK_MARK_NONE);
cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE);
cateAxis.setShowAxisLabel(true);
cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(150, 150, 150)));
//值轴
Axis valueAxis = plot.getyAxis();
valueAxis.setShowAxisLabel(true);
valueAxis.setAxisStyle(Constants.LINE_NONE);
valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(150, 150, 150)));
valueAxis.setMainGridStyle(Constants.LINE_THIN);
valueAxis.setMainGridColor(new Color(63, 62, 62));
}
}
}
//渐变的默认属性设置
private void createCondition4Shade(Chart chart) {
if (chart != null) {
//标题
Title title = new Title(chart.getTitle().getTextObject());
chart.setTitle(title);
title.setTitleVisible(true);
TextAttr textAttr = title.getTextAttr();
if (textAttr == null) {
textAttr = new TextAttr();
title.setTextAttr(textAttr);
}
title.setPosition(Constants.CENTER);
textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(0, 51, 102)));
//图例
Legend legend = new Legend();
legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(128, 128, 128)));
legend.setPosition(Constants.BOTTOM);
chart.getPlot().setLegend(legend);
//分类轴,现在只有柱形图,条形图,面积图
if (chart.getPlot() instanceof CategoryPlot) {
CategoryPlot plot = (CategoryPlot) chart.getPlot();
//分类轴设置
Axis cateAxis = plot.getxAxis();
cateAxis.setAxisStyle(Constants.LINE_THICK);
cateAxis.setAxisColor(new Color(73, 100, 117));
cateAxis.setTickMarkType(Constants.TICK_MARK_NONE);
cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE);
cateAxis.setShowAxisLabel(true);
cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(128, 128, 128)));
//值轴
Axis valueAxis = plot.getyAxis();
valueAxis.setShowAxisLabel(true);
valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(128, 128, 128)));
valueAxis.setAxisStyle(Constants.LINE_NONE);
//绘图区
plot.getyAxis().setMainGridStyle(Constants.LINE_THIN);
plot.getyAxis().setMainGridColor(new Color(192, 192, 192));
plot.setHorizontalIntervalBackgroundColor(new Color(243, 243, 243));
}
}
}
//高光渐变的默认属性设置
private void createCondition4HighLight(Chart chart) {
if (chart != null) {
//标题
Title title = new Title(chart.getTitle().getTextObject());
chart.setTitle(title);
title.setTitleVisible(true);
TextAttr textAttr = title.getTextAttr();
if (textAttr == null) {
textAttr = new TextAttr();
title.setTextAttr(textAttr);
}
title.setPosition(Constants.LEFT);
textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(51, 51, 51)));
//图例
Legend legend = new Legend();
legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(138, 140, 139)));
legend.setPosition(Constants.RIGHT_TOP);
chart.getPlot().setLegend(legend);
//分类轴,现在只有柱形图,条形图,面积图
if (chart.getPlot() instanceof CategoryPlot) {
CategoryPlot plot = (CategoryPlot) chart.getPlot();
//分类轴设置
Axis cateAxis = plot.getxAxis();
cateAxis.setAxisStyle(Constants.LINE_THICK);
cateAxis.setAxisColor(new Color(204, 220, 228));
cateAxis.setTickMarkType(Constants.TICK_MARK_INSIDE);
cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE);
cateAxis.setShowAxisLabel(true);
cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(138, 140, 139)));
//值轴
Axis valueAxis = plot.getyAxis();
valueAxis.setAxisStyle(Constants.NONE);
valueAxis.setAxisColor(null);
valueAxis.setTickMarkType(Constants.TICK_MARK_INSIDE);
valueAxis.setSecTickMarkType(Constants.TICK_MARK_NONE);
valueAxis.setShowAxisLabel(true);
valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(138, 140, 139)));
//绘图区
plot.setBorderStyle(Constants.LINE_THIN);
plot.setBorderColor(new Color(204, 220, 228));
plot.setBackground(ColorBackground.getInstance(new Color(248, 247, 245)));
plot.getyAxis().setMainGridStyle(Constants.LINE_THIN);
plot.getyAxis().setMainGridColor(new Color(192, 192, 192));
}
}
}
private void setPlotFillStyle(Chart chart) {
ChartPreStyleConfig manager = ChartPreStyleConfig.getInstance();
Plot plot = chart.getPlot();
Object preStyle = null;
String name = "";
if (styleList.get(STYLE_SHADE).isPressing) {
name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Retro");
preStyle = manager.getPreStyle(name);
} else if (styleList.get(STYLE_TRANSPARENT).isPressing) {
name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Fresh");
preStyle = manager.getPreStyle(name);
} else if (styleList.get(STYLE_PLANE3D).isPressing) {
name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright");
preStyle = manager.getPreStyle(name);
} else if (styleList.get(STYLE_HIGHLIGHT).isPressing) {
name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright");
preStyle = manager.getPreStyle(name);
}
if (preStyle == null) {
plot.getPlotFillStyle().setColorStyle(ChartConstants.COLOR_DEFAULT);
} else {
AttrFillStyle fillStyle = ChartUtils.chartColorMatching2AttrFillStyle((ChartColorMatching) preStyle);
fillStyle.setFillStyleName(name);
plot.setPlotFillStyle(fillStyle);
}
}
}

2
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AreaPlotPane.java

@ -17,7 +17,7 @@ import com.fr.locale.InterProviderFactory;
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2012-12-25 下午06:57:36
*/
public class AreaPlotPane extends AbstractChartTypePane{
public class AreaPlotPane extends AbstractDeprecatedChartTypePane {
private static final int STACK_AREA_CHART = 0;
private static final int PERCENT_AREA_LINE_CHART = 1;

4
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/BubblePlotPane.java

@ -13,8 +13,8 @@ import com.fr.locale.InterProviderFactory;
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2012-12-25 下午06:56:47
*/
public class BubblePlotPane extends AbstractChartTypePane {
private static final long serialVersionUID = -601566194238908115L;
public class BubblePlotPane extends AbstractDeprecatedChartTypePane {
private static final long serialVersionUID = -601566194238908115L;
private static final int BUBBLE_CHART = 0;

2
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/CustomPlotPane.java

@ -11,7 +11,7 @@ import com.fr.locale.InterProviderFactory;
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2012-12-21 下午06:17:40
*/
public class CustomPlotPane extends AbstractChartTypePane {
public class CustomPlotPane extends AbstractDeprecatedChartTypePane {
@Override
protected String getPlotTypeID() {

8
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/DonutPlotPane.java

@ -22,10 +22,10 @@ import java.text.DecimalFormat;
* @author eason
*
*/
public class DonutPlotPane extends AbstractChartTypePane{
private static final long serialVersionUID = -7084314809934346710L;
private static final int DONUT_CHART = 0; //2d圆环图
private static final int THREE_D_DONUT_CHART = 1; //3D圆环图
public class DonutPlotPane extends AbstractDeprecatedChartTypePane {
private static final long serialVersionUID = -7084314809934346710L;
private static final int DONUT_CHART = 0; //2d圆环图
private static final int THREE_D_DONUT_CHART = 1; //3D圆环图
@Override
protected String[] getTypeIconPath() {

2
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/FunnelPlotPane.java

@ -18,7 +18,7 @@ import java.text.DecimalFormat;
* Time: 下午2:50
* To change this template use File | Settings | File Templates.
*/
public class FunnelPlotPane extends AbstractChartTypePane{
public class FunnelPlotPane extends AbstractDeprecatedChartTypePane {
private static final int FUNNEL_CHART = 0;

2
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GanttPlotPane.java

@ -11,7 +11,7 @@ import com.fr.locale.InterProviderFactory;
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2012-12-26 上午10:38:18
*/
public class GanttPlotPane extends AbstractChartTypePane{
public class GanttPlotPane extends AbstractDeprecatedChartTypePane {
private static final long serialVersionUID = -601566194238908115L;
private static final int GANTT = 0;

6
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GisMapPlotPane.java

@ -19,10 +19,10 @@ import java.awt.BorderLayout;
import java.awt.Component;
public class GisMapPlotPane extends AbstractChartTypePane{
public class GisMapPlotPane extends AbstractDeprecatedChartTypePane {
private static final long serialVersionUID = 2595221900000305396L;
private static final int GISMAP = 0;
private UITextField keyInput;

2
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/LinePlotPane.java

@ -9,7 +9,7 @@ import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory;
public class LinePlotPane extends AbstractChartTypePane{
public class LinePlotPane extends AbstractDeprecatedChartTypePane {
private static final int LINE_CHART = 0;

2
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MapPlotPane.java

@ -16,7 +16,7 @@ import com.fr.log.FineLoggerFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
public class MapPlotPane extends AbstractChartTypePane {
public class MapPlotPane extends AbstractDeprecatedChartTypePane {
private boolean isSvgMap = true; // 默认是svg地图

6
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MeterPlotPane.java

@ -16,9 +16,9 @@ import com.fr.log.FineLoggerFactory;
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2012-12-26 上午10:48:57
*/
public class MeterPlotPane extends AbstractChartTypePane {
private static final int METER = 0;
public class MeterPlotPane extends AbstractDeprecatedChartTypePane {
private static final int METER = 0;
private static final int BLUE_METER =1;
private static final int SIMPLE_METER = 2;

4
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/PiePlotPane.java

@ -21,8 +21,8 @@ import java.text.DecimalFormat;
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2012-12-25 下午06:55:33
*/
public class PiePlotPane extends AbstractChartTypePane{
private static final long serialVersionUID = -601566194238908115L;
public class PiePlotPane extends AbstractDeprecatedChartTypePane {
private static final long serialVersionUID = -601566194238908115L;
private static final int PIE_CHART = 0;
private static final int THREE_D_PIE_CHART = 1;

2
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/RadarPlotPane.java

@ -11,7 +11,7 @@ import com.fr.locale.InterProviderFactory;
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2012-12-26 上午09:55:01
*/
public class RadarPlotPane extends AbstractChartTypePane{
public class RadarPlotPane extends AbstractDeprecatedChartTypePane {
private static final long serialVersionUID = -601566194238908115L;
private static final int RADAR = 0;

2
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/RangePlotPane.java

@ -12,7 +12,7 @@ import com.fr.locale.InterProviderFactory;
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2012-12-26 上午10:43:50
*/
public class RangePlotPane extends AbstractChartTypePane{
public class RangePlotPane extends AbstractDeprecatedChartTypePane {
private static final long serialVersionUID = -601566194238908115L;
private static final int RANGE = 0;

4
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/StockPlotPane.java

@ -11,8 +11,8 @@ import com.fr.locale.InterProviderFactory;
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2012-12-26 上午10:52:36
*/
public class StockPlotPane extends AbstractChartTypePane {
public class StockPlotPane extends AbstractDeprecatedChartTypePane {
private static final int STOCK = 0;

4
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/UserDefinedChartTypePane.java

@ -1,12 +1,14 @@
package com.fr.design.mainframe.chart.gui.type;
import com.fr.chart.chartattr.Chart;
import com.fr.common.annotations.Compatible;
/**
* Created by mengao on 2017/8/30.
* 不能删掉这个类echarts插件中用到
*/
public abstract class UserDefinedChartTypePane extends AbstractChartTypePane {
@Compatible
public abstract class UserDefinedChartTypePane extends AbstractDeprecatedChartTypePane {
protected String[] getTypeLayoutPath() {
return new String[0];
}

2
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/XYScatterPlotPane.java

@ -14,7 +14,7 @@ import com.fr.stable.Constants;
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2012-12-25 下午08:33:55
*/
public class XYScatterPlotPane extends AbstractChartTypePane{
public class XYScatterPlotPane extends AbstractDeprecatedChartTypePane {
private static final long serialVersionUID = -601566194238908115L;
private static final int XYSCATTER_CHART = 0;

13
designer-chart/src/main/java/com/fr/design/module/ChartPreStylePane.java

@ -5,7 +5,6 @@ import com.fr.chart.base.ChartUtils;
import com.fr.chart.chartattr.Bar2DPlot;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.Plot;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.event.UIObserver;
@ -13,7 +12,6 @@ import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.layout.FRGUIPaneFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
@ -30,7 +28,8 @@ public class ChartPreStylePane extends BasicBeanPane<ChartColorMatching> {
private ChartPreFillStylePane fillStylePane;
private ChartComponent chartComponent;
private Bar2DPlot demoPlot;
public ChartPreStylePane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
@ -50,8 +49,9 @@ public class ChartPreStylePane extends BasicBeanPane<ChartColorMatching> {
this.add(boxPane, BorderLayout.CENTER);
ChartCollection cc = new ChartCollection();
cc.addChart(new Chart(new Bar2DPlot()));
demoPlot = new Bar2DPlot();
cc.addChart(new Chart(demoPlot));
chartComponent = new ChartComponent();
chartComponent.populate(cc);
chartComponent.setPreferredSize(new Dimension(400, 300));
@ -82,8 +82,7 @@ public class ChartPreStylePane extends BasicBeanPane<ChartColorMatching> {
private void refreshWhenStyleChange(ChartColorMatching preStyle) {
if(chartComponent != null) {
Plot plot = (Plot) chartComponent.getEditingChart().getBasePlot();
plot.setPlotFillStyle(ChartUtils.chartColorMatching2AttrFillStyle(preStyle));
demoPlot.setPlotFillStyle(ChartUtils.chartColorMatching2AttrFillStyle(preStyle));
chartComponent.reset();
}
}

331
designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java

@ -2,101 +2,34 @@ package com.fr.extended.chart;
import com.fr.base.Utils;
import com.fr.data.util.function.AbstractDataFunction;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.gui.frpane.UICorrelationPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itable.UITable;
import com.fr.design.gui.itable.UITableEditor;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox;
import com.fr.design.chartx.component.AbstractCustomFieldComboBoxPane;
import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper;
import com.fr.stable.StringUtils;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
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;
import java.util.ArrayList;
import java.util.List;
/**
* Created by shine on 2018/9/12.
* Created by shine on 2019/5/16.
*/
public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractDataConfig> {
private static final String[] HEADS = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Field_Name"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Summary_Method")};
private UseFieldValuePane useFieldValuePane;
private CustomFieldNamePane customFieldNamePane;
private List<String> fieldList = new ArrayList<String>();
public class ExtendedCustomFieldComboBoxPane extends AbstractCustomFieldComboBoxPane<AbstractDataConfig> {
@Override
protected void initLayout() {
this.setLayout(new BorderLayout(0, 6));
JPanel northPane = new JPanel(new BorderLayout());
northPane.add(jcb, BorderLayout.CENTER);
UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name_From"));
label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, 20));
northPane.add(label, BorderLayout.WEST);
this.add(northPane, BorderLayout.NORTH);
this.add(cardPane, BorderLayout.CENTER);
protected AbstractUseFieldValuePane createUseFieldValuePane() {
return new ExtendedUseFieldValuePane();
}
@Override
protected List<FurtherBasicBeanPane<? extends AbstractDataConfig>> initPaneList() {
useFieldValuePane = new UseFieldValuePane();
customFieldNamePane = new CustomFieldNamePane();
List<FurtherBasicBeanPane<? extends AbstractDataConfig>> list = new ArrayList<FurtherBasicBeanPane<? extends AbstractDataConfig>>();
list.add(useFieldValuePane);
list.add(customFieldNamePane);
return list;
protected AbstractCustomFieldNamePane createCustomFieldNamePane() {
return new ExtendedCustomFieldNamePane();
}
@Override
protected String title4PopupWindow() {
return StringUtils.EMPTY;
}
protected boolean valueComboBoxHasNone() {
return false;
}
public void checkBoxUse(boolean hasUse) {
jcb.setEnabled(hasUse);
useFieldValuePane.checkBoxUse(hasUse);
}
public void clearAllBoxList() {
useFieldValuePane.clearAllBoxList();
fieldList.clear();
}
protected void refreshBoxListWithSelectTableData(List columnNameList) {
useFieldValuePane.refreshBoxListWithSelectTableData(columnNameList);
fieldList = columnNameList;
}
@Override
public void populateBean(AbstractDataConfig ob) {
if (ob.isCustomName()) {
customFieldNamePane.populateBean(ob);
populateCustomFieldNamePane(ob);
jcb.setSelectedIndex(1);
} else {
useFieldValuePane.populateBean(ob);
populateUseFieldValuePane(ob);
jcb.setSelectedIndex(0);
}
}
@ -105,68 +38,22 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractData
public void updateBean(AbstractDataConfig ob) {
if (jcb.getSelectedIndex() == 0) {
ob.setCustomName(false);
useFieldValuePane.updateBean(ob);
updateUseFieldValuePane(ob);
} else {
ob.setCustomName(true);
customFieldNamePane.updateBean(ob);
updateCustomFieldNamePane(ob);
}
}
private class UseFieldValuePane extends FurtherBasicBeanPane<AbstractDataConfig> {
private UIComboBox series;
private UIComboBox value;
private CalculateComboBox function;
private UseFieldValuePane() {
initComponents();
}
private void initComponents() {
series = new UIComboBox();
value = valueComboBoxHasNone() ? new UIComboBoxWithNone() : new UIComboBox();
function = new CalculateComboBox();
Component[][] components = new Component[][]{
new Component[]{new UILabel(HEADS[1], SwingConstants.LEFT), series},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Value"), SwingConstants.LEFT), value},
new Component[]{new UILabel(HEADS[2], SwingConstants.LEFT), function},
};
double p = TableLayout.PREFERRED;
double[] columnSize = {78, 122};
double[] rowSize = {p, p, p};
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
this.setLayout(new BorderLayout(0, 6));
this.add(panel, BorderLayout.CENTER);
}
public void checkBoxUse(boolean hasUse) {
series.setEnabled(hasUse);
value.setEnabled(hasUse);
function.setEnabled(hasUse);
}
public void clearAllBoxList() {
DataPaneHelper.clearBoxItems(series);
DataPaneHelper.clearBoxItems(value);
}
public void refreshBoxListWithSelectTableData(List columnNameList) {
DataPaneHelper.refreshBoxItems(series, columnNameList);
DataPaneHelper.refreshBoxItems(value, columnNameList);
}
private class ExtendedUseFieldValuePane extends AbstractUseFieldValuePane {
@Override
public void populateBean(AbstractDataConfig ob) {
List<ExtendedField> list = ob.getCustomFields();
if (list.size() == 2) {
series.setSelectedItem(list.get(0).getFieldName());
value.setSelectedItem(list.get(1).getFieldName());
function.populateBean((AbstractDataFunction) list.get(1).getDataFunction());
populateSeries(list.get(0).getFieldName());
populateValue(list.get(1).getFieldName());
populateFunction((AbstractDataFunction) list.get(1).getDataFunction());
}
}
@ -174,90 +61,35 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractData
public void updateBean(AbstractDataConfig ob) {
List<ExtendedField> list = new ArrayList<ExtendedField>();
list.add(new ExtendedField(Utils.objectToString(series.getSelectedItem())));
ExtendedField field = new ExtendedField(Utils.objectToString(value.getSelectedItem()));
field.setDataFunction(function.updateBean());
list.add(new ExtendedField(updateSeries()));
ExtendedField field = new ExtendedField(updateValue());
field.setDataFunction(updateFunction());
list.add(field);
ob.setCustomFields(list);
}
@Override
public boolean accept(Object ob) {
return true;
}
@Override
public void reset() {
}
@Override
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Value");
}
@Override
public AbstractDataConfig updateBean() {
return null;
}
}
private class CustomFieldNamePane extends FurtherBasicBeanPane<AbstractDataConfig> {
private UICorrelationPane correlationPane;
public CustomFieldNamePane() {
initComponents();
}
private void initComponents() {
correlationPane = new UICorrelationPane(HEADS) {
@Override
protected ActionListener getAddButtonListener() {
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
tablePane.addLine(new String[]{StringUtils.EMPTY, StringUtils.EMPTY, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")});
fireTargetChanged();
}
};
}
public UITableEditor createUITableEditor() {
return new Editor() {
@Override
protected UICorrelationPane getParent() {
return correlationPane;
}
};
}
};
this.setLayout(new BorderLayout());
this.add(correlationPane, BorderLayout.CENTER);
}
private class ExtendedCustomFieldNamePane extends AbstractCustomFieldNamePane {
@Override
public void populateBean(AbstractDataConfig ob) {
List<ExtendedField> customFields = ob.getCustomFields();
protected List<Object[]> covertTBeanToTableModelList(AbstractDataConfig dataConfig) {
List<ExtendedField> customFields = dataConfig.getCustomFields();
List<Object[]> list = new ArrayList<Object[]>();
for (ExtendedField field : customFields) {
String[] array = {field.getFieldName(), field.getCustomName(), DataPaneHelper.getFunctionString(field.getDataFunction())};
list.add(array);
}
correlationPane.populateBean(list);
return list;
}
@Override
public void updateBean(AbstractDataConfig ob) {
List<Object[]> list = correlationPane.updateBean();
protected void setTableModelListToTBean(List<Object[]> tableValues, AbstractDataConfig dataConfig) {
List<ExtendedField> customFields = new ArrayList<ExtendedField>();
for (Object[] line : list) {
for (Object[] line : tableValues) {
ExtendedField field = new ExtendedField(Utils.objectToString(line[0]));
field.setCustomName(Utils.objectToString(line[1]));
if (line.length > 2) {
@ -266,122 +98,9 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractData
customFields.add(field);
}
ob.setCustomFields(customFields);
}
@Override
public boolean accept(Object ob) {
return true;
}
@Override
public void reset() {
}
@Override
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Name");
}
@Override
public AbstractDataConfig updateBean() {
return null;
}
}
private abstract class Editor extends UITableEditor {
private JComponent editorComponent;
protected abstract UICorrelationPane getParent();
@Override
public Object getCellEditorValue() {
if (editorComponent instanceof UIComboBox) {
return ((UIComboBox) editorComponent).getSelectedItem();
} else if (editorComponent instanceof UITextField) {
return ((UITextField) editorComponent).getText();
} else if (editorComponent instanceof CalculateComboBox) {
return ((CalculateComboBox) editorComponent).getSelectedItem();
}
return super.getCellEditorValue();
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, final int row, int column) {
switch (column) {
case 0:
editorComponent = createComboBoxEdit(row, value);
break;
case 1:
editorComponent = createTextEdit(value);
break;
default:
editorComponent = createCalculateComboBox(value);
break;
}
return editorComponent;
dataConfig.setCustomFields(customFields);
}
private void setDefaultName(int row) {
UITable table = getParent().getTable();
Object object = table.getValueAt(row, 0);
if (object != null) {
table.setValueAt(object, row, 1);
}
}
private UIComboBox createComboBoxEdit(final int row, Object value) {
UIComboBox uiComboBox = new UIComboBox(fieldList.toArray());
uiComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
getParent().stopCellEditing();
getParent().fireTargetChanged();
setDefaultName(row);
}
});
if (value != null && StringUtils.isNotEmpty(value.toString())) {
uiComboBox.getModel().setSelectedItem(value);
} else {
uiComboBox.getModel().setSelectedItem(value);
}
return uiComboBox;
}
private UITextField createTextEdit(Object value) {
UITextField uiTextField = new UITextField();
if (value != null) {
uiTextField.setText(value.toString());
}
uiTextField.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
getParent().fireTargetChanged();
}
});
return uiTextField;
}
private CalculateComboBox createCalculateComboBox(Object value) {
CalculateComboBox calculateComboBox = new CalculateComboBox();
if (value != null) {
calculateComboBox.setSelectedItem(value);
}
calculateComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
getParent().stopCellEditing();
getParent().fireTargetChanged();
}
});
return calculateComboBox;
}
}
}

10
designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java

@ -1,14 +1,14 @@
package com.fr.extended.chart;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.chartx.attr.ChartProvider;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.design.mainframe.chart.gui.type.ChartImagePane;
/**
* Created by shine on 2018/3/5.
*/
public class ExtendedTypePane<T extends AbstractChart> extends AbstractChartTypePane {
public class ExtendedTypePane<T extends AbstractChart> extends AbstractChartTypePane<AbstractChart> {
@Override
protected String[] getTypeIconPath() {
@ -34,7 +34,7 @@ public class ExtendedTypePane<T extends AbstractChart> extends AbstractChartType
}
@Override
public void populateBean(Chart chart) {
public void populateBean(AbstractChart chart) {
if (getTypeIconPath().length > 0) {
for (ChartImagePane imagePane : typeDemo) {
imagePane.isPressing = false;
@ -46,7 +46,7 @@ public class ExtendedTypePane<T extends AbstractChart> extends AbstractChartType
}
@Override
public void updateBean(Chart chart) {
public void updateBean(AbstractChart chart) {
update((T) chart);
if (getTypeIconPath().length > 0) {
@ -65,7 +65,7 @@ public class ExtendedTypePane<T extends AbstractChart> extends AbstractChartType
}
@Override
public Chart getDefaultChart() {
public ChartProvider getDefaultChart() {
return ChartTypeManager.getInstance().getChartTypes(getPlotID())[0];
}

8
designer-chart/src/main/java/com/fr/van/chart/column/ColumnIndependentVanChartInterface.java

@ -2,7 +2,10 @@ package com.fr.van.chart.column;
import com.fr.chart.chartattr.Plot;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.chartx.MultiCategoryChartDataPane;
import com.fr.design.condition.ConditionAttributesPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.van.chart.vanchart.AbstractMultiCategoryVanChartUI;
@ -33,4 +36,9 @@ public class ColumnIndependentVanChartInterface extends AbstractMultiCategoryVan
public String getPlotTypeTitle4PopupWindow(){
return VanChartColumnPlotPane.TITLE;
}
@Override
public ChartDataPane getChartDataPane(AttributeChangeListener listener) {
return new MultiCategoryChartDataPane(listener);
}
}

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

@ -12,9 +12,8 @@ import com.fr.design.gui.ilable.MultilineLabel;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.design.mainframe.chart.gui.type.ChartImagePane;
import com.fr.general.Background;
import com.fr.log.FineLoggerFactory;
import com.fr.js.NameJavaScriptGroup;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.base.VanChartTools;
import com.fr.plugin.chart.base.VanChartZoom;
@ -25,7 +24,7 @@ import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
public abstract class AbstractVanChartTypePane extends AbstractChartTypePane{
public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Chart> {
private static final long serialVersionUID = 7743244512351499265L;
private UICheckBox largeModelCheckBox;

6
designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java

@ -6,7 +6,6 @@ import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper;
import com.fr.plugin.chart.map.server.ChartGEOJSONHelper;
import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper;
import com.fr.geojson.helper.GEOJSONHelper;
import com.fr.stable.StringUtils;
import javax.swing.JTree;
@ -98,7 +97,8 @@ public class MapDataTree extends JTree {
}
String dirPath = el.getUserObject().toString();
String url = CompatibleGEOJSONHelper.getJsonUrlByPathIncludeParam(dirPath);
if (GEOJSONHelper.getInstance().isValidDirPath(dirPath) && ComparatorUtils.equals(jsonUrl, url)){
//先equals再valid原因:valid 远程下实时去服务器看有没有json文件
if (ComparatorUtils.equals(jsonUrl, url) && GEOJSONTreeHelper.isValidDirPath(dirPath)) {
selectTreeNode(el, m_model);
return el;
}
@ -151,7 +151,7 @@ public class MapDataTree extends JTree {
DefaultMutableTreeNode el = els.nextElement();
String path = el.getUserObject().toString();
String fileName = ChartGEOJSONHelper.getPresentNameWithPath(path);
if (GEOJSONHelper.getInstance().isValidDirPath(path) && StringUtils.contains(fileName, text)) {
if (StringUtils.contains(fileName, text) && GEOJSONTreeHelper.isValidDirPath(path)) {
selectTreeNode(el, m_model);
return;
}

15
designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java

@ -2,14 +2,12 @@ package com.fr.van.chart.multilayer;
import com.fr.chart.chartattr.Plot;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.chartx.MultiPieChartDataPane;
import com.fr.design.condition.ConditionAttributesPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.van.chart.multilayer.data.MultiPiePlotReportDataContentPane;
import com.fr.van.chart.multilayer.data.MultiPiePlotTableDataContentPane;
import com.fr.van.chart.multilayer.other.VanChartMultiPieConditionPane;
import com.fr.van.chart.multilayer.style.VanChartMultiPieSeriesPane;
import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI;
@ -29,13 +27,8 @@ public class MultiPieIndependentVanChartInterface extends AbstractIndependentVan
}
@Override
public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent){
return new MultiPiePlotTableDataContentPane(parent);
}
@Override
public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent){
return new MultiPiePlotReportDataContentPane(parent);
public ChartDataPane getChartDataPane(AttributeChangeListener listener) {
return new MultiPieChartDataPane(listener);
}
public BasicBeanPane<Plot> getPlotSeriesPane(ChartStylePane parent, Plot plot){

21
designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java

@ -3,23 +3,19 @@ package com.fr.van.chart.wordcloud.designer;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Plot;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.chartx.WordCloudChartDataPane;
import com.fr.design.condition.ConditionAttributesPane;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.chart.AbstractChartAttrPane;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.plugin.chart.base.VanChartConstants;
import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort;
import com.fr.van.chart.designer.other.VanChartOtherPane;
import com.fr.van.chart.designer.style.VanChartStylePane;
import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI;
import com.fr.van.chart.wordcloud.designer.data.WordCloudPlotReportDataContentPane;
import com.fr.van.chart.wordcloud.designer.data.WordCloudPlotTableDataContentPane;
import com.fr.van.chart.wordcloud.designer.other.VanChartWordCloudConditionPane;
import com.fr.van.chart.wordcloud.designer.style.VanChartWordCloudSeriesPane;
import com.fr.van.chart.wordcloud.designer.type.VanChartWordCloudTypePane;
@ -50,16 +46,6 @@ public class WordCloudIndependentVanChartInterface extends AbstractIndependentVa
return "com/fr/design/images/form/toolbar/wordcloud.png";
}
@Override
public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) {
return new WordCloudPlotReportDataContentPane();
}
@Override
public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) {
return new WordCloudPlotTableDataContentPane();
}
@Override
public BasicBeanPane<Plot> getPlotSeriesPane(ChartStylePane parent, Plot plot) {
return new VanChartWordCloudSeriesPane(parent, plot);
@ -104,4 +90,9 @@ public class WordCloudIndependentVanChartInterface extends AbstractIndependentVa
public String getPlotTypeTitle4PopupWindow(){
return VanChartWordCloudTypePane.TITLE;
}
@Override
public ChartDataPane getChartDataPane(AttributeChangeListener listener) {
return new WordCloudChartDataPane(listener);
}
}

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

@ -15,10 +15,9 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.menu.MenuKeySet;
import com.fr.design.module.DesignModuleFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.grid.Grid;
import com.fr.grid.selection.FloatSelection;
import com.fr.log.FineLoggerFactory;
import com.fr.report.ReportHelper;
import com.fr.report.cell.FloatElement;
import com.fr.report.elementcase.TemplateElementCase;
@ -27,8 +26,8 @@ import com.fr.stable.bridge.StableFactory;
import com.fr.stable.unit.FU;
import com.fr.stable.unit.OLDPIX;
import javax.swing.*;
import java.awt.*;
import javax.swing.KeyStroke;
import java.awt.Color;
/**
* 图表插入悬浮元素的操作.
@ -80,7 +79,6 @@ public class ChartFloatAction extends ElementCaseAction {
reportPane.stopEditing();
final BaseChartCollection cc = (BaseChartCollection) StableFactory.createXmlObject(BaseChartCollection.XML_TAG);
cc.removeAllNameObject();
final MiddleChartDialog chartDialog = DesignModuleFactory.getChartDialog(DesignerContext.getDesignerFrame());
chartDialog.populate(cc);
chartDialog.addDialogActionListener(new DialogActionAdapter() {

2
designer-realize/src/main/java/com/fr/design/actions/insert/flot/ImageFloatAction.java

@ -87,7 +87,7 @@ public class ImageFloatAction extends ElementCaseAction {
if (selectedFile != null && selectedFile.isFile()) {
CellImage cellImage = selectImagePane.update();
Image image = cellImage.getImage();
Image image = cellImage.getBufferImage();
JTemplate<?, ?> currentEditingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
currentEditingTemplate.setPictureElem(floatElement, cellImage);

2
designer-realize/src/main/java/com/fr/design/headerfooter/ImagePane.java

@ -78,7 +78,7 @@ public class ImagePane extends BasicPane {
}
public Image update() {
return this.imagePreviewPane.getImage();
return this.imagePreviewPane.getImageWithSuffix();
}
/**

3
designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java

@ -68,7 +68,6 @@ import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.general.ImageWithSuffix;
import com.fr.general.ModuleContext;
import com.fr.grid.Grid;
import com.fr.grid.GridUtils;
@ -622,7 +621,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
if (workBook instanceof WorkBookAdapter) {
elem.setValue(new CellImagePainter(cellImage));
} else {
elem.setValue(ImageWithSuffix.build(cellImage.getImage(),cellImage.getSuffix()));
elem.setValue(cellImage.getImage());
}
}

26
designer-realize/src/main/java/com/fr/design/report/SelectImagePane.java

@ -1,21 +1,18 @@
package com.fr.design.report;
import com.fr.base.BaseUtils;
import com.fr.base.Style;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.frpane.ImgChooseWrapper;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.style.background.image.ImageFileChooser;
import com.fr.design.style.background.image.ImagePreviewPane;
import com.fr.design.utils.ImageUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ImageWithSuffix;
import com.fr.report.cell.Elem;
import com.fr.report.cell.cellattr.CellImage;
import com.fr.report.cell.painter.CellImagePainter;
import com.fr.stable.Constants;
import com.fr.stable.CoreGraphHelper;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
@ -27,7 +24,6 @@ import java.awt.GridLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
/**
@ -44,8 +40,6 @@ public class SelectImagePane extends BasicPane {
private Style imageStyle = null;
private Image previewImage = null;
private File imageFile;
public SelectImagePane() {
@ -119,21 +113,8 @@ public class SelectImagePane extends BasicPane {
.showOpenDialog(SelectImagePane.this);
if (returnVal != JFileChooser.CANCEL_OPTION) {
File selectedFile = imageFileChooser.getSelectedFile();
if (selectedFile != null && selectedFile.isFile()) {
String filePath = selectedFile.getPath();
BufferedImage image = BaseUtils.readImage(filePath);
CoreGraphHelper.waitForImage(image);
imageFile = selectedFile;
setImageStyle();
previewPane.setImageWithSuffix(ImageWithSuffix.build(image, ImageUtils.getImageType(selectedFile)));
previewPane.setImageStyle(imageStyle);
previewImage = image;
} else {
previewPane.setImage(null);
}
previewPane.repaint();
imageFile = selectedFile;
ImgChooseWrapper.getInstance(previewPane, imageFileChooser, imageStyle, null).dealWithImageFile(returnVal);
}
}
};
@ -202,7 +183,6 @@ public class SelectImagePane extends BasicPane {
public void setImage(Image image) {
previewPane.setImage(image);
this.previewImage = image;
}
public CellImage update() {

7
designer-realize/src/main/java/com/fr/design/webattr/ViewToolBarPane.java

@ -52,9 +52,10 @@ public class ViewToolBarPane extends AbstractEditToolBarPane {
editToolBarButton.setEnabled(isUseToolBarCheckBox.isSelected());
}
});
sortCheckBox.setSelected(true);
conditonFilterBox.setSelected(true);
listFilterBox.setSelected(true);
// 切换BI工程目录 webView未设置 默认false
sortCheckBox.setSelected(false);
conditonFilterBox.setSelected(false);
listFilterBox.setSelected(false);
northPane.add(GUICoreUtils.createFlowPane(new Component[]{sortCheckBox, conditonFilterBox, listFilterBox}, FlowLayout.LEFT, 6));
northPane.add(GUICoreUtils.createFlowPane(new Component[] {isUseToolBarCheckBox, editToolBarButton}, FlowLayout.LEFT));
northPane.add(GUICoreUtils.createFlowPane(showListenersLabel, FlowLayout.LEFT));

1
designer-realize/src/main/java/com/fr/grid/Grid.java

@ -961,7 +961,6 @@ public class Grid extends BaseGridComponent {
if (!ComparatorUtils.equals_exactly(oldValue, newValue)) {
if (newValue instanceof CellImage) {
CellImage cellImage = (CellImage) newValue;
newValue = cellImage.getImage();
JTemplate<?, ?> currentEditingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
currentEditingTemplate.setPictureElem(selectedFloatElement, cellImage);

9
designer-realize/src/main/java/com/fr/poly/PolyComponentsBar.java

@ -1,7 +1,7 @@
package com.fr.poly;
import com.fr.base.BaseUtils;
import com.fr.base.chart.BaseChart;
import com.fr.base.chart.BaseChartCollection;
import com.fr.base.chart.BaseChartGetter;
import com.fr.base.chart.BaseChartNameID;
import com.fr.base.vcs.DesignerMode;
@ -64,9 +64,10 @@ public class PolyComponentsBar extends JToolBar {
);
this.add(serIcons[0]);
for (int i = 0; i < typeLen; i++) {
BaseChart[] rowChart = BaseChartGetter.getStaticChartTypes(typeName[i].getPlotID());
String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(typeName[i].getPlotID());
serIcons[i + 1] = new SerIcon(rowChart[0], InterProviderFactory.getProvider().getLocText(typeName[i].getName()), iconPath);
String chartID = typeName[i].getChartID();
String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(chartID);
BaseChartCollection chartCollection = BaseChartGetter.createChartCollection(chartID);
serIcons[i + 1] = new SerIcon(chartCollection, InterProviderFactory.getProvider().getLocText(typeName[i].getName()), iconPath);
this.add(serIcons[i + 1]);
}

24
designer-realize/src/main/java/com/fr/poly/PolyUtils.java

@ -4,9 +4,7 @@
package com.fr.poly;
import com.fr.base.ScreenResolution;
import com.fr.base.chart.BaseChart;
import com.fr.base.chart.BaseChartCollection;
import com.fr.base.chart.BasePlot;
import com.fr.log.FineLoggerFactory;
import com.fr.poly.creator.BlockCreator;
import com.fr.poly.creator.ChartBlockCreator;
@ -15,7 +13,6 @@ import com.fr.poly.model.AddedData;
import com.fr.report.poly.PolyChartBlock;
import com.fr.report.poly.PolyECBlock;
import com.fr.report.poly.TemplateBlock;
import com.fr.stable.bridge.StableFactory;
import java.awt.Point;
import java.lang.reflect.Constructor;
@ -53,10 +50,8 @@ public class PolyUtils {
public static BlockCreator createCreator(Class clazz) {
return createCreator(blockGenerate(clazz));
}
public static BlockCreator createCreator(BaseChart chart) {
BaseChartCollection cc = (BaseChartCollection)StableFactory.createXmlObject(BaseChartCollection.XML_TAG);
cc.addChart(chart);
public static BlockCreator createCreator(BaseChartCollection cc) {
TemplateBlock block = new PolyChartBlock(cc);
return createCreator(block);
}
@ -66,20 +61,7 @@ public class PolyUtils {
try {
block = (TemplateBlock) clazz.newInstance();
} catch (Exception e) {
try {
BasePlot plot = (BasePlot)clazz.newInstance();
BaseChartCollection cc = (BaseChartCollection)StableFactory.createXmlObject(BaseChartCollection.XML_TAG);
BaseChart chart = (BaseChart)StableFactory.createXmlObject(BaseChart.XML_TAG);
chart.initChart(plot);
cc.addChart(chart);
block = new PolyChartBlock(cc);
} catch (InstantiationException e1) {
FineLoggerFactory.getLogger().error(e1.getMessage(), e1);
} catch (IllegalAccessException e1) {
FineLoggerFactory.getLogger().error(e1.getMessage(), e1);
}
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return block;
}

133
designer-realize/src/main/java/com/fr/poly/creator/ChartBlockEditor.java

@ -3,25 +3,15 @@
*/
package com.fr.poly.creator;
import com.fr.base.BaseUtils;
import com.fr.base.ScreenResolution;
import com.fr.base.chart.BaseChart;
import com.fr.base.chart.BaseChartCollection;
import com.fr.base.chart.BaseChartGetter;
import com.fr.base.chart.BaseChartNameID;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.design.mainframe.JSliderPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.NoSupportAuthorityEdit;
import com.fr.design.mainframe.cell.QuickEditorRegion;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.poly.PolyConstants;
import com.fr.poly.PolyDesigner;
import com.fr.poly.PolyDesigner.SelectionType;
@ -31,13 +21,8 @@ import com.fr.report.poly.PolyChartBlock;
import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.JToggleButton;
import javax.swing.border.Border;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@ -48,31 +33,10 @@ import java.awt.event.MouseEvent;
*/
// 图片的命名必须符合下面的代码规范(chart类别+序号的方式) 不然读取不到指定图片
public class ChartBlockEditor extends BlockEditor<MiddleChartComponent, PolyChartBlock> {
private static final int BOUND_OFF = 21;
private static Border buttonBorder;
private static String[][] chartsNames;
private static BaseChartNameID[] typeName = BaseChartGetter.getStaticAllChartBaseNames();
private int resolution = (int) (ScreenResolution.getScreenResolution()* JSliderPane.getInstance().resolutionTimes);
static {
buttonBorder = new UIRoundedBorder(new Color(149, 149, 149), 1, 5);
chartsNames = new String[typeName.length][];
for (int i = 0; i < typeName.length; i++) {
BaseChart[] rowCharts = BaseChartGetter.getStaticChartTypes(typeName[i].getPlotID());
chartsNames[i] = new String[rowCharts.length];
for (int j = 0; j < rowCharts.length; j++) {
chartsNames[i][j] = rowCharts[j].getChartName();
}
}
}
private ChartButton[] chartButtons = null;
public ChartBlockEditor(PolyDesigner designer, ChartBlockCreator creator) {
super(designer, creator);
this.resolution = creator.resolution;
//shine:和产品商量后决定把最上面一排切换按钮去掉
// this.initNorthBarComponent();
}
@ -80,33 +44,6 @@ public class ChartBlockEditor extends BlockEditor<MiddleChartComponent, PolyChar
this.resolution = resolution;
}
private void initNorthBarComponent() {
JPanel charttypeToolbar = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 0));
this.add(BlockEditorLayout.TOP, charttypeToolbar);
BaseChart chart = editComponent.getEditingChart();
String selectedName = chart.getChartName();
int index = 0;
for (int i = 0; i < typeName.length; i++) {
String[] rowCharts = chartsNames[i];
for (int j = 0; j < rowCharts.length; j++) {
if (ComparatorUtils.equals(selectedName, rowCharts[j])) {
index = i;
break;
}
}
}
String plotID = typeName[index].getPlotID();
BaseChart[] charts = BaseChartGetter.getStaticChartTypes(plotID);
chartButtons = new ChartButton[charts.length];
for (int i = 0, l = charts.length; i < l; i++) {
chartButtons[i] = new ChartButton(charts[i], charts[i].getChartName(), typeName[index].getName(), i);
charttypeToolbar.add(chartButtons[i]);
}
}
/**
* 检查控件是否可用
*/
@ -192,76 +129,6 @@ public class ChartBlockEditor extends BlockEditor<MiddleChartComponent, PolyChar
}
private class ChartButton extends JToggleButton {
private BaseChart chart;
public ChartButton(BaseChart chart, String text, String pathName, int index) {
this.chart = chart;
this.setToolTipText(text);
String path = "com/fr/design/images/poly/" + pathName + '/' + pathName + '-' + index + ".png";
Icon icon = null;
try {
icon = BaseUtils.readIcon(path);
} catch (Exception e) {
icon = BaseUtils.readIcon("com/fr/design/images/poly/normal.png");
}
this.setIcon(icon);
this.setBorder(null);
this.setMargin(null);
this.setOpaque(false);
this.setContentAreaFilled(false);
this.setFocusPainted(false);
this.setRequestFocusEnabled(false);
this.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (DesignerMode.isAuthorityEditing()) {
return;
}
BaseChart chart = null;
try {
chart = (BaseChart) ChartButton.this.chart.clone();
} catch (CloneNotSupportedException ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
return;
}
BaseChartCollection cc = creator.getValue().getChartCollection();
cc.switchPlot(chart.getBasePlot());
initEffective(cc);
creator.setValue(creator.getValue());
ChartBlockEditor.this.removeAll();
ChartBlockEditor.this.initComponets();
ChartBlockEditor.this.initNorthBarComponent();
ChartBlockEditor.this.addColumnRowListeners();
ChartBlockEditor.this.addBoundsListener();
ChartBlockEditor.this.initDataChangeListener();
ChartBlockEditor.this.doLayout();
ChartBlockEditor.this.repaint();
QuickEditorRegion.getInstance().populate(creator.getQuickEditor(designer));
LayoutUtils.layoutRootContainer(designer);
designer.fireTargetModified();
designer.repaint();
}
@Override
public void mouseEntered(MouseEvent e) {
ChartButton.this.setBorder(buttonBorder);
}
@Override
public void mouseExited(MouseEvent e) {
ChartButton.this.setBorder(null);
}
});
}
@Override
public Dimension getPreferredSize() {
return new Dimension(22, 22);
}
}
public MiddleChartComponent getEditChartComponent() {
return createEffective();
}

6
designer-realize/src/main/java/com/fr/poly/hanlder/PolyDesignerDropTarget.java

@ -4,7 +4,7 @@
package com.fr.poly.hanlder;
import com.fr.base.ScreenResolution;
import com.fr.base.chart.BaseChart;
import com.fr.base.chart.BaseChartCollection;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.mainframe.DesignerContext;
import com.fr.grid.Grid;
@ -73,8 +73,8 @@ public class PolyDesignerDropTarget extends DropTargetAdapter {
if (obj instanceof Class) {
Class clazz = (Class) obj;
creator = PolyUtils.createCreator(clazz);
} else if (obj instanceof BaseChart) {
creator = PolyUtils.createCreator((BaseChart) obj);
} else if (obj instanceof BaseChartCollection) {
creator = PolyUtils.createCreator((BaseChartCollection) obj);
}
if (creator == null) {
return;

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

@ -3,8 +3,12 @@ package com.fr.start.module;
import com.fr.base.BaseFormula;
import com.fr.base.Formula;
import com.fr.base.MultiFieldParameter;
import com.fr.base.passport.FinePassportListenerAdapter;
import com.fr.base.passport.FinePassportManager;
import com.fr.base.process.ProcessOperator;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.NewFormAction;
import com.fr.design.actions.core.ActionFactory;
@ -120,6 +124,7 @@ public class DesignerActivator extends Activator {
loadLogAppender();
DesignerSocketIO.update();
UserInfoPane.getInstance().updateBBSUserInfo();
storePassport();
}
private void loadLogAppender() {
@ -340,6 +345,16 @@ public class DesignerActivator extends Activator {
StableFactory.registerMarkedObject(ElementCaseThumbnailProcessor.MARK_STRING, new ElementCaseThumbnail());
}
private static void storePassport() {
FinePassportManager.getInstance().storePassport(MarketConfig.getInstance().getBbsUsername(), DesignerEnvManager.getEnvManager().getActivationKey());
FinePassportManager.getInstance().addPassportListener(new FinePassportListenerAdapter() {
@Override
public void onLoginSuccess() {
FinePassportManager.getInstance().storePassport(MarketConfig.getInstance().getBbsUsername(), DesignerEnvManager.getEnvManager().getActivationKey());
}
});
}
@Override
public void stop() {
unloadLogAppender();

69
designer-realize/src/test/java/com.fr/design/mainframe/JFileTest.java

@ -0,0 +1,69 @@
package com.fr.design.mainframe;
import com.fr.config.dao.DaoContext;
import com.fr.config.dao.impl.LocalClassHelperDao;
import com.fr.config.dao.impl.LocalEntityDao;
import com.fr.config.dao.impl.LocalXmlEntityDao;
import com.fr.form.main.Form;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.general.ImageWithSuffix;
import com.fr.general.ModuleContext;
import com.fr.main.impl.WorkBook;
import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.CellImage;
import com.fr.report.restriction.CellCountRestriction;
import com.fr.report.restriction.ReportRestrictionScene;
import com.fr.report.worksheet.FormElementCase;
import com.fr.report.worksheet.WorkSheet;
import com.fr.restriction.Restrictions;
import com.fr.stable.module.Module;
import com.fr.start.Designer;
import junit.framework.TestCase;
import org.junit.Assert;
import java.awt.image.BufferedImage;
public class JFileTest extends TestCase {
@Override
protected void setUp() throws Exception {
DaoContext.setEntityDao(new LocalEntityDao());
DaoContext.setClassHelperDao(new LocalClassHelperDao());
DaoContext.setXmlEntityDao(new LocalXmlEntityDao());
Restrictions.register(ReportRestrictionScene.CELL_COUNT, new CellCountRestriction());
ModuleContext.startModule(Module.PAGE_MODULE);
ModuleContext.startModule(Module.VIEW_MODULE);
Designer designer = new Designer(new String[0]);
}
public void testJWorkBookSetPicture() {
WorkBook workBook = new WorkBook();
WorkSheet workSheet = new WorkSheet();
workBook.addReport("sheet1", workSheet);
TemplateCellElement cellElement = new DefaultTemplateCellElement();
workSheet.addCellElement(cellElement);
ImageWithSuffix imageWithSuffix = ImageWithSuffix.build(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB), "jpg");
CellImage cellImage = new CellImage();
cellImage.setImage(imageWithSuffix);
JWorkBook jWorkBook = new JWorkBook(workBook, "text");
jWorkBook.setPictureElem(cellElement, cellImage);
Assert.assertEquals(imageWithSuffix, cellElement.getValue());
}
public void testJFormSetPicture() {
Form form = new Form();
ElementCaseEditor editor = new ElementCaseEditor();
FormElementCase elementCase = new FormElementCase();
TemplateCellElement cellElement = new DefaultTemplateCellElement();
elementCase.addCellElement(cellElement);
editor.setElementCase(elementCase);
form.getContainer().addWidget(editor);
ImageWithSuffix imageWithSuffix = ImageWithSuffix.build(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB), "jpg");
CellImage cellImage = new CellImage();
cellImage.setImage(imageWithSuffix);
JForm jForm = new JForm();
jForm.setTarget(form);
jForm.setPictureElem(cellElement, cellImage);
Assert.assertEquals(imageWithSuffix, cellElement.getValue());
}
}
Loading…
Cancel
Save