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.
161 lines
5.1 KiB
161 lines
5.1 KiB
package com.fr.plugin.pielinecomb.ui; |
|
|
|
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.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.design.style.color.ColorSelectBox; |
|
import com.fr.extended.chart.ExtendedScrollPane; |
|
import com.fr.json.JSONObject; |
|
import com.fr.plugin.pielinecomb.PieLineCombChart; |
|
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 PieLineCombStyleTipsPane extends ExtendedScrollPane<PieLineCombChart> { |
|
|
|
private UIButtonGroup<Integer> chartType; |
|
private JPanel cardPane; |
|
|
|
/** |
|
* 柱形图 配置 |
|
* */ |
|
private PieLineTipsPane pieTipsPane; |
|
|
|
/** |
|
* 折线图 配置 |
|
* */ |
|
private PieLineTipsPane lineTipsPane; |
|
|
|
|
|
@Override |
|
protected JPanel createContentPane() { |
|
return new ContentPane(); |
|
} |
|
|
|
@Override |
|
public void populateBean(PieLineCombChart chart) { |
|
JSONObject chartConf = chart.getTipsConf(); |
|
|
|
this.chartType.setSelectedItem(chartConf.getInt("chartType")); |
|
|
|
JSONObject pieTips = chartConf.getJSONObject("pie"); |
|
if (null == pieTips) { |
|
pieTips = JSONObject.create(); |
|
} |
|
this.pieTipsPane.populateBean(pieTips); |
|
JSONObject lineTips = chartConf.getJSONObject("line"); |
|
if (null == lineTips) { |
|
lineTips = JSONObject.create(); |
|
} |
|
this.lineTipsPane.populateBean(lineTips); |
|
|
|
} |
|
|
|
@Override |
|
public void updateBean(PieLineCombChart chart) { |
|
JSONObject chartConf = new JSONObject(); |
|
|
|
chartConf.put("chartType", this.chartType.getSelectedItem()); |
|
|
|
JSONObject pieTips = this.pieTipsPane.update(); |
|
JSONObject lineTips = this.lineTipsPane.update(); |
|
chartConf.put("pie", pieTips); |
|
chartConf.put("line", lineTips); |
|
|
|
chart.setTipsConf(chartConf); |
|
} |
|
|
|
@Override |
|
protected String title4PopupWindow() { |
|
return Toolkit.i18nText("Plugin-Pielinecomb-StyleLegendTips"); |
|
} |
|
|
|
private class ContentPane extends JPanel { |
|
public ContentPane() { |
|
initComponents(); |
|
} |
|
|
|
private void initComponents() { |
|
this.setLayout(new BorderLayout()); |
|
|
|
JPanel mainPane = createMainPane(); |
|
|
|
double p = TableLayout.PREFERRED; |
|
double f = TableLayout.FILL; |
|
Component[][] acomponents = new Component[][]{ |
|
new Component[]{mainPane} |
|
}; |
|
|
|
JPanel panel = TableLayoutHelper.createTableLayoutPane(acomponents, new double[]{p, p}, new double[]{f}); |
|
|
|
this.add(panel,BorderLayout.CENTER); |
|
this.setVisible(true); |
|
} |
|
} |
|
|
|
private JPanel createChartTypePane() { |
|
chartType = new UIButtonGroup<Integer>(new String[]{ |
|
Toolkit.i18nText("Plugin-Pielinecomb-Typepie"), |
|
Toolkit.i18nText("Plugin-Pielinecomb-Typeline") |
|
}, |
|
new Integer[]{1, 2} |
|
); |
|
chartType.setSelectedItem(1); |
|
|
|
double p = TableLayout.PREFERRED; |
|
double f = TableLayout.FILL; |
|
Component[][] comp = new Component[][]{ |
|
{null}, |
|
new Component[]{this.chartType} |
|
}; |
|
return TableLayout4VanChartHelper.createGapTableLayoutPane(comp, new double[]{p, p}, new double[]{f}); |
|
} |
|
|
|
private JPanel createMainPane() { |
|
double p = TableLayout.PREFERRED; |
|
double f = TableLayout.FILL; |
|
|
|
this.pieTipsPane = new PieLineTipsPane(); |
|
this.lineTipsPane = new PieLineTipsPane(); |
|
|
|
JPanel chartTypePane = createChartTypePane(); |
|
|
|
cardPane = new JPanel(new CardLayout()){ |
|
@Override |
|
public Dimension getPreferredSize() { |
|
if (null != chartType.getSelectedItem() && chartType.getSelectedItem() == 2) { |
|
return lineTipsPane.getPreferredSize(); |
|
} else { |
|
return pieTipsPane.getPreferredSize(); |
|
} |
|
} |
|
}; |
|
cardPane.add(pieTipsPane, "pie"); |
|
cardPane.add(lineTipsPane, "line"); |
|
((CardLayout)cardPane.getLayout()).show(cardPane, "pie"); |
|
chartType.addChangeListener(new ChangeListener() { |
|
@Override |
|
public void stateChanged(ChangeEvent var1x) { |
|
if (chartType.getSelectedItem() == 1) { |
|
((CardLayout)cardPane.getLayout()).show(cardPane, "pie"); |
|
} else { |
|
((CardLayout)cardPane.getLayout()).show(cardPane, "line"); |
|
} |
|
} |
|
}); |
|
|
|
Component[][] comp = new Component[][]{ |
|
new Component[]{chartTypePane}, |
|
new Component[]{cardPane} |
|
}; |
|
return TableLayout4VanChartHelper.createGapTableLayoutPane(comp, new double[]{p, p, p}, new double[]{f}); |
|
} |
|
}
|
|
|