Browse Source

CHART-11090 代码质量

persist/11.0
白岳 5 years ago
parent
commit
8b1ddf4f94
  1. 29
      designer-chart/src/main/java/com/fr/design/chartx/component/MapAreaMatchPane.java
  2. 71
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MapDataSetFieldsPane.java

29
designer-chart/src/main/java/com/fr/design/chartx/component/MapAreaMatchPane.java

@ -24,11 +24,8 @@ import com.fr.design.parameter.ParameterInputPane;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.general.data.DataModel; import com.fr.general.data.DataModel;
import com.fr.general.data.TableDataException; import com.fr.general.data.TableDataException;
import com.fr.plugin.chart.map.MapMatchProvider;
import com.fr.plugin.chart.map.MapMatchResult; import com.fr.plugin.chart.map.MapMatchResult;
import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; import com.fr.plugin.chart.map.server.ChartGEOJSONHelper;
import com.fr.plugin.chart.type.MapType;
import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
@ -58,7 +55,7 @@ import java.awt.event.MouseEvent;
* @version 10.0 * @version 10.0
* Created by Bjorn on 2019-11-04 * Created by Bjorn on 2019-11-04
*/ */
public class MapAreaMatchPane extends BasicBeanPane<MapMatchProvider> { public class MapAreaMatchPane extends BasicBeanPane<MapMatchResult> {
private TableDataComboBox tableNameCombox; private TableDataComboBox tableNameCombox;
private UIComboBox areaNameBox; private UIComboBox areaNameBox;
@ -72,12 +69,8 @@ public class MapAreaMatchPane extends BasicBeanPane<MapMatchProvider> {
private static final Object[] HEADER_WITH_EMPTY = new Object[]{Toolkit.i18nText("Fine-Design_Chart_Area_Name"), Toolkit.i18nText("Fine-Design_Chart_Match_To"), ""}; private static final Object[] HEADER_WITH_EMPTY = new Object[]{Toolkit.i18nText("Fine-Design_Chart_Area_Name"), Toolkit.i18nText("Fine-Design_Chart_Match_To"), ""};
private int level;
public MapAreaMatchPane(int level, TwoTuple<DefaultMutableTreeNode, Set<String>> treeNodeAndItems) {
this.level = level;
public MapAreaMatchPane(TwoTuple<DefaultMutableTreeNode, Set<String>> treeNodeAndItems) {
initButtonGroup(); initButtonGroup();
initRefreshLabel(); initRefreshLabel();
areaNameBox = new UIComboBox(); areaNameBox = new UIComboBox();
@ -183,8 +176,7 @@ public class MapAreaMatchPane extends BasicBeanPane<MapMatchProvider> {
}); });
} }
public void updateBean(MapMatchProvider mapMatchProvider) { public void updateBean(MapMatchResult matchResult) {
MapMatchResult matchResult = mapMatchProvider.getMatchResult(level);
if (matchResult == null) { if (matchResult == null) {
return; return;
} }
@ -196,25 +188,18 @@ public class MapAreaMatchPane extends BasicBeanPane<MapMatchProvider> {
matchResultTable.updateBean(matchResult); matchResultTable.updateBean(matchResult);
} }
public void populateBean(MapMatchProvider vanChart) { public void populateBean(MapMatchResult matchResult) {
} }
public void populateBean(MapMatchProvider mapMatchProvider, String comboBoxName, MapType mapType) { public void populateBean(MapMatchResult matchResult, String tableName, String areaName) {
//先取保存的数据集名称和区域名,若不存在,就取数据集面板配置的数据集名称和区域名 //先取保存的数据集名称和区域名,若不存在,就取数据集面板配置的数据集名称和区域名
MapMatchResult matchResult = mapMatchProvider.getMatchResult(level);
matchResultTable.populateBean(matchResult); matchResultTable.populateBean(matchResult);
String tableName = null; if (matchResult != null && matchResult.getTableName() != null) {
String areaName = null;
if (matchResult != null) {
tableName = matchResult.getTableName(); tableName = matchResult.getTableName();
areaName = matchResult.getColumnName(); areaName = matchResult.getColumnName();
} }
if (tableName == null) {
tableName = mapMatchProvider.getNameTable(mapType, level);
areaName = comboBoxName;
}
tableNameCombox.setSelectedTableDataByName(tableName); tableNameCombox.setSelectedTableDataByName(tableName);
if (StringUtils.isEmpty(areaName)) { if (StringUtils.isEmpty(areaName)) {
return; return;
@ -305,7 +290,7 @@ public class MapAreaMatchPane extends BasicBeanPane<MapMatchProvider> {
areaNameBox.setSelectedItem(null); areaNameBox.setSelectedItem(null);
} }
public VanChart updateBean() { public MapMatchResult updateBean() {
return null; return null;
} }

71
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MapDataSetFieldsPane.java

@ -2,13 +2,21 @@ package com.fr.design.chartx.fields.diff;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.chart.chartattr.Plot;
import com.fr.chartx.TwoTuple; import com.fr.chartx.TwoTuple;
import com.fr.chartx.data.ChartDataDefinitionProvider;
import com.fr.chartx.data.DataSetDefinition;
import com.fr.chartx.data.DrillMapChartDataDefinition;
import com.fr.chartx.data.MapChartDataDefinition;
import com.fr.chartx.data.field.diff.ColumnFieldCollectionWithSeriesValue; import com.fr.chartx.data.field.diff.ColumnFieldCollectionWithSeriesValue;
import com.fr.data.impl.NameTableData;
import com.fr.design.chartx.component.MapAreaMatchPane; import com.fr.design.chartx.component.MapAreaMatchPane;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionListener; import com.fr.design.dialog.DialogActionListener;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.plugin.chart.drillmap.VanChartDrillMapPlot;
import com.fr.plugin.chart.map.MapMatchResult;
import com.fr.plugin.chart.map.VanChartMapPlot; import com.fr.plugin.chart.map.VanChartMapPlot;
import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; import com.fr.plugin.chart.map.server.ChartGEOJSONHelper;
import com.fr.plugin.chart.type.MapType; import com.fr.plugin.chart.type.MapType;
@ -64,13 +72,17 @@ public abstract class MapDataSetFieldsPane<T extends ColumnFieldCollectionWithSe
if (treeNodeAndItems == null) { if (treeNodeAndItems == null) {
treeNodeAndItems = ChartGEOJSONHelper.getTreeNodeAndItems(((VanChartMapPlot) chart.getPlot()).getGeoUrl(), level); treeNodeAndItems = ChartGEOJSONHelper.getTreeNodeAndItems(((VanChartMapPlot) chart.getPlot()).getGeoUrl(), level);
} }
final MapAreaMatchPane pane = new MapAreaMatchPane(level, treeNodeAndItems); final MapAreaMatchPane pane = new MapAreaMatchPane(treeNodeAndItems);
pane.populateBean(chart, Utils.objectToString(areaBox.getSelectedItem()), MapDataSetFieldsPane.this.getMapType());
String nameTable = getNameTable(chart, MapDataSetFieldsPane.this.getMapType(), level);
final MapMatchResult matchResult = getMatchResult(chart, level);
pane.populateBean(matchResult, nameTable, Utils.objectToString(areaBox.getSelectedItem()));
BasicDialog dialog = pane.showWindow(new JFrame()); BasicDialog dialog = pane.showWindow(new JFrame());
dialog.addDialogActionListener(new DialogActionListener() { dialog.addDialogActionListener(new DialogActionListener() {
@Override @Override
public void doOk() { public void doOk() {
pane.updateBean(chart); pane.updateBean(matchResult);
} }
@Override @Override
@ -86,4 +98,57 @@ public abstract class MapDataSetFieldsPane<T extends ColumnFieldCollectionWithSe
} }
public abstract MapType getMapType(); public abstract MapType getMapType();
public String getNameTable(VanChart vanChart, MapType mapType, int level) {
ChartDataDefinitionProvider chartDataDefinition = vanChart.getChartDataDefinition();
if (chartDataDefinition == null) {
return null;
}
DataSetDefinition dataSetDefinition;
if (chartDataDefinition instanceof MapChartDataDefinition) {
MapChartDataDefinition mapChartDataDefinition = (MapChartDataDefinition) chartDataDefinition;
switch (mapType) {
case AREA:
dataSetDefinition = (DataSetDefinition) mapChartDataDefinition.getAreaMapDataDefinition();
break;
case POINT:
dataSetDefinition = (DataSetDefinition) mapChartDataDefinition.getPointMapDataDefinition();
break;
default:
dataSetDefinition = (DataSetDefinition) mapChartDataDefinition.getLineMapDataDefinition();
break;
}
} else if (chartDataDefinition instanceof DrillMapChartDataDefinition) {
DrillMapChartDataDefinition drillMapChartDataDefinition = (DrillMapChartDataDefinition) chartDataDefinition;
if (drillMapChartDataDefinition.isFromBottomData()) {
dataSetDefinition = (DataSetDefinition) drillMapChartDataDefinition.getBottomDataDefinition();
} else {
dataSetDefinition = (DataSetDefinition) drillMapChartDataDefinition.getEachLayerDataDefinitionList().get(level);
}
} else {
dataSetDefinition = (DataSetDefinition) chartDataDefinition;
}
if (dataSetDefinition == null) {
return null;
}
NameTableData nameTableData = dataSetDefinition.getNameTableData();
if (nameTableData == null) {
return null;
}
return nameTableData.getName();
}
public MapMatchResult getMatchResult(VanChart vanChart, int level) {
Plot plot = vanChart.getPlot();
if (plot == null) {
return null;
}
if (level < 0 && plot instanceof VanChartMapPlot) {
return ((VanChartMapPlot) plot).getMatchResult();
} else if (plot instanceof VanChartDrillMapPlot) {
return ((VanChartDrillMapPlot) plot).getMatchResultList().get(level);
}
return null;
}
} }

Loading…
Cancel
Save