Browse Source

Merge pull request #1550 in DESIGN/design from ~BJORN/design:release/10.0 to release/10.0

* commit 'b9ec2f32cfc099e916808e9d2ac053ed5a3f7d15':
  CHART-13213 地图模糊匹配优化
feature/big-screen
Bjorn 5 years ago
parent
commit
99a4995f39
  1. 1
      designer-chart/src/main/java/com/fr/design/chartx/component/MapAreaMatchPane.java
  2. 28
      designer-chart/src/main/java/com/fr/design/chartx/component/MatchAreaTable.java
  3. 39
      designer-chart/src/main/java/com/fr/design/chartx/component/MatchResultTable.java

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

@ -118,6 +118,7 @@ public class MapAreaMatchPane extends BasicBeanPane<MapMatchResult> {
matchAreaTable.setItems(treeNodeAndItems.getSecond()); matchAreaTable.setItems(treeNodeAndItems.getSecond());
matchResultTable = new MatchResultTable(new Object[0][3], HEADER_WITH_EMPTY); matchResultTable = new MatchResultTable(new Object[0][3], HEADER_WITH_EMPTY);
matchResultTable.setItems(treeNodeAndItems.getSecond());
DefaultTableModel model = new DefaultTableModel(new Object[0][3], HEADER_WITH_EMPTY); DefaultTableModel model = new DefaultTableModel(new Object[0][3], HEADER_WITH_EMPTY);
matchResultTable.setModel(model); matchResultTable.setModel(model);

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

@ -1,6 +1,5 @@
package com.fr.design.chartx.component; package com.fr.design.chartx.component;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; import com.fr.plugin.chart.map.server.ChartGEOJSONHelper;
@ -63,6 +62,16 @@ public class MatchAreaTable extends JTable {
this.areaNameIndex = areaNameIndex; this.areaNameIndex = areaNameIndex;
} }
@Override
public boolean isCellEditable(int row, int column) {
//第一列不可编辑
int col = convertColumnIndexToModel(column);
if (col == 0) {
return false;
}
return true;
}
public void setModel(TableModel dataModel) { public void setModel(TableModel dataModel) {
super.setModel(dataModel); super.setModel(dataModel);
@ -70,7 +79,6 @@ public class MatchAreaTable extends JTable {
items = new HashSet<>(); items = new HashSet<>();
} }
TableColumnModel columnModel = getColumnModel(); TableColumnModel columnModel = getColumnModel();
columnModel.getColumn(0).setCellEditor(new UILabelEditor());
columnModel.getColumn(1).setCellEditor(new UIComboBoxRenderAndEditor()); columnModel.getColumn(1).setCellEditor(new UIComboBoxRenderAndEditor());
columnModel.getColumn(1).setCellRenderer(new UIComboBoxRenderAndEditor()); columnModel.getColumn(1).setCellRenderer(new UIComboBoxRenderAndEditor());
} }
@ -131,20 +139,4 @@ public class MatchAreaTable extends JTable {
return comboBox.getSelectedItem(); return comboBox.getSelectedItem();
} }
} }
public static class UILabelEditor extends AbstractCellEditor implements TableCellEditor {
UILabel uiLabel;
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected,
int row, int column) {
uiLabel = new UILabel(GeneralUtils.objectToString(value));
return uiLabel;
}
public Object getCellEditorValue() {
return uiLabel.getText();
}
}
} }

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

@ -3,8 +3,10 @@ package com.fr.design.chartx.component;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.plugin.chart.map.data.MapMatchResult; import com.fr.plugin.chart.map.data.MapMatchResult;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -18,7 +20,9 @@ import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel; import javax.swing.table.TableModel;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.Vector; import java.util.Vector;
import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@ -32,6 +36,8 @@ public class MatchResultTable extends JTable {
private MatchAreaTable matchAreaTable; private MatchAreaTable matchAreaTable;
private Set<String> items;
public MatchResultTable(Object[][] data, Object[] header) { public MatchResultTable(Object[][] data, Object[] header) {
super(data, header); super(data, header);
this.getTableHeader().setReorderingAllowed(false); this.getTableHeader().setReorderingAllowed(false);
@ -41,12 +47,26 @@ public class MatchResultTable extends JTable {
this.matchAreaTable = matchAreaTable; this.matchAreaTable = matchAreaTable;
} }
public void setItems(Set<String> items) {
this.items = items;
}
@Override
public boolean isCellEditable(int row, int column) {
//第一列和第二列不可编辑
int col = convertColumnIndexToModel(column);
if (col == 0 || col == 1) {
return false;
}
return true;
}
public void setModel(TableModel dataModel) { public void setModel(TableModel dataModel) {
super.setModel(dataModel); super.setModel(dataModel);
TableColumnModel columnModel = getColumnModel(); TableColumnModel columnModel = getColumnModel();
columnModel.getColumn(0).setCellEditor(new MatchAreaTable.UILabelEditor()); columnModel.getColumn(1).setCellRenderer(new UILabelEditorAndRender());
columnModel.getColumn(1).setCellEditor(new MatchAreaTable.UILabelEditor());
columnModel.getColumn(2).setCellEditor(new UIButtonEditorAndRender()); columnModel.getColumn(2).setCellEditor(new UIButtonEditorAndRender());
columnModel.getColumn(2).setCellRenderer(new UIButtonEditorAndRender()); columnModel.getColumn(2).setCellRenderer(new UIButtonEditorAndRender());
columnModel.getColumn(2).setMaxWidth(20); columnModel.getColumn(2).setMaxWidth(20);
@ -56,7 +76,6 @@ public class MatchResultTable extends JTable {
int rowCount = this.getRowCount(); int rowCount = this.getRowCount();
for (int i = 0; i < rowCount; i++) { for (int i = 0; i < rowCount; i++) {
if (ComparatorUtils.equals(this.getValueAt(i, 0), areaName)) { if (ComparatorUtils.equals(this.getValueAt(i, 0), areaName)) {
getColumnModel().getColumn(1).getCellEditor().stopCellEditing();
this.setValueAt(result, i, 1); this.setValueAt(result, i, 1);
return; return;
} }
@ -143,4 +162,18 @@ public class MatchResultTable extends JTable {
} }
} }
public class UILabelEditorAndRender implements TableCellRenderer {
UILabel uiLabel;
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
uiLabel = new UILabel(GeneralUtils.objectToString(value));
if (!items.contains(value)) {
uiLabel.setForeground(Color.GRAY);
uiLabel.setText(value + Toolkit.i18nText("Fine-Design_Chart_Lost_Data"));
}
return uiLabel;
}
}
} }

Loading…
Cancel
Save