Browse Source

CHART-11090 模糊匹配代码质量

feature/big-screen
白岳 5 years ago
parent
commit
d51e251b92
  1. 2
      designer-chart/src/main/java/com/fr/design/chartx/component/MapAreaMatchPane.java
  2. 4
      designer-chart/src/main/java/com/fr/design/chartx/component/MatchAreaTable.java
  3. 1
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDataPane.java
  4. 5
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java
  5. 4
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java
  6. 4
      designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapDataPane.java
  7. 3
      designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/EachLayerDataDefinitionPane.java
  8. 24
      designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/type/VanChartDrillMapPlotPane.java
  9. 6
      designer-chart/src/main/java/com/fr/van/chart/map/designer/data/VanChartMapDataPane.java
  10. 3
      designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanAreaMapPlotTableDataContentPane.java
  11. 31
      designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanLineMapPlotTableDataContentPane.java
  12. 29
      designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanMapTableDataContentPane.java
  13. 17
      designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanPointMapPlotTableDataContentPane.java
  14. 17
      designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java

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

@ -261,7 +261,7 @@ public class MapAreaMatchPane extends BasicBeanPane<MapMatchResult> {
private void populateMatchData(Object[] columnData) {
Set<String> geoAreas = matchAreaTable.getItems();
Map<String, String> resultMap = ChartGEOJSONHelper.matchArea(columnData, geoAreas, matchResultTable.getCustomResult());
Map<String, String> resultMap = ChartGEOJSONHelper.matchAreaList(columnData, geoAreas, matchResultTable.getCustomResult());
Object[][] data = new Object[resultMap.size()][2];

4
designer-chart/src/main/java/com/fr/design/chartx/component/MatchAreaTable.java

@ -1,5 +1,6 @@
package com.fr.design.chartx.component;
import com.fr.base.Utils;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.general.GeneralUtils;
@ -80,8 +81,7 @@ public class MatchAreaTable extends JTable {
return;
}
int index = areaNameIndex.get(areaName);
Map<String, String> resultMap = ChartGEOJSONHelper.matchArea(new Object[]{areaName}, items);
String result = resultMap.get(areaName);
String result = ChartGEOJSONHelper.matchArea(Utils.objectToString(areaName), items);
getColumnModel().getColumn(1).getCellEditor().stopCellEditing();
this.setValueAt(result, index, 1);
}

1
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDataPane.java

@ -27,6 +27,7 @@ public class ChartDataPane extends AbstractChartAttrPane {
public ChartDataPane(AttributeChangeListener listener) {
super();
this.listener = listener;
this.addAttributeChangeListener(listener);
}
@Override

5
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java

@ -15,7 +15,6 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.van.chart.map.designer.data.contentpane.table.VanMapTableDataContentPane;
import javax.swing.BorderFactory;
import java.awt.BorderLayout;
@ -128,9 +127,7 @@ public class TableDataPane extends FurtherBasicBeanPane<ChartCollection>{
}
public void refreshLevel(int level){
if(dataContentPane instanceof VanMapTableDataContentPane) {
((VanMapTableDataContentPane) dataContentPane).setLevel(level);
}
dataContentPane.refreshLevel(level);
}
/**

4
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java

@ -139,4 +139,8 @@ public abstract class AbstractTableDataContentPane extends BasicBeanPane<ChartCo
jSeparator.setPreferredSize(new Dimension(246, 2));
return jSeparator;
}
public void refreshLevel(int level) {
}
}

4
designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapDataPane.java

@ -8,8 +8,6 @@ import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.plugin.chart.drillmap.data.DrillMapDefinition;
import com.fr.plugin.chart.map.MapMatchResult;
import com.fr.plugin.chart.map.VanChartMapPlot;
import com.fr.plugin.chart.map.server.ChartGEOJSONHelper;
import com.fr.plugin.chart.type.MapType;
import com.fr.van.chart.map.designer.data.MapDataPaneHelper;
@ -79,9 +77,7 @@ public class DrillMapDataPane extends BasicBeanPane<ChartCollection> {
dataDefinitionType.setSelectedIndex(MapDataPaneHelper.isFromBottomData(ob) ? 0 : 1);
MapMatchResult matchResult = ((VanChartMapPlot) ob.getSelectedChartProvider(Chart.class).getPlot()).getMatchResult();
ChartCollection bottomDataChartCollection = MapDataPaneHelper.getBottomDataDrillMapChartCollection(ob);
((VanChartMapPlot)bottomDataChartCollection.getSelectedChartProvider(Chart.class).getPlot()).setMatchResult(matchResult);
bottomDataDefinitionPane.populateBean(bottomDataChartCollection, ChartGEOJSONHelper.BOTTOM_LEVEL);
eachLayerDataDefinitionPane.populateBean(ob);

3
designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/EachLayerDataDefinitionPane.java

@ -11,7 +11,6 @@ import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.drillmap.DrillMapHelper;
import com.fr.plugin.chart.drillmap.VanChartDrillMapPlot;
import com.fr.plugin.chart.drillmap.data.DrillMapDefinition;
import com.fr.plugin.chart.map.MapMatchResult;
import com.fr.plugin.chart.map.server.CompatibleGeoJSONTreeHelper;
import com.fr.plugin.chart.type.MapType;
import com.fr.van.chart.map.designer.data.MapDataPaneHelper;
@ -91,13 +90,11 @@ public class EachLayerDataDefinitionPane extends MultiTabPane<ChartCollection> {
}
private void populatePaneList(ChartCollection chartCollection) {
List<MapMatchResult> matchResultList = ((VanChartDrillMapPlot) chartCollection.getSelectedChartProvider(Chart.class).getPlot()).getMatchResultList();
for (int i = 0, len = paneList.size(); i < len; i++) {
BasicPane basicPane = paneList.get(i);
MapType mapType = oldMapList.get(i);
if (basicPane instanceof SingleLayerDataDefinitionPane) {
ChartCollection clone = MapDataPaneHelper.getLayerChartCollection(chartCollection, i, mapType);
((VanChartDrillMapPlot)clone.getSelectedChartProvider(Chart.class).getPlot()).setMatchResultList(matchResultList);
((SingleLayerDataDefinitionPane) basicPane).populateBean(clone, i);
}
}

24
designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/type/VanChartDrillMapPlotPane.java

@ -3,20 +3,17 @@ package com.fr.van.chart.drillmap.designer.type;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Plot;
import com.fr.chartx.data.ChartDataDefinitionProvider;
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.drillmap.DrillMapIndependentVanChart;
import com.fr.plugin.chart.drillmap.VanChartDrillMapPlot;
import com.fr.plugin.chart.drillmap.data.DrillMapDefinition;
import com.fr.plugin.chart.map.MapMatchResult;
import com.fr.plugin.chart.type.MapType;
import com.fr.plugin.chart.type.ZoomLevel;
import com.fr.van.chart.map.designer.type.VanChartMapPlotPane;
import com.fr.van.chart.map.designer.type.VanChartMapSourceChoosePane;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Mitisky on 16/6/20.
@ -52,27 +49,6 @@ public class VanChartDrillMapPlotPane extends VanChartMapPlotPane {
return tools;
}
/**
* 同一个钻取地图 类型之间切换
*/
@Override
protected void cloneOldPlot2New(Plot oldPlot, Plot newPlot) {
super.cloneOldPlot2New(oldPlot, newPlot);
try {
List<MapMatchResult> newMatchResultList = new ArrayList<>();
List<MapMatchResult> matchResultList = ((VanChartDrillMapPlot) oldPlot).getMatchResultList();
if (matchResultList != null) {
for (MapMatchResult matchResult : matchResultList) {
newMatchResultList.add((MapMatchResult) matchResult.clone());
}
}
((VanChartDrillMapPlot) newPlot).setMatchResultList(newMatchResultList);
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error in change plot");
}
}
protected Chart[] getDefaultCharts() {
return DrillMapIndependentVanChart.DrillMapVanCharts;
}

6
designer-chart/src/main/java/com/fr/van/chart/map/designer/data/VanChartMapDataPane.java

@ -65,26 +65,20 @@ public class VanChartMapDataPane extends ChartDataPane {
switch (mapType) {
case AREA:
areaClone = MapDataPaneHelper.getAreaMapChartCollection(collection);
((VanChartMapPlot)areaClone.getSelectedChartProvider(Chart.class).getPlot()).setMatchResult(matchResult);
contentsPane.populate(areaClone);
break;
case POINT:
pointClone = MapDataPaneHelper.getPointMapChartCollection(collection);
((VanChartMapPlot)pointClone.getSelectedChartProvider(Chart.class).getPlot()).setMatchResult(matchResult);
contentsPane.populate(pointClone);
break;
case LINE:
lineClone = MapDataPaneHelper.getLineMapChartCollection(collection);
((VanChartMapPlot)lineClone.getSelectedChartProvider(Chart.class).getPlot()).setMatchResult(matchResult);
contentsPane.populate(lineClone);
break;
case CUSTOM:
areaClone = MapDataPaneHelper.getAreaMapChartCollection(collection);
pointClone = MapDataPaneHelper.getPointMapChartCollection(collection);
lineClone = MapDataPaneHelper.getLineMapChartCollection(collection);
((VanChartMapPlot)areaClone.getSelectedChartProvider(Chart.class).getPlot()).setMatchResult(matchResult);
((VanChartMapPlot)pointClone.getSelectedChartProvider(Chart.class).getPlot()).setMatchResult(matchResult);
((VanChartMapPlot)lineClone.getSelectedChartProvider(Chart.class).getPlot()).setMatchResult(matchResult);
((CustomMapChartDataContentsPane) contentsPane).populateAreaMap(areaClone);
((CustomMapChartDataContentsPane) contentsPane).populatePointMap(pointClone);
((CustomMapChartDataContentsPane) contentsPane).populateLineMap(lineClone);

3
designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanAreaMapPlotTableDataContentPane.java

@ -31,6 +31,7 @@ public class VanAreaMapPlotTableDataContentPane extends VanMapTableDataContentPa
protected SeriesTypeUseComboxPaneWithOutFilter seriesTypeUseComboxPane;
public VanAreaMapPlotTableDataContentPane(ChartDataPane parent) {
super(parent);
this.setLayout(new BorderLayout(0, 4));
initAreaNameCom();
@ -139,6 +140,7 @@ public class VanAreaMapPlotTableDataContentPane extends VanMapTableDataContentPa
TopDefinitionProvider topDefinitionProvider = collection.getSelectedChart().getFilterDefinition();
if (topDefinitionProvider instanceof VanMapTableDefinitionProvider) {
VanMapTableDefinitionProvider mapTableDefinitionProvider = (VanMapTableDefinitionProvider) topDefinitionProvider;
mapTableDefinitionProvider.setMatchResult(this.getMatchResult());
updateDefinition(mapTableDefinitionProvider);
}
}
@ -156,6 +158,7 @@ public class VanAreaMapPlotTableDataContentPane extends VanMapTableDataContentPa
TopDefinitionProvider topDefinitionProvider = collection.getSelectedChart().getFilterDefinition();
if (topDefinitionProvider instanceof VanMapTableDefinitionProvider) {
VanMapTableDefinitionProvider mapTableDefinitionProvider = (VanMapTableDefinitionProvider) topDefinitionProvider;
this.setMatchResult(mapTableDefinitionProvider.getMatchResult());
populateDefinition(mapTableDefinitionProvider);
}
}

31
designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanLineMapPlotTableDataContentPane.java

@ -7,7 +7,6 @@ import com.fr.van.chart.map.designer.data.component.table.AbstractLongLatAreaPan
import com.fr.van.chart.map.designer.data.component.table.AreaPane;
import com.fr.van.chart.map.designer.data.component.table.LineMapAreaPane;
import com.fr.van.chart.map.designer.data.component.table.LineMapLongLatAreaPane;
import com.fr.van.chart.map.designer.data.component.table.LongLatAreaPane;
import java.awt.Component;
@ -48,34 +47,6 @@ public class VanLineMapPlotTableDataContentPane extends VanPointMapPlotTableData
}
protected AbstractLongLatAreaPane createLongLatAreaPane(LongLatAreaTableComboPane longLatAreaTableComboPane) {
return new LineMapLongLatAreaPane(longLatAreaTableComboPane){
@Override
protected void initAreaPane(VanPointMapPlotTableDataContentPane.LongLatAreaTableComboPane parentPane) {
areaPane = new LongLatAreaPane(parentPane) {
@Override
protected Component[][] getComponent () {
return new Component[][]{
new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Start_Longitude")), longitudeCom},
new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Start_Latitude")), latitudeCom},
new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Start_Area_Name")), VanLineMapPlotTableDataContentPane.this.createAreaPanel(areaNameCom)}
};
}
};
}
@Override
protected void initEndAreaPane(VanPointMapPlotTableDataContentPane.LongLatAreaTableComboPane parentPane) {
endAreaPane = new LongLatAreaPane(parentPane){
@Override
protected Component[][] getComponent () {
return new Component[][]{
new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_End_Longitude")), longitudeCom},
new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_End_Latitude")), latitudeCom},
new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_End_Area_Name")), VanLineMapPlotTableDataContentPane.this.createAreaPanel(areaNameCom)}
};
}
};
}
};
return new LineMapLongLatAreaPane(longLatAreaTableComboPane);
}
}

29
designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanMapTableDataContentPane.java

@ -8,6 +8,7 @@ import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionListener;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.plugin.chart.map.MapMatchResult;
import com.fr.plugin.chart.map.VanChartMapPlot;
@ -29,27 +30,36 @@ import java.awt.event.ActionListener;
*/
public abstract class VanMapTableDataContentPane extends AbstractTableDataContentPane {
private ChartDataPane parent;
private VanChartMapPlot plot;
//钻取地图有层级,默认-1代表无层级关系
private int level = ChartGEOJSONHelper.DEFAULT_LEVEL;
public int getLevel() {
return level;
private MapMatchResult matchResult = new MapMatchResult();
public VanMapTableDataContentPane(ChartDataPane parent){
this.parent = parent;
}
public void setLevel(int level) {
this.level = level;
}
public VanChartMapPlot getPlot() {
return plot;
}
public void setPlot(VanChartMapPlot plot) {
this.plot = plot;
}
public MapMatchResult getMatchResult() {
return matchResult;
}
public void setMatchResult(MapMatchResult matchResult) {
this.matchResult = matchResult;
}
public JPanel createAreaPanel(final UIComboBox areaBox) {
JPanel areaPanel = new JPanel(new BorderLayout(4, 0));
areaBox.setPreferredSize(new Dimension(70, 20));
@ -66,7 +76,6 @@ public abstract class VanMapTableDataContentPane extends AbstractTableDataConten
final MapAreaMatchPane pane = new MapAreaMatchPane(treeNodeAndItems);
String nameTable = getTableName();
final MapMatchResult matchResult = plot.getMatchResult(level);
pane.populateBean(matchResult, nameTable, Utils.objectToString(areaBox.getSelectedItem()));
BasicDialog dialog = pane.showWindow(new JFrame());
@ -74,6 +83,7 @@ public abstract class VanMapTableDataContentPane extends AbstractTableDataConten
@Override
public void doOk() {
pane.updateBean(matchResult);
parent.attributeChanged();
}
@Override
@ -87,4 +97,9 @@ public abstract class VanMapTableDataContentPane extends AbstractTableDataConten
areaPanel.add(uiButton, BorderLayout.EAST);
return areaPanel;
}
@Override
public void refreshLevel(int level) {
this.setLevel(level);
}
}

17
designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanPointMapPlotTableDataContentPane.java

@ -10,7 +10,6 @@ import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.plugin.chart.map.data.VanMapTableDefinitionProvider;
import com.fr.van.chart.map.designer.data.component.table.AbstractLongLatAreaPane;
import com.fr.van.chart.map.designer.data.component.table.AreaPane;
import com.fr.van.chart.map.designer.data.component.table.LongLatAreaPane;
import com.fr.van.chart.map.designer.data.component.table.PointMapAreaPane;
import com.fr.van.chart.map.designer.data.component.table.PointMapLongLatAreaPane;
@ -222,7 +221,7 @@ public class VanPointMapPlotTableDataContentPane extends VanAreaMapPlotTableData
areaPane = new AreaPane(parentPane) {
protected Component[][] getComponent () {
return new Component[][]{
new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Start_Area_Name")), VanPointMapPlotTableDataContentPane.this.createAreaPanel(areaNameCom)}
new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area_Name")), VanPointMapPlotTableDataContentPane.this.createAreaPanel(areaNameCom)}
};
}
};
@ -231,19 +230,7 @@ public class VanPointMapPlotTableDataContentPane extends VanAreaMapPlotTableData
}
protected AbstractLongLatAreaPane createLongLatAreaPane(LongLatAreaTableComboPane longLatAreaTableComboPane) {
return new PointMapLongLatAreaPane(longLatAreaTableComboPane) {
protected void initAreaPane(VanPointMapPlotTableDataContentPane.LongLatAreaTableComboPane parentPane) {
areaPane = new LongLatAreaPane(parentPane) {
protected Component[][] getComponent () {
return new Component[][]{
new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Longitude")), longitudeCom},
new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Latitude")), latitudeCom},
new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area_Name")), VanPointMapPlotTableDataContentPane.this.createAreaPanel(areaNameCom)}
};
}
};
}
};
return new PointMapLongLatAreaPane(longLatAreaTableComboPane);
}
}

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

@ -10,7 +10,6 @@ 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.map.MapIndependentVanChart;
import com.fr.plugin.chart.map.MapMatchResult;
import com.fr.plugin.chart.map.VanChartMapPlot;
import com.fr.plugin.chart.map.data.VanMapDefinition;
import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper;
@ -90,22 +89,6 @@ public class VanChartMapPlotPane extends AbstractVanChartTypePane {
}
}
}
/**
* 同一个地图 类型之间切换
*/
@Override
protected void cloneOldPlot2New(Plot oldPlot, Plot newPlot) {
super.cloneOldPlot2New(oldPlot, newPlot);
try {
if (((VanChartMapPlot) oldPlot).getMatchResult() != null) {
((VanChartMapPlot) newPlot).setMatchResult((MapMatchResult) ((VanChartMapPlot) oldPlot).getMatchResult().clone());
}
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error in change plot");
}
}
/**
* 不同地图类型的超链不需要复制
*

Loading…
Cancel
Save