Browse Source

CHART-14744 结果数据使用可编辑标签

feature/big-screen
Qinghui.Liu 4 years ago
parent
commit
879cf2f2fd
  1. 75
      designer-chart/src/main/java/com/fr/van/chart/box/data/report/BoxPlotReportResultDataSeriesPane.java
  2. 71
      designer-chart/src/main/java/com/fr/van/chart/box/data/report/TinyFormulaWithEditLabel.java
  3. 155
      designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableResultDataSeriesPane.java
  4. 86
      designer-chart/src/main/java/com/fr/van/chart/box/data/table/UIComboBoxWithEditLabel.java

75
designer-chart/src/main/java/com/fr/van/chart/box/data/report/BoxPlotReportResultDataSeriesPane.java

@ -20,11 +20,12 @@ public class BoxPlotReportResultDataSeriesPane extends AbstractReportDataContent
private TinyFormulaPane category; private TinyFormulaPane category;
private TinyFormulaPane seriesName; private TinyFormulaPane seriesName;
private TinyFormulaPane max;
private TinyFormulaPane q3; private TinyFormulaWithEditLabel max;
private TinyFormulaPane median; private TinyFormulaWithEditLabel q3;
private TinyFormulaPane q1; private TinyFormulaWithEditLabel median;
private TinyFormulaPane min; private TinyFormulaWithEditLabel q1;
private TinyFormulaWithEditLabel min;
public BoxPlotReportResultDataSeriesPane() { public BoxPlotReportResultDataSeriesPane() {
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
@ -42,11 +43,12 @@ public class BoxPlotReportResultDataSeriesPane extends AbstractReportDataContent
category = createTinyFormulaPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Category")); category = createTinyFormulaPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Category"));
seriesName = createTinyFormulaPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Series_Name")); seriesName = createTinyFormulaPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Series_Name"));
max = createTinyFormulaPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Data_Max"));
q3 = createTinyFormulaPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Data_Q3")); max = createTinyFormulaWithEditLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Max"));
median = createTinyFormulaPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Data_Median")); q3 = createTinyFormulaWithEditLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Q3"));
q1 = createTinyFormulaPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Data_Q1")); median = createTinyFormulaWithEditLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Median"));
min = createTinyFormulaPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Data_Min")); q1 = createTinyFormulaWithEditLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Q1"));
min = createTinyFormulaWithEditLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Min"));
} }
private JPanel createContentPane() { private JPanel createContentPane() {
@ -85,6 +87,25 @@ public class BoxPlotReportResultDataSeriesPane extends AbstractReportDataContent
}; };
} }
private TinyFormulaWithEditLabel createTinyFormulaWithEditLabel(String title) {
return new TinyFormulaWithEditLabel(title) {
protected void clearAllBackground() {
clearAllLabelBackground();
}
};
}
private void clearAllLabelBackground() {
TinyFormulaWithEditLabel[] editLabels = new TinyFormulaWithEditLabel[]{max, q3, median, q1, min};
for (TinyFormulaWithEditLabel label : editLabels) {
if (label != null) {
label.clearBackGround();
}
}
}
public void populateBean(ChartCollection ob) { public void populateBean(ChartCollection ob) {
VanBoxReportResultDefinition detailedDefinition = BoxReportDefinitionHelper.getBoxReportResultDefinition(ob); VanBoxReportResultDefinition detailedDefinition = BoxReportDefinitionHelper.getBoxReportResultDefinition(ob);
@ -94,11 +115,18 @@ public class BoxPlotReportResultDataSeriesPane extends AbstractReportDataContent
populateFormulaPane(category, detailedDefinition.getCategoryName()); populateFormulaPane(category, detailedDefinition.getCategoryName());
populateFormulaPane(seriesName, detailedDefinition.getSeriesName()); populateFormulaPane(seriesName, detailedDefinition.getSeriesName());
populateFormulaPane(max, detailedDefinition.getMax());
populateFormulaPane(q3, detailedDefinition.getQ3()); max.setHeaderName(detailedDefinition.getMaxLabel());
populateFormulaPane(median, detailedDefinition.getMedian()); q3.setHeaderName(detailedDefinition.getQ3Label());
populateFormulaPane(q1, detailedDefinition.getQ1()); median.setHeaderName(detailedDefinition.getMedianLabel());
populateFormulaPane(min, detailedDefinition.getMin()); q1.setHeaderName(detailedDefinition.getQ1Label());
min.setHeaderName(detailedDefinition.getMinLabel());
max.populateFormula(detailedDefinition.getMax());
q3.populateFormula(detailedDefinition.getQ3());
median.populateFormula(detailedDefinition.getMedian());
q1.populateFormula(detailedDefinition.getQ1());
min.populateFormula(detailedDefinition.getMin());
} }
private void populateFormulaPane(TinyFormulaPane pane, Object ob) { private void populateFormulaPane(TinyFormulaPane pane, Object ob) {
@ -118,11 +146,18 @@ public class BoxPlotReportResultDataSeriesPane extends AbstractReportDataContent
resultDefinition.setCategoryName(canBeFormula(category.getUITextField().getText())); resultDefinition.setCategoryName(canBeFormula(category.getUITextField().getText()));
resultDefinition.setSeriesName(canBeFormula(seriesName.getUITextField().getText())); resultDefinition.setSeriesName(canBeFormula(seriesName.getUITextField().getText()));
resultDefinition.setMax(canBeFormula(max.getUITextField().getText()));
resultDefinition.setQ3(canBeFormula(q3.getUITextField().getText())); resultDefinition.setMaxLabel(max.getHeaderName());
resultDefinition.setMedian(canBeFormula(median.getUITextField().getText())); resultDefinition.setQ3Label(q3.getHeaderName());
resultDefinition.setQ1(canBeFormula(q1.getUITextField().getText())); resultDefinition.setMedianLabel(median.getHeaderName());
resultDefinition.setMin(canBeFormula(min.getUITextField().getText())); resultDefinition.setQ1Label(q1.getHeaderName());
resultDefinition.setMinLabel(min.getHeaderName());
resultDefinition.setMax(canBeFormula(max.updateFormula()));
resultDefinition.setQ3(canBeFormula(q3.updateFormula()));
resultDefinition.setMedian(canBeFormula(median.updateFormula()));
resultDefinition.setQ1(canBeFormula(q1.updateFormula()));
resultDefinition.setMin(canBeFormula(min.updateFormula()));
report.setResultDefinition(resultDefinition); report.setResultDefinition(resultDefinition);
} }

