Browse Source

Pull request #1727: CHART-11701 仪表盘百分比设置逻辑优化

Merge in DESIGN/design from ~BJORN/design:release/10.0 to release/10.0

* commit '4d85a74ecac09cec5ce5fd08350120a9329eadb1':
  CHART-11701 仪表盘百分比设置逻辑优化
feature/big-screen
Bjorn 4 years ago
parent
commit
4f1e136abe
  1. 49
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/MeterPlotReportDataContentPane.java
  2. 106
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/MeterPlotTableDataContentPane.java
  3. 25
      designer-chart/src/main/java/com/fr/van/chart/designer/data/OneDimensionalPlotReportDataContentPane.java
  4. 33
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java

49
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/MeterPlotReportDataContentPane.java

@ -6,11 +6,11 @@ import com.fr.chart.chartattr.MeterPlot;
import com.fr.chart.chartdata.MeterReportDefinition;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.ChartDataFilterPane;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.BorderFactory;
@ -20,16 +20,19 @@ import java.awt.Component;
/**
* 仪表盘 属性表 单元格数据界面
*
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2012-12-21 下午02:47:57
*/
public class MeterPlotReportDataContentPane extends AbstractReportDataContentPane {
private static final String CATENAME = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Category_Name");
private static final String NVALUE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Pointer_Value");
private static final String CATENAME = Toolkit.i18nText("Fine-Design_Chart_Category_Name");
private static final String NVALUE = Toolkit.i18nText("Fine-Design_Chart_Pointer_Value");
private static final String TARGET_VALUE = Toolkit.i18nText("Fine-Design_Chart_Target_Value");
private TinyFormulaPane singCatePane;
private TinyFormulaPane singValuePane;
public TinyFormulaPane singValuePane;
private TinyFormulaPane customPane;
private ChartDataFilterPane filterPane;
public MeterPlotReportDataContentPane(ChartDataPane parent) {
@ -45,16 +48,12 @@ public class MeterPlotReportDataContentPane extends AbstractReportDataContentPan
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f};
double[] rowSize = { p, p, p};
double[] rowSize = getRowSize();
Component[][] components = new Component[][]{
new Component[]{new UILabel(getCateNameString()), getSingCatePane()},
new Component[]{new UILabel(getNValueString()), singValuePane = new TinyFormulaPane()},
new Component[]{null, null}
};
Component[][] components = getShowComponents();
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 24, 6);
panel.setBorder(BorderFactory.createEmptyBorder(0,24,0,15));
panel.setBorder(BorderFactory.createEmptyBorder(0, 24, 5, 15));
this.setLayout(new BorderLayout());
this.add(panel, BorderLayout.NORTH);
@ -66,6 +65,19 @@ public class MeterPlotReportDataContentPane extends AbstractReportDataContentPan
this.add(pane, BorderLayout.CENTER);
}
protected double[] getRowSize() {
double p = TableLayout.PREFERRED;
return new double[]{p, p, p};
}
protected Component[][] getShowComponents() {
return new Component[][]{
new Component[]{new UILabel(getCateNameString()), getSingCatePane()},
new Component[]{new UILabel(getNValueString()), singValuePane = new TinyFormulaPane()},
new Component[]{new UILabel(TARGET_VALUE), customPane = new TinyFormulaPane()}
};
}
protected String getCateNameString() {
return CATENAME;
}
@ -85,11 +97,18 @@ public class MeterPlotReportDataContentPane extends AbstractReportDataContentPan
if (meterDefinition.getValue() != null) {
singValuePane.getUITextField().setText(meterDefinition.getValue().toString());
}
if (meterDefinition.getTarget() != null) {
populateCustomPane(meterDefinition.getTarget().toString());
}
}
filterPane.populateBean(collection);
}
protected void populateCustomPane(String target) {
customPane.getUITextField().setText(target);
}
protected void populateSingCatePane(String name) {
singCatePane.getUITextField().setText(name);
}
@ -103,12 +122,20 @@ public class MeterPlotReportDataContentPane extends AbstractReportDataContentPan
meterDefinition.setValue(canBeFormula(singValuePane.getUITextField().getText()));
updateCustomPane(meterDefinition);
collection.getSelectedChart().setFilterDefinition(meterDefinition);
filterPane.updateBean(collection);
}
}
protected void updateCustomPane(MeterReportDefinition meterDefinition) {
meterDefinition.setTarget(canBeFormula(customPane.getUITextField().getText()));
}
protected void updateSingCatePane(MeterReportDefinition meterDefinition) {
meterDefinition.setName(canBeFormula(singCatePane.getUITextField().getText()));

106
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/MeterPlotTableDataContentPane.java

@ -4,73 +4,121 @@ import com.fr.base.Utils;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.MeterPlot;
import com.fr.chart.chartdata.MeterTableDefinition;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.ChartDataFilterPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.extended.chart.StringFormula;
import com.fr.extended.chart.UIComboBoxWithNone;
import com.fr.general.GeneralUtils;
import com.fr.stable.StringUtils;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import java.util.List;
import java.awt.BorderLayout;
import java.awt.Component;
import java.util.List;
import java.awt.Dimension;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* 仪表盘, 属性表, 数据集数据界面.
*
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2012-12-21 下午04:51:50
*/
public class MeterPlotTableDataContentPane extends AbstractTableDataContentPane {
private static final String METER_NAME = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Format_Category_Name");
private static final String METER_VALUE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Pointer_Value");
private static final String METER_NAME = Toolkit.i18nText("Fine-Design_Chart_Style_Format_Category_Name");
private static final String METER_VALUE = Toolkit.i18nText("Fine-Design_Chart_Pointer_Value");
private static final String TARGET_VALUE = Toolkit.i18nText("Fine-Design_Chart_Target_Value");
private static final int COMBOBOX_WIDTH = 115;
private static final int COMBOBOX_HEIGHT = 20;
private static final int LABEL_WIDTH = 85;
private UIComboBox nameBox;
private UIComboBox valueBox;
private UIComboBox targetBox;
private TinyFormulaPane custom;
private ChartDataFilterPane filterPane;
private JPanel boxPane;
public MeterPlotTableDataContentPane(ChartDataPane parent) {
this.setLayout(new BorderLayout());
nameBox = new UIComboBox();
nameBox = new UIComboBoxWithNone();
valueBox = new UIComboBox();
targetBox = new UIComboBox();
custom = new TinyFormulaPane();
filterPane = new ChartDataFilterPane(new MeterPlot(), parent);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {f, COMPONENT_WIDTH};
double[] rowSize = {p, p};
boxPane = new JPanel();
boxPane.setLayout(new BoxLayout(boxPane, BoxLayout.Y_AXIS));
JPanel namePane = createPaneWithLabel(Toolkit.i18nText(METER_NAME), getNameComponent());
boxPane.add(namePane);
JPanel valuePane = createPaneWithLabel(Toolkit.i18nText(METER_VALUE), valueBox);
boxPane.add(valuePane);
JPanel targetPane = createPaneWithLabel(Toolkit.i18nText(TARGET_VALUE), targetBox);
boxPane.add(targetPane);
Component[][] components = createComponents();
final JPanel customPane = createPaneWithLabel(StringUtils.EMPTY, custom);
boxPane.add(customPane);
customPane.setVisible(false);
initTargetBoxValue();
targetBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (targetBox.getSelectedIndex() == targetBox.getItemCount() - 1) {
customPane.setVisible(true);
} else {
customPane.setVisible(false);
}
}
});
JPanel jPanel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), filterPane);
JPanel panel = TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize);
filterPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 15));
panel.setBorder(BorderFactory.createEmptyBorder(10,24,10,15));
boxPane.setBorder(BorderFactory.createEmptyBorder(7, 24, 7, 15));
jPanel.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 5));
this.add(getJSeparator(), BorderLayout.NORTH);
this.add(panel,BorderLayout.CENTER);
this.add(boxPane, BorderLayout.CENTER);
this.add(jPanel, BorderLayout.SOUTH);
nameBox.addItemListener(tooltipListener);
valueBox.addItemListener(tooltipListener);
targetBox.addItemListener(tooltipListener);
}
private Component[][] createComponents() {
return new Component[][]{
new Component[]{new BoldFontTextLabel(METER_NAME), getNameComponent()},
new Component[]{new BoldFontTextLabel(METER_VALUE), valueBox},
};
private JPanel createPaneWithLabel(String labelName, Component component) {
component.setPreferredSize(new Dimension(COMBOBOX_WIDTH, COMBOBOX_HEIGHT));
UILabel label = new BoldFontTextLabel(labelName);
label.setPreferredSize(new Dimension(LABEL_WIDTH, COMBOBOX_HEIGHT));
JPanel paneWithLabel = GUICoreUtils.createBorderLayoutPane(new Component[]{component, null, null, label, null});
paneWithLabel.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0));
return paneWithLabel;
}
protected void refreshBoxListWithSelectTableData(List list) {
refreshBoxItems(nameBox, list);
refreshBoxItems(valueBox, list);
refreshBoxItems(targetBox, list);
initTargetBoxValue();
}
/**
@ -81,6 +129,11 @@ public class MeterPlotTableDataContentPane extends AbstractTableDataContentPane
clearBoxItems(valueBox);
}
private void initTargetBoxValue() {
targetBox.addItem(Toolkit.i18nText("Fine-Design_Chart_Custom"));
targetBox.setSelectedItem(null);
}
/**
* 更新仪表盘数据界面
*/
@ -91,6 +144,12 @@ public class MeterPlotTableDataContentPane extends AbstractTableDataContentPane
populateNameComponent(meter);
valueBox.setSelectedItem(meter.getValue());
custom.getUITextField().setText(meter.getCustomTarget().getContent());
if (meter.isCustom()) {
targetBox.setSelectedIndex(targetBox.getItemCount() - 1);
} else {
targetBox.setSelectedItem(meter.getTargetValue());
}
filterPane.populateBean(ob);
}
}
@ -110,6 +169,13 @@ public class MeterPlotTableDataContentPane extends AbstractTableDataContentPane
updateNameComponent(meter);
meter.setValue(Utils.objectToString(valueBox.getSelectedItem()));
if (targetBox.getSelectedIndex() == targetBox.getItemCount() - 1) {
meter.setCustom(true);
meter.setCustomTarget(new StringFormula(custom.getUITextField().getText()));
} else {
meter.setCustom(false);
meter.setTargetValue(GeneralUtils.objectToString(targetBox.getSelectedItem()));
}
filterPane.updateBean(ob);
}
}

