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.
140 lines
6.1 KiB
140 lines
6.1 KiB
2 years ago
|
package com.fr.plugin.pielinecomb.ui;
|
||
|
|
||
|
import com.fr.base.BaseUtils;
|
||
|
import com.fr.chart.base.TextAttr;
|
||
|
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.ispinner.UISpinner;
|
||
|
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.PieLineCombChart;
|
||
|
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
|
||
|
|
||
|
import javax.swing.*;
|
||
|
import java.awt.*;
|
||
|
|
||
|
public class PieLineCombStyleLegendPane extends ExtendedScrollPane<PieLineCombChart> {
|
||
|
|
||
|
private UICheckBox showlegend;
|
||
|
private UIButtonGroup<Integer> legendposition;
|
||
|
private UIButtonGroup<Integer> legendalignment;
|
||
|
private UISpinner legendmargin;
|
||
|
|
||
|
private ChartTextAttrPane textAttrPane;
|
||
|
|
||
|
@Override
|
||
|
protected JPanel createContentPane() {
|
||
|
return new ContentPane();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void populateBean(PieLineCombChart chart) {
|
||
|
JSONObject chartConf = chart.getLegendConf();
|
||
|
|
||
|
this.showlegend.setSelected(chartConf.getBoolean("showlegend"));
|
||
|
this.legendposition.setSelectedItem(chartConf.getInt("legendposition"));
|
||
|
this.legendalignment.setSelectedItem(chartConf.getInt("legendalignment"));
|
||
|
this.legendmargin.setValue(chartConf.getDouble("legendmargin"));
|
||
|
|
||
|
FRFont textFont = FRFont.getInstance(chartConf.getString("legendfamily"),
|
||
|
chartConf.getInt("legendstyle"),
|
||
|
chartConf.getInt("legendsize"),
|
||
|
MapUtil.toColor(chartConf.getString("legendcolor")));
|
||
|
this.textAttrPane.populate(textFont);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void updateBean(PieLineCombChart chart) {
|
||
|
JSONObject chartConf = new JSONObject();
|
||
|
|
||
|
chartConf.put("showlegend", this.showlegend.isSelected());
|
||
|
chartConf.put("legendposition", this.legendposition.getSelectedItem());
|
||
|
chartConf.put("legendalignment", this.legendalignment.getSelectedItem());
|
||
|
chartConf.put("legendmargin", this.legendmargin.getValue());
|
||
|
|
||
|
TextAttr textAttr = this.textAttrPane.update();
|
||
|
chartConf.put("legendsize", textAttr.getFRFont().getSize());
|
||
|
chartConf.put("legendstyle", textAttr.getFRFont().getStyle());
|
||
|
chartConf.put("legendfamily", textAttr.getFRFont().getFamily());
|
||
|
chartConf.put("legendcolor", MapUtil.toHex(textAttr.getFRFont().getForeground()));
|
||
|
|
||
|
chart.setLegendConf(chartConf);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected String title4PopupWindow() {
|
||
|
return Toolkit.i18nText("Plugin-Pielinecomb-StyleLegendTitle");
|
||
|
}
|
||
|
|
||
|
private class ContentPane extends JPanel {
|
||
|
public ContentPane() {
|
||
|
initComponents();
|
||
|
}
|
||
|
|
||
|
private void initComponents() {
|
||
|
this.setLayout(new BorderLayout());
|
||
|
|
||
|
JPanel positionPane = createLegendPosition();
|
||
|
JPanel stylePane = createTitleStylePane();
|
||
|
|
||
|
double p = TableLayout.PREFERRED;
|
||
|
double f = TableLayout.FILL;
|
||
|
Component[][] acomponents = new Component[][]{
|
||
|
new Component[]{showlegend},
|
||
|
new Component[]{positionPane},
|
||
|
new Component[]{stylePane}
|
||
|
};
|
||
|
|
||
|
JPanel panel = TableLayoutHelper.createTableLayoutPane(acomponents, new double[]{p, p, p, p}, new double[]{f});
|
||
|
|
||
|
this.add(panel,BorderLayout.CENTER);
|
||
|
|
||
|
this.setVisible(true);
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
private JPanel createLegendPosition(){
|
||
|
String[] var3 = new String[]{Toolkit.i18nText("Fine-Design_Chart_Style_Alignment_Top"), Toolkit.i18nText("Fine-Design_Chart_Style_Alignment_Bottom"), Toolkit.i18nText("Fine-Design_Chart_Style_Alignment_Left"), Toolkit.i18nText("Fine-Design_Chart_Style_Alignment_Right")};
|
||
|
Integer[] var4 = new Integer[]{1, 3, 2, 4};
|
||
|
Icon[] var5 = new Icon[]{BaseUtils.readIcon("/com/fr/design/images/chart/ChartLegend/layout_top.png"), BaseUtils.readIcon("/com/fr/design/images/chart/ChartLegend/layout_bottom.png"), BaseUtils.readIcon("/com/fr/design/images/chart/ChartLegend/layout_left.png"), BaseUtils.readIcon("/com/fr/design/images/chart/ChartLegend/layout_right.png")};
|
||
|
|
||
|
this.legendposition = new UIButtonGroup(var5, var4);
|
||
|
this.legendposition.setAllToolTips(var3);
|
||
|
|
||
|
this.showlegend = new UICheckBox(Toolkit.i18nText("Plugin-Pielinecomb-showylegend"));
|
||
|
|
||
|
Icon[] titlePositonIcons = new Icon[]{BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png")};
|
||
|
Integer[] titlePositionVal = new Integer[]{2, 0, 4};
|
||
|
this.legendalignment = new UIButtonGroup(titlePositonIcons, titlePositionVal);
|
||
|
|
||
|
this.legendmargin = new UISpinner(0, 500, 1, 20);
|
||
|
double p = TableLayout.PREFERRED;
|
||
|
double f = TableLayout.FILL;
|
||
|
Component[][] comps = new Component[][]{
|
||
|
new Component[]{null, null},
|
||
|
new Component[]{new UILabel(Toolkit.i18nText("Plugin-Pielinecomb-legendposition")), this.legendposition},
|
||
|
new Component[]{new UILabel(Toolkit.i18nText("Plugin-Pielinecomb-legendalignment")), this.legendalignment},
|
||
|
new Component[]{new UILabel(Toolkit.i18nText("Plugin-Pielinecomb-legendmargin")), this.legendmargin}
|
||
|
};
|
||
|
|
||
|
JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(comps, new double[]{p, p, p, p, p}, new double[]{p, f});
|
||
|
|
||
|
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-Pielinecomb-ChartLegendPositionExpand"), panel);
|
||
|
|
||
|
}
|
||
|
|
||
|
private JPanel createTitleStylePane() {
|
||
|
this.textAttrPane = new ChartTextAttrPane();
|
||
|
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-Pielinecomb-TitleStyle"), this.textAttrPane);
|
||
|
}
|
||
|
|
||
|
}
|