200 lines
6.5 KiB

package com.fr.plugin.pielinecomb.ui;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.extended.chart.ExtendedScrollPane;
import com.fr.json.JSONObject;
import com.fr.plugin.pielinecomb.PieLineCombChart;
import com.fr.plugin.pielinecomb.vo.HyperLinkObject;
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 PieLineCombStyleAnimalPane extends ExtendedScrollPane<PieLineCombChart> {
private UIButtonGroup<Integer> chartType;
private JPanel cardPane;
/**
* 柱形图
* */
private PieLineCombHyperLink pieHyperLink;
private PieCondListPane pieStyleCondPane;
/**
* 折线图
* */
private PieLineCombHyperLink lineHyperLink;
private LineCondListPane lineStyleCondPane;
@Override
protected JPanel createContentPane() {
return new ContentPane();
}
@Override
public void populateBean(PieLineCombChart chart) {
this.pieHyperLink.populateBean(chart);
this.lineHyperLink.populateBean(chart);
this.pieStyleCondPane.populateStyle(chart);
this.lineStyleCondPane.populateStyle(chart);
}
@Override
public void updateBean(PieLineCombChart chart) {
JSONObject chartConf = new JSONObject();
this.pieHyperLink.updateBean(chart);
this.lineHyperLink.updateBean(chart);
this.pieStyleCondPane.updateStyle(chart);
this.lineStyleCondPane.updateStyle(chart);
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Plugin-Pielinecomb-AnimalTitle");
}
private class ContentPane extends JPanel {
public ContentPane() {
initComponents();
}
private void initComponents() {
this.setLayout(new BorderLayout());
JPanel chartTypePane = createChartTypePane();
JPanel mainPane = createMainPane();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
Component[][] acomponents = new Component[][]{
new Component[]{chartTypePane},
new Component[]{mainPane}
};
JPanel panel = TableLayoutHelper.createTableLayoutPane(acomponents, new double[]{p, p, p, p}, new double[]{f});
this.add(panel,BorderLayout.CENTER);
this.setVisible(true);
}
}
private JPanel createMainPane() {
JPanel piePane = createPiePane();
JPanel linePane = createLinePane();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
cardPane = new JPanel(new CardLayout()){
@Override
public Dimension getPreferredSize() {
if (null != chartType.getSelectedItem() && chartType.getSelectedItem() == 2) {
return linePane.getPreferredSize();
} else {
return piePane.getPreferredSize();
}
}
};
cardPane.add(piePane, "pie");
cardPane.add(linePane, "line");
((CardLayout)cardPane.getLayout()).show(cardPane, "pie");
Component[][] comp = new Component[][]{
new Component[]{cardPane}
};
return TableLayout4VanChartHelper.createGapTableLayoutPane(comp, new double[]{p, p}, new double[]{f});
}
private JPanel createLinePane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
JPanel linkPane = createLineLinkPane();
JPanel condPane = createLineCondPane();
Component[][] comp = new Component[][]{
new Component[]{condPane},
new Component[]{linkPane}
};
return TableLayout4VanChartHelper.createGapTableLayoutPane(comp, new double[]{p, p}, new double[]{f});
}
private JPanel createPiePane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
JPanel linkPane = createPieLinkPane();
JPanel condPane = createPieCondPane();
Component[][] comp = new Component[][]{
new Component[]{condPane},
new Component[]{linkPane}
};
return TableLayout4VanChartHelper.createGapTableLayoutPane(comp, new double[]{p, p}, new double[]{f});
}
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);
chartType.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent var1x) {
CardLayout card = (CardLayout) cardPane.getLayout();
if (chartType.getSelectedItem() == 1) {
card.show(cardPane, "pie");
} else {
card.show(cardPane, "line");
}
}
});
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 createPieLinkPane() {
this.pieHyperLink = new PieLineCombHyperLink(HyperLinkObject.CHART_TYPE_PIE);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-Pielinecomb-hyperLink"), this.pieHyperLink);
}
private JPanel createLineLinkPane() {
this.lineHyperLink = new PieLineCombHyperLink(HyperLinkObject.CHART_TYPE_LINE);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-Pielinecomb-hyperLink"), this.lineHyperLink);
}
private JPanel createPieCondPane() {
this.pieStyleCondPane = new PieCondListPane();
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-Pielinecomb-styleCondition"), this.pieStyleCondPane);
}
private JPanel createLineCondPane() {
this.lineStyleCondPane = new LineCondListPane();
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-Pielinecomb-styleCondition"), this.lineStyleCondPane);
}
}