|
|
|
package com.fanruan.api.design.chart;
|
|
|
|
|
|
|
|
import com.fanruan.api.engine.chart.BaseChartWithData;
|
|
|
|
import com.fr.chart.charttypes.ChartTypeManager;
|
|
|
|
import com.fr.chartx.attr.ChartProvider;
|
|
|
|
import com.fr.design.ChartTypeInterfaceManager;
|
|
|
|
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
|
|
|
|
import com.fr.design.mainframe.chart.gui.type.ChartImagePane;
|
|
|
|
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
import java.awt.Component;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Bjorn
|
|
|
|
* @version 10.0
|
|
|
|
* Created by Bjorn on 2019-09-18
|
|
|
|
*/
|
|
|
|
public class DefaultTypePane<T extends BaseChartWithData> extends AbstractChartTypePane<T> {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取图表类型界面图表选择子类型的缩略图路径,默认使用UI界面插入图表时子类型的图片路径
|
|
|
|
*
|
|
|
|
* @return 图片路径集合
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
protected String[] getTypeIconPath() {
|
|
|
|
return ChartTypeInterfaceManager.getInstance().getDemoImagePath(getPlotID());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取图表类型界面图表选择子类型的缩略图提示内容,默认使用UI界面插入图表时的图表子类型名称
|
|
|
|
*
|
|
|
|
* @return 提示内容集合
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
protected String[] getTypeTipName() {
|
|
|
|
return ChartTypeInterfaceManager.getInstance().getSubName(getPlotID());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取图表子类型对象,默认使用AbstractChartType.getChartTypes()返回的第一个对象
|
|
|
|
*
|
|
|
|
* @return 图表对象
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public ChartProvider getDefaultChart() {
|
|
|
|
return ChartTypeManager.getInstance().getChartTypes(getPlotID())[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取图表类型界面切换图表类型名称。默认使用UI界面插入图表时的图表名称。
|
|
|
|
*
|
|
|
|
* @return 图表名称
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public String title4PopupWindow() {
|
|
|
|
return ChartTypeInterfaceManager.getInstance().getName(getPlotID());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 根据图表对象返回该图表对象的所对应的子类型序号,默认返回0
|
|
|
|
*
|
|
|
|
* @return 子类型序号
|
|
|
|
*/
|
|
|
|
protected int getSelectIndexInChart(T chart) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 根据图表子类型序号,还原图表对象对应的属性。
|
|
|
|
*/
|
|
|
|
protected void setSelectIndexInChart(T chart, int index) {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通过图表对象的属性,还原选择的图表类型
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void populateBean(T ob) {
|
|
|
|
if (getTypeIconPath().length > 0) {
|
|
|
|
for (ChartImagePane imagePane : typeDemo) {
|
|
|
|
imagePane.isPressing = false;
|
|
|
|
}
|
|
|
|
typeDemo.get(getSelectIndexInChart(ob)).isPressing = true;
|
|
|
|
checkDemosBackground();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 根据所选择的图表类型,还原图表类型的属性。
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void updateBean(T ob) {
|
|
|
|
if (getTypeIconPath().length > 0) {
|
|
|
|
for (int index = 0, len = typeDemo.size(); index < len; index++) {
|
|
|
|
if (typeDemo.get(index).isPressing) {
|
|
|
|
setSelectIndexInChart(ob, index);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 构建类型选择面板的组件。
|
|
|
|
*
|
|
|
|
* @return 面板组件集合
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
protected Component[][] getPaneComponents(JPanel typePane) {
|
|
|
|
return super.getPaneComponents(typePane);
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO 已经在父类中加了默认实现,jar包更新后直接删除
|
|
|
|
@Override
|
|
|
|
protected String[] getTypeLayoutPath() {
|
|
|
|
return new String[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected String[] getTypeLayoutTipName() {
|
|
|
|
return new String[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected String getPlotTypeID() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|