Browse Source

数据面板自定义(数据集数据不用下拉框&单元格数据不用公式输入框)。

master
zheng 6 years ago
parent
commit
ad31a8f43a
  1. 2
      src/com/fr/plugin/demo/DemoChart.java
  2. 16
      src/com/fr/plugin/demo/DemoDataConfig.java
  3. 23
      src/com/fr/plugin/demo/DemoReportDataPane.java
  4. 23
      src/com/fr/plugin/demo/DemoTableDataPane.java

2
src/com/fr/plugin/demo/DemoChart.java

@ -134,6 +134,8 @@ public class DemoChart extends AbstractChart<DemoDataConfig>{
List<Object> yValues = dataConfig.getY().getValues(); List<Object> yValues = dataConfig.getY().getValues();
List<Object> zValues = dataConfig.getZ().getValues(); List<Object> zValues = dataConfig.getZ().getValues();
jsonObject.put("targetName", dataConfig.getTargetName());
for (int i = 0, len = xValues.size(); i < len; i++) { for (int i = 0, len = xValues.size(); i < len; i++) {
maxValue = Math.max(GeneralUtils.objectToNumber(zValues.get(i)).doubleValue(), maxValue); maxValue = Math.max(GeneralUtils.objectToNumber(zValues.get(i)).doubleValue(), maxValue);

16
src/com/fr/plugin/demo/DemoDataConfig.java

@ -2,7 +2,6 @@ package com.fr.plugin.demo;
import com.fr.extended.chart.AbstractDataConfig; import com.fr.extended.chart.AbstractDataConfig;
import com.fr.extended.chart.ExtendedField; import com.fr.extended.chart.ExtendedField;
import com.fr.general.ComparatorUtils;
import com.fr.stable.AssistUtils; import com.fr.stable.AssistUtils;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
@ -13,6 +12,7 @@ import com.fr.stable.xml.XMLableReader;
public class DemoDataConfig extends AbstractDataConfig { public class DemoDataConfig extends AbstractDataConfig {
private ExtendedField x = new ExtendedField(); private ExtendedField x = new ExtendedField();
private String targetName;
private ExtendedField y = new ExtendedField(); private ExtendedField y = new ExtendedField();
private ExtendedField z = new ExtendedField(); private ExtendedField z = new ExtendedField();
@ -40,9 +40,18 @@ public class DemoDataConfig extends AbstractDataConfig {
this.z = z; this.z = z;
} }
public String getTargetName() {
return targetName;
}
public void setTargetName(String targetName) {
this.targetName = targetName;
}
@Override @Override
protected void readAttr(XMLableReader reader) { protected void readAttr(XMLableReader reader) {
readExtendedField(x, "x", reader); readExtendedField(x, "x", reader);
this.setTargetName(reader.getAttrAsString("targetName", ""));
readExtendedField(y, "y", reader); readExtendedField(y, "y", reader);
readExtendedField(z, "z", reader); readExtendedField(z, "z", reader);
} }
@ -50,6 +59,7 @@ public class DemoDataConfig extends AbstractDataConfig {
@Override @Override
protected void writeAttr(XMLPrintWriter writer) { protected void writeAttr(XMLPrintWriter writer) {
writeExtendedField(x, "x", writer); writeExtendedField(x, "x", writer);
writer.attr("targetName", this.getTargetName());
writeExtendedField(y, "y", writer); writeExtendedField(y, "y", writer);
writeExtendedField(z, "z", writer); writeExtendedField(z, "z", writer);
} }
@ -67,6 +77,7 @@ public class DemoDataConfig extends AbstractDataConfig {
public DemoDataConfig clone() throws CloneNotSupportedException { public DemoDataConfig clone() throws CloneNotSupportedException {
DemoDataConfig result = new DemoDataConfig(); DemoDataConfig result = new DemoDataConfig();
result.setX(this.getX().clone()); result.setX(this.getX().clone());
result.setTargetName(this.getTargetName());
result.setY(this.getY().clone()); result.setY(this.getY().clone());
result.setZ(this.getZ().clone()); result.setZ(this.getZ().clone());
return result; return result;
@ -74,13 +85,14 @@ public class DemoDataConfig extends AbstractDataConfig {
@Override @Override
public int hashCode() { public int hashCode() {
return super.hashCode() + AssistUtils.hashCode(this.getX(), this.getY(), this.getZ()); return super.hashCode() + AssistUtils.hashCode(this.getX(), this.getY(), this.getZ(), this.getTargetName());
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
return obj instanceof DemoDataConfig return obj instanceof DemoDataConfig
&& AssistUtils.equals(this.getX(), ((DemoDataConfig) obj).getX()) && AssistUtils.equals(this.getX(), ((DemoDataConfig) obj).getX())
&& AssistUtils.equals(this.getTargetName(), ((DemoDataConfig) obj).getTargetName())
&& AssistUtils.equals(this.getY(), ((DemoDataConfig) obj).getY()) && AssistUtils.equals(this.getY(), ((DemoDataConfig) obj).getY())
&& AssistUtils.equals(this.getZ(), ((DemoDataConfig) obj).getZ()) && AssistUtils.equals(this.getZ(), ((DemoDataConfig) obj).getZ())
; ;

23
src/com/fr/plugin/demo/DemoReportDataPane.java

@ -1,14 +1,18 @@
package com.fr.plugin.demo; package com.fr.plugin.demo;
import com.fr.design.formula.TinyFormulaPane; import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.extended.chart.AbstractExtendedChartReportDataPane; import com.fr.extended.chart.AbstractExtendedChartReportDataPane;
import java.awt.Component;
/** /**
* Created by shine on 2018/3/24. * Created by shine on 2018/3/24.
*/ */
public class DemoReportDataPane extends AbstractExtendedChartReportDataPane<DemoDataConfig> { public class DemoReportDataPane extends AbstractExtendedChartReportDataPane<DemoDataConfig> {
private TinyFormulaPane xPane; private TinyFormulaPane xPane;
private UITextField targetName;
private TinyFormulaPane yPane; private TinyFormulaPane yPane;
private TinyFormulaPane zPane; private TinyFormulaPane zPane;
@ -16,11 +20,28 @@ public class DemoReportDataPane extends AbstractExtendedChartReportDataPane<Demo
protected String[] fieldLabel() { protected String[] fieldLabel() {
return new String[]{ return new String[]{
"X轴", "X轴",
"指标名",
"Y轴", "Y轴",
"Z轴" "Z轴"
}; };
} }
@Override
protected Component[] fieldComponents() {
if (xPane == null) {
xPane = new TinyFormulaPane();
targetName = new UITextField();
yPane = new TinyFormulaPane();
zPane = new TinyFormulaPane();
}
return new Component[]{
xPane,
targetName,
yPane,
zPane
};
}
@Override @Override
protected TinyFormulaPane[] formulaPanes() { protected TinyFormulaPane[] formulaPanes() {
if (xPane == null) { if (xPane == null) {
@ -38,6 +59,7 @@ public class DemoReportDataPane extends AbstractExtendedChartReportDataPane<Demo
@Override @Override
protected void populate(DemoDataConfig dataConf) { protected void populate(DemoDataConfig dataConf) {
populateField(xPane, dataConf.getX()); populateField(xPane, dataConf.getX());
targetName.setText(dataConf.getTargetName());
populateField(yPane, dataConf.getY()); populateField(yPane, dataConf.getY());
populateField(zPane, dataConf.getZ()); populateField(zPane, dataConf.getZ());
} }
@ -47,6 +69,7 @@ public class DemoReportDataPane extends AbstractExtendedChartReportDataPane<Demo
DemoDataConfig dataConfig = new DemoDataConfig(); DemoDataConfig dataConfig = new DemoDataConfig();
updateField(xPane, dataConfig.getX()); updateField(xPane, dataConfig.getX());
dataConfig.setTargetName(targetName.getText());
updateField(yPane, dataConfig.getY()); updateField(yPane, dataConfig.getY());
updateField(zPane, dataConfig.getZ()); updateField(zPane, dataConfig.getZ());

23
src/com/fr/plugin/demo/DemoTableDataPane.java

@ -1,13 +1,17 @@
package com.fr.plugin.demo; package com.fr.plugin.demo;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.extended.chart.AbstractExtendedChartTableDataPane; import com.fr.extended.chart.AbstractExtendedChartTableDataPane;
import java.awt.Component;
/** /**
* Created by shine on 2018/3/24. * Created by shine on 2018/3/24.
*/ */
public class DemoTableDataPane extends AbstractExtendedChartTableDataPane<DemoDataConfig>{ public class DemoTableDataPane extends AbstractExtendedChartTableDataPane<DemoDataConfig>{
private UIComboBox xComboBox; private UIComboBox xComboBox;
private UITextField targetName;
private UIComboBox yComboBox; private UIComboBox yComboBox;
private UIComboBox zComboBox; private UIComboBox zComboBox;
@ -15,11 +19,28 @@ public class DemoTableDataPane extends AbstractExtendedChartTableDataPane<DemoDa
protected String[] fieldLabels() { protected String[] fieldLabels() {
return new String[]{ return new String[]{
"X轴", "X轴",
"指标名",
"Y轴", "Y轴",
"Z轴" "Z轴"
}; };
} }
@Override
protected Component[] fieldComponents() {
if (xComboBox == null) {
xComboBox = new UIComboBox();
targetName = new UITextField();
yComboBox = new UIComboBox();
zComboBox = new UIComboBox();
}
return new Component[]{
xComboBox,
targetName,
yComboBox,
zComboBox
};
}
@Override @Override
protected UIComboBox[] filedComboBoxes() { protected UIComboBox[] filedComboBoxes() {
if (xComboBox == null) { if (xComboBox == null) {
@ -37,6 +58,7 @@ public class DemoTableDataPane extends AbstractExtendedChartTableDataPane<DemoDa
@Override @Override
protected void populate(DemoDataConfig dataConf) { protected void populate(DemoDataConfig dataConf) {
populateField(xComboBox, dataConf.getX()); populateField(xComboBox, dataConf.getX());
targetName.setText(dataConf.getTargetName());
populateField(yComboBox, dataConf.getY()); populateField(yComboBox, dataConf.getY());
populateField(zComboBox, dataConf.getZ()); populateField(zComboBox, dataConf.getZ());
} }
@ -46,6 +68,7 @@ public class DemoTableDataPane extends AbstractExtendedChartTableDataPane<DemoDa
DemoDataConfig dataConfig = new DemoDataConfig(); DemoDataConfig dataConfig = new DemoDataConfig();
updateField(xComboBox, dataConfig.getX()); updateField(xComboBox, dataConfig.getX());
dataConfig.setTargetName(targetName.getText());
updateField(yComboBox, dataConfig.getY()); updateField(yComboBox, dataConfig.getY());
updateField(zComboBox, dataConfig.getZ()); updateField(zComboBox, dataConfig.getZ());

Loading…
Cancel
Save