71
designer-chart/src/main/java/com/fr/van/chart/box/data/report/TinyFormulaWithEditLabel.java

@ -0,0 +1,71 @@
package com.fr.van.chart.box.data.report;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.mainframe.chart.gui.UIEditLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Dimension;
public abstract class TinyFormulaWithEditLabel extends JPanel implements UIObserver {
private UIEditLabel editLabel;
private TinyFormulaPane tinyFormulaPane;
protected UIObserverListener listener;
public TinyFormulaWithEditLabel(String text) {
editLabel = new UIEditLabel(text, SwingConstants.LEFT) {
protected void doAfterMousePress() {
clearAllBackground();
}
protected boolean appendOriginalLabel() {
return false;
}
};
editLabel.setPreferredSize(new Dimension(75, 20));
tinyFormulaPane = new TinyFormulaPane();
this.setLayout(new BorderLayout(4, 0));
this.add(editLabel, BorderLayout.WEST);
this.add(tinyFormulaPane, BorderLayout.CENTER);
}
protected abstract void clearAllBackground();
public void clearBackGround() {
editLabel.resetNomalrBackground();
}
public boolean shouldResponseChangeListener() {
return true;
}
public void registerChangeListener(UIObserverListener listener) {
this.listener = listener;
editLabel.registerChangeListener(listener);
}
public void populateFormula(Object ob) {
if (ob != null) {
tinyFormulaPane.populateBean(ob.toString());
}
}
public Object updateFormula() {
return tinyFormulaPane.getUITextField().getText();
}
public String getHeaderName() {
return editLabel.getText();
}
public void setHeaderName(String text) {
editLabel.setText(text);
}
}

155
designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableResultDataSeriesPane.java

