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.
 
 

363 lines
15 KiB

package com.fr.plugin.pielinecomb.ui;
import com.fr.base.BaseUtils;
import com.fr.chart.base.TextAttr;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.frpane.UINumberDragPane;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextarea.UITextArea;
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.style.ChartTextAttrPane;
import com.fr.extended.chart.ExtendedScrollPane;
import com.fr.general.FRFont;
import com.fr.json.JSONObject;
import com.fr.plugin.pielinecomb.comp.CustomFormatPane;
import com.fr.plugin.pielinecomb.comp.TextFormat;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
public class PieLineCombStyleAxisYPane extends ExtendedScrollPane<JSONObject> {
private UICheckBox isTitleVisiable;
private TinyFormulaPane titleName;
private UIButtonGroup<Integer> titleAlignment;
private ChartTextAttrPane titleTextAttrPane;
private UINumberDragPane titleRotation;
private UICheckBox isLabelVisiable;
private ChartTextAttrPane labelTextAttrPane;
private UINumberDragPane labelRotation;
private UIButtonGroup<Integer> labelFormatType;
private CustomFormatPane formatPane;
private UITextArea labelJsPane;
private UICheckBox showMinValue;
private UICheckBox showMaxValue;
private UICheckBox showInterval;
private TinyFormulaPane minValue;
private TinyFormulaPane maxValue;
private TinyFormulaPane intervalValue;
private UIButtonGroup<String> position;
private PieLineCombStylePane stylePane;
public PieLineCombStyleAxisYPane(PieLineCombStylePane stylePane) {
this.stylePane = stylePane;
}
@Override
protected JPanel createContentPane() {
return new ContentPane();
}
@Override
public void populateBean(JSONObject chartConf) {
this.isTitleVisiable.setSelected(chartConf.getBoolean("isTitleVisiable"));
this.titleName.populateBean(chartConf.getString("titleName"));
this.titleAlignment.setSelectedItem(chartConf.getInt("titleAlignment"));
FRFont textFont = FRFont.getInstance(chartConf.getString("titlefamily"),
chartConf.getInt("titlestyle"),
chartConf.getInt("titlesize"),
MapUtil.toColor(chartConf.getString("titlecolor")));
this.titleTextAttrPane.populate(textFont);
this.titleRotation.populateBean(chartConf.getDouble("titleRotation"));
this.isLabelVisiable.setSelected(chartConf.getBoolean("isLabelVisiable"));
textFont = FRFont.getInstance(chartConf.getString("labelfamily"),
chartConf.getInt("labelstyle"),
chartConf.getInt("labelsize"),
MapUtil.toColor(chartConf.getString("labelcolor")));
this.labelTextAttrPane.populate(textFont);
this.labelRotation.populateBean(chartConf.getDouble("labelRotation"));
this.labelFormatType.setSelectedItem(chartConf.getInt("labelFormatType"));
TextFormat format = new TextFormat();
format.setType(chartConf.getInt("yformattype"));
format.setFormatStr(chartConf.getString("yformatstr"));
this.formatPane.populateBean(format);
this.labelJsPane.setText(chartConf.getString("labelJsPane"));
this.showMinValue.setSelected(chartConf.getBoolean("showMinValue"));
this.showMaxValue.setSelected(chartConf.getBoolean("showMaxValue"));
this.showInterval.setSelected(chartConf.getBoolean("showInterval"));
this.minValue.populateBean(chartConf.getString("minValue"));
this.maxValue.populateBean(chartConf.getString("maxValue"));
this.intervalValue.populateBean(chartConf.getString("intervalValue"));
this.position.setSelectedItem(chartConf.getString("position"));
}
@Override
public void updateBean(JSONObject json) {
}
public JSONObject update() {
JSONObject chartConf = new JSONObject();
chartConf.put("isTitleVisiable", isTitleVisiable.isSelected());
chartConf.put("titleName", titleName.updateBean());
chartConf.put("titleAlignment", titleAlignment.getSelectedItem());
TextAttr textAttr = this.titleTextAttrPane.update();
chartConf.put("titlesize", textAttr.getFRFont().getSize());
chartConf.put("titlestyle", textAttr.getFRFont().getStyle());
chartConf.put("titlefamily", textAttr.getFRFont().getFamily());
chartConf.put("titlecolor", MapUtil.toHex(textAttr.getFRFont().getForeground()));
chartConf.put("titleRotation", titleRotation.updateBean());
chartConf.put("isLabelVisiable", isLabelVisiable.isSelected());
textAttr = this.labelTextAttrPane.update();
chartConf.put("labelsize", textAttr.getFRFont().getSize());
chartConf.put("labelstyle", textAttr.getFRFont().getStyle());
chartConf.put("labelfamily", textAttr.getFRFont().getFamily());
chartConf.put("labelcolor", MapUtil.toHex(textAttr.getFRFont().getForeground()));
chartConf.put("labelRotation", labelRotation.updateBean());
chartConf.put("labelFormatType", labelFormatType.getSelectedItem());
TextFormat format = formatPane.updateBean();
chartConf.put("yformatstr", format.getFormatStr());
chartConf.put("yformattype", format.getType());
chartConf.put("labelJsPane", labelJsPane.getText());
chartConf.put("showMinValue", showMinValue.isSelected());
chartConf.put("showMaxValue", showMaxValue.isSelected());
chartConf.put("showInterval", showInterval.isSelected());
chartConf.put("minValue", minValue.updateBean());
chartConf.put("maxValue", maxValue.updateBean());
chartConf.put("intervalValue", intervalValue.updateBean());
chartConf.put("position", position.getSelectedItem());
return chartConf;
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Plugin-Pielinecomb-StyleAxisYTitle");
}
private class ContentPane extends JPanel {
public ContentPane() {
initComponents();
initListener(this);
}
private void initComponents() {
this.setLayout(new BorderLayout());
JPanel titlePane = createTitlePane();
JPanel labelPane = createLabelPane();
JPanel valuePane = createValuePane();
JPanel posPane = createPositionPane();
JPanel formatPane = createLabelFormatPane();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
Component[][] acomponents = new Component[][]{
new Component[]{titlePane},
new Component[]{labelPane},
new Component[]{valuePane},
new Component[]{posPane},
new Component[]{formatPane}
};
JPanel panel = TableLayoutHelper.createTableLayoutPane(acomponents, new double[]{p, p, p, p, p, p}, new double[]{f});
this.add(panel,BorderLayout.CENTER);
this.setVisible(true);
}
public void initListener(Container var1) {
for(int var2 = 0; var2 < var1.getComponentCount(); ++var2) {
Component var3 = var1.getComponent(var2);
if (var3 instanceof Container) {
this.initListener((Container)var3);
}
if (var3 instanceof UIObserver) {
((UIObserver)var3).registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
PieLineCombStyleAxisYPane.this.stylePane.attributeChanged();
}
});
}
}
}
}
private JPanel createTitlePane() {
isTitleVisiable = new UICheckBox(Toolkit.i18nText("Plugin-Pielinecomb-isVisiableTitle"));
titleName = new TinyFormulaPane();
Icon[] titlePositonIcons = new Icon[]{BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_top_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_center_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_down_normal.png")};
Integer[] titlePositionVal = new Integer[]{2, 0, 4};
this.titleAlignment = new UIButtonGroup(titlePositonIcons, titlePositionVal);
titleRotation = new UINumberDragPane(-90, 90);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
Component[][] comps = new Component[][]{
new Component[]{null, null},
new Component[]{new UILabel(Toolkit.i18nText("Plugin-Pielinecomb-TitleText")), this.titleName},
new Component[]{new UILabel(Toolkit.i18nText("Plugin-Pielinecomb-TitlePosition")), this.titleAlignment},
new Component[]{new UILabel(Toolkit.i18nText("Plugin-Pielinecomb-textRotation")), this.titleRotation}
};
JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(comps, new double[]{p, p, p, p, p}, new double[]{p, f});
titleTextAttrPane = new ChartTextAttrPane();
Component[][] sumComp = new Component[][]{
new Component[]{isTitleVisiable},
new Component[]{panel},
new Component[]{titleTextAttrPane}
};
JPanel sumPane = TableLayout4VanChartHelper.createGapTableLayoutPane(sumComp, new double[]{p, p, p}, new double[]{f});
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-Pielinecomb-TitleNameExpand"), sumPane);
}
private JPanel createLabelPane() {
isLabelVisiable = new UICheckBox(Toolkit.i18nText("Plugin-Pielinecomb-isLabelVisiable"));
labelTextAttrPane = new ChartTextAttrPane();
labelRotation = new UINumberDragPane(-90, 90);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
Component[][] comps = new Component[][]{
new Component[]{null, null},
new Component[]{new UILabel(Toolkit.i18nText("Plugin-Pielinecomb-textRotation")), this.labelRotation}
};
JPanel rotatePane = TableLayout4VanChartHelper.createGapTableLayoutPane(comps, new double[]{p, p, p}, new double[]{p, f});
Component[][] sumComp = new Component[][]{
new Component[]{isLabelVisiable},
new Component[]{labelTextAttrPane},
new Component[]{rotatePane}
};
JPanel sumPane = TableLayout4VanChartHelper.createGapTableLayoutPane(sumComp, new double[]{p, p, p}, new double[]{f});
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-Pielinecomb-axisLabelTitle"), sumPane);
}
private JPanel createLabelFormatPane() {
labelFormatType = new UIButtonGroup<Integer>(new String[]{
Toolkit.i18nText("Plugin-Pielinecomb-general"),
Toolkit.i18nText("Plugin-Pielinecomb-custom")
}, new Integer[]{1, 2});
labelFormatType.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
checkFormatType();
}
});
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
Component[][] comps = new Component[][]{
new Component[]{null, null},
new Component[]{new UILabel(Toolkit.i18nText("Plugin-Pielinecomb-labelFormatType")), this.labelFormatType}
};
JPanel typePane = TableLayout4VanChartHelper.createGapTableLayoutPane(comps, new double[]{p, p, p}, new double[]{p, f});
formatPane = new CustomFormatPane() {
@Override
protected Component[][] getComponent(JPanel var1, JPanel var2, JPanel var3) {
var3.setBorder(BorderFactory.createEmptyBorder());
return new Component[][]{{var3, null}, {var2, null}};
}
};
labelJsPane = new UITextArea(6, 6);
JPanel contentPane = new JPanel(new BorderLayout());
contentPane.add(formatPane, BorderLayout.NORTH);
contentPane.add(labelJsPane, BorderLayout.CENTER);
labelJsPane.setVisible(false);
Component[][] comp = new Component[][]{
new Component[]{typePane},
new Component[]{contentPane}
};
JPanel compPane = TableLayout4VanChartHelper.createGapTableLayoutPane(comp, new double[]{p, p, p}, new double[]{f});
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-Pielinecomb-format"), compPane);
}
private JPanel createValuePane() {
showMinValue = new UICheckBox(Toolkit.i18nText("Plugin-Pielinecomb-minValue"));
showMaxValue = new UICheckBox(Toolkit.i18nText("Plugin-Pielinecomb-maxValue"));
showInterval = new UICheckBox(Toolkit.i18nText("Plugin-Pielinecomb-intervalValue"));
minValue = new TinyFormulaPane();
maxValue = new TinyFormulaPane();
intervalValue = new TinyFormulaPane();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
Component[][] comps = new Component[][]{
new Component[]{null, null},
new Component[]{showMinValue, minValue},
new Component[]{showMaxValue, maxValue},
new Component[]{showInterval, intervalValue}
};
JPanel valuePane = TableLayout4VanChartHelper.createGapTableLayoutPane(comps, new double[]{p, p, p, p}, new double[]{p, f});
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-Pielinecomb-valueDefined"), valuePane);
}
private JPanel createPositionPane() {
position = new UIButtonGroup<>(new String[]{
Toolkit.i18nText("Plugin-Pielinecomb-left"),
Toolkit.i18nText("Plugin-Pielinecomb-right")
},
new String[]{"left", "right"}
);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
Component[][] comps = new Component[][]{
new Component[]{null, null},
new Component[]{new UILabel(Toolkit.i18nText("Plugin-Pielinecomb-yAxisPosition")), position}
};
JPanel posPane = TableLayout4VanChartHelper.createGapTableLayoutPane(comps, new double[]{p, p, p}, new double[]{p, f});
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-Pielinecomb-TitlePosition"), posPane);
}
private void checkFormatType() {
if (labelFormatType.getSelectedItem() == 1) {
formatPane.setVisible(true);
labelJsPane.setVisible(false);
} else {
formatPane.setVisible(false);
labelJsPane.setVisible(true);
}
}
}