fangdong sun 8 years ago
parent
commit
86f4e7ec1b
  1. 82
      designer_chart/src/com/fr/design/chart/series/PlotSeries/MapCustomPane.java
  2. 55
      designer_chart/src/com/fr/design/chart/series/PlotSeries/MapDefiAreaNamePane.java

82
designer_chart/src/com/fr/design/chart/series/PlotSeries/MapCustomPane.java

@ -1,37 +1,36 @@
package com.fr.design.chart.series.PlotSeries; package com.fr.design.chart.series.PlotSeries;
import java.awt.BorderLayout; import com.fr.base.FRContext;
import java.awt.Dimension; import com.fr.base.TableData;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.chart.base.MapSvgAttr; import com.fr.chart.base.MapSvgAttr;
import com.fr.data.impl.EmbeddedTableData;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.data.TableDataSource;
import com.fr.data.core.DataCoreUtils;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.FilterComboBox; import com.fr.design.gui.icombobox.FilterComboBox;
import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.chart.gui.data.DatabaseTableDataPane; import com.fr.design.mainframe.chart.gui.data.DatabaseTableDataPane;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.data.DataModel;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import org.apache.batik.swing.svg.SVGFileFilter; import org.apache.batik.swing.svg.SVGFileFilter;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/** /**
* 自定义地图界面. * 自定义地图界面.
* *
@ -131,21 +130,50 @@ refreshAreaNameBox();
String colName = Utils.objectToString(areaString.getSelectedItem()); String colName = Utils.objectToString(areaString.getSelectedItem());
TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper(); TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper();
TableDataSource source = DesignTableDataManager.getEditingTableDataSource();
if (tableDataWrappe == null || source == null) { imageShowPane.refreshFromDataList(getColValuesInData(tableDataWrappe, colName));
return;
} }
}
};
String[] values = DataCoreUtils.getColValuesInData(source, tableDataWrappe.getTableDataName(), colName); public static List<String> getColValuesInData(TableDataWrapper tableDataWrappe, String colName) {
ArrayList list = new ArrayList(); List<String> colValues = new ArrayList<>();
for(int i = 0; i < values.length; i++) {
list.add(values[i]); EmbeddedTableData embeddedTableData = null;
try {
embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tableDataWrappe.getTableData(), TableData.RESULT_ALL, false);
} catch (Exception ee) {
FRContext.getLogger().error(ee.getMessage(), ee);
} }
imageShowPane.refreshFromDataList(list); if(embeddedTableData == null){
return colValues;
} }
int columnIndex = getColumnIndex(embeddedTableData, colName);
if(columnIndex == DataModel.COLUMN_NAME_NOT_FOUND){
return colValues;
}
for (int rowIndex = 0, rowCount = embeddedTableData.getRowCount(); rowIndex < rowCount; rowIndex++) {
String colValueName = GeneralUtils.objectToString(embeddedTableData.getValueAt(rowIndex, columnIndex));
if (!colValues.contains(colValueName)) {
colValues.add(colValueName);
}
}
return colValues;
}
private static int getColumnIndex(EmbeddedTableData tableData, String colName) {
for (int columnIndex = 0, columnCount = tableData.getColumnCount(); columnIndex < columnCount; columnIndex++) {
if (ComparatorUtils.tableDataColumnNameEquals(tableData.getColumnName(columnIndex), colName)) {
return columnIndex;
}
}
return DataModel.COLUMN_NAME_NOT_FOUND;
} }
};
/** /**
* 选中方式: 区域或者点 * 选中方式: 区域或者点

55
designer_chart/src/com/fr/design/chart/series/PlotSeries/MapDefiAreaNamePane.java

@ -1,42 +1,31 @@
package com.fr.design.chart.series.PlotSeries; package com.fr.design.chart.series.PlotSeries;
import java.awt.BorderLayout; import com.fr.base.Utils;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.swing.AbstractCellEditor;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellEditor;
import com.fr.chart.base.MapSvgAttr; import com.fr.chart.base.MapSvgAttr;
import com.fr.chart.base.MapSvgXMLHelper; import com.fr.chart.base.MapSvgXMLHelper;
import com.fr.base.Utils;
import com.fr.design.data.DesignTableDataManager;
import com.fr.data.TableDataSource;
import com.fr.data.core.DataCoreUtils;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.editor.ValueEditorPane;
import com.fr.design.editor.ValueEditorPaneFactory;
import com.fr.design.editor.editor.Editor;
import com.fr.design.editor.editor.TextEditor;
import com.fr.design.gui.icombobox.FilterComboBox; import com.fr.design.gui.icombobox.FilterComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itableeditorpane.UIArrayTableModel; import com.fr.design.gui.itableeditorpane.UIArrayTableModel;
import com.fr.design.gui.itableeditorpane.UITableEditorPane; import com.fr.design.gui.itableeditorpane.UITableEditorPane;
import com.fr.design.mainframe.chart.gui.data.DatabaseTableDataPane;
import com.fr.design.editor.ValueEditorPane;
import com.fr.design.editor.ValueEditorPaneFactory;
import com.fr.design.gui.xcombox.ComboBoxUseEditor; import com.fr.design.gui.xcombox.ComboBoxUseEditor;
import com.fr.design.editor.editor.Editor; import com.fr.design.mainframe.chart.gui.data.DatabaseTableDataPane;
import com.fr.design.editor.editor.TextEditor;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.third.org.apache.poi.hssf.record.formula.functions.T;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellEditor;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/** /**
* 地图, 定义区域名. * 地图, 定义区域名.
@ -90,7 +79,7 @@ public class MapDefiAreaNamePane extends BasicBeanPane<String> implements Abstrc
tableDataBox.setPreferredSize(new Dimension(200, 20)); tableDataBox.setPreferredSize(new Dimension(200, 20));
northPane.add(tableDataBox); northPane.add(tableDataBox);
columnBox = new FilterComboBox<T>(); columnBox = new FilterComboBox<>();
columnBox.setPreferredSize(new Dimension(40, 20)); columnBox.setPreferredSize(new Dimension(40, 20));
columnBox.addItemListener(columnChange); columnBox.addItemListener(columnChange);
@ -114,12 +103,10 @@ public class MapDefiAreaNamePane extends BasicBeanPane<String> implements Abstrc
String columnName = Utils.objectToString(columnBox.getSelectedItem()); String columnName = Utils.objectToString(columnBox.getSelectedItem());
TableDataWrapper tableDataWrappe = tableDataBox.getTableDataWrapper(); TableDataWrapper tableDataWrappe = tableDataBox.getTableDataWrapper();
TableDataSource source = DesignTableDataManager.getEditingTableDataSource();
if (tableDataWrappe == null || source == null) {
return;
}
initNames = DataCoreUtils.getColValuesInData(source, tableDataWrappe.getTableDataName(), columnName); List<String> list = MapCustomPane.getColValuesInData(tableDataWrappe, columnName);
initNames = list.toArray(initNames);
if (tableEditorModel != null) { if (tableEditorModel != null) {
tableEditorModel.stopCellEditing();// 只是用来刷新列表的combox tableEditorModel.stopCellEditing();// 只是用来刷新列表的combox

Loading…
Cancel
Save