Browse Source
* commit '376cc491e49fb854ba31cbcc35ae066d80e479b5': (33 commits) KERNEL-896 修改VcsFolderManagerActivator位置 KERNEL-896 修改vcs目录位置 CHART-9141 filter界面&xml、processor不合理改成枚举、result流程一部分 CHART-4798 数据集数据源 REPORT-19083 设计器内删除当前模板时,未自动退回到最后一张已打开的模板 无JIRA任务 数据收集,为了规避获取username要在启动之后,写了个中转文件 REPORT-18422 图片控件插件问题 设计器部分漏提交 CHART-9141 删除图表设计器相关代码 CHART-9141 replace chart with chartProvider(eg:typePane) && 图表公式相关接口 && 删除图表内部对datamodel的cache(和engine确认过) CHART-9783 地图相关操作慢 REPORT-18570 fr连接bi 数据分析预览单元格没有过滤设置 限制文件大小 REPORT-19059 环境切换同名程序数据集还是使用上一个环境的sql 换个名字 REPORT-18855 加下单元测试 REPORT-19058 环境切换暂存文件为保存提示 REPORT-18855 & REPORT-18857 jpg图片持久化遗漏了一些场景 CHART-9576 远程设计 设计器中用实时的 内存配置推荐:设计器安装插件随lic显示状态不对 REPORT-18955 填报属性配置,提交条件的删除按钮没有灰色化 ...research/11.0
vito
5 years ago
100 changed files with 3679 additions and 1536 deletions
@ -0,0 +1,102 @@
|
||||
package com.fr.design.data; |
||||
|
||||
import com.fr.base.TableData; |
||||
import com.fr.data.impl.storeproc.StoreProcedure; |
||||
import com.fr.design.data.tabledata.wrapper.TableDataFactory; |
||||
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; |
||||
import com.fr.file.ProcedureConfig; |
||||
import com.fr.file.TableDataConfig; |
||||
import org.easymock.EasyMock; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.powermock.api.easymock.PowerMock; |
||||
import org.powermock.core.classloader.annotations.PrepareForTest; |
||||
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; |
||||
import org.powermock.modules.junit4.PowerMockRunner; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
@RunWith(PowerMockRunner.class) |
||||
@PrepareForTest({TableDataFactory.class, StoreProcedure.class, TableDataConfig.class, ProcedureConfig.class}) |
||||
@SuppressStaticInitializationFor({"com.fr.design.data.tabledata.wrapper.TableDataFactory"}) |
||||
public class DesignTableDataManagerTest { |
||||
|
||||
@Test |
||||
public void testFireDataChange() { |
||||
|
||||
DesignTableDataManager.envChange(); |
||||
|
||||
|
||||
PowerMock.mockStatic(TableDataConfig.class); |
||||
|
||||
TableDataConfig config = EasyMock.mock(TableDataConfig.class); |
||||
TableDataConfig config2 = EasyMock.mock(TableDataConfig.class); |
||||
|
||||
TableData td1 = EasyMock.mock(TableData.class); |
||||
TableData td2 = EasyMock.mock(TableData.class); |
||||
TableData td3 = EasyMock.mock(TableData.class); |
||||
TableData td4 = EasyMock.mock(TableData.class); |
||||
EasyMock.expect(config.getTableData("firstData")).andReturn(td1).once(); |
||||
EasyMock.expect(config.getTableData("secondData")).andReturn(td2).once(); |
||||
EasyMock.expect(config2.getTableData("firstData")).andReturn(td3).once(); |
||||
EasyMock.expect(config2.getTableData("secondData")).andReturn(td4).once(); |
||||
|
||||
EasyMock.expect(TableDataConfig.getInstance()).andReturn(config).once().andReturn(config2).once(); |
||||
|
||||
PowerMock.mockStatic(TableDataFactory.class); |
||||
EasyMock.expect(TableDataFactory.getSortOfChineseNameOfServerData(config)) |
||||
.andReturn(new String[]{"firstData", "secondData"}).once(); |
||||
EasyMock.expect(TableDataFactory.getSortOfChineseNameOfServerData(config2)) |
||||
.andReturn(new String[]{"firstData", "secondData"}).once(); |
||||
|
||||
|
||||
ProcedureConfig proConfig = EasyMock.mock(ProcedureConfig.class); |
||||
StoreProcedure pc1 = PowerMock.createMock(StoreProcedure.class); |
||||
StoreProcedure pc2 = PowerMock.createMock(StoreProcedure.class); |
||||
ProcedureConfig proConfig2 = EasyMock.mock(ProcedureConfig.class); |
||||
StoreProcedure pc3 = PowerMock.createMock(StoreProcedure.class); |
||||
StoreProcedure pc4 = PowerMock.createMock(StoreProcedure.class); |
||||
|
||||
Map<String, StoreProcedure> procedureMap = new HashMap<>(); |
||||
procedureMap.put("firstPRO", pc1); |
||||
procedureMap.put("secondPRO", pc2); |
||||
EasyMock.expect(proConfig.getProcedure("firstPRO")).andReturn(pc1).once(); |
||||
EasyMock.expect(proConfig.getProcedure("secondPRO")).andReturn(pc2).once(); |
||||
|
||||
Map<String, StoreProcedure> procedureMap2 = new HashMap<>(); |
||||
procedureMap2.put("firstPRO", pc3); |
||||
procedureMap2.put("secondPRO", pc4); |
||||
EasyMock.expect(proConfig2.getProcedure("firstPRO")).andReturn(pc3).once(); |
||||
EasyMock.expect(proConfig2.getProcedure("secondPRO")).andReturn(pc4).once(); |
||||
|
||||
EasyMock.expect(proConfig.getProcedures()).andReturn(procedureMap).once(); |
||||
EasyMock.expect(proConfig2.getProcedures()).andReturn(procedureMap2).once(); |
||||
|
||||
PowerMock.mockStatic(ProcedureConfig.class); |
||||
EasyMock.expect(ProcedureConfig.getInstance()).andReturn(proConfig).once().andReturn(proConfig2).once(); |
||||
|
||||
EasyMock.replay(proConfig, config, config2, proConfig2); |
||||
PowerMock.replay(TableDataFactory.class, TableDataConfig.class, ProcedureConfig.class); |
||||
|
||||
|
||||
Map<String, TableDataWrapper> map = DesignTableDataManager.getAllEditingDataSet(null); |
||||
Assert.assertEquals(4, map.size()); |
||||
Assert.assertSame(pc1, map.get("firstPRO").getTableData()); |
||||
Assert.assertSame(pc2, map.get("secondPRO").getTableData()); |
||||
Assert.assertSame(td1, map.get("firstData").getTableData()); |
||||
Assert.assertSame(td2, map.get("secondData").getTableData()); |
||||
|
||||
DesignTableDataManager.fireDSChanged(new HashMap<String, String>()); |
||||
|
||||
Map<String, TableDataWrapper> map2 = DesignTableDataManager.getAllEditingDataSet(null); |
||||
Assert.assertEquals(4, map2.size()); |
||||
Assert.assertSame(pc3, map2.get("firstPRO").getTableData()); |
||||
Assert.assertSame(pc4, map2.get("secondPRO").getTableData()); |
||||
Assert.assertSame(td3, map2.get("firstData").getTableData()); |
||||
Assert.assertSame(td4, map2.get("secondData").getTableData()); |
||||
|
||||
|
||||
} |
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.fr.file; |
||||
|
||||
import org.easymock.EasyMock; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
public class StashedFILETest { |
||||
|
||||
/** |
||||
* 用于测试暂存文件未保存时的提示 |
||||
*/ |
||||
@Test |
||||
public void testToString() { |
||||
FILE file = EasyMock.mock(FILE.class); |
||||
String name = "getA.cpt"; |
||||
EasyMock.expect(file.getName()).andReturn(name).once(); |
||||
EasyMock.replay(file); |
||||
FILE stashedFILE = new StashedFILE(file, new byte[0]); |
||||
String expectString = FILEFactory.MEM_PREFIX + name; |
||||
Assert.assertEquals(expectString, stashedFILE + ""); |
||||
EasyMock.verify(file); |
||||
} |
||||
} |
@ -1,128 +0,0 @@
|
||||
package com.fr.design.chart; |
||||
|
||||
import com.fr.chart.chartattr.Chart; |
||||
import com.fr.chart.chartattr.ChartCollection; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.gui.controlpane.JListControlPane; |
||||
import com.fr.design.gui.controlpane.NameObjectCreator; |
||||
import com.fr.design.gui.controlpane.NameableCreator; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
|
||||
import com.fr.general.NameObject; |
||||
import com.fr.stable.Nameable; |
||||
|
||||
import java.awt.*; |
||||
import java.util.HashMap; |
||||
|
||||
/** |
||||
* 管理图表类型Pane |
||||
* @author kunsnat: ChartComponent移出. |
||||
*/ |
||||
public class ChartControlPane extends JListControlPane { |
||||
private static final long serialVersionUID = 7336270815128413184L; |
||||
|
||||
public ChartControlPane() { |
||||
super(); |
||||
// 重新设定大小. 因为JControlPane默认的(450,450) 不适合图表这边 @ChartSize
|
||||
// this.setPreferredSize(new Dimension(770, 520));
|
||||
} |
||||
|
||||
@Override |
||||
public NameableCreator[] createNameableCreators() { |
||||
return new NameableCreator[] { |
||||
new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Chart"), Chart.class, ChartTypeUpdatePane.class) |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Manage_Chart_Type"); |
||||
} |
||||
|
||||
public void populate(ChartCollection cc) { |
||||
if(cc == null)return; |
||||
|
||||
NameObject[] nameObjects = new NameObject[cc.getChartCount()]; |
||||
for (int i = 0; i < nameObjects.length; i++) { |
||||
nameObjects[i] = new NameObject(cc.getChartName(i), cc.getChart(i)); |
||||
} |
||||
|
||||
populate(nameObjects); |
||||
// kunsnat: 选中当前图表选中的name
|
||||
String chartSelectedName = cc.getChartName(cc.getSelectedIndex() < cc.getChartCount() ? cc.getSelectedIndex() : 0); |
||||
setSelectedName(chartSelectedName); |
||||
} |
||||
|
||||
public void update(ChartCollection cc) { |
||||
HashMap namesChart = new HashMap();// 暂存判断是否有必要更新
|
||||
for(int i = 0; i < cc.getChartCount(); i++) { |
||||
try { |
||||
namesChart.put(cc.getChartName(i), cc.getChart(i).clone()); |
||||
} catch (CloneNotSupportedException e) { |
||||
|
||||
} |
||||
} |
||||
|
||||
Nameable[] nameables = update(); |
||||
if (nameables.length == 0 || cc == null) { |
||||
return; |
||||
} |
||||
|
||||
cc.removeAllNameObject(); |
||||
String select = getSelectedName(); |
||||
for (int i = 0; i < nameables.length; i++) { |
||||
if (nameables[i] instanceof NameObject && ((NameObject)nameables[i]).getObject() instanceof Chart) { |
||||
NameObject no = (NameObject)nameables[i]; |
||||
|
||||
String name = no.getName(); |
||||
Chart chart = (Chart)no.getObject(); |
||||
if(namesChart.containsKey(name)) { |
||||
Chart tmpChart = (Chart)namesChart.get(name); |
||||
if(chart.getPlot() != null && tmpChart.getPlot() != null |
||||
&& chart.getPlot().match4GUI(tmpChart.getPlot())) { |
||||
chart = tmpChart;// 代替之前做过编辑的Chart
|
||||
} |
||||
} |
||||
cc.addNamedChart(name, chart); |
||||
if(no.getName().equals(select)) { |
||||
cc.setSelectedIndex(i); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
/* |
||||
* alex:继承UpdatePane的ChartTypePane |
||||
*/ |
||||
public static class ChartTypeUpdatePane extends BasicBeanPane<Chart> { |
||||
private static final long serialVersionUID = -7058348930816218415L; |
||||
private Chart editing; |
||||
|
||||
private ChartTypePane typePane; |
||||
|
||||
public ChartTypeUpdatePane() { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
|
||||
typePane = new ChartTypePane(); |
||||
this.add(typePane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "Chart Type"; |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(Chart ob) { |
||||
editing = ob; |
||||
typePane.populate(ob); |
||||
} |
||||
|
||||
@Override |
||||
public Chart updateBean() { |
||||
typePane.update(editing); |
||||
|
||||
return editing; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,58 @@
|
||||
package com.fr.design.chartx; |
||||
|
||||
import com.fr.chart.chartattr.ChartCollection; |
||||
import com.fr.chartx.data.ChartDataDefinitionProvider; |
||||
import com.fr.design.gui.frpane.AttributeChangeListener; |
||||
import com.fr.design.mainframe.chart.gui.ChartDataPane; |
||||
import com.fr.plugin.chart.vanchart.VanChart; |
||||
|
||||
import java.awt.BorderLayout; |
||||
|
||||
/** |
||||
* Created by shine on 2019/4/15. |
||||
*/ |
||||
public abstract class AbstractChartDataPane<T extends ChartDataDefinitionProvider> extends ChartDataPane { |
||||
|
||||
public AbstractChartDataPane(AttributeChangeListener listener) { |
||||
super(listener); |
||||
} |
||||
|
||||
protected abstract void populate(T t); |
||||
|
||||
protected abstract T update(); |
||||
|
||||
@Override |
||||
public void populate(ChartCollection collection) { |
||||
if (collection == null) { |
||||
return; |
||||
} |
||||
VanChart chart = collection.getSelectedChart(VanChart.class); |
||||
if (chart == null) { |
||||
return; |
||||
} |
||||
|
||||
this.removeAll(); |
||||
this.add(createContentPane(), BorderLayout.CENTER); |
||||
|
||||
ChartDataDefinitionProvider dataSetCollection = chart.getChartDataDefinition(); |
||||
|
||||
populate((T) dataSetCollection); |
||||
|
||||
this.initAllListeners(); |
||||
this.validate(); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void update(ChartCollection collection) { |
||||
if (collection == null) { |
||||
return; |
||||
} |
||||
VanChart chart = collection.getSelectedChart(VanChart.class); |
||||
if (chart == null) { |
||||
return; |
||||
} |
||||
|
||||
chart.setChartDataDefinition(update()); |
||||
} |
||||
} |
@ -0,0 +1,39 @@
|
||||
package com.fr.design.chartx; |
||||
|
||||
import com.fr.chartx.data.GanttChartDataDefinition; |
||||
import com.fr.design.gui.frpane.AttributeChangeListener; |
||||
import com.fr.van.chart.map.designer.VanChartGroupPane; |
||||
|
||||
import javax.swing.JPanel; |
||||
|
||||
/** |
||||
* Created by shine on 2019/5/22. |
||||
*/ |
||||
public class GanttChartDataPane extends AbstractChartDataPane<GanttChartDataDefinition> { |
||||
|
||||
private MultiCategoryChartDataPane dataPane; |
||||
private MultiCategoryChartDataPane linkPane; |
||||
|
||||
@Override |
||||
protected JPanel createContentPane() { |
||||
dataPane = new MultiCategoryChartDataPane(listener); |
||||
linkPane = new MultiCategoryChartDataPane(listener); |
||||
return new VanChartGroupPane(new String[]{"data", "link"}, new JPanel[]{dataPane, linkPane}) { |
||||
}; |
||||
} |
||||
|
||||
public GanttChartDataPane(AttributeChangeListener listener) { |
||||
super(listener); |
||||
} |
||||
|
||||
@Override |
||||
protected void populate(GanttChartDataDefinition ganttChartDataDefinition) { |
||||
dataPane.populate(ganttChartDataDefinition.getDataDefinition()); |
||||
linkPane.populate(ganttChartDataDefinition.getLinkDefinition()); |
||||
} |
||||
|
||||
@Override |
||||
protected GanttChartDataDefinition update() { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,43 @@
|
||||
package com.fr.design.chartx; |
||||
|
||||
import com.fr.chartx.data.AbstractDataDefinition; |
||||
import com.fr.design.chartx.fields.diff.MultiCategoryCellDataFieldsPane; |
||||
import com.fr.design.chartx.fields.diff.MultiCategoryDataSetFieldsPane; |
||||
import com.fr.design.chartx.single.SingleDataPane; |
||||
import com.fr.design.gui.frpane.AttributeChangeListener; |
||||
|
||||
import javax.swing.JPanel; |
||||
|
||||
/** |
||||
* Created by shine on 2019/5/22. |
||||
*/ |
||||
public class MultiCategoryChartDataPane extends AbstractChartDataPane<AbstractDataDefinition> { |
||||
|
||||
private SingleDataPane singleDataPane; |
||||
|
||||
public MultiCategoryChartDataPane(AttributeChangeListener listener) { |
||||
super(listener); |
||||
} |
||||
|
||||
@Override |
||||
protected void populate(AbstractDataDefinition dataDefinition) { |
||||
singleDataPane.populateBean(dataDefinition); |
||||
} |
||||
|
||||
@Override |
||||
protected AbstractDataDefinition update() { |
||||
return singleDataPane.updateBean(); |
||||
} |
||||
|
||||
@Override |
||||
protected JPanel createContentPane() { |
||||
singleDataPane = createSingleDataPane(); |
||||
return singleDataPane; |
||||
} |
||||
|
||||
protected SingleDataPane createSingleDataPane() { |
||||
return new SingleDataPane(new MultiCategoryDataSetFieldsPane(), new MultiCategoryCellDataFieldsPane()); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,21 @@
|
||||
package com.fr.design.chartx; |
||||
|
||||
import com.fr.design.chartx.fields.diff.MultiPieCellDataFieldsPane; |
||||
import com.fr.design.chartx.fields.diff.MultiPieDataSetFieldsPane; |
||||
import com.fr.design.chartx.single.SingleDataPane; |
||||
import com.fr.design.gui.frpane.AttributeChangeListener; |
||||
|
||||
/** |
||||
* Created by shine on 2019/6/18. |
||||
*/ |
||||
public class MultiPieChartDataPane extends MultiCategoryChartDataPane { |
||||
|
||||
public MultiPieChartDataPane(AttributeChangeListener listener) { |
||||
super(listener); |
||||
} |
||||
|
||||
@Override |
||||
protected SingleDataPane createSingleDataPane() { |
||||
return new SingleDataPane(new MultiPieDataSetFieldsPane(), new MultiPieCellDataFieldsPane()); |
||||
} |
||||
} |
@ -0,0 +1,20 @@
|
||||
package com.fr.design.chartx; |
||||
|
||||
import com.fr.design.chartx.fields.diff.WordCloudCellDataFieldsPane; |
||||
import com.fr.design.chartx.fields.diff.WordCloudDataSetFieldsPane; |
||||
import com.fr.design.chartx.single.SingleDataPane; |
||||
import com.fr.design.gui.frpane.AttributeChangeListener; |
||||
|
||||
/** |
||||
* Created by shine on 2019/5/22. |
||||
*/ |
||||
public class WordCloudChartDataPane extends MultiCategoryChartDataPane { |
||||
public WordCloudChartDataPane(AttributeChangeListener listener) { |
||||
super(listener); |
||||
} |
||||
|
||||
@Override |
||||
protected SingleDataPane createSingleDataPane() { |
||||
return new SingleDataPane(new WordCloudDataSetFieldsPane(), new WordCloudCellDataFieldsPane()); |
||||
} |
||||
} |
@ -0,0 +1,252 @@
|
||||
package com.fr.design.chartx.component; |
||||
|
||||
import com.fr.data.util.function.AbstractDataFunction; |
||||
import com.fr.design.beans.FurtherBasicBeanPane; |
||||
import com.fr.design.chartx.component.correlation.AbstractCorrelationPane; |
||||
import com.fr.design.chartx.component.correlation.CalculateComboBoxEditorComponent; |
||||
import com.fr.design.chartx.component.correlation.FieldEditorComponentWrapper; |
||||
import com.fr.design.chartx.component.correlation.UIComboBoxEditorComponent; |
||||
import com.fr.design.chartx.component.correlation.UITextFieldEditorComponent; |
||||
import com.fr.design.gui.frpane.UIComboBoxPane; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.chart.gui.ChartDataPane; |
||||
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; |
||||
import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper; |
||||
import com.fr.extended.chart.UIComboBoxWithNone; |
||||
import com.fr.general.GeneralUtils; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.JPanel; |
||||
import javax.swing.SwingConstants; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by shine on 2018/9/12. |
||||
* 系列名使用字段名or字段值的抽象的pane 支持多种属性结构的存取 |
||||
*/ |
||||
public abstract class AbstractCustomFieldComboBoxPane<T> extends UIComboBoxPane<T> { |
||||
|
||||
private AbstractUseFieldValuePane useFieldValuePane; |
||||
|
||||
private AbstractCustomFieldNamePane customFieldNamePane; |
||||
|
||||
private List<String> fieldList = new ArrayList<String>(); |
||||
|
||||
@Override |
||||
protected void initLayout() { |
||||
this.setLayout(new BorderLayout(0, 6)); |
||||
JPanel northPane = new JPanel(new BorderLayout()); |
||||
northPane.add(jcb, BorderLayout.CENTER); |
||||
UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name_From")); |
||||
label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, 20)); |
||||
northPane.add(label, BorderLayout.WEST); |
||||
this.add(northPane, BorderLayout.NORTH); |
||||
this.add(cardPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
@Override |
||||
protected List<FurtherBasicBeanPane<? extends T>> initPaneList() { |
||||
useFieldValuePane = createUseFieldValuePane(); |
||||
customFieldNamePane = createCustomFieldNamePane(); |
||||
List<FurtherBasicBeanPane<? extends T>> list = new ArrayList<FurtherBasicBeanPane<? extends T>>(); |
||||
list.add(useFieldValuePane); |
||||
list.add(paneWrapper()); |
||||
return list; |
||||
} |
||||
|
||||
private FurtherBasicBeanPane<? extends T> paneWrapper() { |
||||
FurtherBasicBeanPane pane = new FurtherBasicBeanPane() { |
||||
@Override |
||||
public String title4PopupWindow() { |
||||
return Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Name"); |
||||
} |
||||
|
||||
@Override |
||||
public boolean accept(Object ob) { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void reset() { |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(Object ob) { |
||||
} |
||||
|
||||
@Override |
||||
public Object updateBean() { |
||||
return null; |
||||
} |
||||
}; |
||||
pane.setLayout(new BorderLayout(0, 6)); |
||||
pane.add(customFieldNamePane, BorderLayout.CENTER); |
||||
return pane; |
||||
} |
||||
|
||||
protected abstract AbstractUseFieldValuePane createUseFieldValuePane(); |
||||
|
||||
protected abstract AbstractCustomFieldNamePane createCustomFieldNamePane(); |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
|
||||
protected boolean valueComboBoxHasNone() { |
||||
return false; |
||||
} |
||||
|
||||
public void checkBoxUse(boolean hasUse) { |
||||
jcb.setEnabled(hasUse); |
||||
useFieldValuePane.checkBoxUse(hasUse); |
||||
} |
||||
|
||||
public void clearAllBoxList() { |
||||
useFieldValuePane.clearAllBoxList(); |
||||
fieldList.clear(); |
||||
} |
||||
|
||||
public void refreshBoxListWithSelectTableData(List columnNameList) { |
||||
useFieldValuePane.refreshBoxListWithSelectTableData(columnNameList); |
||||
fieldList = columnNameList; |
||||
} |
||||
|
||||
protected void populateCustomFieldNamePane(T t) { |
||||
customFieldNamePane.populateBean(t); |
||||
} |
||||
|
||||
protected void updateCustomFieldNamePane(T t) { |
||||
customFieldNamePane.updateBean(t); |
||||
} |
||||
|
||||
protected void populateUseFieldValuePane(T t) { |
||||
useFieldValuePane.populateBean(t); |
||||
} |
||||
|
||||
protected void updateUseFieldValuePane(T t) { |
||||
useFieldValuePane.updateBean(t); |
||||
} |
||||
|
||||
protected abstract class AbstractUseFieldValuePane extends FurtherBasicBeanPane<T> { |
||||
private UIComboBox series; |
||||
private UIComboBox value; |
||||
private CalculateComboBox function; |
||||
|
||||
public AbstractUseFieldValuePane() { |
||||
initComponents(); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
|
||||
series = new UIComboBox(); |
||||
value = valueComboBoxHasNone() ? new UIComboBoxWithNone() : new UIComboBox(); |
||||
|
||||
function = new CalculateComboBox(); |
||||
|
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Series_Name"), SwingConstants.LEFT), series}, |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Use_Value"), SwingConstants.LEFT), value}, |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Summary_Method"), SwingConstants.LEFT), function}, |
||||
}; |
||||
|
||||
double p = TableLayout.PREFERRED; |
||||
double[] columnSize = {78, 122}; |
||||
double[] rowSize = {p, p, p}; |
||||
|
||||
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
||||
|
||||
this.setLayout(new BorderLayout(0, 6)); |
||||
this.add(panel, BorderLayout.CENTER); |
||||
} |
||||
|
||||
public void checkBoxUse(boolean hasUse) { |
||||
series.setEnabled(hasUse); |
||||
value.setEnabled(hasUse); |
||||
function.setEnabled(hasUse); |
||||
} |
||||
|
||||
public void clearAllBoxList() { |
||||
DataPaneHelper.clearBoxItems(series); |
||||
DataPaneHelper.clearBoxItems(value); |
||||
} |
||||
|
||||
public void refreshBoxListWithSelectTableData(List columnNameList) { |
||||
DataPaneHelper.refreshBoxItems(series, columnNameList); |
||||
DataPaneHelper.refreshBoxItems(value, columnNameList); |
||||
} |
||||
|
||||
protected void populateSeries(String item) { |
||||
series.setSelectedItem(item); |
||||
} |
||||
|
||||
protected void populateValue(String item) { |
||||
value.setSelectedItem(item); |
||||
} |
||||
|
||||
protected void populateFunction(AbstractDataFunction _function) { |
||||
function.populateBean(_function); |
||||
} |
||||
|
||||
protected String updateSeries() { |
||||
return GeneralUtils.objectToString(series.getSelectedItem()); |
||||
} |
||||
|
||||
protected String updateValue() { |
||||
return GeneralUtils.objectToString(value.getSelectedItem()); |
||||
} |
||||
|
||||
protected AbstractDataFunction updateFunction() { |
||||
return function.updateBean(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean accept(Object ob) { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public void reset() { |
||||
} |
||||
|
||||
@Override |
||||
public String title4PopupWindow() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Value"); |
||||
} |
||||
|
||||
@Override |
||||
public T updateBean() { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
protected abstract class AbstractCustomFieldNamePane extends AbstractCorrelationPane<T> { |
||||
|
||||
@Override |
||||
protected FieldEditorComponentWrapper[] createFieldEditorComponentWrappers() { |
||||
return new FieldEditorComponentWrapper[]{ |
||||
new UIComboBoxEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Field_Name")) { |
||||
@Override |
||||
protected List<String> items() { |
||||
return fieldList; |
||||
} |
||||
}, |
||||
new UITextFieldEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Name")), |
||||
new CalculateComboBoxEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Summary_Method")) |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
protected Object[] createLine() { |
||||
return new String[]{StringUtils.EMPTY, StringUtils.EMPTY, Toolkit.i18nText("Fine-Design_Chart_Use_None")}; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,168 @@
|
||||
package com.fr.design.chartx.component; |
||||
|
||||
import com.fr.chartx.data.field.ColumnField; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.ilable.BoldFontTextLabel; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.mainframe.chart.gui.ChartDataPane; |
||||
import com.fr.general.IOUtils; |
||||
|
||||
import javax.swing.BoxLayout; |
||||
import javax.swing.JComponent; |
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
|
||||
/** |
||||
* Created by shine on 2019/4/10. |
||||
* 一列组件<T extends JComponent> 可增可删,通过JComponent后面的加减button增删。 |
||||
*/ |
||||
public abstract class AbstractMultiComponentPane<T extends JComponent> extends JPanel { |
||||
private static final int COM_W = 96; |
||||
private static final int H = 20; |
||||
private static final int ICON_W = 20; |
||||
|
||||
private JPanel boxPane; |
||||
private UIButton addButton; |
||||
|
||||
private T firstFieldComponent; |
||||
|
||||
private List<T> categoryComponentList = new ArrayList<T>(); |
||||
|
||||
|
||||
protected abstract T createFirstFieldComponent(); |
||||
|
||||
protected abstract T createOtherFieldComponent(); |
||||
|
||||
protected abstract void populateField(T component, ColumnField field); |
||||
|
||||
protected abstract void updateField(T component, ColumnField field); |
||||
|
||||
public AbstractMultiComponentPane() { |
||||
|
||||
UILabel label = new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Category")); |
||||
label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); |
||||
|
||||
firstFieldComponent = createFirstFieldComponent(); |
||||
firstFieldComponent.setPreferredSize(new Dimension(COM_W, H)); |
||||
|
||||
addButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); |
||||
addButton.setPreferredSize(new Dimension(ICON_W, H)); |
||||
addButton.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
if (canAdd()) { |
||||
addNewComboBox(); |
||||
} |
||||
} |
||||
}); |
||||
|
||||
final JPanel panel = new JPanel(); |
||||
panel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2)); |
||||
|
||||
panel.add(label); |
||||
panel.add(firstFieldComponent); |
||||
panel.add(addButton); |
||||
|
||||
boxPane = new JPanel(); |
||||
boxPane.setLayout(new BoxLayout(boxPane, BoxLayout.Y_AXIS)); |
||||
|
||||
this.setLayout(new BorderLayout(4, 0)); |
||||
this.add(panel, BorderLayout.NORTH); |
||||
this.add(boxPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
private JPanel addComboBoxAndButtonToBox(T uiComboBox, UIButton uiButton) { |
||||
final JPanel panel = new JPanel(); |
||||
panel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2)); |
||||
|
||||
panel.add(uiComboBox); |
||||
panel.add(uiButton); |
||||
|
||||
boxPane.add(panel); |
||||
categoryComponentList.add(uiComboBox); |
||||
|
||||
return panel; |
||||
} |
||||
|
||||
private void addNewComboBox() { |
||||
final T comboBox = createOtherFieldComponent(); |
||||
comboBox.setPreferredSize(new Dimension(COM_W, H)); |
||||
|
||||
UIButton delButton = new UIButton(IOUtils.readIcon("com/fr/design/images/toolbarbtn/close.png")); |
||||
delButton.setPreferredSize(new Dimension(ICON_W, H)); |
||||
|
||||
final JPanel panel = addComboBoxAndButtonToBox(comboBox, delButton); |
||||
|
||||
delButton.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
boxPane.remove(panel); |
||||
categoryComponentList.remove(comboBox); |
||||
checkAddButton(); |
||||
relayoutPane(); |
||||
} |
||||
}); |
||||
|
||||
relayoutPane(); |
||||
checkAddButton(); |
||||
} |
||||
|
||||
private void relayoutPane() { |
||||
this.revalidate(); |
||||
} |
||||
|
||||
private void checkAddButton() { |
||||
addButton.setEnabled(canAdd()); |
||||
} |
||||
|
||||
private boolean canAdd() { |
||||
return categoryComponentList.size() < 3; |
||||
} |
||||
|
||||
public List<T> componentList() { |
||||
List<T> list = new ArrayList<>(categoryComponentList); |
||||
list.add(firstFieldComponent); |
||||
return list; |
||||
} |
||||
|
||||
public void populate(List<ColumnField> categoryList) { |
||||
int comboBoxSize = categoryComponentList.size(), |
||||
len = categoryList.size(); |
||||
|
||||
if (len > 0) { |
||||
populateField(firstFieldComponent, categoryList.get(0)); |
||||
} |
||||
|
||||
for (int i = 1; i < len; i++) { |
||||
if (i > comboBoxSize) { |
||||
addNewComboBox(); |
||||
} |
||||
T comboBox = categoryComponentList.get(i - 1); |
||||
populateField(comboBox, categoryList.get(i)); |
||||
} |
||||
|
||||
checkAddButton(); |
||||
relayoutPane(); |
||||
} |
||||
|
||||
public void update(List<ColumnField> categoryList) { |
||||
categoryList.clear(); |
||||
|
||||
ColumnField temp1 = new ColumnField(); |
||||
categoryList.add(temp1); |
||||
updateField(firstFieldComponent, temp1); |
||||
|
||||
for (T comboBox : categoryComponentList) { |
||||
ColumnField temp = new ColumnField(); |
||||
categoryList.add(temp); |
||||
updateField(comboBox, temp); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,150 @@
|
||||
package com.fr.design.chartx.component; |
||||
|
||||
import com.fr.chartx.data.field.ColumnField; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.ispinner.UISpinner; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.chart.gui.ChartDataPane; |
||||
|
||||
import javax.swing.JComponent; |
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by shine on 2019/6/18. |
||||
* 一列组件<T extends JComponent> 可增可删,通过UISpinner增删。 |
||||
*/ |
||||
public abstract class AbstractMultiComponentPaneWithUISpinner<T extends JComponent> extends JPanel { |
||||
|
||||
private UISpinner levelNumSpinner; |
||||
|
||||
private List<T> levelComponentList = new ArrayList<T>(); |
||||
|
||||
private JPanel levelPane; |
||||
|
||||
private int currentNum = 3; |
||||
|
||||
public AbstractMultiComponentPaneWithUISpinner() { |
||||
initComps(); |
||||
} |
||||
|
||||
public List<T> getComponentList() { |
||||
return levelComponentList; |
||||
} |
||||
|
||||
protected abstract T createJComponent(); |
||||
|
||||
protected abstract void populateField(T component, ColumnField field); |
||||
|
||||
protected abstract void updateField(T component, ColumnField field); |
||||
|
||||
protected void initComps() { |
||||
|
||||
this.setLayout(new BorderLayout(0, 6)); |
||||
|
||||
levelNumSpinner = new UISpinner(1, 15, 1, currentNum) { |
||||
@Override |
||||
protected void fireStateChanged() { |
||||
//先处理自身的空间布局
|
||||
refreshLevelPane(); |
||||
//然后更新数据
|
||||
super.fireStateChanged(); |
||||
} |
||||
|
||||
@Override |
||||
public void setTextFieldValue(double value) { |
||||
//如果为0,则没有改变值
|
||||
if (value == 0) { |
||||
return; |
||||
} |
||||
super.setTextFieldValue(value); |
||||
} |
||||
}; |
||||
|
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Level_Number")), levelNumSpinner}, |
||||
}; |
||||
|
||||
JPanel northPane = TableLayoutHelper.createGapTableLayoutPane(components, new double[]{TableLayout.PREFERRED}, new double[]{ChartDataPane.LABEL_WIDTH, 122}, 0, 6); |
||||
|
||||
this.add(northPane, BorderLayout.NORTH); |
||||
|
||||
initLevelPane(); |
||||
} |
||||
|
||||
private void initLevelPane() { |
||||
double[] rows = new double[currentNum]; |
||||
|
||||
Component[][] components = new Component[currentNum][2]; |
||||
|
||||
List<T> newList = new ArrayList<T>(); |
||||
|
||||
int maxSize = levelComponentList.size(); |
||||
for (int i = 0; i < currentNum; i++) { |
||||
rows[i] = TableLayout.PREFERRED; |
||||
T component = i < maxSize ? levelComponentList.get(i) : createJComponent(); |
||||
newList.add(component); |
||||
|
||||
components[i] = new Component[]{ |
||||
new UILabel(Toolkit.i18nText("Fine-Design_Chart_Level") + String.valueOf(i + 1)), |
||||
component |
||||
}; |
||||
} |
||||
|
||||
levelComponentList = newList; |
||||
|
||||
levelPane = TableLayoutHelper.createGapTableLayoutPane(components, rows, new double[]{ChartDataPane.LABEL_WIDTH, 122}, 0, 6); |
||||
|
||||
this.add(levelPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
private void refreshLevelPane() { |
||||
if (levelNumSpinner == null) { |
||||
return; |
||||
} |
||||
|
||||
int newNum = (int) levelNumSpinner.getValue(); |
||||
|
||||
if (newNum != currentNum) { |
||||
currentNum = newNum; |
||||
this.remove(levelPane); |
||||
this.initLevelPane(); |
||||
} |
||||
|
||||
refreshPane(); |
||||
} |
||||
|
||||
private void refreshPane() { |
||||
this.validate(); |
||||
this.repaint(); |
||||
this.revalidate(); |
||||
} |
||||
|
||||
public void populate(List<ColumnField> categoryList) { |
||||
int len = categoryList.size(); |
||||
levelNumSpinner.setValue(len); |
||||
|
||||
refreshLevelPane(); |
||||
|
||||
for (int i = 0; i < len; i++) { |
||||
ColumnField columnField = categoryList.get(i); |
||||
T component = levelComponentList.get(i); |
||||
populateField(component, columnField); |
||||
} |
||||
} |
||||
|
||||
public void update(List<ColumnField> categoryList) { |
||||
categoryList.clear(); |
||||
|
||||
for (T comboBox : levelComponentList) { |
||||
ColumnField temp = new ColumnField(); |
||||
categoryList.add(temp); |
||||
updateField(comboBox, temp); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,171 @@
|
||||
package com.fr.design.chartx.component; |
||||
|
||||
import com.fr.base.Utils; |
||||
import com.fr.chartx.data.field.DataFilterProperties; |
||||
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; |
||||
import com.fr.design.gui.icheckbox.UICheckBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.mainframe.chart.gui.data.PresentComboBox; |
||||
import com.fr.design.mainframe.chart.gui.style.AbstractChartTabPane; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
|
||||
/** |
||||
* Created by shine on 2019/07/18. |
||||
*/ |
||||
public abstract class AbstractSingleFilterPane extends AbstractChartTabPane<DataFilterProperties> { |
||||
|
||||
private static final int FIL_HEIGHT = 150; |
||||
|
||||
private UICheckBox useTopCheckBox; |
||||
|
||||
private UITextField topNumTextField; |
||||
private UICheckBox hideNullCheckBox; |
||||
private UICheckBox mergeOtherCheckBox; |
||||
|
||||
private PresentComboBox present; |
||||
|
||||
private AbstractAttrNoScrollPane parent; |
||||
|
||||
private JPanel topPane; |
||||
|
||||
public AbstractSingleFilterPane() { |
||||
super(true); |
||||
//todo@shinerefactor present的时候这边可以整理下
|
||||
// this.parent = parent;
|
||||
} |
||||
|
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
Dimension dim = super.getPreferredSize(); |
||||
dim.height = FIL_HEIGHT; |
||||
return dim; |
||||
} |
||||
|
||||
|
||||
protected void layoutContentPane() { |
||||
super.layoutContentPane(); |
||||
leftcontentPane.setBorder(BorderFactory.createEmptyBorder()); |
||||
} |
||||
|
||||
public void reloaPane(JPanel pane) { |
||||
super.reloaPane(pane); |
||||
leftcontentPane.setBorder(BorderFactory.createEmptyBorder()); |
||||
} |
||||
|
||||
@Override |
||||
protected JPanel createContentPane() { |
||||
this.setLayout(new BorderLayout()); |
||||
JPanel pane = initPane(); |
||||
this.add(pane, BorderLayout.NORTH); |
||||
return pane; |
||||
} |
||||
|
||||
|
||||
private JPanel initPane() { |
||||
useTopCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Only_Use_Before_Records")); |
||||
JPanel panel1 = new JPanel(new BorderLayout()); |
||||
JPanel panel2 = new JPanel(new BorderLayout()); |
||||
panel1.add(useTopCheckBox, BorderLayout.NORTH); |
||||
topNumTextField = new UITextField(); |
||||
UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Records_Num")); |
||||
mergeOtherCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_CombineOther")); |
||||
mergeOtherCheckBox.setSelected(true); |
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double[] columnSize = {p, f}; |
||||
double[] rowSize = {p, p}; |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{label, topNumTextField}, |
||||
new Component[]{mergeOtherCheckBox, null} |
||||
}; |
||||
|
||||
topPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); |
||||
topPane.setBorder(BorderFactory.createEmptyBorder(10, 15, 0, 0)); |
||||
//默认不显示
|
||||
topPane.setVisible(false); |
||||
panel1.add(topPane, BorderLayout.CENTER); |
||||
hideNullCheckBox = new UICheckBox(title4PopupWindow() + " is null, hidden"); |
||||
panel2.add(hideNullCheckBox, BorderLayout.NORTH); |
||||
|
||||
useTopCheckBox.addChangeListener(new ChangeListener() { |
||||
public void stateChanged(ChangeEvent e) { |
||||
checkBoxUse(); |
||||
} |
||||
}); |
||||
|
||||
present = new PresentComboBox() { |
||||
protected void fireChange() { |
||||
fire(); |
||||
} |
||||
}; |
||||
JPanel presentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Present"), present); |
||||
panel2.add(presentPane, BorderLayout.SOUTH); |
||||
|
||||
double[] column = {f}; |
||||
double[] row = {p, p}; |
||||
Component[][] coms = new Component[][]{ |
||||
new Component[]{panel1}, |
||||
new Component[]{panel2} |
||||
}; |
||||
return TableLayout4VanChartHelper.createGapTableLayoutPane(coms, row, column); |
||||
} |
||||
|
||||
|
||||
private void fire() { |
||||
if (this.parent != null) { |
||||
parent.attributeChanged(); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 检查Box是否可用 |
||||
*/ |
||||
public void checkBoxUse() { |
||||
topPane.setVisible(useTopCheckBox.isSelected()); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(DataFilterProperties ob) { |
||||
useTopCheckBox.setSelected(ob.isUseTop()); |
||||
|
||||
topNumTextField.setText(String.valueOf(ob.getTop())); |
||||
|
||||
hideNullCheckBox.setSelected(ob.isHideNull()); |
||||
|
||||
mergeOtherCheckBox.setSelected(ob.isMerge()); |
||||
|
||||
present.populate(ob.getPresent()); |
||||
|
||||
checkBoxUse(); |
||||
} |
||||
|
||||
@Override |
||||
public DataFilterProperties updateBean() { |
||||
DataFilterProperties dataFilterProperties = new DataFilterProperties(); |
||||
|
||||
dataFilterProperties.setUseTop(useTopCheckBox.isSelected()); |
||||
|
||||
Number number = Utils.objectToNumber(topNumTextField.getText(), true); |
||||
if (number != null) { |
||||
dataFilterProperties.setTop(number.intValue()); |
||||
} |
||||
dataFilterProperties.setHideNull(hideNullCheckBox.isSelected()); |
||||
|
||||
dataFilterProperties.setMerge(mergeOtherCheckBox.isSelected()); |
||||
|
||||
dataFilterProperties.setPresent(present.update()); |
||||
|
||||
return dataFilterProperties; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,56 @@
|
||||
package com.fr.design.chartx.component; |
||||
|
||||
import com.fr.chartx.data.field.ColumnField; |
||||
import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; |
||||
import com.fr.chartx.data.field.SeriesValueField; |
||||
import com.fr.design.chartx.component.correlation.AbstractCorrelationPane; |
||||
import com.fr.design.chartx.component.correlation.FieldEditorComponentWrapper; |
||||
import com.fr.design.chartx.component.correlation.TinyFormulaPaneEditorComponent; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.general.GeneralUtils; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by shine on 2019/6/4. |
||||
*/ |
||||
public class CellDataSeriesValueCorrelationPane extends AbstractCorrelationPane<SeriesValueCorrelationDefinition> { |
||||
|
||||
@Override |
||||
protected FieldEditorComponentWrapper[] createFieldEditorComponentWrappers() { |
||||
return new FieldEditorComponentWrapper[]{ |
||||
new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Name")), |
||||
new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Value")) |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
protected List<Object[]> covertTBeanToTableModelList(SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) { |
||||
List<Object[]> result = new ArrayList<Object[]>(); |
||||
|
||||
List<SeriesValueField> seriesValueFieldList = seriesValueCorrelationDefinition.getSeriesValueFieldList(); |
||||
for (SeriesValueField seriesValueField : seriesValueFieldList) { |
||||
Object[] array = new Object[]{seriesValueField.getSeries().getFieldName(), seriesValueField.getValue().getFieldName()}; |
||||
result.add(array); |
||||
} |
||||
|
||||
return result; |
||||
} |
||||
|
||||
@Override |
||||
protected void setTableModelListToTBean(List<Object[]> tableValues, SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) { |
||||
List<SeriesValueField> seriesValueFieldList = new ArrayList<SeriesValueField>(); |
||||
|
||||
for (Object[] oneLine : tableValues) { |
||||
SeriesValueField seriesValueField = new SeriesValueField(); |
||||
ColumnField series = new ColumnField(GeneralUtils.objectToString(oneLine[0])); |
||||
ColumnField value = new ColumnField(GeneralUtils.objectToString(oneLine[1])); |
||||
seriesValueField.setSeries(series); |
||||
seriesValueField.setValue(value); |
||||
seriesValueFieldList.add(seriesValueField); |
||||
} |
||||
|
||||
seriesValueCorrelationDefinition.setSeriesValueFieldList(seriesValueFieldList); |
||||
} |
||||
} |
@ -0,0 +1,40 @@
|
||||
package com.fr.design.chartx.component; |
||||
|
||||
import com.fr.chartx.data.field.ColumnField; |
||||
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.extended.chart.UIComboBoxWithNone; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by shine on 2019/4/12. |
||||
*/ |
||||
public class MultiComboBoxPane extends AbstractMultiComponentPane<UIComboBox> { |
||||
private List currentBoxItems = new ArrayList(); |
||||
|
||||
public void setCurrentBoxItems(List currentBoxItems) { |
||||
this.currentBoxItems = currentBoxItems; |
||||
} |
||||
|
||||
@Override |
||||
protected UIComboBox createFirstFieldComponent() { |
||||
return new UIComboBoxWithNone(); |
||||
} |
||||
|
||||
@Override |
||||
protected UIComboBox createOtherFieldComponent() { |
||||
return new UIComboBox(currentBoxItems.toArray(new Object[currentBoxItems.size()])); |
||||
} |
||||
|
||||
@Override |
||||
protected void populateField(UIComboBox component, ColumnField field) { |
||||
AbstractDataSetFieldsPane.populateField(component, field); |
||||
} |
||||
|
||||
@Override |
||||
protected void updateField(UIComboBox component, ColumnField field) { |
||||
AbstractDataSetFieldsPane.updateField(component, field); |
||||
} |
||||
} |
@ -0,0 +1,40 @@
|
||||
package com.fr.design.chartx.component; |
||||
|
||||
import com.fr.chartx.data.field.ColumnField; |
||||
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by shine on 2019/6/18. |
||||
*/ |
||||
public class MultiComboBoxPaneWithUISpinner extends AbstractMultiComponentPaneWithUISpinner<UIComboBox> { |
||||
private List currentBoxList = new ArrayList(); |
||||
|
||||
@Override |
||||
protected void initComps() { |
||||
currentBoxList = new ArrayList(); |
||||
super.initComps(); |
||||
} |
||||
|
||||
public void setCurrentBoxList(List currentBoxList) { |
||||
this.currentBoxList = currentBoxList; |
||||
} |
||||
|
||||
@Override |
||||
protected UIComboBox createJComponent() { |
||||
return new UIComboBox(currentBoxList.toArray(new Object[currentBoxList.size()])); |
||||
} |
||||
|
||||
@Override |
||||
protected void populateField(UIComboBox component, ColumnField field) { |
||||
AbstractDataSetFieldsPane.populateField(component, field); |
||||
} |
||||
|
||||
@Override |
||||
protected void updateField(UIComboBox component, ColumnField field) { |
||||
AbstractDataSetFieldsPane.updateField(component, field); |
||||
} |
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.fr.design.chartx.component; |
||||
|
||||
import com.fr.chartx.data.field.ColumnField; |
||||
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; |
||||
import com.fr.design.formula.TinyFormulaPane; |
||||
|
||||
/** |
||||
* Created by shine on 2019/4/12. |
||||
*/ |
||||
public class MultiTinyFormulaPane extends AbstractMultiComponentPane<TinyFormulaPane> { |
||||
@Override |
||||
protected TinyFormulaPane createFirstFieldComponent() { |
||||
return new TinyFormulaPane(); |
||||
} |
||||
|
||||
@Override |
||||
protected TinyFormulaPane createOtherFieldComponent() { |
||||
return new TinyFormulaPane(); |
||||
} |
||||
|
||||
@Override |
||||
protected void populateField(TinyFormulaPane component, ColumnField field) { |
||||
AbstractCellDataFieldsPane.populateField(component, field); |
||||
} |
||||
|
||||
@Override |
||||
protected void updateField(TinyFormulaPane component, ColumnField field) { |
||||
AbstractCellDataFieldsPane.updateField(component, field); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fr.design.chartx.component; |
||||
|
||||
import com.fr.chartx.data.field.ColumnField; |
||||
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; |
||||
import com.fr.design.formula.TinyFormulaPane; |
||||
|
||||
/** |
||||
* Created by shine on 2019/6/19. |
||||
*/ |
||||
public class MultiTinyFormulaPaneWithUISpinner extends AbstractMultiComponentPaneWithUISpinner<TinyFormulaPane> { |
||||
@Override |
||||
protected TinyFormulaPane createJComponent() { |
||||
return new TinyFormulaPane(); |
||||
} |
||||
|
||||
@Override |
||||
protected void populateField(TinyFormulaPane component, ColumnField field) { |
||||
AbstractCellDataFieldsPane.populateField(component, field); |
||||
} |
||||
|
||||
@Override |
||||
protected void updateField(TinyFormulaPane component, ColumnField field) { |
||||
AbstractCellDataFieldsPane.updateField(component, field); |
||||
} |
||||
} |
@ -0,0 +1,107 @@
|
||||
package com.fr.design.chartx.component; |
||||
|
||||
import com.fr.chartx.data.field.ColumnField; |
||||
import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; |
||||
import com.fr.chartx.data.field.SeriesValueField; |
||||
import com.fr.data.util.function.AbstractDataFunction; |
||||
import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper; |
||||
import com.fr.general.GeneralUtils; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by shine on 2019/5/17. |
||||
*/ |
||||
public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPane<SeriesValueCorrelationDefinition> { |
||||
|
||||
@Override |
||||
protected AbstractUseFieldValuePane createUseFieldValuePane() { |
||||
return new UseFieldValuePane(); |
||||
} |
||||
|
||||
@Override |
||||
protected AbstractCustomFieldNamePane createCustomFieldNamePane() { |
||||
return new CustomFieldNamePane(); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(SeriesValueCorrelationDefinition ob) { |
||||
if (ob.isCustomFieldValue()) { |
||||
populateCustomFieldNamePane(ob); |
||||
jcb.setSelectedIndex(1); |
||||
} else { |
||||
populateUseFieldValuePane(ob); |
||||
jcb.setSelectedIndex(0); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void updateBean(SeriesValueCorrelationDefinition ob) { |
||||
if (jcb.getSelectedIndex() == 0) { |
||||
ob.setCustomFieldValue(false); |
||||
updateUseFieldValuePane(ob); |
||||
} else { |
||||
ob.setCustomFieldValue(true); |
||||
updateCustomFieldNamePane(ob); |
||||
} |
||||
} |
||||
|
||||
private class UseFieldValuePane extends AbstractUseFieldValuePane { |
||||
|
||||
@Override |
||||
public void populateBean(SeriesValueCorrelationDefinition ob) { |
||||
List<SeriesValueField> list = ob.getSeriesValueFieldList(); |
||||
if (list != null && list.size() > 0) { |
||||
populateSeries(list.get(0).getSeries().getFieldName()); |
||||
populateValue(list.get(0).getValue().getFieldName()); |
||||
populateFunction((AbstractDataFunction) list.get(0).getValue().getDataFunction()); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void updateBean(SeriesValueCorrelationDefinition ob) { |
||||
List<SeriesValueField> list = new ArrayList<SeriesValueField>(); |
||||
SeriesValueField seriesValueField = new SeriesValueField(); |
||||
ColumnField series = new ColumnField(updateSeries()); |
||||
ColumnField value = new ColumnField(updateValue()); |
||||
value.setDataFunction(updateFunction()); |
||||
seriesValueField.setValue(value); |
||||
seriesValueField.setSeries(series); |
||||
list.add(seriesValueField); |
||||
ob.setSeriesValueFieldList(list); |
||||
} |
||||
} |
||||
|
||||
private class CustomFieldNamePane extends AbstractCustomFieldNamePane { |
||||
@Override |
||||
protected List<Object[]> covertTBeanToTableModelList(SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) { |
||||
List<Object[]> list = new ArrayList<Object[]>(); |
||||
for (SeriesValueField seriesValueField : seriesValueCorrelationDefinition.getSeriesValueFieldList()) { |
||||
Object[] array = new Object[]{ |
||||
seriesValueField.getValue().getFieldName(), |
||||
seriesValueField.getSeries().getFieldName(), |
||||
DataPaneHelper.getFunctionString(seriesValueField.getValue().getDataFunction()) |
||||
}; |
||||
list.add(array); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
@Override |
||||
protected void setTableModelListToTBean(List<Object[]> tableValues, SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) { |
||||
List<SeriesValueField> seriesValueFields = new ArrayList<SeriesValueField>(); |
||||
for (Object[] line : tableValues) { |
||||
ColumnField value = new ColumnField(GeneralUtils.objectToString(line[0])); |
||||
ColumnField series = new ColumnField(GeneralUtils.objectToString(line[1])); |
||||
value.setDataFunction(DataPaneHelper.getFunctionByName(GeneralUtils.objectToString(line[2]))); |
||||
SeriesValueField seriesValueField = new SeriesValueField(); |
||||
seriesValueField.setValue(value); |
||||
seriesValueField.setSeries(series); |
||||
seriesValueFields.add(seriesValueField); |
||||
} |
||||
seriesValueCorrelationDefinition.setSeriesValueFieldList(seriesValueFields); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,130 @@
|
||||
package com.fr.design.chartx.component.correlation; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.gui.frpane.UICorrelationPane; |
||||
import com.fr.design.gui.itable.UITable; |
||||
import com.fr.design.gui.itable.UITableEditor; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.JTable; |
||||
import javax.swing.event.ChangeEvent; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by shine on 2019/6/4. |
||||
* 自定义editorComponent + 支持多种数据格式 |
||||
*/ |
||||
public abstract class AbstractCorrelationPane<T> extends BasicBeanPane<T> { |
||||
private FieldEditorComponentWrapper[] editorComponents; |
||||
|
||||
private UICorrelationPane correlationPane; |
||||
|
||||
public AbstractCorrelationPane() { |
||||
|
||||
this.editorComponents = createFieldEditorComponentWrappers(); |
||||
|
||||
String[] headers = new String[editorComponents.length]; |
||||
|
||||
for (int i = 0, len = editorComponents.length; i < len; i++) { |
||||
headers[i] = editorComponents[i].headerName(); |
||||
} |
||||
|
||||
initComps(headers); |
||||
} |
||||
|
||||
protected abstract FieldEditorComponentWrapper[] createFieldEditorComponentWrappers(); |
||||
|
||||
@Override |
||||
public void populateBean(T ob) { |
||||
correlationPane.populateBean(covertTBeanToTableModelList(ob)); |
||||
} |
||||
|
||||
@Override |
||||
public void updateBean(T ob) { |
||||
setTableModelListToTBean(correlationPane.updateBean(), ob); |
||||
} |
||||
|
||||
@Override |
||||
public T updateBean() { |
||||
return null; |
||||
} |
||||
|
||||
protected abstract List<Object[]> covertTBeanToTableModelList(T t); |
||||
|
||||
protected abstract void setTableModelListToTBean(List<Object[]> tableValues, T t); |
||||
|
||||
private void initComps(String[] headers) { |
||||
correlationPane = new UICorrelationPane(headers) { |
||||
public UITableEditor createUITableEditor() { |
||||
return new Editor(); |
||||
} |
||||
|
||||
protected UITable initUITable() { |
||||
return new UITable(columnCount) { |
||||
|
||||
public UITableEditor createTableEditor() { |
||||
return createUITableEditor(); |
||||
} |
||||
|
||||
public void tableCellEditingStopped(ChangeEvent e) { |
||||
stopPaneEditing(e); |
||||
} |
||||
}; |
||||
} |
||||
|
||||
protected ActionListener getAddButtonListener() { |
||||
return new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
tablePane.addLine(createLine()); |
||||
fireTargetChanged(); |
||||
} |
||||
}; |
||||
} |
||||
}; |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
this.add(correlationPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
protected Object[] createLine() { |
||||
return new Object[this.editorComponents.length]; |
||||
} |
||||
|
||||
|
||||
private class Editor extends UITableEditor { |
||||
|
||||
private Component currentComponent; |
||||
private FieldEditorComponentWrapper currentEditorWrapper; |
||||
|
||||
public Object getCellEditorValue() { |
||||
return currentEditorWrapper.getValue(currentComponent); |
||||
} |
||||
|
||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
||||
if (column == table.getModel().getColumnCount()) { |
||||
return null; |
||||
} |
||||
|
||||
correlationPane.stopCellEditing(); |
||||
|
||||
currentEditorWrapper = AbstractCorrelationPane.this.editorComponents[column]; |
||||
|
||||
currentComponent = currentEditorWrapper.getTableCellEditorComponent(correlationPane, table, isSelected, row, column); |
||||
currentEditorWrapper.setValue(currentComponent, value); |
||||
|
||||
return currentComponent; |
||||
} |
||||
|
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,19 @@
|
||||
package com.fr.design.chartx.component.correlation; |
||||
|
||||
import java.awt.Component; |
||||
|
||||
/** |
||||
* Created by shine on 2019/6/10. |
||||
*/ |
||||
public abstract class AbstractEditorComponent<T extends Component> implements FieldEditorComponentWrapper<T> { |
||||
private String header; |
||||
|
||||
public AbstractEditorComponent(String header) { |
||||
this.header = header; |
||||
} |
||||
|
||||
@Override |
||||
public String headerName() { |
||||
return this.header; |
||||
} |
||||
} |
@ -0,0 +1,45 @@
|
||||
package com.fr.design.chartx.component.correlation; |
||||
|
||||
import com.fr.design.gui.frpane.UICorrelationPane; |
||||
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; |
||||
|
||||
import javax.swing.JTable; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
|
||||
/** |
||||
* Created by shine on 2019/6/10. |
||||
*/ |
||||
public class CalculateComboBoxEditorComponent extends AbstractEditorComponent<CalculateComboBox> { |
||||
|
||||
public CalculateComboBoxEditorComponent(String header) { |
||||
super(header); |
||||
} |
||||
|
||||
@Override |
||||
public CalculateComboBox getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, int row, int column) { |
||||
|
||||
CalculateComboBox calculateComboBox = new CalculateComboBox(); |
||||
|
||||
calculateComboBox.addItemListener(new ItemListener() { |
||||
public void itemStateChanged(ItemEvent e) { |
||||
parent.stopCellEditing(); |
||||
parent.fireTargetChanged(); |
||||
} |
||||
}); |
||||
return calculateComboBox; |
||||
} |
||||
|
||||
@Override |
||||
public Object getValue(CalculateComboBox calculateComboBox) { |
||||
return calculateComboBox.getSelectedItem(); |
||||
} |
||||
|
||||
@Override |
||||
public void setValue(CalculateComboBox calculateComboBox, Object o) { |
||||
|
||||
if (o != null) { |
||||
calculateComboBox.setSelectedItem(o); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,20 @@
|
||||
package com.fr.design.chartx.component.correlation; |
||||
|
||||
import com.fr.design.gui.frpane.UICorrelationPane; |
||||
|
||||
import javax.swing.JTable; |
||||
import java.awt.Component; |
||||
|
||||
/** |
||||
* Created by shine on 2019/6/4. |
||||
*/ |
||||
public interface FieldEditorComponentWrapper<T extends Component> { |
||||
|
||||
String headerName(); |
||||
|
||||
T getTableCellEditorComponent(UICorrelationPane parent, JTable table, boolean isSelected, final int row, int column); |
||||
|
||||
Object getValue(T t); |
||||
|
||||
void setValue(T t, Object o); |
||||
} |
@ -0,0 +1,56 @@
|
||||
package com.fr.design.chartx.component.correlation; |
||||
|
||||
import com.fr.base.BaseFormula; |
||||
import com.fr.base.Utils; |
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.event.UIObserverListener; |
||||
import com.fr.design.formula.TinyFormulaPane; |
||||
import com.fr.design.gui.frpane.UICorrelationPane; |
||||
|
||||
import javax.swing.JTable; |
||||
|
||||
/** |
||||
* Created by shine on 2019/6/4. |
||||
*/ |
||||
public class TinyFormulaPaneEditorComponent extends AbstractEditorComponent<TinyFormulaPane> { |
||||
|
||||
public TinyFormulaPaneEditorComponent(String header) { |
||||
super(header); |
||||
} |
||||
|
||||
@Override |
||||
public TinyFormulaPane getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, final int row, int column) { |
||||
TinyFormulaPane editorComponent = new TinyFormulaPane() { |
||||
@Override |
||||
public void okEvent() { |
||||
parent.stopCellEditing(); |
||||
parent.fireTargetChanged(); |
||||
} |
||||
|
||||
@Override |
||||
protected void populateTextField(BaseFormula fm) { |
||||
formulaTextField.setText(fm.getContent()); |
||||
} |
||||
}; |
||||
editorComponent.setBackground(UIConstants.FLESH_BLUE); |
||||
|
||||
editorComponent.getUITextField().registerChangeListener(new UIObserverListener() { |
||||
@Override |
||||
public void doChange() { |
||||
parent.fireTargetChanged(); |
||||
} |
||||
}); |
||||
|
||||
return editorComponent; |
||||
} |
||||
|
||||
@Override |
||||
public Object getValue(TinyFormulaPane formulaPane) { |
||||
return formulaPane.getUITextField().getText(); |
||||
} |
||||
|
||||
@Override |
||||
public void setValue(TinyFormulaPane formulaPane, Object o) { |
||||
formulaPane.getUITextField().setText(Utils.objectToString(o)); |
||||
} |
||||
} |
@ -0,0 +1,55 @@
|
||||
package com.fr.design.chartx.component.correlation; |
||||
|
||||
import com.fr.design.gui.frpane.UICorrelationPane; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.itable.UITable; |
||||
|
||||
import javax.swing.JTable; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by shine on 2019/6/10. |
||||
*/ |
||||
public class UIComboBoxEditorComponent extends AbstractEditorComponent<UIComboBox> { |
||||
|
||||
public UIComboBoxEditorComponent(String header) { |
||||
super(header); |
||||
} |
||||
|
||||
protected List<String> items() { |
||||
return new ArrayList<String>(); |
||||
} |
||||
|
||||
@Override |
||||
public UIComboBox getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, final int row, int column) { |
||||
UIComboBox uiComboBox = new UIComboBox(items().toArray()); |
||||
|
||||
uiComboBox.addItemListener(new ItemListener() { |
||||
public void itemStateChanged(ItemEvent e) { |
||||
parent.stopCellEditing(); |
||||
parent.fireTargetChanged(); |
||||
UITable table = parent.getTable(); |
||||
Object object = table.getValueAt(row, 0); |
||||
if (object != null) { |
||||
table.setValueAt(object, row, 1); |
||||
} |
||||
} |
||||
}); |
||||
|
||||
return uiComboBox; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public Object getValue(UIComboBox uiComboBox) { |
||||
return uiComboBox.getSelectedItem(); |
||||
} |
||||
|
||||
@Override |
||||
public void setValue(UIComboBox uiComboBox, Object o) { |
||||
uiComboBox.getModel().setSelectedItem(o); |
||||
} |
||||
} |
@ -0,0 +1,41 @@
|
||||
package com.fr.design.chartx.component.correlation; |
||||
|
||||
import com.fr.design.event.UIObserverListener; |
||||
import com.fr.design.gui.frpane.UICorrelationPane; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.general.GeneralUtils; |
||||
|
||||
import javax.swing.JTable; |
||||
|
||||
/** |
||||
* Created by shine on 2019/6/10. |
||||
*/ |
||||
public class UITextFieldEditorComponent extends AbstractEditorComponent<UITextField> { |
||||
public UITextFieldEditorComponent(String header) { |
||||
super(header); |
||||
} |
||||
|
||||
@Override |
||||
public UITextField getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, int row, int column) { |
||||
UITextField uiTextField = new UITextField(); |
||||
|
||||
uiTextField.registerChangeListener(new UIObserverListener() { |
||||
@Override |
||||
public void doChange() { |
||||
parent.fireTargetChanged(); |
||||
} |
||||
}); |
||||
|
||||
return uiTextField; |
||||
} |
||||
|
||||
@Override |
||||
public Object getValue(UITextField uiTextField) { |
||||
return uiTextField.getText(); |
||||
} |
||||
|
||||
@Override |
||||
public void setValue(UITextField uiTextField, Object o) { |
||||
uiTextField.setText(GeneralUtils.objectToString(o)); |
||||
} |
||||
} |
@ -0,0 +1,97 @@
|
||||
package com.fr.design.chartx.fields; |
||||
|
||||
import com.fr.chartx.data.field.AbstractColumnFieldCollection; |
||||
import com.fr.chartx.data.field.ColumnField; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.formula.TinyFormulaPane; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.chart.gui.ChartDataPane; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.SwingConstants; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.util.Arrays; |
||||
|
||||
/** |
||||
* Created by shine on 2019/5/16. |
||||
* 单元格数据源 具体有哪些字段的一个抽象pane |
||||
*/ |
||||
public abstract class AbstractCellDataFieldsPane<T extends AbstractColumnFieldCollection> extends BasicBeanPane<T> { |
||||
|
||||
public AbstractCellDataFieldsPane() { |
||||
initComponents(); |
||||
} |
||||
|
||||
protected void initComponents() { |
||||
|
||||
this.setLayout(new BorderLayout(0, 6)); |
||||
|
||||
this.add(createNorthPane(), BorderLayout.NORTH); |
||||
this.add(createCenterPane(), BorderLayout.CENTER); |
||||
this.add(createSouthPane(), BorderLayout.SOUTH); |
||||
|
||||
this.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 8)); |
||||
} |
||||
|
||||
protected JPanel createCenterPane() { |
||||
String[] labels = fieldLabels(); |
||||
Component[] formulaPanes = fieldComponents(); |
||||
|
||||
int len = Math.min(labels.length, formulaPanes.length); |
||||
|
||||
if (len == 0) { |
||||
return null; |
||||
} |
||||
|
||||
Component[][] components = new Component[len][2]; |
||||
for (int i = 0; i < len; i++) { |
||||
components[i] = new Component[]{new UILabel(labels[i], SwingConstants.LEFT), formulaPanes[i]}; |
||||
} |
||||
|
||||
|
||||
double p = TableLayout.PREFERRED; |
||||
double[] columnSize = {ChartDataPane.LABEL_WIDTH, 124}; |
||||
double[] rowSize = new double[len]; |
||||
Arrays.fill(rowSize, p); |
||||
|
||||
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 6); |
||||
} |
||||
|
||||
|
||||
protected JPanel createNorthPane() { |
||||
return new JPanel(); |
||||
} |
||||
|
||||
protected JPanel createSouthPane() { |
||||
return new JPanel(); |
||||
} |
||||
|
||||
protected Component[] fieldComponents() { |
||||
return formulaPanes(); |
||||
} |
||||
|
||||
protected abstract String[] fieldLabels(); |
||||
|
||||
protected abstract TinyFormulaPane[] formulaPanes(); |
||||
|
||||
@Override |
||||
public abstract T updateBean(); |
||||
|
||||
public static void populateField(TinyFormulaPane formulaPane, ColumnField field) { |
||||
formulaPane.populateBean(field.getFieldName()); |
||||
} |
||||
|
||||
public static void updateField(TinyFormulaPane formulaPane, ColumnField field) { |
||||
field.setFieldName(formulaPane.updateBean()); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
} |
@ -0,0 +1,149 @@
|
||||
package com.fr.design.chartx.fields; |
||||
|
||||
import com.fr.chartx.data.field.AbstractColumnFieldCollection; |
||||
import com.fr.chartx.data.field.ColumnField; |
||||
import com.fr.data.util.function.AbstractDataFunction; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.chart.gui.ChartDataPane; |
||||
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; |
||||
import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper; |
||||
import com.fr.general.GeneralUtils; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.SwingConstants; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
|
||||
import static com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper.refreshBoxItems; |
||||
|
||||
/** |
||||
* Created by shine on 2019/5/16. |
||||
* 数据集数据源 具体有哪些字段的一个抽象pane |
||||
*/ |
||||
public abstract class AbstractDataSetFieldsPane<T extends AbstractColumnFieldCollection> extends BasicBeanPane<T> { |
||||
|
||||
public AbstractDataSetFieldsPane() { |
||||
initComponents(); |
||||
} |
||||
|
||||
protected void initComponents() { |
||||
|
||||
this.setLayout(new BorderLayout(0, 4)); |
||||
this.setBorder(BorderFactory.createEmptyBorder(2, 24, 0, 15)); |
||||
|
||||
JPanel north = createNorthPane(), |
||||
center = createCenterPane(), |
||||
south = createSouthPane(); |
||||
|
||||
if (north != null) { |
||||
this.add(north, BorderLayout.NORTH); |
||||
} |
||||
|
||||
if (center != null) { |
||||
this.add(center, BorderLayout.CENTER); |
||||
} |
||||
|
||||
if (south != null) { |
||||
this.add(south, BorderLayout.SOUTH); |
||||
} |
||||
} |
||||
|
||||
protected JPanel createNorthPane() { |
||||
return null; |
||||
} |
||||
|
||||
protected JPanel createCenterPane() { |
||||
String[] labels = fieldLabels(); |
||||
Component[] fieldComponents = fieldComponents(); |
||||
|
||||
int len = Math.min(labels.length, fieldComponents.length); |
||||
|
||||
if (len == 0) { |
||||
return null; |
||||
} |
||||
|
||||
Component[][] components = new Component[len][2]; |
||||
for (int i = 0; i < len; i++) { |
||||
components[i] = new Component[]{new UILabel(labels[i], SwingConstants.LEFT), fieldComponents[i]}; |
||||
} |
||||
|
||||
double p = TableLayout.PREFERRED; |
||||
double[] columnSize = {ChartDataPane.LABEL_WIDTH, 122}; |
||||
double[] rowSize = new double[len]; |
||||
Arrays.fill(rowSize, p); |
||||
|
||||
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 6); |
||||
} |
||||
|
||||
protected JPanel createSouthPane() { |
||||
return null; |
||||
} |
||||
|
||||
protected Component[] fieldComponents() { |
||||
return filedComboBoxes(); |
||||
} |
||||
|
||||
protected abstract String[] fieldLabels(); |
||||
|
||||
protected abstract UIComboBox[] filedComboBoxes(); |
||||
|
||||
public void checkBoxUse(boolean hasUse) { |
||||
for (Component component : fieldComponents()) { |
||||
component.setEnabled(hasUse); |
||||
} |
||||
} |
||||
|
||||
public void clearAllBoxList() { |
||||
for (UIComboBox comboBox : filedComboBoxes()) { |
||||
DataPaneHelper.clearBoxItems(comboBox); |
||||
} |
||||
} |
||||
|
||||
public void refreshBoxListWithSelectTableData(List columnNameList) { |
||||
for (UIComboBox comboBox : filedComboBoxes()) { |
||||
refreshBoxItems(comboBox, columnNameList); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public abstract T updateBean(); |
||||
|
||||
public static void populateField(UIComboBox comboBox, ColumnField field) { |
||||
populateFunctionField(comboBox, null, field); |
||||
} |
||||
|
||||
public static void updateField(UIComboBox comboBox, ColumnField field) { |
||||
updateFunctionField(comboBox, null, field); |
||||
} |
||||
|
||||
protected static void populateFunctionField(UIComboBox comboBox, CalculateComboBox calculateComboBox, ColumnField field) { |
||||
comboBox.setSelectedItem(field.getFieldName()); |
||||
if (calculateComboBox != null) { |
||||
calculateComboBox.populateBean((AbstractDataFunction) field.getDataFunction()); |
||||
} |
||||
} |
||||
|
||||
protected static void updateFunctionField(UIComboBox comboBox, CalculateComboBox calculateComboBox, ColumnField field) { |
||||
field.setFieldName(GeneralUtils.objectToString(comboBox.getSelectedItem())); |
||||
if (calculateComboBox != null) { |
||||
field.setDataFunction(calculateComboBox.updateBean()); |
||||
} else { |
||||
field.setDataFunction(null); |
||||
} |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,41 @@
|
||||
package com.fr.design.chartx.fields.diff; |
||||
|
||||
import com.fr.chartx.data.field.diff.AbstractColumnFieldCollectionWithSeriesValue; |
||||
import com.fr.design.chartx.component.CellDataSeriesValueCorrelationPane; |
||||
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
|
||||
/** |
||||
* Created by shine on 2019/6/4. |
||||
*/ |
||||
public abstract class AbstractCellDataFieldsWithSeriesValuePane<T extends AbstractColumnFieldCollectionWithSeriesValue> |
||||
extends AbstractCellDataFieldsPane<T> { |
||||
|
||||
private CellDataSeriesValueCorrelationPane seriesValueFieldsPane; |
||||
|
||||
@Override |
||||
protected JPanel createCenterPane() { |
||||
JPanel normalCenter = super.createCenterPane(); |
||||
seriesValueFieldsPane = new CellDataSeriesValueCorrelationPane(); |
||||
|
||||
if (normalCenter != null) { |
||||
JPanel panel = new JPanel(new BorderLayout()); |
||||
panel.add(normalCenter, BorderLayout.CENTER); |
||||
panel.add(seriesValueFieldsPane, BorderLayout.SOUTH); |
||||
return panel; |
||||
} else { |
||||
return seriesValueFieldsPane; |
||||
} |
||||
} |
||||
|
||||
protected void populateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue fieldCollectionWithSeriesValue) { |
||||
seriesValueFieldsPane.populateBean(fieldCollectionWithSeriesValue.getSeriesValueCorrelationDefinition()); |
||||
} |
||||
|
||||
protected void updateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue fieldCollectionWithSeriesValue) { |
||||
seriesValueFieldsPane.updateBean(fieldCollectionWithSeriesValue.getSeriesValueCorrelationDefinition()); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,60 @@
|
||||
package com.fr.design.chartx.fields.diff; |
||||
|
||||
import com.fr.chartx.data.field.diff.AbstractColumnFieldCollectionWithSeriesValue; |
||||
import com.fr.design.chartx.component.SeriesValueFieldComboBoxPane; |
||||
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by shine on 2019/5/16. |
||||
* 带有 自定义系列名(fr表现为 系列名使用字段名) 的字段集合 的一个pane |
||||
*/ |
||||
public abstract class AbstractDataSetFieldsWithSeriesValuePane<T extends AbstractColumnFieldCollectionWithSeriesValue> |
||||
extends AbstractDataSetFieldsPane<T> { |
||||
|
||||
private SeriesValueFieldComboBoxPane seriesValueFieldComboBoxPane; |
||||
|
||||
@Override |
||||
protected JPanel createCenterPane() { |
||||
JPanel normalCenter = super.createCenterPane(); |
||||
seriesValueFieldComboBoxPane = new SeriesValueFieldComboBoxPane(); |
||||
|
||||
if (normalCenter != null) { |
||||
JPanel panel = new JPanel(new BorderLayout()); |
||||
panel.add(normalCenter, BorderLayout.CENTER); |
||||
panel.add(seriesValueFieldComboBoxPane, BorderLayout.SOUTH); |
||||
return panel; |
||||
} else { |
||||
return seriesValueFieldComboBoxPane; |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void checkBoxUse(boolean hasUse) { |
||||
super.checkBoxUse(hasUse); |
||||
seriesValueFieldComboBoxPane.checkBoxUse(hasUse); |
||||
} |
||||
|
||||
@Override |
||||
public void clearAllBoxList() { |
||||
super.clearAllBoxList(); |
||||
seriesValueFieldComboBoxPane.clearAllBoxList(); |
||||
} |
||||
|
||||
@Override |
||||
public void refreshBoxListWithSelectTableData(List columnNameList) { |
||||
super.refreshBoxListWithSelectTableData(columnNameList); |
||||
seriesValueFieldComboBoxPane.refreshBoxListWithSelectTableData(columnNameList); |
||||
} |
||||
|
||||
protected void populateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue fieldCollectionWithSeriesValue) { |
||||
seriesValueFieldComboBoxPane.populateBean(fieldCollectionWithSeriesValue.getSeriesValueCorrelationDefinition()); |
||||
} |
||||
|
||||
protected void updateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue fieldCollectionWithSeriesValue) { |
||||
seriesValueFieldComboBoxPane.updateBean(fieldCollectionWithSeriesValue.getSeriesValueCorrelationDefinition()); |
||||
} |
||||
} |
@ -0,0 +1,115 @@
|
||||
package com.fr.design.chartx.fields.diff; |
||||
|
||||
import com.fr.chartx.data.field.ColumnField; |
||||
import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; |
||||
import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; |
||||
import com.fr.design.chartx.component.AbstractSingleFilterPane; |
||||
import com.fr.design.chartx.component.MultiTinyFormulaPane; |
||||
import com.fr.design.formula.TinyFormulaPane; |
||||
import com.fr.van.chart.map.designer.VanChartGroupPane; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by shine on 2019/4/12. |
||||
*/ |
||||
public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithSeriesValuePane<MultiCategoryColumnFieldCollection> { |
||||
|
||||
private MultiTinyFormulaPane multiCategoryPane; |
||||
|
||||
private AbstractSingleFilterPane seriesFilterPane; |
||||
private AbstractSingleFilterPane categoryFilterPane; |
||||
|
||||
private void createMultiFormulaPane() { |
||||
if (multiCategoryPane == null) { |
||||
multiCategoryPane = new MultiTinyFormulaPane(); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
protected JPanel createNorthPane() { |
||||
|
||||
createMultiFormulaPane(); |
||||
|
||||
return multiCategoryPane; |
||||
} |
||||
|
||||
@Override |
||||
protected JPanel createSouthPane() { |
||||
if (seriesFilterPane == null) { |
||||
seriesFilterPane = new AbstractSingleFilterPane() { |
||||
@Override |
||||
public String title4PopupWindow() { |
||||
//todo@shinerefactor
|
||||
return "series"; |
||||
} |
||||
}; |
||||
categoryFilterPane = new AbstractSingleFilterPane() { |
||||
@Override |
||||
public String title4PopupWindow() { |
||||
return "category"; |
||||
} |
||||
}; |
||||
} |
||||
return new VanChartGroupPane(new String[]{seriesFilterPane.title4PopupWindow(), categoryFilterPane.title4PopupWindow()} |
||||
, new JPanel[]{seriesFilterPane, categoryFilterPane}) { |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
protected String[] fieldLabels() { |
||||
return new String[0]; |
||||
} |
||||
|
||||
@Override |
||||
protected TinyFormulaPane[] formulaPanes() { |
||||
|
||||
createMultiFormulaPane(); |
||||
|
||||
List<TinyFormulaPane> list = multiCategoryPane.componentList(); |
||||
return list.toArray(new TinyFormulaPane[list.size()]); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(MultiCategoryColumnFieldCollection multiCategoryColumnFieldCollection) { |
||||
|
||||
List<ColumnField> categoryList = multiCategoryColumnFieldCollection.getCategoryList(); |
||||
|
||||
multiCategoryPane.populate(categoryList); |
||||
|
||||
populateSeriesValuePane(multiCategoryColumnFieldCollection); |
||||
|
||||
SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = multiCategoryColumnFieldCollection.getSeriesValueCorrelationDefinition(); |
||||
if (seriesValueCorrelationDefinition != null) { |
||||
seriesFilterPane.populateBean(seriesValueCorrelationDefinition.getFilterProperties()); |
||||
|
||||
} |
||||
|
||||
if (categoryList != null && !categoryList.isEmpty()) { |
||||
categoryFilterPane.populateBean(categoryList.get(0).getFilterProperties()); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public MultiCategoryColumnFieldCollection updateBean() { |
||||
|
||||
MultiCategoryColumnFieldCollection fieldCollection = new MultiCategoryColumnFieldCollection(); |
||||
List<ColumnField> categoryList = fieldCollection.getCategoryList(); |
||||
|
||||
multiCategoryPane.update(categoryList); |
||||
|
||||
updateSeriesValuePane(fieldCollection); |
||||
|
||||
SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = fieldCollection.getSeriesValueCorrelationDefinition(); |
||||
if (seriesValueCorrelationDefinition != null) { |
||||
seriesValueCorrelationDefinition.setFilterProperties(seriesFilterPane.updateBean()); |
||||
} |
||||
|
||||
if (categoryList != null && !categoryList.isEmpty()) { |
||||
categoryList.get(0).setFilterProperties(categoryFilterPane.updateBean()); |
||||
} |
||||
|
||||
return fieldCollection; |
||||
} |
||||
} |
@ -0,0 +1,116 @@
|
||||
package com.fr.design.chartx.fields.diff; |
||||
|
||||
import com.fr.chartx.data.field.ColumnField; |
||||
import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; |
||||
import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; |
||||
import com.fr.design.chartx.component.AbstractSingleFilterPane; |
||||
import com.fr.design.chartx.component.MultiComboBoxPane; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.van.chart.map.designer.VanChartGroupPane; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.util.List; |
||||
|
||||
|
||||
/** |
||||
* Created by shine on 2019/4/10. |
||||
*/ |
||||
public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSeriesValuePane<MultiCategoryColumnFieldCollection> { |
||||
|
||||
private MultiComboBoxPane multiCategoryPane; |
||||
|
||||
private AbstractSingleFilterPane seriesFilterPane; |
||||
private AbstractSingleFilterPane categoryFilterPane; |
||||
|
||||
@Override |
||||
protected String[] fieldLabels() { |
||||
return new String[0]; |
||||
} |
||||
|
||||
@Override |
||||
protected UIComboBox[] filedComboBoxes() { |
||||
List<UIComboBox> list = initMultiCategoryPane().componentList(); |
||||
return list.toArray(new UIComboBox[list.size()]); |
||||
} |
||||
|
||||
private MultiComboBoxPane initMultiCategoryPane() { |
||||
if (multiCategoryPane == null) { |
||||
multiCategoryPane = new MultiComboBoxPane(); |
||||
} |
||||
return multiCategoryPane; |
||||
} |
||||
|
||||
@Override |
||||
protected JPanel createNorthPane() { |
||||
return initMultiCategoryPane(); |
||||
} |
||||
|
||||
@Override |
||||
protected JPanel createSouthPane() { |
||||
if (seriesFilterPane == null) { |
||||
seriesFilterPane = new AbstractSingleFilterPane() { |
||||
@Override |
||||
public String title4PopupWindow() { |
||||
//todo@shinerefactor
|
||||
return "series"; |
||||
} |
||||
}; |
||||
categoryFilterPane = new AbstractSingleFilterPane() { |
||||
@Override |
||||
public String title4PopupWindow() { |
||||
return "category"; |
||||
} |
||||
}; |
||||
} |
||||
return new VanChartGroupPane(new String[]{seriesFilterPane.title4PopupWindow(), categoryFilterPane.title4PopupWindow()} |
||||
, new JPanel[]{seriesFilterPane, categoryFilterPane}) { |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
public void refreshBoxListWithSelectTableData(List columnNameList) { |
||||
super.refreshBoxListWithSelectTableData(columnNameList); |
||||
multiCategoryPane.setCurrentBoxItems(columnNameList); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(MultiCategoryColumnFieldCollection multiCategoryColumnFieldCollection) { |
||||
List<ColumnField> categoryList = multiCategoryColumnFieldCollection.getCategoryList(); |
||||
|
||||
multiCategoryPane.populate(categoryList); |
||||
|
||||
populateSeriesValuePane(multiCategoryColumnFieldCollection); |
||||
|
||||
SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = multiCategoryColumnFieldCollection.getSeriesValueCorrelationDefinition(); |
||||
if (seriesValueCorrelationDefinition != null) { |
||||
seriesFilterPane.populateBean(seriesValueCorrelationDefinition.getFilterProperties()); |
||||
|
||||
} |
||||
|
||||
if (categoryList != null && !categoryList.isEmpty()) { |
||||
categoryFilterPane.populateBean(categoryList.get(0).getFilterProperties()); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public MultiCategoryColumnFieldCollection updateBean() { |
||||
|
||||
MultiCategoryColumnFieldCollection columnFieldCollection = new MultiCategoryColumnFieldCollection(); |
||||
List<ColumnField> categoryList = columnFieldCollection.getCategoryList(); |
||||
|
||||
multiCategoryPane.update(categoryList); |
||||
|
||||
updateSeriesValuePane(columnFieldCollection); |
||||
|
||||
SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = columnFieldCollection.getSeriesValueCorrelationDefinition(); |
||||
if (seriesValueCorrelationDefinition != null) { |
||||
seriesValueCorrelationDefinition.setFilterProperties(seriesFilterPane.updateBean()); |
||||
} |
||||
|
||||
if (categoryList != null && !categoryList.isEmpty()) { |
||||
categoryList.get(0).setFilterProperties(categoryFilterPane.updateBean()); |
||||
} |
||||
|
||||
return columnFieldCollection; |
||||
} |
||||
} |
@ -0,0 +1,67 @@
|
||||
package com.fr.design.chartx.fields.diff; |
||||
|
||||
import com.fr.chartx.data.field.diff.MultiPieColumnFieldCollection; |
||||
import com.fr.design.chartx.component.MultiTinyFormulaPaneWithUISpinner; |
||||
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; |
||||
import com.fr.design.formula.TinyFormulaPane; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.i18n.Toolkit; |
||||
|
||||
import javax.swing.JPanel; |
||||
|
||||
/** |
||||
* Created by shine on 2019/6/18. |
||||
*/ |
||||
public class MultiPieCellDataFieldsPane extends AbstractCellDataFieldsPane<MultiPieColumnFieldCollection> { |
||||
|
||||
private UITextField nameField;//指标名称
|
||||
|
||||
private MultiTinyFormulaPaneWithUISpinner levelPane; |
||||
|
||||
private TinyFormulaPane value; |
||||
|
||||
@Override |
||||
protected void initComponents() { |
||||
nameField = new UITextField(); |
||||
levelPane = new MultiTinyFormulaPaneWithUISpinner(); |
||||
value = new TinyFormulaPane(); |
||||
super.initComponents(); |
||||
} |
||||
|
||||
@Override |
||||
protected JPanel createNorthPane() { |
||||
return levelPane; |
||||
} |
||||
|
||||
@Override |
||||
protected String[] fieldLabels() { |
||||
return new String[]{ |
||||
Toolkit.i18nText("Fine-Design_Chart_Use_Value"), |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
protected TinyFormulaPane[] formulaPanes() { |
||||
return new TinyFormulaPane[]{ |
||||
value |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(MultiPieColumnFieldCollection ob) { |
||||
nameField.setText(ob.getTargetName()); |
||||
levelPane.populate(ob.getLevels()); |
||||
populateField(value, ob.getValue()); |
||||
} |
||||
|
||||
@Override |
||||
public MultiPieColumnFieldCollection updateBean() { |
||||
MultiPieColumnFieldCollection result = new MultiPieColumnFieldCollection(); |
||||
|
||||
result.setTargetName(nameField.getText()); |
||||
levelPane.update(result.getLevels()); |
||||
updateField(value, result.getValue()); |
||||
|
||||
return result; |
||||
} |
||||
} |
@ -0,0 +1,94 @@
|
||||
package com.fr.design.chartx.fields.diff; |
||||
|
||||
import com.fr.chartx.data.field.diff.MultiPieColumnFieldCollection; |
||||
import com.fr.design.chartx.component.MultiComboBoxPaneWithUISpinner; |
||||
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.Component; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by shine on 2019/6/18. |
||||
*/ |
||||
public class MultiPieDataSetFieldsPane extends AbstractDataSetFieldsPane<MultiPieColumnFieldCollection> { |
||||
private UITextField nameField; |
||||
|
||||
private MultiComboBoxPaneWithUISpinner levelComboBoxPane; |
||||
|
||||
private UIComboBox value; |
||||
|
||||
private CalculateComboBox function; |
||||
|
||||
@Override |
||||
protected void initComponents() { |
||||
nameField = new UITextField(); |
||||
levelComboBoxPane = new MultiComboBoxPaneWithUISpinner(); |
||||
value = new UIComboBox(); |
||||
function = new CalculateComboBox(); |
||||
super.initComponents(); |
||||
} |
||||
|
||||
@Override |
||||
protected JPanel createNorthPane() { |
||||
return levelComboBoxPane; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected String[] fieldLabels() { |
||||
return new String[]{ |
||||
Toolkit.i18nText("Fine-Design_Chart_Use_Value"), |
||||
Toolkit.i18nText("Fine-Design_Chart_Summary_Method") |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
protected Component[] fieldComponents() { |
||||
return new UIComboBox[]{ |
||||
value, |
||||
function |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
protected UIComboBox[] filedComboBoxes() { |
||||
List<UIComboBox> list = levelComboBoxPane.getComponentList(); |
||||
|
||||
int len = list.size(); |
||||
UIComboBox[] result = new UIComboBox[len + 1]; |
||||
for (int i = 0; i < len; i++) { |
||||
result[i] = list.get(i); |
||||
} |
||||
result[len] = value; |
||||
|
||||
return result; |
||||
} |
||||
|
||||
@Override |
||||
public void refreshBoxListWithSelectTableData(List columnNameList) { |
||||
super.refreshBoxListWithSelectTableData(columnNameList); |
||||
levelComboBoxPane.setCurrentBoxList(columnNameList); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(MultiPieColumnFieldCollection ob) { |
||||
levelComboBoxPane.populate(ob.getLevels()); |
||||
populateFunctionField(value, function, ob.getValue()); |
||||
} |
||||
|
||||
@Override |
||||
public MultiPieColumnFieldCollection updateBean() { |
||||
MultiPieColumnFieldCollection result = new MultiPieColumnFieldCollection(); |
||||
|
||||
levelComboBoxPane.update(result.getLevels()); |
||||
|
||||
updateFunctionField(value, function, result.getValue()); |
||||
|
||||
return result; |
||||
} |
||||
} |
@ -0,0 +1,70 @@
|
||||
package com.fr.design.chartx.fields.diff; |
||||
|
||||
import com.fr.chartx.data.field.diff.WordCloudColumnFieldCollection; |
||||
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; |
||||
import com.fr.design.formula.TinyFormulaPane; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.i18n.Toolkit; |
||||
|
||||
import java.awt.Component; |
||||
|
||||
/** |
||||
* Created by shine on 2019/6/18. |
||||
*/ |
||||
public class WordCloudCellDataFieldsPane extends AbstractCellDataFieldsPane<WordCloudColumnFieldCollection> { |
||||
|
||||
private UITextField name; |
||||
private TinyFormulaPane wordName; |
||||
private TinyFormulaPane wordValue; |
||||
|
||||
@Override |
||||
protected void initComponents() { |
||||
name = new UITextField(); |
||||
wordName = new TinyFormulaPane(); |
||||
wordValue = new TinyFormulaPane(); |
||||
|
||||
super.initComponents(); |
||||
} |
||||
|
||||
@Override |
||||
protected String[] fieldLabels() { |
||||
return new String[]{ |
||||
Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"), |
||||
Toolkit.i18nText("Fine-Design_Chart_Word_Name"), |
||||
Toolkit.i18nText("Fine-Design_Chart_Word_Value") |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
protected TinyFormulaPane[] formulaPanes() { |
||||
return new TinyFormulaPane[]{ |
||||
wordName, |
||||
wordValue |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
protected Component[] fieldComponents() { |
||||
return new Component[]{ |
||||
name, |
||||
wordName, |
||||
wordValue |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(WordCloudColumnFieldCollection ob) { |
||||
name.setText(ob.getTargetName()); |
||||
populateField(wordName, ob.getWordName()); |
||||
populateField(wordValue, ob.getWordValue()); |
||||
} |
||||
|
||||
@Override |
||||
public WordCloudColumnFieldCollection updateBean() { |
||||
WordCloudColumnFieldCollection result = new WordCloudColumnFieldCollection(); |
||||
result.setTargetName(name.getText()); |
||||
updateField(wordName, result.getWordName()); |
||||
populateField(wordValue, result.getWordValue()); |
||||
return result; |
||||
} |
||||
} |
@ -0,0 +1,74 @@
|
||||
package com.fr.design.chartx.fields.diff; |
||||
|
||||
import com.fr.chartx.data.field.diff.WordCloudColumnFieldCollection; |
||||
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; |
||||
|
||||
import java.awt.Component; |
||||
|
||||
/** |
||||
* Created by shine on 2019/6/18. |
||||
*/ |
||||
public class WordCloudDataSetFieldsPane extends AbstractDataSetFieldsPane<WordCloudColumnFieldCollection> { |
||||
private UITextField name; |
||||
private UIComboBox wordName; |
||||
private UIComboBox wordValue; |
||||
private CalculateComboBox calculateCombox; |
||||
|
||||
@Override |
||||
protected void initComponents() { |
||||
name = new UITextField(); |
||||
wordName = new UIComboBox(); |
||||
wordValue = new UIComboBox(); |
||||
calculateCombox = new CalculateComboBox(); |
||||
|
||||
super.initComponents(); |
||||
} |
||||
|
||||
@Override |
||||
protected String[] fieldLabels() { |
||||
return new String[]{ |
||||
Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"), |
||||
Toolkit.i18nText("Fine-Design_Chart_Word_Name"), |
||||
Toolkit.i18nText("Fine-Design_Chart_Word_Value"), |
||||
Toolkit.i18nText("Fine-Design_Chart_Summary_Method") |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
protected UIComboBox[] filedComboBoxes() { |
||||
return new UIComboBox[]{ |
||||
wordName, |
||||
wordValue |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
protected Component[] fieldComponents() { |
||||
return new Component[]{ |
||||
name, |
||||
wordName, |
||||
wordValue, |
||||
calculateCombox |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(WordCloudColumnFieldCollection ob) { |
||||
name.setText(ob.getTargetName()); |
||||
populateField(wordName, ob.getWordName()); |
||||
populateFunctionField(wordValue, calculateCombox, ob.getWordValue()); |
||||
} |
||||
|
||||
@Override |
||||
public WordCloudColumnFieldCollection updateBean() { |
||||
WordCloudColumnFieldCollection result = new WordCloudColumnFieldCollection(); |
||||
result.setTargetName(name.getText()); |
||||
updateField(wordName, result.getWordName()); |
||||
updateFunctionField(wordValue, calculateCombox, result.getWordValue()); |
||||
return result; |
||||
} |
||||
} |
@ -0,0 +1,56 @@
|
||||
package com.fr.design.chartx.single; |
||||
|
||||
import com.fr.chartx.data.CellDataDefinition; |
||||
import com.fr.design.beans.FurtherBasicBeanPane; |
||||
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; |
||||
import com.fr.design.i18n.Toolkit; |
||||
|
||||
import java.awt.BorderLayout; |
||||
|
||||
/** |
||||
* Created by shine on 2019/5/21. |
||||
*/ |
||||
public class CellDataPane extends FurtherBasicBeanPane<CellDataDefinition> { |
||||
|
||||
private AbstractCellDataFieldsPane cellDataFieldsPane; |
||||
|
||||
public CellDataPane(AbstractCellDataFieldsPane cellDataFieldsPane) { |
||||
initComps(cellDataFieldsPane); |
||||
} |
||||
|
||||
private void initComps(AbstractCellDataFieldsPane cellDataFieldsPane) { |
||||
this.cellDataFieldsPane = cellDataFieldsPane; |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
this.add(cellDataFieldsPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
@Override |
||||
public String title4PopupWindow() { |
||||
return Toolkit.i18nText("Fine-Design_Chart_Cell_Data"); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public boolean accept(Object ob) { |
||||
return ob instanceof CellDataDefinition; |
||||
} |
||||
|
||||
@Override |
||||
public void reset() { |
||||
this.removeAll(); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(CellDataDefinition ob) { |
||||
cellDataFieldsPane.populateBean(ob.getColumnFieldCollection()); |
||||
} |
||||
|
||||
@Override |
||||
public CellDataDefinition updateBean() { |
||||
CellDataDefinition cellDataDefinition = new CellDataDefinition(); |
||||
cellDataDefinition.setColumnFieldCollection(cellDataFieldsPane.updateBean()); |
||||
|
||||
return cellDataDefinition; |
||||
} |
||||
} |
@ -0,0 +1,121 @@
|
||||
package com.fr.design.chartx.single; |
||||
|
||||
import com.fr.chartx.data.DataSetDefinition; |
||||
import com.fr.data.impl.NameTableData; |
||||
import com.fr.design.beans.FurtherBasicBeanPane; |
||||
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; |
||||
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; |
||||
import com.fr.design.gui.ilable.BoldFontTextLabel; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.chart.gui.ChartDataPane; |
||||
import com.fr.design.mainframe.chart.gui.data.DatabaseTableDataPane; |
||||
import com.fr.design.utils.gui.UIComponentUtils; |
||||
|
||||
import java.awt.BorderLayout; |
||||
import java.awt.Dimension; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by shine on 2019/5/21. |
||||
*/ |
||||
public class DataSetPane extends FurtherBasicBeanPane<DataSetDefinition> { |
||||
private static final int TABLE_DATA_LABEL_LINE_WRAP_WIDTH = 65; |
||||
private static final int TABLE_DATA_PANE_WIDTH = 246; |
||||
|
||||
private DatabaseTableDataPane tableDataPane; |
||||
|
||||
private AbstractDataSetFieldsPane dataSetFieldsPane; |
||||
|
||||
public DataSetPane(AbstractDataSetFieldsPane dataSetFieldsPane) { |
||||
initComps(dataSetFieldsPane); |
||||
} |
||||
|
||||
private void initComps(AbstractDataSetFieldsPane dataSetFieldsPane) { |
||||
UILabel label = new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Table_Data")); |
||||
UIComponentUtils.setLineWrap(label, TABLE_DATA_LABEL_LINE_WRAP_WIDTH); |
||||
UIComponentUtils.setPreferedWidth(label, ChartDataPane.LABEL_WIDTH); |
||||
|
||||
tableDataPane = new DatabaseTableDataPane(label) { |
||||
@Override |
||||
protected void userEvent() { |
||||
refreshBoxList(); |
||||
checkBoxUse(); |
||||
} |
||||
}; |
||||
tableDataPane.setPreferredSize(new Dimension(TABLE_DATA_PANE_WIDTH, tableDataPane.getPreferredSize().height)); |
||||
|
||||
this.dataSetFieldsPane = dataSetFieldsPane; |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
this.add(tableDataPane, BorderLayout.NORTH); |
||||
this.add(dataSetFieldsPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
/** |
||||
* 检查box是否可用. |
||||
*/ |
||||
public void checkBoxUse() { |
||||
TableDataWrapper dataWrap = tableDataPane.getTableDataWrapper(); |
||||
|
||||
if (dataSetFieldsPane != null) { |
||||
dataSetFieldsPane.checkBoxUse(dataWrap != null); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 刷新字段下拉列表 |
||||
*/ |
||||
private void refreshBoxList() { |
||||
TableDataWrapper dataWrap = tableDataPane.getTableDataWrapper(); |
||||
|
||||
if (dataWrap == null) { |
||||
return; |
||||
} |
||||
|
||||
List<String> columnNameList = dataWrap.calculateColumnNameList(); |
||||
|
||||
if (dataSetFieldsPane != null) { |
||||
dataSetFieldsPane.refreshBoxListWithSelectTableData(columnNameList); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public boolean accept(Object ob) { |
||||
return ob instanceof DataSetDefinition; |
||||
} |
||||
|
||||
@Override |
||||
public String title4PopupWindow() { |
||||
return Toolkit.i18nText("Fine-Design_Chart_TableData"); |
||||
} |
||||
|
||||
@Override |
||||
public void reset() { |
||||
this.removeAll(); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(DataSetDefinition ob) { |
||||
refreshBoxList(); |
||||
checkBoxUse(); |
||||
|
||||
tableDataPane.populateBean(ob.getNameTableData()); |
||||
|
||||
dataSetFieldsPane.populateBean(ob.getColumnFieldCollection()); |
||||
} |
||||
|
||||
@Override |
||||
public DataSetDefinition updateBean() { |
||||
DataSetDefinition dataSetDefinition = new DataSetDefinition(); |
||||
|
||||
TableDataWrapper tableDataWrapper = tableDataPane.getTableDataWrapper(); |
||||
if (tableDataWrapper != null) { |
||||
dataSetDefinition.setNameTableData(new NameTableData(tableDataWrapper.getTableDataName())); |
||||
} |
||||
|
||||
dataSetDefinition.setColumnFieldCollection(dataSetFieldsPane.updateBean()); |
||||
|
||||
return dataSetDefinition; |
||||
} |
||||
} |
@ -0,0 +1,90 @@
|
||||
package com.fr.design.chartx.single; |
||||
|
||||
import com.fr.chartx.data.AbstractDataDefinition; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.beans.FurtherBasicBeanPane; |
||||
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; |
||||
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; |
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.gui.frpane.UIComboBoxPane; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.mainframe.chart.gui.ChartDataPane; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by shine on 2019/5/21. |
||||
*/ |
||||
public class SingleDataPane extends BasicBeanPane<AbstractDataDefinition> { |
||||
|
||||
private UIComboBoxPane<AbstractDataDefinition> comboBoxPane; |
||||
|
||||
private DataSetPane dataSetPane; |
||||
|
||||
private CellDataPane cellDataPane; |
||||
|
||||
public SingleDataPane(AbstractDataSetFieldsPane dataSetFieldsPane, AbstractCellDataFieldsPane cellDataFieldsPane) { |
||||
initComps(dataSetFieldsPane, cellDataFieldsPane); |
||||
} |
||||
|
||||
private void initComps(AbstractDataSetFieldsPane dataSetFieldsPane, AbstractCellDataFieldsPane cellDataFieldsPane) { |
||||
|
||||
cellDataPane = new CellDataPane(cellDataFieldsPane); |
||||
dataSetPane = new DataSetPane(dataSetFieldsPane); |
||||
|
||||
comboBoxPane = new UIComboBoxPane<AbstractDataDefinition>() { |
||||
@Override |
||||
protected List<FurtherBasicBeanPane<? extends AbstractDataDefinition>> initPaneList() { |
||||
List<FurtherBasicBeanPane<? extends AbstractDataDefinition>> list = new ArrayList<FurtherBasicBeanPane<? extends AbstractDataDefinition>>(); |
||||
list.add(dataSetPane); |
||||
list.add(cellDataPane); |
||||
return list; |
||||
} |
||||
|
||||
protected void initLayout() { |
||||
this.setLayout(new BorderLayout(LayoutConstants.HGAP_LARGE, 6)); |
||||
JPanel northPane = new JPanel(new BorderLayout(LayoutConstants.HGAP_LARGE, 0)); |
||||
northPane.add(jcb, BorderLayout.CENTER); |
||||
UILabel label1 = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Source")); |
||||
label1.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); |
||||
northPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{jcb, null, null, label1, null})); |
||||
northPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 8)); |
||||
this.add(northPane, BorderLayout.NORTH); |
||||
this.add(cardPane, BorderLayout.CENTER); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return null; |
||||
} |
||||
}; |
||||
|
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
this.add(comboBoxPane, BorderLayout.CENTER); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(AbstractDataDefinition ob) { |
||||
comboBoxPane.populateBean(ob); |
||||
} |
||||
|
||||
@Override |
||||
public AbstractDataDefinition updateBean() { |
||||
return comboBoxPane.updateBean(); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return null; |
||||
} |
||||
} |
@ -1,65 +0,0 @@
|
||||
/* |
||||
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved. |
||||
*/ |
||||
|
||||
package com.fr.design.mainframe.chart.gui; |
||||
|
||||
import com.fr.design.mainframe.chart.gui.other.ChartDesignerConditionAttrPane; |
||||
import com.fr.design.mainframe.chart.gui.other.ChartDesignerInteractivePane; |
||||
import com.fr.design.dialog.BasicPane; |
||||
|
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.util.*; |
||||
|
||||
/** |
||||
* 图表设计器的图标属性表高级tab |
||||
* Created by IntelliJ IDEA. |
||||
* Author : daisy |
||||
* Version: 6.5.6 |
||||
* Date: 14-10-16 |
||||
* Time: 下午2:04 |
||||
*/ |
||||
public class ChartDesignerOtherPane extends ChartOtherPane { |
||||
|
||||
@Override |
||||
protected JPanel createContentPane() { |
||||
JPanel content = new JPanel(new BorderLayout()); |
||||
otherPane = new ChartTabPane(); |
||||
content.add(otherPane, BorderLayout.CENTER); |
||||
return content; |
||||
} |
||||
|
||||
/** |
||||
* 界面标题 |
||||
* |
||||
* @return 返回标题. |
||||
*/ |
||||
public String title4PopupWindow() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Advanced"); |
||||
} |
||||
|
||||
private boolean isHaveCondition() { |
||||
return hasCondition; |
||||
} |
||||
|
||||
|
||||
private class ChartTabPane extends TabPane { |
||||
|
||||
@Override |
||||
protected java.util.List<BasicPane> initPaneList() { |
||||
java.util.List<BasicPane> paneList = new ArrayList<BasicPane>(); |
||||
interactivePane = new ChartDesignerInteractivePane(ChartDesignerOtherPane.this); |
||||
|
||||
paneList.add(interactivePane); |
||||
|
||||
if (ChartDesignerOtherPane.this.isHaveCondition()) { |
||||
conditionAttrPane = new ChartDesignerConditionAttrPane(); |
||||
paneList.add(conditionAttrPane); |
||||
} |
||||
return paneList; |
||||
} |
||||
|
||||
} |
||||
} |
@ -1,33 +0,0 @@
|
||||
package com.fr.design.mainframe.chart.gui; |
||||
|
||||
import com.fr.chart.chartattr.ChartCollection; |
||||
import com.fr.design.gui.frpane.AttributeChangeListener; |
||||
import com.fr.design.mainframe.chart.gui.style.series.ChartSeriesPane; |
||||
import com.fr.design.mainframe.chart.gui.style.series.SeriesPane4ChartDesigner; |
||||
|
||||
/** |
||||
* 图表设计器的样式面板 |
||||
* Created by IntelliJ IDEA. |
||||
* Author : daisy |
||||
* Version: 6.5.6 |
||||
* Date: 14-10-25 |
||||
* Time: 下午6:56 |
||||
*/ |
||||
public class StylePane4Chart extends ChartStylePane { |
||||
|
||||
public StylePane4Chart(AttributeChangeListener listener, boolean isNeedFormula) { |
||||
super(listener, isNeedFormula); |
||||
} |
||||
|
||||
public void update(ChartCollection collection) { |
||||
int selectIndex = collection.getSelectedIndex(); |
||||
super.update(collection); |
||||
collection.getSelectedChart().setStyleGlobal(false); |
||||
collection.setChartName(selectIndex, collection.getSelectedChart().getTitle().getTextObject().toString()); |
||||
} |
||||
|
||||
protected ChartSeriesPane createChartSeriesPane(){ |
||||
return new SeriesPane4ChartDesigner(StylePane4Chart.this); |
||||
} |
||||
|
||||
} |
@ -1,94 +0,0 @@
|
||||
package com.fr.design.mainframe.chart.gui.other; |
||||
|
||||
import java.awt.BorderLayout; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
import javax.swing.JPanel; |
||||
import javax.swing.SwingUtilities; |
||||
|
||||
import com.fr.design.chart.ChartControlPane; |
||||
import com.fr.chart.chartattr.ChartCollection; |
||||
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.mainframe.chart.ChartEditPane; |
||||
import com.fr.design.mainframe.chart.PaneTitleConstants; |
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
|
||||
|
||||
public class ChartSwitchPane extends AbstractAttrNoScrollPane{ |
||||
|
||||
private UIButton changeButton; |
||||
|
||||
private ChartCollection editingChartCollection; |
||||
|
||||
private ChartEditPane currentChartEditPane; |
||||
|
||||
public ChartSwitchPane() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
protected JPanel createContentPane() { |
||||
JPanel pane = new JPanel(); |
||||
pane.setLayout(new BorderLayout()); |
||||
|
||||
changeButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Switch")); |
||||
|
||||
pane.add(changeButton, BorderLayout.NORTH); |
||||
|
||||
changeButton.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
final ChartControlPane chartTypeManager = new ChartControlPane(); |
||||
chartTypeManager.populate(editingChartCollection); |
||||
|
||||
BasicDialog dlg = chartTypeManager.showWindow4ChartType(SwingUtilities.getWindowAncestor(new JPanel()), new DialogActionAdapter() { |
||||
public void doOk() { |
||||
chartTypeManager.update(editingChartCollection);//kunsnat: 确定刷新"chartSelectIndex"
|
||||
|
||||
if(currentChartEditPane != null) { |
||||
currentChartEditPane.populate(editingChartCollection);// 选中新Plot之后 刷新对应界面, 比如超级链接等, 然后才能update.
|
||||
currentChartEditPane.gotoPane(PaneTitleConstants.CHART_TYPE_TITLE); |
||||
currentChartEditPane.gotoPane(PaneTitleConstants.CHART_OTHER_TITLE, PaneTitleConstants.CHART_OTHER_TITLE_CHANGE); |
||||
currentChartEditPane.fire(); |
||||
} |
||||
} |
||||
}); |
||||
|
||||
dlg.setVisible(true); |
||||
} |
||||
}); |
||||
|
||||
return pane; |
||||
} |
||||
|
||||
/** |
||||
* 注册 切换事件的改变 和超链不同. |
||||
* @param listener |
||||
*/ |
||||
public void registerChartEditPane(ChartEditPane currentChartEditPane) { |
||||
this.currentChartEditPane = currentChartEditPane; |
||||
} |
||||
|
||||
public void populateBean(ChartCollection c) { |
||||
this.editingChartCollection = c; |
||||
} |
||||
|
||||
public void updateBean(ChartCollection c) { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 界面标题 |
||||
* @param 返回标题 |
||||
*/ |
||||
public String title4PopupWindow() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Switch_Chart"); |
||||
} |
||||
|
||||
@Override |
||||
public String getIconPath() { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,409 @@
|
||||
package com.fr.design.mainframe.chart.gui.type; |
||||
|
||||
import com.fr.base.ChartColorMatching; |
||||
import com.fr.base.ChartPreStyleConfig; |
||||
import com.fr.base.background.ColorBackground; |
||||
import com.fr.chart.base.AttrContents; |
||||
import com.fr.chart.base.AttrFillStyle; |
||||
import com.fr.chart.base.ChartConstants; |
||||
import com.fr.chart.base.ChartUtils; |
||||
import com.fr.chart.base.DataSeriesCondition; |
||||
import com.fr.chart.base.TextAttr; |
||||
import com.fr.chart.chartattr.Axis; |
||||
import com.fr.chart.chartattr.CategoryPlot; |
||||
import com.fr.chart.chartattr.Chart; |
||||
import com.fr.chart.chartattr.Legend; |
||||
import com.fr.chart.chartattr.Plot; |
||||
import com.fr.chart.chartattr.Title; |
||||
import com.fr.chart.chartglyph.ConditionAttr; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.FRFont; |
||||
import com.fr.js.NameJavaScriptGroup; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.Constants; |
||||
|
||||
import java.awt.Color; |
||||
import java.awt.Font; |
||||
|
||||
/** |
||||
* Created by shine on 2019/7/1. |
||||
*/ |
||||
public abstract class AbstractDeprecatedChartTypePane extends AbstractChartTypePane<Chart> { |
||||
|
||||
protected void changePlotWithClone(Chart chart, Plot plot) { |
||||
try { |
||||
chart.switchPlot((Plot) plot.clone()); |
||||
} catch (CloneNotSupportedException e) { |
||||
FineLoggerFactory.getLogger().error("Error in change plot"); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 更新界面属性 |
||||
*/ |
||||
public void populateBean(Chart chart) { |
||||
for (ChartImagePane imagePane : typeDemo) { |
||||
imagePane.isPressing = false; |
||||
} |
||||
for (ChartImagePane imagePane : styleList) { |
||||
imagePane.isPressing = false; |
||||
} |
||||
|
||||
if (styleList != null && !styleList.isEmpty()) { |
||||
int plotStyle = chart.getPlot().getPlotStyle(); |
||||
String styleName = chart.getPlot().getPlotFillStyle().getFillStyleName(); |
||||
|
||||
switch (plotStyle) { |
||||
case ChartConstants.STYLE_SHADE: |
||||
if (ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Retro"), styleName)) { |
||||
styleList.get(STYLE_SHADE).isPressing = true; |
||||
lastStyleIndex = STYLE_SHADE; |
||||
} |
||||
break; |
||||
case ChartConstants.STYLE_TRANSPARENT: |
||||
if (ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Fresh"), styleName)) { |
||||
styleList.get(STYLE_TRANSPARENT).isPressing = true; |
||||
lastStyleIndex = STYLE_TRANSPARENT; |
||||
} |
||||
break; |
||||
case ChartConstants.STYLE_3D: |
||||
if (ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"), styleName)) { |
||||
styleList.get(STYLE_PLANE3D).isPressing = true; |
||||
lastStyleIndex = STYLE_PLANE3D; |
||||
} |
||||
break; |
||||
case ChartConstants.STYLE_OUTER: |
||||
if (ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"), styleName)) { |
||||
styleList.get(STYLE_HIGHLIGHT).isPressing = true; |
||||
lastStyleIndex = STYLE_HIGHLIGHT; |
||||
} |
||||
break; |
||||
default: |
||||
lastStyleIndex = -1; |
||||
break; |
||||
} |
||||
stylePane.setVisible(!(chart.getPlot().isSupport3D())); |
||||
this.repaint(); |
||||
} |
||||
} |
||||
|
||||
public void updateBean(Chart chart) { |
||||
Plot oldPlot = chart.getPlot(); |
||||
Plot newPlot = this.setSelectedClonedPlotWithCondition(oldPlot); |
||||
checkTypeChange(oldPlot);//判断图表的类型是否发生变化
|
||||
if (styleList != null && !styleList.isEmpty()) { |
||||
if (styleList.get(STYLE_SHADE).isPressing && lastStyleIndex != STYLE_SHADE) { |
||||
lastStyleIndex = STYLE_SHADE; |
||||
chart.setPlot(newPlot); |
||||
chart.getPlot().setPlotStyle(ChartConstants.STYLE_SHADE); |
||||
resetChart(chart); |
||||
createCondition4Shade(chart); |
||||
setPlotFillStyle(chart); |
||||
} else if (styleList.get(STYLE_TRANSPARENT).isPressing && lastStyleIndex != STYLE_TRANSPARENT) { |
||||
lastStyleIndex = STYLE_TRANSPARENT; |
||||
chart.setPlot(newPlot); |
||||
chart.getPlot().setPlotStyle(ChartConstants.STYLE_TRANSPARENT); |
||||
resetChart(chart); |
||||
createCondition4Transparent(chart); |
||||
setPlotFillStyle(chart); |
||||
} else if (styleList.get(STYLE_PLANE3D).isPressing && lastStyleIndex != STYLE_PLANE3D) { |
||||
lastStyleIndex = STYLE_PLANE3D; |
||||
chart.setPlot(newPlot); |
||||
chart.getPlot().setPlotStyle(ChartConstants.STYLE_3D); |
||||
resetChart(chart); |
||||
createCondition4Plane3D(chart); |
||||
setPlotFillStyle(chart); |
||||
} else if (styleList.get(STYLE_HIGHLIGHT).isPressing && lastStyleIndex != STYLE_HIGHLIGHT) { |
||||
lastStyleIndex = STYLE_HIGHLIGHT; |
||||
chart.setPlot(newPlot); |
||||
chart.getPlot().setPlotStyle(ChartConstants.STYLE_OUTER); |
||||
resetChart(chart); |
||||
createCondition4HighLight(chart); |
||||
setPlotFillStyle(chart); |
||||
} else if (lastStyleIndex >= STYLE_SHADE && lastStyleIndex <= STYLE_HIGHLIGHT) { |
||||
if (styleList.get(lastStyleIndex).isDoubleClicked || typeChanged) { |
||||
chart.setPlot(newPlot); |
||||
resetChart(chart); |
||||
styleList.get(lastStyleIndex).isPressing = false; |
||||
checkDemosBackground(); |
||||
lastStyleIndex = -1; |
||||
} |
||||
} |
||||
|
||||
stylePane.setVisible(!(chart.getPlot().isSupport3D())); |
||||
this.repaint(); |
||||
} |
||||
} |
||||
|
||||
private Plot setSelectedClonedPlotWithCondition(Plot oldPlot) { |
||||
Plot newPlot = getSelectedClonedPlot(); |
||||
if (oldPlot != null && ComparatorUtils.equals(newPlot.getClass(), oldPlot.getClass())) { |
||||
if (oldPlot.getHotHyperLink() != null) { |
||||
NameJavaScriptGroup hotHyper = oldPlot.getHotHyperLink(); |
||||
try { |
||||
newPlot.setHotHyperLink((NameJavaScriptGroup) hotHyper.clone()); |
||||
} catch (CloneNotSupportedException e) { |
||||
FineLoggerFactory.getLogger().error("Error in Hyperlink, Please Check it.", e); |
||||
} |
||||
} |
||||
newPlot.setConditionCollection(oldPlot.getConditionCollection()); |
||||
newPlot.setSeriesDragEnable(oldPlot.isSeriesDragEnable()); |
||||
if (newPlot.isSupportZoomCategoryAxis() && newPlot.getxAxis() != null) { |
||||
newPlot.getxAxis().setZoom(oldPlot.getxAxis().isZoom()); |
||||
} |
||||
if (newPlot.isSupportTooltipInInteractivePane()) { |
||||
newPlot.setHotTooltipStyle(oldPlot.getHotTooltipStyle()); |
||||
} |
||||
|
||||
if (newPlot.isSupportAutoRefresh()) { |
||||
newPlot.setAutoRefreshPerSecond(oldPlot.getAutoRefreshPerSecond()); |
||||
} |
||||
|
||||
if (newPlot.isSupportAxisTip()) { |
||||
newPlot.setInteractiveAxisTooltip(oldPlot.isInteractiveAxisTooltip()); |
||||
} |
||||
} |
||||
return newPlot; |
||||
} |
||||
|
||||
//平面3D的默认属性设置
|
||||
private void createCondition4Plane3D(Chart chart) { |
||||
if (chart != null) { |
||||
//标题
|
||||
Title title = new Title(chart.getTitle().getTextObject()); |
||||
chart.setTitle(title); |
||||
title.setTitleVisible(true); |
||||
TextAttr textAttr = title.getTextAttr(); |
||||
if (textAttr == null) { |
||||
textAttr = new TextAttr(); |
||||
title.setTextAttr(textAttr); |
||||
} |
||||
title.setPosition(Constants.CENTER); |
||||
textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 16f, new Color(51, 51, 51))); |
||||
|
||||
//图例
|
||||
Legend legend = new Legend(); |
||||
legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(128, 128, 128))); |
||||
legend.setPosition(Constants.TOP); |
||||
chart.getPlot().setLegend(legend); |
||||
|
||||
//分类轴,现在只有柱形图,条形图,面积图
|
||||
if (chart.getPlot() instanceof CategoryPlot) { |
||||
CategoryPlot plot = (CategoryPlot) chart.getPlot(); |
||||
//分类轴设置
|
||||
Axis cateAxis = plot.getxAxis(); |
||||
cateAxis.setAxisStyle(Constants.LINE_THICK); |
||||
cateAxis.setAxisColor(new Color(57, 57, 57)); |
||||
cateAxis.setTickMarkType(Constants.TICK_MARK_NONE); |
||||
cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); |
||||
cateAxis.setShowAxisLabel(true); |
||||
cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(57, 57, 57))); |
||||
|
||||
//值轴设置
|
||||
Axis valueAxis = plot.getyAxis(); |
||||
valueAxis.setAxisStyle(Constants.LINE_NONE); |
||||
valueAxis.setTickMarkType(Constants.TICK_MARK_NONE); |
||||
valueAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); |
||||
valueAxis.setShowAxisLabel(false); |
||||
|
||||
//绘图区
|
||||
plot.getyAxis().setMainGridStyle(Constants.LINE_THIN); |
||||
plot.getyAxis().setMainGridColor(new Color(192, 192, 192)); |
||||
chart.setBorderStyle(Constants.LINE_NONE); |
||||
|
||||
//数据标签
|
||||
ConditionAttr attrList = plot.getConditionCollection().getDefaultAttr(); |
||||
DataSeriesCondition attr = attrList.getExisted(AttrContents.class); |
||||
if (attr != null) { |
||||
attrList.remove(attr); |
||||
} |
||||
AttrContents attrContents = new AttrContents(); |
||||
attrContents.setPosition(Constants.OUTSIDE); |
||||
attrContents.setSeriesLabel(ChartConstants.VALUE_PARA); |
||||
attrContents.setTextAttr(new TextAttr(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(51, 51, 51)))); |
||||
attrList.addDataSeriesCondition(attrContents); |
||||
} |
||||
} |
||||
} |
||||
|
||||
//透明风格的默认属性设置
|
||||
private void createCondition4Transparent(Chart chart) { |
||||
if (chart != null) { |
||||
//标题
|
||||
Title title = new Title(chart.getTitle().getTextObject()); |
||||
chart.setTitle(title); |
||||
title.setTitleVisible(true); |
||||
TextAttr textAttr = title.getTextAttr(); |
||||
if (textAttr == null) { |
||||
textAttr = new TextAttr(); |
||||
title.setTextAttr(textAttr); |
||||
} |
||||
title.setPosition(Constants.LEFT); |
||||
textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(192, 192, 192))); |
||||
|
||||
//图例
|
||||
Legend legend = new Legend(); |
||||
legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(138, 140, 139))); |
||||
legend.setPosition(Constants.RIGHT_TOP); |
||||
chart.getPlot().setLegend(legend); |
||||
|
||||
Plot plot = chart.getPlot(); |
||||
//绘图区
|
||||
chart.setBackground(ColorBackground.getInstance(new Color(51, 51, 51))); |
||||
|
||||
//分类轴,现在只有柱形图,条形图,面积图
|
||||
if (plot instanceof CategoryPlot) { |
||||
//边框
|
||||
plot.setBorderStyle(Constants.LINE_THIN); |
||||
plot.setBorderColor(new Color(65, 65, 65)); |
||||
|
||||
//分类轴设置
|
||||
Axis cateAxis = plot.getxAxis(); |
||||
cateAxis.setAxisStyle(Constants.LINE_THICK); |
||||
cateAxis.setAxisColor(new Color(192, 192, 192)); |
||||
cateAxis.setTickMarkType(Constants.TICK_MARK_NONE); |
||||
cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); |
||||
cateAxis.setShowAxisLabel(true); |
||||
cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(150, 150, 150))); |
||||
|
||||
//值轴
|
||||
Axis valueAxis = plot.getyAxis(); |
||||
valueAxis.setShowAxisLabel(true); |
||||
valueAxis.setAxisStyle(Constants.LINE_NONE); |
||||
valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(150, 150, 150))); |
||||
valueAxis.setMainGridStyle(Constants.LINE_THIN); |
||||
valueAxis.setMainGridColor(new Color(63, 62, 62)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
//渐变的默认属性设置
|
||||
private void createCondition4Shade(Chart chart) { |
||||
if (chart != null) { |
||||
//标题
|
||||
Title title = new Title(chart.getTitle().getTextObject()); |
||||
chart.setTitle(title); |
||||
title.setTitleVisible(true); |
||||
TextAttr textAttr = title.getTextAttr(); |
||||
if (textAttr == null) { |
||||
textAttr = new TextAttr(); |
||||
title.setTextAttr(textAttr); |
||||
} |
||||
title.setPosition(Constants.CENTER); |
||||
textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(0, 51, 102))); |
||||
|
||||
//图例
|
||||
Legend legend = new Legend(); |
||||
legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(128, 128, 128))); |
||||
legend.setPosition(Constants.BOTTOM); |
||||
chart.getPlot().setLegend(legend); |
||||
|
||||
//分类轴,现在只有柱形图,条形图,面积图
|
||||
if (chart.getPlot() instanceof CategoryPlot) { |
||||
CategoryPlot plot = (CategoryPlot) chart.getPlot(); |
||||
|
||||
//分类轴设置
|
||||
Axis cateAxis = plot.getxAxis(); |
||||
cateAxis.setAxisStyle(Constants.LINE_THICK); |
||||
cateAxis.setAxisColor(new Color(73, 100, 117)); |
||||
cateAxis.setTickMarkType(Constants.TICK_MARK_NONE); |
||||
cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); |
||||
cateAxis.setShowAxisLabel(true); |
||||
cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(128, 128, 128))); |
||||
|
||||
//值轴
|
||||
Axis valueAxis = plot.getyAxis(); |
||||
valueAxis.setShowAxisLabel(true); |
||||
valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(128, 128, 128))); |
||||
valueAxis.setAxisStyle(Constants.LINE_NONE); |
||||
|
||||
//绘图区
|
||||
plot.getyAxis().setMainGridStyle(Constants.LINE_THIN); |
||||
plot.getyAxis().setMainGridColor(new Color(192, 192, 192)); |
||||
plot.setHorizontalIntervalBackgroundColor(new Color(243, 243, 243)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
//高光渐变的默认属性设置
|
||||
private void createCondition4HighLight(Chart chart) { |
||||
if (chart != null) { |
||||
//标题
|
||||
Title title = new Title(chart.getTitle().getTextObject()); |
||||
chart.setTitle(title); |
||||
title.setTitleVisible(true); |
||||
TextAttr textAttr = title.getTextAttr(); |
||||
if (textAttr == null) { |
||||
textAttr = new TextAttr(); |
||||
title.setTextAttr(textAttr); |
||||
} |
||||
title.setPosition(Constants.LEFT); |
||||
textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(51, 51, 51))); |
||||
|
||||
//图例
|
||||
Legend legend = new Legend(); |
||||
legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(138, 140, 139))); |
||||
legend.setPosition(Constants.RIGHT_TOP); |
||||
chart.getPlot().setLegend(legend); |
||||
|
||||
//分类轴,现在只有柱形图,条形图,面积图
|
||||
if (chart.getPlot() instanceof CategoryPlot) { |
||||
CategoryPlot plot = (CategoryPlot) chart.getPlot(); |
||||
|
||||
//分类轴设置
|
||||
Axis cateAxis = plot.getxAxis(); |
||||
cateAxis.setAxisStyle(Constants.LINE_THICK); |
||||
cateAxis.setAxisColor(new Color(204, 220, 228)); |
||||
cateAxis.setTickMarkType(Constants.TICK_MARK_INSIDE); |
||||
cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); |
||||
cateAxis.setShowAxisLabel(true); |
||||
cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(138, 140, 139))); |
||||
|
||||
//值轴
|
||||
Axis valueAxis = plot.getyAxis(); |
||||
valueAxis.setAxisStyle(Constants.NONE); |
||||
valueAxis.setAxisColor(null); |
||||
valueAxis.setTickMarkType(Constants.TICK_MARK_INSIDE); |
||||
valueAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); |
||||
valueAxis.setShowAxisLabel(true); |
||||
valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(138, 140, 139))); |
||||
|
||||
//绘图区
|
||||
plot.setBorderStyle(Constants.LINE_THIN); |
||||
plot.setBorderColor(new Color(204, 220, 228)); |
||||
plot.setBackground(ColorBackground.getInstance(new Color(248, 247, 245))); |
||||
plot.getyAxis().setMainGridStyle(Constants.LINE_THIN); |
||||
plot.getyAxis().setMainGridColor(new Color(192, 192, 192)); |
||||
} |
||||
|
||||
} |
||||
} |
||||
|
||||
private void setPlotFillStyle(Chart chart) { |
||||
ChartPreStyleConfig manager = ChartPreStyleConfig.getInstance(); |
||||
Plot plot = chart.getPlot(); |
||||
Object preStyle = null; |
||||
String name = ""; |
||||
if (styleList.get(STYLE_SHADE).isPressing) { |
||||
name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Retro"); |
||||
preStyle = manager.getPreStyle(name); |
||||
} else if (styleList.get(STYLE_TRANSPARENT).isPressing) { |
||||
name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Fresh"); |
||||
preStyle = manager.getPreStyle(name); |
||||
} else if (styleList.get(STYLE_PLANE3D).isPressing) { |
||||
name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"); |
||||
preStyle = manager.getPreStyle(name); |
||||
} else if (styleList.get(STYLE_HIGHLIGHT).isPressing) { |
||||
name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"); |
||||
preStyle = manager.getPreStyle(name); |
||||
} |
||||
if (preStyle == null) { |
||||
plot.getPlotFillStyle().setColorStyle(ChartConstants.COLOR_DEFAULT); |
||||
} else { |
||||
AttrFillStyle fillStyle = ChartUtils.chartColorMatching2AttrFillStyle((ChartColorMatching) preStyle); |
||||
fillStyle.setFillStyleName(name); |
||||
plot.setPlotFillStyle(fillStyle); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,69 @@
|
||||
package com.fr.design.mainframe; |
||||
|
||||
import com.fr.config.dao.DaoContext; |
||||
import com.fr.config.dao.impl.LocalClassHelperDao; |
||||
import com.fr.config.dao.impl.LocalEntityDao; |
||||
import com.fr.config.dao.impl.LocalXmlEntityDao; |
||||
import com.fr.form.main.Form; |
||||
import com.fr.form.ui.ElementCaseEditor; |
||||
import com.fr.general.ImageWithSuffix; |
||||
import com.fr.general.ModuleContext; |
||||
import com.fr.main.impl.WorkBook; |
||||
import com.fr.report.cell.DefaultTemplateCellElement; |
||||
import com.fr.report.cell.TemplateCellElement; |
||||
import com.fr.report.cell.cellattr.CellImage; |
||||
import com.fr.report.restriction.CellCountRestriction; |
||||
import com.fr.report.restriction.ReportRestrictionScene; |
||||
import com.fr.report.worksheet.FormElementCase; |
||||
import com.fr.report.worksheet.WorkSheet; |
||||
import com.fr.restriction.Restrictions; |
||||
import com.fr.stable.module.Module; |
||||
import com.fr.start.Designer; |
||||
import junit.framework.TestCase; |
||||
import org.junit.Assert; |
||||
|
||||
import java.awt.image.BufferedImage; |
||||
|
||||
public class JFileTest extends TestCase { |
||||
@Override |
||||
protected void setUp() throws Exception { |
||||
DaoContext.setEntityDao(new LocalEntityDao()); |
||||
DaoContext.setClassHelperDao(new LocalClassHelperDao()); |
||||
DaoContext.setXmlEntityDao(new LocalXmlEntityDao()); |
||||
Restrictions.register(ReportRestrictionScene.CELL_COUNT, new CellCountRestriction()); |
||||
ModuleContext.startModule(Module.PAGE_MODULE); |
||||
ModuleContext.startModule(Module.VIEW_MODULE); |
||||
Designer designer = new Designer(new String[0]); |
||||
} |
||||
|
||||
public void testJWorkBookSetPicture() { |
||||
WorkBook workBook = new WorkBook(); |
||||
WorkSheet workSheet = new WorkSheet(); |
||||
workBook.addReport("sheet1", workSheet); |
||||
TemplateCellElement cellElement = new DefaultTemplateCellElement(); |
||||
workSheet.addCellElement(cellElement); |
||||
ImageWithSuffix imageWithSuffix = ImageWithSuffix.build(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB), "jpg"); |
||||
CellImage cellImage = new CellImage(); |
||||
cellImage.setImage(imageWithSuffix); |
||||
JWorkBook jWorkBook = new JWorkBook(workBook, "text"); |
||||
jWorkBook.setPictureElem(cellElement, cellImage); |
||||
Assert.assertEquals(imageWithSuffix, cellElement.getValue()); |
||||
} |
||||
|
||||
public void testJFormSetPicture() { |
||||
Form form = new Form(); |
||||
ElementCaseEditor editor = new ElementCaseEditor(); |
||||
FormElementCase elementCase = new FormElementCase(); |
||||
TemplateCellElement cellElement = new DefaultTemplateCellElement(); |
||||
elementCase.addCellElement(cellElement); |
||||
editor.setElementCase(elementCase); |
||||
form.getContainer().addWidget(editor); |
||||
ImageWithSuffix imageWithSuffix = ImageWithSuffix.build(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB), "jpg"); |
||||
CellImage cellImage = new CellImage(); |
||||
cellImage.setImage(imageWithSuffix); |
||||
JForm jForm = new JForm(); |
||||
jForm.setTarget(form); |
||||
jForm.setPictureElem(cellElement, cellImage); |
||||
Assert.assertEquals(imageWithSuffix, cellElement.getValue()); |
||||
} |
||||
} |
Loading…
Reference in new issue