@ -6,12 +6,12 @@ import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.plugin.chart.box.data.VanBoxTableDefinition; import com.fr.plugin.chart.box.data.VanBoxTableDefinition;
import com.fr.plugin.chart.box.data.VanBoxTableResultDefinition; import com.fr.plugin.chart.box.data.VanBoxTableResultDefinition;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -24,11 +24,15 @@ public class BoxPlotTableResultDataSeriesPane extends AbstractTableDataContentPa
private UIComboBox category; private UIComboBox category;
private UIComboBox seriesName; private UIComboBox seriesName;
private UIComboBox max;
private UIComboBox q3; private JPanel categoryPane;
private UIComboBox median; private JPanel seriesNamePane;
private UIComboBox q1;
private UIComboBox min; private UIComboBoxWithEditLabel max;
private UIComboBoxWithEditLabel q3;
private UIComboBoxWithEditLabel median;
private UIComboBoxWithEditLabel q1;
private UIComboBoxWithEditLabel min;
public BoxPlotTableResultDataSeriesPane() { public BoxPlotTableResultDataSeriesPane() {
@ -41,23 +45,49 @@ public class BoxPlotTableResultDataSeriesPane extends AbstractTableDataContentPa
} }
private void initComboxSize() { private void initComboxSize() {
Dimension preferredSize = new Dimension(100, 20);
category = new UIComboBox(); category = new UIComboBox();
seriesName = new UIComboBox(); seriesName = new UIComboBox();
max = new UIComboBox();
q3 = new UIComboBox(); categoryPane = createUIComboBoxPane(category, Toolkit.i18nText("Fine-Design_Chart_Category"));
median = new UIComboBox(); seriesNamePane = createUIComboBoxPane(seriesName, Toolkit.i18nText("Fine-Design_Chart_Series_Name"));
q1 = new UIComboBox();
min = new UIComboBox(); max = createUIComboBoxWithEditLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Max"));
q3 = createUIComboBoxWithEditLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Q3"));
category.setPreferredSize(preferredSize); median = createUIComboBoxWithEditLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Median"));
seriesName.setPreferredSize(preferredSize); q1 = createUIComboBoxWithEditLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Q1"));
max.setPreferredSize(preferredSize); min = createUIComboBoxWithEditLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Min"));
q3.setPreferredSize(preferredSize); }
median.setPreferredSize(preferredSize);
q1.setPreferredSize(preferredSize); private JPanel createUIComboBoxPane(UIComboBox comboBox, String title) {
min.setPreferredSize(preferredSize); UILabel label = new UILabel(title);
label.setPreferredSize(new Dimension(75, 20));
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout(4, 0));
panel.add(label, BorderLayout.WEST);
panel.add(comboBox, BorderLayout.CENTER);
return panel;
}
private UIComboBoxWithEditLabel createUIComboBoxWithEditLabel(String title) {
return new UIComboBoxWithEditLabel(title) {
protected void clearAllBackground() {
clearAllLabelBackground();
}
};
}
private void clearAllLabelBackground() {
UIComboBoxWithEditLabel[] editLabels = new UIComboBoxWithEditLabel[]{max, q3, median, q1, min};
for (UIComboBoxWithEditLabel label : editLabels) {
if (label != null) {
label.clearBackGround();
}
}
} }
private void addItemListener() { private void addItemListener() {
@ -73,24 +103,23 @@ public class BoxPlotTableResultDataSeriesPane extends AbstractTableDataContentPa
private JPanel createDataSeriesPane() { private JPanel createDataSeriesPane() {
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] column = {f, COMPONENT_WIDTH};
double[] row = {p, p, p, p, p, p, p}; double[] row = {p, p, p, p, p, p, p};
double[] col = {f};
Component[][] components_north = new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Category")), category}, Component[][] components = new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Series_Name")), seriesName}, new Component[]{categoryPane},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Data_Max")), max}, new Component[]{seriesNamePane},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Data_Q3")), q3}, new Component[]{max},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Data_Median")), median}, new Component[]{q3},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Data_Q1")), q1}, new Component[]{median},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Data_Min")), min}, new Component[]{q1},
new Component[]{min}
}; };
JPanel center = TableLayout4VanChartHelper.createGapTableLayoutPane(components_north, row, column); JPanel panel = TableLayoutHelper.createTableLayoutPane(components, row, col);
center.setBorder(BorderFactory.createEmptyBorder(10, 24, 10, 15)); panel.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 15));
return center; return panel;
} }
public void checkBoxUse(boolean hasUse) { public void checkBoxUse(boolean hasUse) {
@ -99,21 +128,23 @@ public class BoxPlotTableResultDataSeriesPane extends AbstractTableDataContentPa
protected void refreshBoxListWithSelectTableData(List list) { protected void refreshBoxListWithSelectTableData(List list) {
refreshBoxItems(category, list); refreshBoxItems(category, list);
refreshBoxItems(seriesName, list); refreshBoxItems(seriesName, list);
refreshBoxItems(max, list);
refreshBoxItems(q3, list); refreshBoxItems(max.getComboBox(), list);
refreshBoxItems(median, list); refreshBoxItems(q3.getComboBox(), list);
refreshBoxItems(q1, list); refreshBoxItems(median.getComboBox(), list);
refreshBoxItems(min, list); refreshBoxItems(q1.getComboBox(), list);
refreshBoxItems(min.getComboBox(), list);
} }
public void clearAllBoxList() { public void clearAllBoxList() {
clearBoxItems(category); clearBoxItems(category);
clearBoxItems(seriesName); clearBoxItems(seriesName);
clearBoxItems(max);
clearBoxItems(q3); clearBoxItems(max.getComboBox());
clearBoxItems(median); clearBoxItems(q3.getComboBox());
clearBoxItems(q1); clearBoxItems(median.getComboBox());
clearBoxItems(min); clearBoxItems(q1.getComboBox());
clearBoxItems(min.getComboBox());
} }
public void populateBean(ChartCollection collection) { public void populateBean(ChartCollection collection) {
@ -127,11 +158,18 @@ public class BoxPlotTableResultDataSeriesPane extends AbstractTableDataContentPa
combineCustomEditValue(category, definition.getCategoryName()); combineCustomEditValue(category, definition.getCategoryName());
combineCustomEditValue(seriesName, definition.getSeriesName()); combineCustomEditValue(seriesName, definition.getSeriesName());
combineCustomEditValue(max, definition.getMax());
combineCustomEditValue(q3, definition.getQ3()); max.populateComboBox(definition.getMax());
combineCustomEditValue(median, definition.getMedian()); q3.populateComboBox(definition.getQ3());
combineCustomEditValue(q1, definition.getQ1()); median.populateComboBox(definition.getMedian());
combineCustomEditValue(min, definition.getMin()); q1.populateComboBox(definition.getQ1());
min.populateComboBox(definition.getMin());
max.setHeaderName(definition.getMaxLabel());
q3.setHeaderName(definition.getQ3Label());
median.setHeaderName(definition.getMedianLabel());
q1.setHeaderName(definition.getQ1Label());
min.setHeaderName(definition.getMinLabel());
} }
public void updateBean(ChartCollection collection) { public void updateBean(ChartCollection collection) {
@ -141,11 +179,12 @@ public class BoxPlotTableResultDataSeriesPane extends AbstractTableDataContentPa
Object resultCategory = category.getSelectedItem(); Object resultCategory = category.getSelectedItem();
Object resultSeries = seriesName.getSelectedItem(); Object resultSeries = seriesName.getSelectedItem();
Object resultMax = max.getSelectedItem();
Object resultQ3 = q3.getSelectedItem(); Object resultMax = max.updateComboBox();
Object resultMedian = median.getSelectedItem(); Object resultQ3 = q3.updateComboBox();
Object resultQ1 = q1.getSelectedItem(); Object resultMedian = median.updateComboBox();
Object resultMin = min.getSelectedItem(); Object resultQ1 = q1.updateComboBox();
Object resultMin = min.updateComboBox();
if (resultCategory == null || ArrayUtils.contains(ChartConstants.getNoneKeys(), resultCategory)) { if (resultCategory == null || ArrayUtils.contains(ChartConstants.getNoneKeys(), resultCategory)) {
definition.setCategoryName(StringUtils.EMPTY); definition.setCategoryName(StringUtils.EMPTY);
@ -173,6 +212,12 @@ public class BoxPlotTableResultDataSeriesPane extends AbstractTableDataContentPa
definition.setMin(resultMin.toString()); definition.setMin(resultMin.toString());
} }
definition.setMaxLabel(max.getHeaderName());
definition.setQ3Label(q3.getHeaderName());
definition.setMedianLabel(median.getHeaderName());
definition.setQ1Label(q1.getHeaderName());
definition.setMinLabel(min.getHeaderName());
table.setResultDefinition(definition); table.setResultDefinition(definition);
} }
} }

