Browse Source

CHART-22531 多分类轴分层设置标签样式—设计器面板

feature/x
方磊 3 years ago
parent
commit
9105c2d33f
  1. 33
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java
  2. 34
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java
  3. 2
      designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomAxisPane.java
  4. 10
      designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomAxisTabPane.java
  5. 7
      designer-chart/src/main/java/com/fr/van/chart/designer/data/VanChartMoreCateReportDataContentPane.java
  6. 7
      designer-chart/src/main/java/com/fr/van/chart/designer/data/VanChartMoreCateTableDataContentPane.java
  7. 4
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartAxisPane.java
  8. 70
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java
  9. 12
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartCategoryStylePaneWithCheckBox.java

33
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java

@ -26,7 +26,8 @@ import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedHashMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -41,10 +42,10 @@ public class CategoryPlotMoreCateReportDataContentPane extends CategoryPlotRepor
private JPanel boxPane;
private UIButton addButton;
private Map<String, TinyFormulaPane> formualList = new LinkedHashMap<>();
private List<TinyFormulaPane> formualList = new ArrayList<TinyFormulaPane>();
private UIObserverListener uiobListener = null;
public Map<String, TinyFormulaPane> getFormualList() {
public List<TinyFormulaPane> getFormualList() {
return formualList;
}
@ -100,17 +101,12 @@ public class CategoryPlotMoreCateReportDataContentPane extends CategoryPlotRepor
}
private TinyFormulaPane addNewCatePane() {
String uuid = UUIDUtil.generate();
return addNewCatePane(uuid);
}
private TinyFormulaPane addNewCatePane(String uuid) {
final TinyFormulaPane pane = initCategoryBox(StringUtils.EMPTY);
pane.setPreferredSize(new Dimension(100, 16));
pane.registerChangeListener(uiobListener);
formualList.put(uuid, pane);
formualList.add(pane);
final JPanel newButtonPane = new JPanel();
newButtonPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
@ -125,7 +121,7 @@ public class CategoryPlotMoreCateReportDataContentPane extends CategoryPlotRepor
@Override
public void actionPerformed(ActionEvent e) {
boxPane.remove(newButtonPane);
formualList.remove(uuid);
formualList.remove(pane);
checkComponent();
relayoutPane();
}
@ -177,11 +173,11 @@ public class CategoryPlotMoreCateReportDataContentPane extends CategoryPlotRepor
TopDefinitionProvider definition = collection.getSelectedChart().getFilterDefinition();
if (definition instanceof NormalReportDataDefinition) {
NormalReportDataDefinition reportDefinition = (NormalReportDataDefinition) definition;
Map<String, Object> moreCateLabels = reportDefinition.getMoreCateLabels();
if (reportDefinition.getCategoryName() != null && !moreCateLabels.isEmpty()) {
for (Map.Entry<String, Object> entry : moreCateLabels.entrySet()) {
TinyFormulaPane pane = addNewCatePane(entry.getKey());
pane.populateBean(Utils.objectToString(entry.getValue()));
int size = reportDefinition.getMoreCateSize();
if (reportDefinition.getCategoryName() != null && size > 0) {
for(int i = 0; i < size; i++) {
TinyFormulaPane pane = addNewCatePane();
pane.populateBean(Utils.objectToString(reportDefinition.getMoreCateWithIndex(i)));
}
}
}
@ -204,10 +200,9 @@ public class CategoryPlotMoreCateReportDataContentPane extends CategoryPlotRepor
}
protected void updateMoreCate(NormalReportDataDefinition reportDefinition, Plot plot) {
for (Map.Entry<String, TinyFormulaPane> entry : formualList.entrySet()) {
String uuid = entry.getKey();
TinyFormulaPane pane = entry.getValue();
reportDefinition.addMoreCate(uuid, canBeFormula(pane.updateBean()));
for (int i = 0, size = formualList.size(); i < size; i++) {
TinyFormulaPane pane = formualList.get(i);
reportDefinition.addMoreCate(canBeFormula(pane.updateBean()));
}
}
}

34
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java

@ -6,7 +6,6 @@ import com.fr.chart.chartattr.Bar2DPlot;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartdata.NormalTableDataDefinition;
import com.fr.decision.base.util.UUIDUtil;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ibutton.UIButton;
@ -27,9 +26,8 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.LinkedHashMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 多分类轴 的数据集定义界面.
@ -45,12 +43,12 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD
private JPanel boxPane;
private Map<String, UIComboBox> boxList = new LinkedHashMap<>();
private List<UIComboBox> boxList = new ArrayList<UIComboBox>();
private UIButton addButton;
private UIObserverListener uiobListener = null;
public Map<String, UIComboBox> getBoxList() {
public List<UIComboBox> getBoxList() {
return boxList;
}
@ -114,11 +112,6 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD
}
private UIComboBox addNewCombox() {
String uuid = UUIDUtil.generate();
return addNewCombox(uuid);
}
private UIComboBox addNewCombox(String uuid) {
final JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2));
@ -145,7 +138,7 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD
UIButton delButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/toolbarbtn/close.png"));
buttonPane.add(delButton);
boxPane.add(buttonPane);
boxList.put(uuid, combox);
boxList.add(combox);
checkComponent();
@ -153,7 +146,7 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD
@Override
public void actionPerformed(ActionEvent e) {
boxPane.remove(buttonPane);
boxList.remove(uuid);
boxList.remove(combox);
checkComponent();
relayoutPane();
}
@ -227,10 +220,10 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD
TopDefinitionProvider top = collection.getSelectedChart().getFilterDefinition();
if (top instanceof NormalTableDataDefinition) {
NormalTableDataDefinition normal = (NormalTableDataDefinition) top;
Map<String, String> moreCateLabels = normal.getMoreCateLabels();
for(Map.Entry<String, String> entry : moreCateLabels.entrySet()) {
UIComboBox box = addNewCombox(entry.getKey());
box.setSelectedItem(entry.getValue());
int size = normal.getMoreCateSize();
for (int i = 0; i < size; i++) {
UIComboBox box = addNewCombox();
box.setSelectedItem(normal.getMoreCateWithIndex(i));
}
}
@ -256,11 +249,10 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD
}
protected void updateMoreCate(NormalTableDataDefinition normal, Plot plot) {
for (Map.Entry<String, UIComboBox> entry : boxList.entrySet()) {
String uuid = entry.getKey();
UIComboBox comboBox = entry.getValue();
if (comboBox != null && comboBox.getSelectedItem() != null) {
normal.addMoreCate(uuid, comboBox.getSelectedItem().toString());
for (int i = 0, size = boxList.size(); i < size; i++) {
UIComboBox box = boxList.get(i);
if (box.getSelectedItem() != null) {
normal.addMoreCate(box.getSelectedItem().toString());
}
}
}

2
designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomAxisPane.java

@ -54,7 +54,7 @@ public class VanChartCustomAxisPane extends BasicScrollPane<Chart> {
}
if(axisPane != null) {
axisPane.populateBean((VanChartCustomPlot) chart.getPlot());
axisPane.populateBean((VanChart) chart);
}
}

10
designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomAxisTabPane.java

@ -87,11 +87,16 @@ public class VanChartCustomAxisTabPane extends VanChartCustomPlotTabPane<VanChar
}
@Override
public void populateBean(VanChartCustomPlot plot) {
}
/**
* 标准坐标轴属性存在最外层的customPlot的坐标轴变量中
* 不使用标准坐标轴的坐标轴属性存在相应的plot中的坐标轴变量中
*/
public void populateBean(VanChartCustomPlot plot) {
public void populateBean(VanChart chart) {
VanChartCustomPlot plot = (VanChartCustomPlot) chart.getPlot();
List<VanChartPlot> customPlotList = plot.getCustomPlotList();
ArrayList<Integer> plotOrder = plot.getDiffAxisOrder();
@ -100,12 +105,13 @@ public class VanChartCustomAxisTabPane extends VanChartCustomPlotTabPane<VanChar
//先更新标准坐标轴界面
//获取相应点的属性,并更新界面
VanChartPlot vanChartPlot = customPlotList.get(plotOrder.get(i));
((VanChartAxisPane)paneList.get(i)).setChart(chart);
((VanChartAxisPane)paneList.get(i)).populateBean(vanChartPlot);
}
if (plot.isHaveStandardAxis()){
((VanChartAxisPane)paneList.get(paneList.size() - 1)).setChart(chart);
((VanChartAxisPane)paneList.get(paneList.size() - 1)).populateBean(plot);
}
}

7
designer-chart/src/main/java/com/fr/van/chart/designer/data/VanChartMoreCateReportDataContentPane.java

@ -3,14 +3,11 @@ package com.fr.van.chart.designer.data;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartdata.NormalReportDataDefinition;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.report.CategoryPlotMoreCateReportDataContentPane;
import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot;
import java.util.Map;
/**
* Created by mengao on 2017/7/3.
*/
@ -44,8 +41,8 @@ public class VanChartMoreCateReportDataContentPane extends CategoryPlotMoreCateR
private void checkBoxList(boolean isSupportMulticategory) {
if (getFormualList().size() != 0) {
for (Map.Entry<String, TinyFormulaPane> entry : getFormualList().entrySet()) {
entry.getValue().setEnabled(isSupportMulticategory);
for (int i = 0; i < getFormualList().size(); i++) {
getFormualList().get(i).setEnabled(isSupportMulticategory);
}
}
}

7
designer-chart/src/main/java/com/fr/van/chart/designer/data/VanChartMoreCateTableDataContentPane.java

@ -3,14 +3,11 @@ package com.fr.van.chart.designer.data;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartdata.NormalTableDataDefinition;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.table.CategoryPlotMoreCateTableDataContentPane;
import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot;
import java.util.Map;
/**
* Created by mengao on 2017/7/3.
*/
@ -46,8 +43,8 @@ public class VanChartMoreCateTableDataContentPane extends CategoryPlotMoreCateTa
private void checkBoxList(boolean isSupportMulticategory) {
if (getBoxList().size() != 0) {
for (Map.Entry<String, UIComboBox> entry : getBoxList().entrySet()) {
entry.getValue().setEnabled(isSupportMulticategory);
for (int i = 0; i < getBoxList().size(); i++) {
getBoxList().get(i).setEnabled(isSupportMulticategory);
}
}
}

4
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartAxisPane.java

@ -287,4 +287,8 @@ public class VanChartAxisPane extends BasicBeanPane<VanChart> {
public VanChart updateBean() {
return null;
}
public void setChart(Chart chart) {
this.chart = chart;
}
}

70
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java

@ -7,8 +7,6 @@ import com.fr.base.chart.chartdata.TopDefinitionProvider;
import com.fr.chart.base.TextAttr;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Title;
import com.fr.chart.chartdata.NormalReportDataDefinition;
import com.fr.chart.chartdata.NormalTableDataDefinition;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.frpane.UINumberDragPane;
@ -51,9 +49,7 @@ import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* 坐标轴的基础配置项分类时间值等公共的部分
@ -616,73 +612,44 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
}
categoryStylePane.removeAll();
categoryStyles.clear();
populateDefaultCateLabelStyle(axis);
populateMoreCateLabelStyle(axis);
populateCateLabelStyle(axis);
categoryStylePane.revalidate();
}
/**
* 默认一定会有一个分类标签就populate这个
*/
private void populateDefaultCateLabelStyle(VanChartAxis axis) {
populateCategoryStyles(axis, VanChartAxis.DEFAULT_CATEGORY_UUID, 0);
}
/**
* populate其余的分类标签
* populate分类标签
*
* @param axis
*/
private void populateMoreCateLabelStyle(VanChartAxis axis) {
private void populateCateLabelStyle(VanChartAxis axis) {
Chart chart = axis.getChart();
Map<String, String> moreCateLabels = new LinkedHashMap<>();
int size;
TopDefinitionProvider definition = chart.getFilterDefinition();
if (definition == null) {
return;
}
if (definition instanceof NormalTableDataDefinition) {
NormalTableDataDefinition tableDataDefinition = (NormalTableDataDefinition) definition;
moreCateLabels.putAll(tableDataDefinition.getMoreCateLabels());
} else if (definition instanceof NormalReportDataDefinition) {
NormalReportDataDefinition reportDataDefinition = (NormalReportDataDefinition) definition;
for (Map.Entry<String, Object> entry : reportDataDefinition.getMoreCateLabels().entrySet()) {
String uuid = entry.getKey();
String cateLabel = Utils.objectToString(entry.getValue());
moreCateLabels.put(uuid, cateLabel);
}
}
size = definition == null ? 1 : definition.getMoreCateSize() + 1;
int i = 1;
List<String> uuids = new ArrayList<>();
for (Map.Entry<String, String> entry : moreCateLabels.entrySet()) {
String uuid = entry.getKey();
uuids.add(uuid);
populateCategoryStyles(axis, uuid, i);
i++;
for (int i = 0; i < size; i++) {
populateCategoryStyles(axis, i);
}
axis.retainUsefulCategoryStyles(uuids);
}
private void populateCategoryStyles(VanChartAxis axis, String uuid, int index) {
private void populateCategoryStyles(VanChartAxis axis, int index) {
VanChartCategoryStylePaneWithCheckBox pane = new VanChartCategoryStylePaneWithCheckBox(parent, this, Toolkit.i18nText("Fine-Design_Chart_Style_Category") + (index + 1));
VanChartAxisLabelStyle style = populateAxisCategoryStyles(axis, uuid, index);
pane.populate(style, uuid);
VanChartAxisLabelStyle style = populateAxisCategoryStyles(axis, index);
pane.populate(style);
categoryStyles.add(pane);
categoryStylePane.add(createCateLableStylePanel(), BorderLayout.NORTH);
}
private VanChartAxisLabelStyle populateAxisCategoryStyles(VanChartAxis axis, String uuid, int index) {
private VanChartAxisLabelStyle populateAxisCategoryStyles(VanChartAxis axis, int index) {
VanChartAxisLabelStyle style;
if (axis.getCategoryStyle(uuid) != null) {
style = axis.getCategoryStyle(uuid);
if (axis.getCategoryStylesSize() > index && axis.getCategoryStyle(index) != null) {
style = axis.getCategoryStyle(index);
} else {
style = axis.getCategoryStyleByIndex(index);
if (style == null) {
style = new VanChartAxisLabelStyle();
}
axis.addCategoryStyle(uuid, style);
style = new VanChartAxisLabelStyle();
axis.addCategoryStyle(style);
}
return style;
}
@ -875,12 +842,11 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
* @param axis
*/
private void updateLayerDisplayPane(VanChartAxis axis) {
List<VanChartAxisLabelStyle> styles = new ArrayList<>();
for (VanChartCategoryStylePaneWithCheckBox categoryStyle : categoryStyles) {
Map<String, VanChartAxisLabelStyle> styleMap = categoryStyle.update();
for (Map.Entry<String, VanChartAxisLabelStyle> entry : styleMap.entrySet()) {
axis.addCategoryStyle(entry.getKey(), entry.getValue());
}
styles.add(categoryStyle.update());
}
axis.setCategoryStyles(styles);
}
//轴线样式

12
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartCategoryStylePaneWithCheckBox.java

@ -19,8 +19,6 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.LinkedHashMap;
import java.util.Map;
public class VanChartCategoryStylePaneWithCheckBox extends JPanel {
private UICheckBox checkBox; // 复选框
@ -30,7 +28,6 @@ public class VanChartCategoryStylePaneWithCheckBox extends JPanel {
private JPanel showOnPane;
private AbstractAttrNoScrollPane parent;
private String axisId;
private VanChartAxisLabelStyle axis;
public VanChartCategoryStylePaneWithCheckBox(AbstractAttrNoScrollPane parent, JPanel showOnPane, String checkBoxName) {
@ -88,16 +85,13 @@ public class VanChartCategoryStylePaneWithCheckBox extends JPanel {
}
}
public void populate(VanChartAxisLabelStyle style, String uuid) {
public void populate(VanChartAxisLabelStyle style) {
this.axis = style;
this.axisId = uuid;
checkBox.setSelected(axis.isShowLabel());
}
public Map<String, VanChartAxisLabelStyle> update() {
public VanChartAxisLabelStyle update() {
axis.setShowLabel(checkBox.isSelected());
Map<String, VanChartAxisLabelStyle> map = new LinkedHashMap<>();
map.put(axisId, axis);
return map;
return axis;
}
}

Loading…
Cancel
Save