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.
162 lines
6.0 KiB
162 lines
6.0 KiB
2 years ago
|
package com.fr.plugin.pielinecomb.ui;
|
||
|
|
||
|
import com.fr.chart.chartattr.Plot;
|
||
|
import com.fr.design.beans.BasicBeanPane;
|
||
|
import com.fr.design.gui.controlpane.NameObjectCreator;
|
||
|
import com.fr.design.gui.controlpane.NameableCreator;
|
||
|
import com.fr.design.gui.imenutable.UIMenuNameableCreator;
|
||
|
import com.fr.design.i18n.Toolkit;
|
||
|
import com.fr.general.NameObject;
|
||
|
import com.fr.json.JSONArray;
|
||
|
import com.fr.json.JSONObject;
|
||
|
import com.fr.log.FineLoggerFactory;
|
||
|
import com.fr.plugin.pielinecomb.PieLineCombChart;
|
||
|
import com.fr.plugin.pielinecomb.vo.CustomJsonObject;
|
||
|
import com.fr.plugin.pielinecomb.vo.ItemColorJson;
|
||
|
import com.fr.plugin.pielinecomb.vo.ItemLabelJson;
|
||
|
import com.fr.plugin.pielinecomb.vo.ItemTipsJson;
|
||
|
import com.fr.stable.ListMap;
|
||
|
import com.fr.stable.Nameable;
|
||
|
import com.fr.van.chart.designer.component.VanChartUIListControlPane;
|
||
|
|
||
|
import java.lang.reflect.Constructor;
|
||
|
import java.lang.reflect.InvocationTargetException;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.HashMap;
|
||
|
|
||
|
/**
|
||
|
* @author duan.jingliang
|
||
|
*/
|
||
|
public class LineCondListPane extends VanChartUIListControlPane {
|
||
|
|
||
|
private PieLineCombChart chart;
|
||
|
|
||
|
private HashMap paneMap;
|
||
|
private HashMap jsonMap;
|
||
|
|
||
|
public LineCondListPane() {
|
||
|
paneMap = new HashMap(6);
|
||
|
paneMap.put(CustomJsonObject.ITEM_COLOR, PieLineCombColorCondCreator.class);
|
||
|
paneMap.put(CustomJsonObject.ITEM_LABEL, LineLabelCondCreator.class);
|
||
|
paneMap.put(CustomJsonObject.ITEM_TIPS, PieLineCombTipsCondCreator.class);
|
||
|
|
||
|
jsonMap = new HashMap(6);
|
||
|
jsonMap.put(CustomJsonObject.ITEM_COLOR, ItemColorJson.class);
|
||
|
jsonMap.put(CustomJsonObject.ITEM_LABEL, ItemLabelJson.class);
|
||
|
jsonMap.put(CustomJsonObject.ITEM_TIPS, ItemTipsJson.class);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void update(Plot plot) {
|
||
|
}
|
||
|
|
||
|
public void populateStyle(PieLineCombChart chart) {
|
||
|
this.chart = chart;
|
||
|
|
||
|
JSONObject styleCond = chart.getStyleCond();
|
||
|
if (null != styleCond && null != styleCond.get("line")) {
|
||
|
JSONArray chartConf = styleCond.getJSONArray("line");
|
||
|
ArrayList noList = new ArrayList();
|
||
|
for (int i = 0; null != chartConf && i < chartConf.size(); i++) {
|
||
|
JSONObject line = chartConf.getJSONObject(i);
|
||
|
if (null != line) {
|
||
|
try {
|
||
|
CustomJsonObject json = (CustomJsonObject)this.getJsonByTitle(line.getString("title")).newInstance();
|
||
|
json.put(line);
|
||
|
UIMenuNameableCreator var11 = new UIMenuNameableCreator(line.getString("titleName"), json, this.getEditPaneByTitle(line.getString("title")));
|
||
|
noList.add(new NameObject(var11.getName(), var11.getObj()));
|
||
|
} catch (InstantiationException e) {
|
||
|
e.printStackTrace();
|
||
|
} catch (IllegalAccessException e) {
|
||
|
e.printStackTrace();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
this.populate((Nameable[])noList.toArray(new NameObject[noList.size()]));
|
||
|
this.doLayout();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
public void updateStyle(PieLineCombChart chart) {
|
||
|
Nameable[] nameables = this.update();
|
||
|
|
||
|
JSONArray objConf = JSONArray.create();
|
||
|
for (int i = 0; i < nameables.length; i++) {
|
||
|
CustomJsonObject noObj = (CustomJsonObject)((NameObject)nameables[i]).getObject();
|
||
|
if (null == noObj) {
|
||
|
noObj = new CustomJsonObject();
|
||
|
noObj.put(JSONObject.create());
|
||
|
}
|
||
|
if (null == noObj.get()) {
|
||
|
noObj.put(JSONObject.create());
|
||
|
}
|
||
|
|
||
|
noObj.get().put("titleName", ((NameObject)nameables[i]).getName());
|
||
|
objConf.add(noObj.get());
|
||
|
}
|
||
|
|
||
|
if (null == chart.getStyleCond()) {
|
||
|
chart.setStyleCond(JSONObject.create());
|
||
|
}
|
||
|
chart.getStyleCond().put("line", objConf);
|
||
|
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public NameableCreator[] createNameableCreators() {
|
||
|
ListMap creatorMap = new ListMap();
|
||
|
|
||
|
NameableCreator color = new NameObjectCreator(Toolkit.i18nText("Plugin-Pielinecomb-color"), ItemColorJson.class, PieLineCombColorCondCreator.class);
|
||
|
creatorMap.put(color.menuName(), color);
|
||
|
|
||
|
NameableCreator label = new NameObjectCreator(Toolkit.i18nText("Plugin-Pielinecomb-StyleLegendLabel"), ItemLabelJson.class, LineLabelCondCreator.class);
|
||
|
creatorMap.put(label.menuName(), label);
|
||
|
|
||
|
NameableCreator tips = new NameObjectCreator(Toolkit.i18nText("Plugin-Pielinecomb-StyleLegendTips"), ItemTipsJson.class, PieLineCombTipsCondCreator.class);
|
||
|
creatorMap.put(tips.menuName(), tips);
|
||
|
|
||
|
return (NameableCreator[])creatorMap.values().toArray(new NameableCreator[creatorMap.size()]);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected String title4PopupWindow() {
|
||
|
return Toolkit.i18nText("Plugin-Pielinecomb-Cond-AddCondtion");
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected String getAddItemText() {
|
||
|
return Toolkit.i18nText("Plugin-Pielinecomb-Cond-AddCondtion");
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public BasicBeanPane createPaneByCreators(NameableCreator nameableCreator) {
|
||
|
Constructor var2 = null;
|
||
|
try {
|
||
|
var2 = nameableCreator.getUpdatePane().getConstructor();
|
||
|
return (BasicBeanPane)var2.newInstance();
|
||
|
} catch (InstantiationException var4) {
|
||
|
FineLoggerFactory.getLogger().error(var4.getMessage(), var4);
|
||
|
} catch (IllegalAccessException var5) {
|
||
|
FineLoggerFactory.getLogger().error(var5.getMessage(), var5);
|
||
|
} catch (NoSuchMethodException var6) {
|
||
|
return super.createPaneByCreators(nameableCreator);
|
||
|
} catch (InvocationTargetException var7) {
|
||
|
FineLoggerFactory.getLogger().error(var7.getMessage(), var7);
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
private Class<? extends BasicBeanPane> getEditPaneByTitle(String title) {
|
||
|
return (Class)paneMap.get(title);
|
||
|
}
|
||
|
|
||
|
private Class getJsonByTitle(String title) {
|
||
|
return (Class)jsonMap.get(title);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|