25
designer-chart/src/main/java/com/fr/van/chart/designer/data/OneDimensionalPlotReportDataContentPane.java

@ -1,8 +1,13 @@
package com.fr.van.chart.designer.data;
import com.fr.chart.chartdata.MeterReportDefinition;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.report.MeterPlotReportDataContentPane;
import java.awt.Component;
/**
@ -23,4 +28,24 @@ public class OneDimensionalPlotReportDataContentPane extends MeterPlotReportData
protected String getNValueString() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Value");
}
@Override
protected double[] getRowSize() {
double p = TableLayout.PREFERRED;
return new double[]{p, p, p};
}
@Override
protected Component[][] getShowComponents() {
return new Component[][]{
new Component[]{new UILabel(getCateNameString()), getSingCatePane()},
new Component[]{new UILabel(getNValueString()), singValuePane = new TinyFormulaPane()},
};
}
protected void populateCustomPane(String target) {
}
protected void updateCustomPane(MeterReportDefinition meterDefinition) {
}
}

33
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java

@ -9,7 +9,6 @@ import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithAuto;
import com.fr.design.style.color.ColorSelectBox;
import com.fr.plugin.chart.attr.axis.VanChartAxis;
import com.fr.plugin.chart.attr.axis.VanChartGaugeAxis;
import com.fr.plugin.chart.gauge.VanChartGaugePlot;
@ -18,7 +17,6 @@ import com.fr.plugin.chart.type.GaugeStyle;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.style.VanChartStylePane;
import com.fr.van.chart.designer.style.axis.VanChartValueAxisPane;
import com.fr.van.chart.designer.style.axis.component.MinMaxValuePaneWithOutTick;
import com.fr.van.chart.designer.style.axis.component.VanChartMinMaxValuePane;
import javax.swing.BorderFactory;
@ -112,7 +110,36 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane {
switch (gaugeStyle) {
case RING:
case SLOT:
minMaxValuePane = new MinMaxValuePaneWithOutTick();
minMaxValuePane = new VanChartMinMaxValuePane() {
@Override
protected double[] getRowSize(double p) {
return new double[]{p};
}
@Override
protected Component[][] getShowComponents(JPanel minPaneWithCheckBox, JPanel maxPaneWithCheckBox, JPanel mainPaneWithCheckBox, JPanel secPaneWithCheckBox) {
return new Component[][]{
{minPaneWithCheckBox},
};
}
};
break;
case THERMOMETER:
minMaxValuePane = new VanChartMinMaxValuePane() {
@Override
protected double[] getRowSize(double p) {
return new double[]{p, p, p};
}
@Override
protected Component[][] getShowComponents(JPanel minPaneWithCheckBox, JPanel maxPaneWithCheckBox, JPanel mainPaneWithCheckBox, JPanel secPaneWithCheckBox) {
return new Component[][]{
{minPaneWithCheckBox},
{mainPaneWithCheckBox},
{secPaneWithCheckBox},
};
}
};
break;
default:
minMaxValuePane = new VanChartMinMaxValuePane();

Loading…
Cancel
Save