forked from fanruan/demo-chart-pie
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.
56 lines
1.6 KiB
56 lines
1.6 KiB
package com.fr.plugin.demo; |
|
|
|
import com.fanruan.api.design.DesignKit; |
|
import com.fanruan.api.design.chart.DefaultTypePane; |
|
import com.fanruan.api.design.ui.component.UIButtonGroup; |
|
import com.fanruan.api.util.StringKit; |
|
|
|
import javax.swing.JPanel; |
|
import java.awt.Component; |
|
|
|
/** |
|
* @author Bjorn |
|
* @version 10.0 |
|
* Created by Bjorn on 2019-09-05 |
|
*/ |
|
public class DemoTypePane extends DefaultTypePane<DemoChart> { |
|
private UIButtonGroup buttonGroup = new UIButtonGroup(new String[]{DesignKit.i18nText("Fine-Plugin_Legend_Right"), DesignKit.i18nText("Fine-Plugin_Legend_Left")}); |
|
|
|
@Override |
|
protected String[] getTypeIconPath() { |
|
return new String[]{ |
|
"com/fr/plugin/demo/pieType.png", |
|
"com/fr/plugin/demo/ringType.png" |
|
}; |
|
} |
|
|
|
@Override |
|
protected int getSelectIndexInChart(DemoChart chart) { |
|
return chart.getPieType().ordinal(); |
|
} |
|
|
|
@Override |
|
protected void setSelectIndexInChart(DemoChart chart, int index) { |
|
chart.setPieType(PieType.parseInt(index)); |
|
} |
|
|
|
@Override |
|
protected Component[][] getPaneComponents(JPanel typePane) { |
|
return new Component[][]{ |
|
new Component[]{typePane}, |
|
new Component[]{buttonGroup} |
|
}; |
|
} |
|
|
|
@Override |
|
public void populateBean(DemoChart ob) { |
|
super.populateBean(ob); |
|
buttonGroup.setSelectedIndex(StringKit.equals("left", ob.getLegendPosition()) ? 0 : 1); |
|
} |
|
|
|
@Override |
|
public void updateBean(DemoChart ob) { |
|
super.updateBean(ob); |
|
ob.setLegendPosition(buttonGroup.getSelectedIndex() == 0 ? "left" : "right"); |
|
} |
|
}
|
|
|