Browse Source

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

feature/x
方磊 3 years ago
parent
commit
46f00406e9
  1. 35
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java
  2. 44
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java
  3. 7
      designer-chart/src/main/java/com/fr/van/chart/designer/data/VanChartMoreCateReportDataContentPane.java
  4. 7
      designer-chart/src/main/java/com/fr/van/chart/designer/data/VanChartMoreCateTableDataContentPane.java
  5. 6
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartAxisPane.java
  6. 158
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartAxisStyleSettingPane.java
  7. 242
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java
  8. 102
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartCategoryStylePaneWithCheckBox.java

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

@ -7,6 +7,7 @@ import com.fr.chart.chartattr.Bar2DPlot;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartdata.NormalReportDataDefinition;
import com.fr.decision.base.util.UUIDUtil;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.formula.TinyFormulaPane;
@ -19,14 +20,14 @@ import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import java.util.ArrayList;
import java.util.List;
import java.awt.BorderLayout;
import java.awt.Color;
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.Map;
/**
@ -40,10 +41,10 @@ public class CategoryPlotMoreCateReportDataContentPane extends CategoryPlotRepor
private JPanel boxPane;
private UIButton addButton;
private ArrayList<TinyFormulaPane> formualList = new ArrayList<TinyFormulaPane>();
private Map<String, TinyFormulaPane> formualList = new LinkedHashMap<>();
private UIObserverListener uiobListener = null;
public List<TinyFormulaPane> getFormualList() {
public Map<String, TinyFormulaPane> getFormualList() {
return formualList;
}
@ -99,12 +100,17 @@ 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.add(pane);
formualList.put(uuid, pane);
final JPanel newButtonPane = new JPanel();
newButtonPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
@ -119,7 +125,7 @@ public class CategoryPlotMoreCateReportDataContentPane extends CategoryPlotRepor
@Override
public void actionPerformed(ActionEvent e) {
boxPane.remove(newButtonPane);
formualList.remove(pane);
formualList.remove(uuid);
checkComponent();
relayoutPane();
}
@ -171,11 +177,11 @@ public class CategoryPlotMoreCateReportDataContentPane extends CategoryPlotRepor
TopDefinitionProvider definition = collection.getSelectedChart().getFilterDefinition();
if (definition instanceof NormalReportDataDefinition) {
NormalReportDataDefinition reportDefinition = (NormalReportDataDefinition) definition;
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)));
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()));
}
}
}
@ -198,9 +204,10 @@ public class CategoryPlotMoreCateReportDataContentPane extends CategoryPlotRepor
}
protected void updateMoreCate(NormalReportDataDefinition reportDefinition, Plot plot) {
for (int i = 0, size = formualList.size(); i < size; i++) {
TinyFormulaPane pane = formualList.get(i);
reportDefinition.addMoreCate(canBeFormula(pane.updateBean()));
for (Map.Entry<String, TinyFormulaPane> entry : formualList.entrySet()) {
String uuid = entry.getKey();
TinyFormulaPane pane = entry.getValue();
reportDefinition.addMoreCate(uuid, canBeFormula(pane.updateBean()));
}
}
}

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

@ -6,6 +6,7 @@ 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;
@ -15,15 +16,20 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.*;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
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.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* 多分类轴 的数据集定义界面.
@ -39,12 +45,12 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD
private JPanel boxPane;
private ArrayList<UIComboBox> boxList = new ArrayList<UIComboBox>();
private Map<String, UIComboBox> boxList = new LinkedHashMap<>();
private UIButton addButton;
private UIObserverListener uiobListener = null;
public List<UIComboBox> getBoxList() {
public Map<String, UIComboBox> getBoxList() {
return boxList;
}
@ -108,6 +114,11 @@ 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));
@ -134,7 +145,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.add(combox);
boxList.put(uuid, combox);
checkComponent();
@ -142,7 +153,7 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD
@Override
public void actionPerformed(ActionEvent e) {
boxPane.remove(buttonPane);
boxList.remove(combox);
boxList.remove(uuid);
checkComponent();
relayoutPane();
}
@ -216,10 +227,10 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD
TopDefinitionProvider top = collection.getSelectedChart().getFilterDefinition();
if (top instanceof NormalTableDataDefinition) {
NormalTableDataDefinition normal = (NormalTableDataDefinition) top;
int size = normal.getMoreCateSize();
for (int i = 0; i < size; i++) {
UIComboBox box = addNewCombox();
box.setSelectedItem(normal.getMoreCateWithIndex(i));
Map<String, String> moreCateLabels = normal.getMoreCateLabels();
for(Map.Entry<String, String> entry : moreCateLabels.entrySet()) {
UIComboBox box = addNewCombox(entry.getKey());
box.setSelectedItem(entry.getValue());
}
}
@ -245,10 +256,11 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD
}
protected void updateMoreCate(NormalTableDataDefinition normal, Plot plot) {
for (int i = 0, size = boxList.size(); i < size; i++) {
UIComboBox box = boxList.get(i);
if (box.getSelectedItem() != null) {
normal.addMoreCate(box.getSelectedItem().toString());
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());
}
}
}

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

@ -3,11 +3,14 @@ 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.
*/
@ -41,8 +44,8 @@ public class VanChartMoreCateReportDataContentPane extends CategoryPlotMoreCateR
private void checkBoxList(boolean isSupportMulticategory) {
if (getFormualList().size() != 0) {
for (int i = 0; i < getFormualList().size(); i++) {
getFormualList().get(i).setEnabled(isSupportMulticategory);
for (Map.Entry<String, TinyFormulaPane> entry : getFormualList().entrySet()) {
entry.getValue().setEnabled(isSupportMulticategory);
}
}
}

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

@ -3,11 +3,14 @@ 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.
*/
@ -43,8 +46,8 @@ public class VanChartMoreCateTableDataContentPane extends CategoryPlotMoreCateTa
private void checkBoxList(boolean isSupportMulticategory) {
if (getBoxList().size() != 0) {
for (int i = 0; i < getBoxList().size(); i++) {
getBoxList().get(i).setEnabled(isSupportMulticategory);
for (Map.Entry<String, UIComboBox> entry : getBoxList().entrySet()) {
entry.getValue().setEnabled(isSupportMulticategory);
}
}
}

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

@ -1,5 +1,6 @@
package com.fr.van.chart.designer.style.axis;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.ConditionAttr;
import com.fr.chart.chartglyph.ConditionCollection;
@ -41,6 +42,7 @@ public class VanChartAxisPane extends BasicBeanPane<VanChart> {
protected VanChartAxisPlot editingPlot;
protected VanChartStylePane parent;
private Chart chart;
public VanChartAxisPane(VanChartAxisPlot plot, VanChartStylePane parent){
this.editingPlot = plot;
@ -188,6 +190,7 @@ public class VanChartAxisPane extends BasicBeanPane<VanChart> {
if(chart == null){
return;
}
this.chart = chart;
Plot plot = chart.getPlot();
populateBean(plot);
@ -208,10 +211,12 @@ public class VanChartAxisPane extends BasicBeanPane<VanChart> {
}
for(VanChartAxis axis : editingPlot.getXAxisList()){
axis.setChart(chart);
VanChartXYAxisPaneInterface axisPane = xAxisPaneMap.get(axis.getAxisName());
axisPane.populate(axis);
}
for(VanChartAxis axis : editingPlot.getYAxisList()){
axis.setChart(chart);
VanChartXYAxisPaneInterface axisPane = yAxisPaneMap.get(axis.getAxisName());
axisPane.populate(axis);
}
@ -237,6 +242,7 @@ public class VanChartAxisPane extends BasicBeanPane<VanChart> {
if(chart == null){
return;
}
this.chart = chart;
Plot plot = chart.getPlot();

158
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartAxisStyleSettingPane.java

@ -0,0 +1,158 @@
package com.fr.van.chart.designer.style.axis;
import com.fr.base.BaseFormula;
import com.fr.chart.base.TextAttr;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.frpane.UINumberDragPane;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithThemeStyle;
import com.fr.design.mainframe.chart.mode.ChartEditContext;
import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.plugin.chart.VanChartAxisCategoryStyle;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.style.axis.component.AxisLabelDisplayComboBox;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class VanChartAxisStyleSettingPane extends BasicBeanPane<VanChartAxisCategoryStyle> {
private static final double ROTATION_MAX = 90.0;
private AxisLabelDisplayComboBox labelDisplayComboBox;
private ChartTextAttrPane labelTextAttrPane;
private UINumberDragPane labelTextRotation;
private UIButtonGroup<Integer> labelGapStyle;
private UITextField labelGapValue;
private JPanel labelGapPane;
private JPanel labelGapValuePane;
private JPanel contentPane;
public VanChartAxisStyleSettingPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double s = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH;
double[] column = {f, s};
double[] row = {p, p, p};
labelDisplayComboBox = new AxisLabelDisplayComboBox();
JPanel labelDisplayPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Show"), labelDisplayComboBox, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH);
labelTextAttrPane = getChartTextAttrPane();
labelTextRotation = new UINumberDragPane(-ROTATION_MAX, ROTATION_MAX);
labelGapStyle = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Automatic"), Toolkit.i18nText("Fine-Design_Chart_Fixed")});
labelGapValue = new UITextField();
labelGapPane = createLabelGapPane(row, column);
this.setLayout(new BorderLayout());
contentPane = new JPanel(new BorderLayout());
contentPane.add(labelDisplayPane, BorderLayout.NORTH);
contentPane.add(labelTextAttrPane, BorderLayout.CENTER);
contentPane.add(labelGapPane, BorderLayout.SOUTH);
this.add(contentPane, BorderLayout.NORTH);
initListner();
}
@Override
public Dimension getPreferredSize() {
Dimension defaultSize = super.getPreferredSize();
return new Dimension(defaultSize.width, contentPane.getPreferredSize().height);
}
private void initListner() {
labelDisplayComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
labelGapPane.setVisible(labelDisplayComboBox.getSelectedIndex() == 0);
}
});
labelGapStyle.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
labelGapValuePane.setVisible(labelGapStyle.getSelectedIndex() == 1);
}
});
}
@Override
public void populateBean(VanChartAxisCategoryStyle style) {
labelDisplayComboBox.populateBean(style.getLabelDisplay());
labelTextAttrPane.populate(style.getTextAttr());
labelTextRotation.populateBean((double) style.getTextAttr().getRotation());
labelGapStyle.setSelectedIndex(style.isAutoLabelGap() ? 0 : 1);
labelGapValue.setText(style.getLabelIntervalNumber().getContent());
labelGapPane.setVisible(labelDisplayComboBox.getSelectedIndex() == 0);
labelGapValuePane.setVisible(labelGapStyle.getSelectedIndex() == 1);
}
@Override
public VanChartAxisCategoryStyle updateBean() {
VanChartAxisCategoryStyle style = new VanChartAxisCategoryStyle();
style.setLabelDisplay(labelDisplayComboBox.updateBean());
TextAttr textAttr = style.getTextAttr();
labelTextAttrPane.update(textAttr);
textAttr.setRotation(labelTextRotation.updateBean().intValue());
style.setTextAttr(textAttr);
style.setAutoLabelGap(labelGapStyle.getSelectedIndex() == 0);
if (style.isAutoLabelGap()) {
style.setLabelIntervalNumber(BaseFormula.createFormulaBuilder().build("0"));
} else {
style.setLabelIntervalNumber(BaseFormula.createFormulaBuilder().build(labelGapValue.getText()));
}
return style;
}
@Override
protected String title4PopupWindow() {
return null;
}
private JPanel createLabelGapPane(double[] row, double[] col) {
Component[][] gapComponents = new Component[][]{
new Component[]{null, null},
new Component[]{
FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_TextRotation")),
UIComponentUtils.wrapWithBorderLayoutPane(labelTextRotation)
},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Label_Interval")), labelGapStyle}
};
JPanel gapDetailPane = TableLayout4VanChartHelper.createGapTableLayoutPane(gapComponents, row, col);
labelGapValuePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText(""), labelGapValue, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH);
JPanel panel = new JPanel(new BorderLayout());
panel.add(gapDetailPane, BorderLayout.CENTER);
panel.add(labelGapValuePane, BorderLayout.SOUTH);
return panel;
}
protected ChartTextAttrPane getChartTextAttrPane() {
return ChartEditContext.supportTheme() ? new ChartTextAttrPaneWithThemeStyle() {
protected double getEdithAreaWidth() {
return TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH;
}
} : new ChartTextAttrPane() {
@Override
protected JPanel getContentPane(JPanel buttonPane) {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH;
double[] columnSize = {f, e};
double[] rowSize = {p, p, p};
return TableLayout4VanChartHelper.createGapTableLayoutPane(getComponents(buttonPane), rowSize, columnSize);
}
};
}
}

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