86
designer-chart/src/main/java/com/fr/van/chart/box/data/table/UIComboBoxWithEditLabel.java

@ -0,0 +1,86 @@
package com.fr.van.chart.box.data.table;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.mainframe.chart.gui.UIEditLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ItemListener;
public abstract class UIComboBoxWithEditLabel extends JPanel implements UIObserver {
private UIEditLabel editLabel;
private UIComboBox comboBox;
protected UIObserverListener listener;
public UIComboBoxWithEditLabel(String text) {
editLabel = new UIEditLabel(text, SwingConstants.LEFT) {
protected void doAfterMousePress() {
clearAllBackground();
}
protected boolean appendOriginalLabel() {
return false;
}
};
editLabel.setPreferredSize(new Dimension(75, 20));
comboBox = new UIComboBox();
this.setLayout(new BorderLayout(4, 0));
this.add(editLabel, BorderLayout.WEST);
this.add(comboBox, BorderLayout.CENTER);
}
public UIComboBox getComboBox() {
return comboBox;
}
public void setComboBox(UIComboBox comboBox) {
this.comboBox = comboBox;
}
protected void addItemListener(ItemListener aListener) {
comboBox.addItemListener(aListener);
}
protected abstract void clearAllBackground();
public void clearBackGround() {
editLabel.resetNomalrBackground();
}
public boolean shouldResponseChangeListener() {
return true;
}
public void registerChangeListener(UIObserverListener listener) {
this.listener = listener;
editLabel.registerChangeListener(listener);
}
public void populateComboBox(String value) {
if (comboBox != null) {
comboBox.setEditable(true);
comboBox.setSelectedItem(value);
comboBox.setEditable(false);
}
}
public Object updateComboBox() {
return comboBox.getSelectedItem();
}
public String getHeaderName() {
return editLabel.getText();
}
public void setHeaderName(String text) {
editLabel.setText(text);
}
}
Loading…
Cancel
Save