默认
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

230 lines
10 KiB

package com.fr.plugin.sqy.surface.pane.style;
import com.fanruan.api.design.ui.component.UITextArea;
import com.fanruan.api.design.ui.component.code.UISyntaxTextArea;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.ispinner.chart.UISpinnerWithPx;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.style.color.ColorSelectBox;
import com.fr.extended.chart.ExtendedScrollPane;
import com.fr.plugin.chart.type.LineType;
import com.fr.plugin.sqy.surface.chart.Chart;
import com.fr.plugin.sqy.surface.config.AxisConfig;
import com.fr.plugin.sqy.surface.config.LabelConfig;
import com.fr.plugin.sqy.surface.config.LineStyleConfig;
import com.fr.plugin.sqy.surface.util.CreatePaneUtils;
import com.fr.plugin.sqy.surface.zenum.AxisTypeEnum;
import com.fr.plugin.sqy.surface.zenum.LineTypeEnum;
import com.fr.stable.StringUtils;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.LineTypeComboBox;
import javax.swing.*;
import java.awt.*;
public class Axis3DYPane extends ExtendedScrollPane<Chart> {
private UIButtonGroup titleIsShow;
private TinyFormulaPane title;
private UISpinner titleFontsize;
private ColorSelectBox titleFontColor;
private UIButtonGroup axisLabelIsShow;
private UISpinner axisLabelFontsize;
private ColorSelectBox axisLabelFontColor;
private UITextArea axisFormatter;
private LineTypeComboBox axisLineTypeComboBox;
private UISpinner axisLineWidth;
private ColorSelectBox axisLineColor;
private UIButtonGroup axisTickIsShow;
private LineTypeComboBox splitLineTypeComboBox;
private UISpinner splitLineWidth;
private ColorSelectBox splitLineColor;
private UIComboBox valueType;
private TinyFormulaPane minValue;
private TinyFormulaPane maxValue;
@Override
public void populateBean(Chart ob) {
AxisConfig axisConfigY = ob.getAxisConfigY();
//标题
LabelConfig nameTextStyle = axisConfigY.getNameTextStyle();
this.titleIsShow.setSelectedIndex(nameTextStyle.isShow() ? 0 : 1);
this.title.populateBean(axisConfigY.getName().getContent());
this.titleFontsize.setValue(nameTextStyle.getFontSize() == 0 ? 16 : nameTextStyle.getFontSize());
this.titleFontColor.setSelectObject(nameTextStyle.getColor());
//标签
LabelConfig axisLabel = axisConfigY.getAxisLabel();
this.axisLabelIsShow.setSelectedIndex(axisLabel.isShow() ? 0 : 1);
this.axisLabelFontsize.setValue(axisLabel.getFontSize() == 0 ? 12 : axisLabel.getFontSize());
this.axisLabelFontColor.setSelectObject(axisLabel.getColor());
this.axisFormatter.setText(axisLabel.getFormatter());
//轴线
LineStyleConfig axisLine = axisConfigY.getAxisLine();
this.axisLineTypeComboBox.setSelectedIndex(LineTypeEnum.parseString(axisLine.getType()).ordinal());
this.axisLineWidth.setValue(axisLine.getWidth() == 0 ? 2 : axisLine.getWidth());
this.axisLineColor.setSelectObject(axisLine.getColor());
//刻度线
this.axisTickIsShow.setSelectedIndex(axisConfigY.getAxisTick().isShow() ? 0 : 1);
//网格线
LineStyleConfig splitLine = axisConfigY.getSplitLine();
this.splitLineTypeComboBox.setSelectedIndex(LineTypeEnum.parseString(splitLine.getType()).ordinal());
this.splitLineWidth.setValue(splitLine.getWidth() == 0 ? 1 : splitLine.getWidth());
this.splitLineColor.setSelectObject(splitLine.getColor());
//值定义
this.valueType.setSelectedIndex(StringUtils.isBlank(axisConfigY.getType()) ? 0 : AxisTypeEnum.parseString(axisConfigY.getType()).ordinal());
this.minValue.populateBean(axisConfigY.getMin().getContent());
this.maxValue.populateBean(axisConfigY.getMax().getContent());
}
@Override
public void updateBean(Chart ob) {
//标题
ob.getAxisConfigY().getNameTextStyle().setShow(this.titleIsShow.getSelectedIndex() == 0);
ob.getAxisConfigY().getName().setContent(this.title.updateBean());
ob.getAxisConfigY().getNameTextStyle().setFontSize((int) this.titleFontsize.getValue());
ob.getAxisConfigY().getNameTextStyle().setColor(this.titleFontColor.getSelectObject());
//标签
ob.getAxisConfigY().getAxisLabel().setShow(this.axisLabelIsShow.getSelectedIndex() == 0);
ob.getAxisConfigY().getAxisLabel().setFontSize((int) this.axisLabelFontsize.getValue());
ob.getAxisConfigY().getAxisLabel().setColor(this.axisLabelFontColor.getSelectObject());
ob.getAxisConfigY().getAxisLabel().setFormatter(this.axisFormatter.getText());
//轴线
ob.getAxisConfigY().getAxisLine().setType(LineTypeEnum.parseInt(this.axisLineTypeComboBox.getSelectedIndex()).getName());
ob.getAxisConfigY().getAxisLine().setWidth((int) this.axisLineWidth.getValue());
ob.getAxisConfigY().getAxisLine().setColor(this.axisLineColor.getSelectObject());
//刻度线
ob.getAxisConfigY().getAxisTick().setShow(this.axisTickIsShow.getSelectedIndex() == 0);//网格线
//网格线
ob.getAxisConfigY().getSplitLine().setType(LineTypeEnum.parseInt(this.splitLineTypeComboBox.getSelectedIndex()).getName());
ob.getAxisConfigY().getSplitLine().setWidth((int) this.splitLineWidth.getValue());
ob.getAxisConfigY().getSplitLine().setColor(this.splitLineColor.getSelectObject());
//值定义
ob.getAxisConfigY().setType(AxisTypeEnum.parseInt(this.valueType.getSelectedIndex()).getName());
ob.getAxisConfigY().getMin().setContent(this.minValue.updateBean());
ob.getAxisConfigY().getMax().setContent(this.maxValue.updateBean());
}
private JPanel getValuePane(){
this.valueType = new UIComboBox(new String[]{"数值","类目"});
this.minValue = new TinyFormulaPane();
this.maxValue = new TinyFormulaPane();
JPanel contentPane = CreatePaneUtils.createGapTableLayoutPane(new Component[][]{{null, null}
, {new UILabel("值类型"), this.valueType}
, {new UILabel("最小值"), this.minValue}
, {new UILabel("最大值"), this.maxValue}
});
JPanel var2 = TableLayout4VanChartHelper.createExpandablePaneWithTitle("值定义", contentPane);
return var2;
}
private JPanel getSplitLinePane(){
this.splitLineTypeComboBox = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.SOLID,LineType.DASHED});
this.splitLineWidth = new UISpinnerWithPx(1D, 2.147483647E9D, 1D, 1D);
this.splitLineColor = new ColorSelectBox(1);
JPanel contentPane = CreatePaneUtils.createGapTableLayoutPane(new Component[][]{{null, null}
, {new UILabel("线型"), this.splitLineTypeComboBox}
, {new UILabel("线宽"), this.splitLineWidth}
, {new UILabel("颜色"), this.splitLineColor}
});
JPanel var2 = TableLayout4VanChartHelper.createExpandablePaneWithTitle("网格线", contentPane);
return var2;
}
private JPanel getAxisLinePane(){
this.axisLineTypeComboBox = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.SOLID,LineType.DASHED});
this.axisLineWidth = new UISpinnerWithPx(1D, 2.147483647E9D, 1D, 1D);
this.axisLineColor = new ColorSelectBox(1);
this.axisTickIsShow = new UIButtonGroup(new String[]{"显示","隐藏"});
JPanel contentPane = CreatePaneUtils.createGapTableLayoutPane(new Component[][]{{null, null}
, {new UILabel("线型"), this.axisLineTypeComboBox}
, {new UILabel("线宽"), this.axisLineWidth}
, {new UILabel("颜色"), this.axisLineColor}
, {new UILabel("刻度线"), this.axisTickIsShow}
});
JPanel var2 = TableLayout4VanChartHelper.createExpandablePaneWithTitle("轴线", contentPane);
return var2;
}
private JPanel getAxisLabelPane(){
this.axisLabelIsShow = new UIButtonGroup(new String[]{"显示","隐藏"});
this.axisLabelFontsize = new UISpinnerWithPx(1D, 2.147483647E9D, 1D, 1D);
this.axisLabelFontColor = new ColorSelectBox(1);
this.axisFormatter = new UITextArea("return value;");
JPanel contentPane = CreatePaneUtils.createGapTableLayoutPane(new Component[][]{{null, null}
, {new UILabel("轴标签"), this.axisLabelIsShow}
, {new UILabel("字体大小"), this.axisLabelFontsize}
, {new UILabel("字体颜色"), this.axisLabelFontColor}
, {new UILabel("标签格式化"), this.axisFormatter}
});
JPanel var2 = TableLayout4VanChartHelper.createExpandablePaneWithTitle("标签", contentPane);
return var2;
}
private JPanel getTitlePane(){
this.title = new TinyFormulaPane();
this.titleIsShow = new UIButtonGroup(new String[]{"显示","隐藏"});
this.titleFontsize = new UISpinnerWithPx(1D, 2.147483647E9D, 1D, 1D);
this.titleFontColor = new ColorSelectBox(1);
JPanel contentPane = CreatePaneUtils.createGapTableLayoutPane(new Component[][]{{null, null}
, {new UILabel("轴标题"), this.titleIsShow}
, {new UILabel("内容"), this.title}
, {new UILabel("字体大小"), this.titleFontsize}
, {new UILabel("字体颜色"), this.titleFontColor}
});
JPanel var2 = TableLayout4VanChartHelper.createExpandablePaneWithTitle("标题", contentPane);
return var2;
}
@Override
protected JPanel createContentPane() {
JPanel panel = new JPanel(new BorderLayout());
Component[][] components = {{null}
, {this.getTitlePane()}
, {this.getAxisLabelPane()}
, {this.getAxisLinePane()}
, {this.getSplitLinePane()}
, {this.getValuePane()}
};
panel.add(TableLayoutHelper.createTableLayoutPane(components,1), BorderLayout.CENTER);
return panel;
}
@Override
protected String title4PopupWindow() {
return "Y维度";
}
}