@ -3,8 +3,12 @@ package com.fr.van.chart.designer.style.axis;
import com.fr.base.BaseFormula;
import com.fr.base.BaseUtils;
import com.fr.base.Utils;
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;
@ -25,6 +29,7 @@ import com.fr.design.mainframe.chart.gui.style.ColorSelectBoxWithThemeStyle;
import com.fr.design.mainframe.chart.mode.ChartEditContext;
import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.plugin.chart.VanChartAxisCategoryStyle;
import com.fr.plugin.chart.attr.axis.VanChartAxis;
import com.fr.plugin.chart.base.OverlapHandleType;
import com.fr.plugin.chart.base.VanChartConstants;
@ -37,6 +42,7 @@ import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.VanChartHtmlLabelPane;
import com.fr.van.chart.designer.style.VanChartStylePane;
import com.fr.van.chart.designer.style.axis.component.AxisLabelDisplayComboBox;
import com.fr.van.chart.designer.style.axis.component.VanChartCategoryStylePaneWithCheckBox;
import javax.swing.BorderFactory;
import javax.swing.Icon;
@ -49,14 +55,20 @@ import java.awt.CardLayout;
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;
/**
* 坐标轴的基础配置项分类时间值等公共的部分
*/
public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
private static final long serialVersionUID = -5717246802333308973L;
private static final double ROTATION_MAX = 90.0;
private static final String WHOLE_DISPLAY = "wholeDisplay"; // 整体显示
private static final String LAYER_DISPLAY = "layerDisplay"; // 分层显示
protected UIButtonGroup showTitle;
protected TinyFormulaPane titleContent;
protected UIButtonGroup<Integer> titleAlignPane;
@ -66,6 +78,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
protected JPanel titlePane;
protected UIButtonGroup showLabel;
protected UIButtonGroup showLogic;
protected ChartTextAttrPane labelTextAttrPane;
protected UINumberDragPane labelTextRotation;
@ -80,10 +93,14 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
//protected UISpinner labelGapValue;
protected JPanel labelPanel;
private JPanel labelStylePane;
private JPanel showLogicPane;
private JPanel labelGapPane;
private JPanel labelGapStylePane;
private JPanel labelGapValuePane;
private JPanel labelDisplayPane;
private JPanel categoryStylePane;
private List<VanChartCategoryStylePaneWithCheckBox> categoryStyles = new ArrayList<>();
protected LineComboBox axisLineStyle;
@ -107,6 +124,8 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
protected JPanel centerPane;
private VanChartHtmlLabelPane htmlLabelPane;
private VanChartStylePane parent;
public VanChartBaseAxisPane() {
this(true);
}
@ -117,6 +136,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
}
public void setParentPane(VanChartStylePane parent) {
this.parent = parent;
htmlLabelPane.setParent(parent);
}
@ -220,16 +240,19 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
addComponentsListener();
JPanel showLabelPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Axis_Label"), showLabel);
JPanel showLogicPane = createShowLogicPane();
JPanel labelPane = new JPanel(new BorderLayout());
labelPane.add(showLabelPane, BorderLayout.NORTH);
labelPane.add(labelPanel, BorderLayout.CENTER);
labelPane.add(showLogicPane, BorderLayout.CENTER);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(PaneTitleConstants.CHART_STYLE_LABEL_TITLE, labelPane);
}
private void initLabelComponents() {
showLabel = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Use_Show"), Toolkit.i18nText("Fine-Design_Chart_Hidden")});
showLogic = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Axis_Style_Whole_Display"), Toolkit.i18nText("Fine-Design_Chart_Axis_Style_Layer_Display")});
initButtonGroupListener();
labelDisplayComboBox = new AxisLabelDisplayComboBox();
labelDisplayPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Show"), labelDisplayComboBox, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH);
@ -241,6 +264,51 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
labelGapValue = new UITextField();
}
private void initButtonGroupListener() {
showLogic.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
showLabelStyleCard();
}
});
}
private void showLabelStyleCard() {
CardLayout layout = (CardLayout) labelStylePane.getLayout();
if (showLogic.getSelectedIndex() == 0) {
layout.show(labelStylePane, WHOLE_DISPLAY);
} else {
layout.show(labelStylePane, LAYER_DISPLAY);
}
labelStylePane.revalidate();
}
/**
* 创建显示逻辑以及其下面面板
*
* @return
*/
private JPanel createShowLogicPane() {
showLogicPane = new JPanel(new BorderLayout());
labelStylePane = new JPanel(new CardLayout());
labelStylePane.add(labelPanel, WHOLE_DISPLAY);
labelStylePane.add(createCategoryStylePane(), LAYER_DISPLAY);
showLogicPane.add(TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Show_Logic"), showLogic), BorderLayout.NORTH);
showLogicPane.add(labelStylePane, BorderLayout.CENTER);
return showLogicPane;
}
/**
* 创建多分类轴标签设置面板
*
* @return
*/
private JPanel createCategoryStylePane() {
categoryStylePane = new JPanel(new BorderLayout());
categoryStylePane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
return categoryStylePane;
}
private JPanel createLabelGapPane(double[] row, double[] col) {
Component[][] gapComponents = new Component[][]{
new Component[]{null, null},
@ -570,8 +638,8 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
protected void checkLabelPane() {
if (showLabel != null) {
boolean enabled = showLabel.getSelectedIndex() == 0;
if (labelPanel != null) {
labelPanel.setVisible(enabled);
if (showLogicPane != null) {
showLogicPane.setVisible(enabled);
}
if (enabled) {
//轴标签缩略间隔显示 恢复用注释。下面1行删除。
@ -698,6 +766,24 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
if (showLabel != null) {
showLabel.setSelectedIndex(axis.isShowAxisLabel() ? 0 : 1);
}
populateShowLogicPane(axis);
}
private void populateShowLogicPane(VanChartAxis axis) {
if (showLogic != null) {
showLogic.setSelectedIndex(axis.getLabelDisplayMode());
}
populateWholeDisplayPane(axis);
populateLayerDisplayPane(axis);
showLabelStyleCard();
labelStylePane.revalidate();
}
/**
* populate整体显示那个card面板
*/
private void populateWholeDisplayPane(VanChartAxis axis) {
TextAttr labelTextAttr = axis.getTextAttr();
if (labelTextAttrPane != null) {
labelTextAttrPane.populate(labelTextAttr);
@ -723,6 +809,124 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
}
}
/**
* populate分层显示那个card面板
*
* @param axis
*/
private void populateLayerDisplayPane(VanChartAxis axis) {
Chart chart = axis.getChart();
if (chart == null) {
return;
}
categoryStylePane.removeAll();
categoryStyles.clear();
populateDefaultCateLabelStyle(axis);
populateMoreCateLabelStyle(axis);
categoryStylePane.revalidate();
}
/**
* 默认一定会有一个分类标签就populate这个
*/
private void populateDefaultCateLabelStyle(VanChartAxis axis) {
populateCategoryStyles(axis, VanChartAxis.DEFAULT_CATEGORY_UUID, 0);
}
/**
* populate其余的分类标签
*
* @param axis
*/
private void populateMoreCateLabelStyle(VanChartAxis axis) {
Chart chart = axis.getChart();
Map<String, String> moreCateLabels = new LinkedHashMap<>();
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);
}
}
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++;
}
axis.retainUsefulCategoryStyles(uuids);
}
private void populateCategoryStyles(VanChartAxis axis, String uuid, int index) {
VanChartCategoryStylePaneWithCheckBox pane = new VanChartCategoryStylePaneWithCheckBox(parent, this, Toolkit.i18nText("Fine-Design_Chart_Style_Category") + (index + 1));
VanChartAxisCategoryStyle style = populateAxisCategoryStyles(axis, uuid, index);
pane.populate(style, uuid);
categoryStyles.add(pane);
categoryStylePane.add(createCateLableStylePanel(), BorderLayout.NORTH);
}
private VanChartAxisCategoryStyle populateAxisCategoryStyles(VanChartAxis axis, String uuid, int index) {
VanChartAxisCategoryStyle style;
if (axis.getCategoryStyle(uuid) != null) {
style = axis.getCategoryStyle(uuid);
} else {
style = axis.getCategoryStyleByIndex(index);
if (style == null) {
style = new VanChartAxisCategoryStyle();
}
axis.addCategoryStyle(uuid, style);
}
return style;
}
private JPanel createCateLableStylePanel() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double[] row = getCateLableStylePaneRow();
double[] column = {f, p};
JPanel content = TableLayoutHelper.createTableLayoutPane(getCateLabelStyleComponents(), row, column);
Component[][] components = new Component[][]{
new Component[]{null, null},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Style_Category")), content}
};
return TableLayoutHelper.createTableLayoutPane(components, new double[]{p, p}, new double[]{f, e});
}
private Component[][] getCateLabelStyleComponents() {
Component[][] components = new Component[categoryStyles.size()][];
for (int i = 0; i < categoryStyles.size(); i++) {
components[i] = new Component[2];
components[i][0] = categoryStyles.get(i);
components[i][1] = null;
}
return components;
}
private double[] getCateLableStylePaneRow() {
double[] row = new double[categoryStyles.size()];
for (int i = 0; i < categoryStyles.size(); i++) {
row[i] = TableLayout.PREFERRED;
}
return row;
}
//轴线样式
private void populateLineStyle(VanChartAxis axis) {
if (axisLineStyle != null) {
@ -837,6 +1041,22 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
if (showLabel != null) {
axis.setShowAxisLabel(showLabel.getSelectedIndex() == 0);
}
updateShowLogicPane(axis);
}
private void updateShowLogicPane(VanChartAxis axis) {
if (showLogic != null) {
axis.setLabelDisplayMode(showLogic.getSelectedIndex());
}
updateWholeDisplayPane(axis);
updateLayerDisplayPane(axis);
}
/**
* update整体显示那个card面板
*/
private void updateWholeDisplayPane(VanChartAxis axis) {
TextAttr labelTextAttr = axis.getTextAttr();
if (labelTextAttrPane != null) {
labelTextAttrPane.update(labelTextAttr);
@ -866,6 +1086,20 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
}
}
/**
* update分层显示那个card面板
*
* @param axis
*/
private void updateLayerDisplayPane(VanChartAxis axis) {
for (VanChartCategoryStylePaneWithCheckBox categoryStyle : categoryStyles) {
Map<String, VanChartAxisCategoryStyle> styleMap = categoryStyle.update();
for (Map.Entry<String, VanChartAxisCategoryStyle> entry : styleMap.entrySet()) {
axis.addCategoryStyle(entry.getKey(), entry.getValue());
}
}
}
//轴线样式
private void updateLineStyle(VanChartAxis axis) {
if (axisLineStyle != null) {

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

@ -0,0 +1,102 @@
package com.fr.van.chart.designer.style.axis.component;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.frpane.UIBubbleFloatPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.i18n.Toolkit;
import com.fr.plugin.chart.VanChartAxisCategoryStyle;
import com.fr.stable.Constants;
import com.fr.van.chart.designer.style.axis.VanChartAxisStyleSettingPane;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Point;
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; // 复选框
private UIButton settingButton; // 设置按钮
private VanChartAxisStyleSettingPane settingPane; // 设置弹窗面板
private JPanel showOnPane;
private AbstractAttrNoScrollPane parent;
private String axisId;
private VanChartAxisCategoryStyle axis;
public VanChartCategoryStylePaneWithCheckBox(AbstractAttrNoScrollPane parent, JPanel showOnPane, String checkBoxName) {
this.parent = parent;
this.showOnPane = showOnPane;
this.setLayout(new BorderLayout());
checkBox = new UICheckBox(checkBoxName);
checkBox.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
checkBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
/* 为什么需要这句话呢因为这个checkBox是动态加上去的没有走最上层父组件ChartStylePane的initAllListener方法
* 所以不会触发update监听下面的bubble弹窗则是不属于ChartStylePane的单独悬浮组件也只能这样触发update监听
*/
if(parent != null){
parent.attributeChanged();
}
}
});
settingButton = new UIButton(Toolkit.i18nText("Fine-Design_Chart_Axis_Style_Setting"));
this.add(checkBox, BorderLayout.CENTER);
this.add(settingButton, BorderLayout.EAST);
initListener();
}
private void initListener() {
if(settingButton != null) {
settingButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
if (settingPane == null) {
settingPane = new VanChartAxisStyleSettingPane();
}
Point comPoint = settingButton.getLocationOnScreen();
Point arrowPoint = new Point(comPoint.x +settingButton.getWidth() - 25, comPoint.y + settingButton.getHeight());
Dimension size = settingPane.getPreferredSize();
UIBubbleFloatPane<VanChartAxisCategoryStyle> pane = new UIBubbleFloatPane(Constants.LEFT, arrowPoint, settingPane, size.width, 216) {
@Override
public void updateContentPane() {
axis = settingPane.updateBean();
if(parent != null){//条件属性没有parent
parent.attributeChanged();
}
}
};
pane.show(showOnPane, axis);
super.mouseReleased(e);
}
});
}
}
public void populate(VanChartAxisCategoryStyle style, String uuid) {
this.axis = style;
this.axisId = uuid;
checkBox.setSelected(axis.isAvailable());
}
public Map<String, VanChartAxisCategoryStyle> update() {
axis.setAvailable(checkBox.isSelected());
Map<String, VanChartAxisCategoryStyle> map = new LinkedHashMap<>();
map.put(axisId, axis);
return map;
}
}
Loading…
Cancel
Save