|
|
@ -2,72 +2,114 @@ package com.fr.design.module; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.ChartColorMatching; |
|
|
|
import com.fr.base.ChartColorMatching; |
|
|
|
import com.fr.base.ChartPreStyleConfig; |
|
|
|
import com.fr.base.ChartPreStyleConfig; |
|
|
|
import com.fr.base.Utils; |
|
|
|
import com.fr.design.chartx.component.combobox.ColorSchemeComboBox; |
|
|
|
import com.fr.design.gui.controlpane.JListControlPane; |
|
|
|
import com.fr.design.dialog.BasicPane; |
|
|
|
import com.fr.design.gui.controlpane.NameObjectCreator; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.gui.controlpane.NameableCreator; |
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
|
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
|
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
|
|
|
|
import com.fr.general.GeneralUtils; |
|
|
|
import com.fr.general.NameObject; |
|
|
|
import com.fr.general.NameObject; |
|
|
|
import com.fr.stable.Nameable; |
|
|
|
import com.fr.stable.Nameable; |
|
|
|
|
|
|
|
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.Iterator; |
|
|
|
|
|
|
|
import java.util.LinkedHashMap; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
|
|
|
import java.awt.Dimension; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 图表预定义管理 界面, 在工具栏-服务器管理中. |
|
|
|
* 图表预定义管理 界面, 在工具栏-服务器管理中. |
|
|
|
|
|
|
|
* |
|
|
|
* @author kunsnat E-mail:kunsnat@gmail.com |
|
|
|
* @author kunsnat E-mail:kunsnat@gmail.com |
|
|
|
* @version 创建时间:2013-8-21 下午02:33:48 |
|
|
|
* @version 创建时间:2013-8-21 下午02:33:48 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class ChartPreStyleManagerPane extends JListControlPane { |
|
|
|
public class ChartPreStyleManagerPane extends BasicPane { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
private ColorSchemeComboBox defaultColorBox; |
|
|
|
/** |
|
|
|
|
|
|
|
* 创建有名字的creator |
|
|
|
|
|
|
|
* @return 有名字的creator数组 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public NameableCreator[] createNameableCreators() { |
|
|
|
|
|
|
|
return new NameableCreator[]{ |
|
|
|
|
|
|
|
new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_PreStyle_Duplicate"), |
|
|
|
|
|
|
|
ChartColorMatching.class, ChartPreStylePane.class) |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
private ChartPreStyleListPane chartPreStyleListPane; |
|
|
|
protected String title4PopupWindow() { |
|
|
|
|
|
|
|
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_PreStyle"); |
|
|
|
public ChartPreStyleManagerPane() { |
|
|
|
|
|
|
|
initComponent(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void populateBean() { |
|
|
|
private void initComponent() { |
|
|
|
ChartPreStyleConfig config = ChartPreStyleConfig.getInstance().mirror(); |
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
ArrayList list = new ArrayList(); |
|
|
|
JPanel colorBoxPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
|
|
|
|
|
|
|
|
|
|
|
Iterator keys = config.names(); |
|
|
|
chartPreStyleListPane = new ChartPreStyleListPane(this); |
|
|
|
while(keys.hasNext()) { |
|
|
|
|
|
|
|
Object key = keys.next(); |
|
|
|
|
|
|
|
ChartColorMatching value = (ChartColorMatching) config.getPreStyle(key); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
list.add(new NameObject(Utils.objectToString(key), value)); |
|
|
|
initDefaultColorBox(); |
|
|
|
} |
|
|
|
colorBoxPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Match_Default_Color_Scheme") + ":")); |
|
|
|
|
|
|
|
colorBoxPane.add(defaultColorBox); |
|
|
|
|
|
|
|
|
|
|
|
Nameable[] values = (Nameable[])list.toArray(new Nameable[list.size()]); |
|
|
|
this.add(colorBoxPane, BorderLayout.NORTH); |
|
|
|
populate(values); |
|
|
|
this.add(chartPreStyleListPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(config.containsName(config.getCurrentStyle())) { |
|
|
|
private void initDefaultColorBox() { |
|
|
|
this.setSelectedName(config.getCurrentStyle()); |
|
|
|
Map<String, ColorSchemeComboBox.ColorInfo> colorSchemes = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); |
|
|
|
|
|
|
|
Iterator names = config.names(); |
|
|
|
|
|
|
|
while (names.hasNext()) { |
|
|
|
|
|
|
|
Object key = names.next(); |
|
|
|
|
|
|
|
ColorSchemeComboBox.ColorInfo colorInfo = new ColorSchemeComboBox.ColorInfo(); |
|
|
|
|
|
|
|
ChartColorMatching colorMatching = (ChartColorMatching) config.getPreStyle(key); |
|
|
|
|
|
|
|
colorInfo.setGradient(colorMatching.getGradient()); |
|
|
|
|
|
|
|
colorInfo.setColors(colorMatching.getColorList()); |
|
|
|
|
|
|
|
colorSchemes.put(colorMatching.getId(), colorInfo); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
defaultColorBox = new ColorSchemeComboBox(colorSchemes); |
|
|
|
|
|
|
|
defaultColorBox.setPreferredSize(new Dimension(TableLayout4VanChartHelper.EDIT_AREA_WIDTH, 20)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void updateBean() { |
|
|
|
private void refreshColorSchemes() { |
|
|
|
ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); |
|
|
|
Nameable[] nameables = chartPreStyleListPane.update(); |
|
|
|
|
|
|
|
Map<String, ColorSchemeComboBox.ColorInfo> colorSchemes = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
for (Nameable value : nameables) { |
|
|
|
|
|
|
|
String name = value.getName(); |
|
|
|
|
|
|
|
ChartColorMatching colorMatching = (ChartColorMatching) ((NameObject) value).getObject(); |
|
|
|
|
|
|
|
ColorSchemeComboBox.ColorInfo colorInfo = new ColorSchemeComboBox.ColorInfo(); |
|
|
|
|
|
|
|
colorInfo.setGradient(colorMatching.getGradient()); |
|
|
|
|
|
|
|
colorInfo.setColors(colorMatching.getColorList()); |
|
|
|
|
|
|
|
colorSchemes.put(name, colorInfo); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
defaultColorBox.refresh(colorSchemes); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
config.setCurrentStyle(getSelectedName()); |
|
|
|
public void refreshDefaultColorBox() { |
|
|
|
|
|
|
|
Object selectedItem = defaultColorBox.getSelectedItem(); |
|
|
|
|
|
|
|
refreshColorSchemes(); |
|
|
|
|
|
|
|
defaultColorBox.setSelectedItem(selectedItem); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Nameable[] values = update(); |
|
|
|
public void refreshDefaultColorBox(String oldName, String newName) { |
|
|
|
config.clearAllPreStyle(); |
|
|
|
Object selectedItem = defaultColorBox.getSelectedItem(); |
|
|
|
|
|
|
|
if (ComparatorUtils.equals(selectedItem, oldName)) { |
|
|
|
|
|
|
|
selectedItem = newName; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
refreshColorSchemes(); |
|
|
|
|
|
|
|
defaultColorBox.setSelectedItem(selectedItem); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (Nameable value : values) { |
|
|
|
@Override |
|
|
|
config.putPreStyle(value.getName(), ((NameObject) value).getObject()); |
|
|
|
protected String title4PopupWindow() { |
|
|
|
|
|
|
|
return Toolkit.i18nText("Fine-Design_Report_ServerM_Predefined_Styles"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void populateBean() { |
|
|
|
|
|
|
|
ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); |
|
|
|
|
|
|
|
String currentStyle = config.getCurrentStyle(); |
|
|
|
|
|
|
|
defaultColorBox.setSelectedItem(currentStyle); |
|
|
|
|
|
|
|
chartPreStyleListPane.populateBean(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void updateBean() { |
|
|
|
|
|
|
|
ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); |
|
|
|
|
|
|
|
config.setCurrentStyle(GeneralUtils.objectToString(defaultColorBox.getSelectedItem())); |
|
|
|
|
|
|
|
chartPreStyleListPane.updateBean(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|