diff --git a/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaPlotPane.java index 5cec0753a7..5d254ebb6a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaPlotPane.java @@ -5,12 +5,12 @@ import com.fr.chart.chartattr.Plot; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.area.AreaIndependentVanChart; import com.fr.plugin.chart.area.VanChartAreaPlot; -import com.fr.van.chart.designer.type.AbstractVanChartTypePane; +import com.fr.van.chart.designer.type.AbstractRectanglePlotPane; /** * Created by Mitisky on 15/11/18. */ -public class VanChartAreaPlotPane extends AbstractVanChartTypePane { +public class VanChartAreaPlotPane extends AbstractRectanglePlotPane { @Override protected String[] getTypeIconPath() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/bar/VanChartBarPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/bar/VanChartBarPlotPane.java index 83d1db2e96..811dde312c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/bar/VanChartBarPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/bar/VanChartBarPlotPane.java @@ -5,12 +5,12 @@ import com.fr.chart.chartattr.Plot; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.bar.BarIndependentVanChart; import com.fr.plugin.chart.column.VanChartColumnPlot; -import com.fr.van.chart.designer.type.AbstractVanChartTypePane; +import com.fr.van.chart.designer.type.AbstractRectanglePlotPane; /** * Created by Mitisky on 15/10/20. */ -public class VanChartBarPlotPane extends AbstractVanChartTypePane { +public class VanChartBarPlotPane extends AbstractRectanglePlotPane { @Override protected String[] getTypeIconPath() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubblePlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubblePlotPane.java index 407c7758ba..ef90c8a017 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubblePlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubblePlotPane.java @@ -12,15 +12,22 @@ import com.fr.chartx.data.field.AbstractColumnFieldCollection; import com.fr.chartx.data.field.diff.BubbleColumnFieldCollection; import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.area.VanChartAreaPlot; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.base.VanChartZoom; import com.fr.plugin.chart.bubble.BubbleIndependentVanChart; import com.fr.plugin.chart.bubble.VanChartBubblePlot; +import com.fr.plugin.chart.column.VanChartColumnPlot; +import com.fr.plugin.chart.line.VanChartLinePlot; +import com.fr.plugin.chart.scatter.VanChartScatterPlot; import com.fr.plugin.chart.scatter.attr.ScatterAttrLabel; import com.fr.plugin.chart.vanchart.VanChart; import com.fr.van.chart.designer.type.AbstractVanChartTypePane; +import java.util.HashSet; +import java.util.Set; + /** * Created by Mitisky on 16/3/31. */ @@ -32,6 +39,20 @@ public class VanChartBubblePlotPane extends AbstractVanChartTypePane { private static final float ALPHA = 0.7f; + private static Set forceExtendPlotIds = new HashSet<>(); + + private static Set extendPlotIds = new HashSet<>(); + + static { + extendPlotIds.add(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID); + extendPlotIds.add(VanChartColumnPlot.VAN_CHART_BAR_PLOT_ID); + extendPlotIds.add(VanChartLinePlot.VAN_CHART_LINE_PLOT); + extendPlotIds.add(VanChartAreaPlot.VAN_CHART_AREA_PLOT_ID); + extendPlotIds.add(VanChartScatterPlot.VAN_CHART_SCATTER_PLOT_ID); + + forceExtendPlotIds.add(VanChartScatterPlot.VAN_CHART_SCATTER_PLOT_ID); + } + @Override protected String[] getTypeIconPath() { return new String[]{"/com/fr/van/chart/bubble/images/bubble.png", @@ -122,16 +143,16 @@ public class VanChartBubblePlotPane extends AbstractVanChartTypePane { * @param chart */ @Override - protected void resetChartAttr4SamePlot(Chart chart) { + protected void resetChartAttr4SamePlot(VanChart chart) { //图表缩放新设计 恢复用注释。下面2行删除。 VanChartZoom vanChartZoom = new VanChartZoom(); - ((VanChart) chart).setVanChartZoom(vanChartZoom); + chart.setVanChartZoom(vanChartZoom); //图表缩放新设计 恢复用注释。下面一行取消注释。 //((VanChart) chart).setZoomAttribute(new ZoomAttribute()); //重置监控刷新选项 - resetRefreshMoreLabelAttr((VanChart) chart); + resetRefreshMoreLabelAttr(chart); } @Override @@ -147,4 +168,12 @@ public class VanChartBubblePlotPane extends AbstractVanChartTypePane { } return false; } + + //是否支持属性的继承 + @Override + protected boolean supportExtendAttr(VanChart chart) { + VanChartBubblePlot selectedClonedPlot = (VanChartBubblePlot) getSelectedClonedPlot(); + return selectedClonedPlot.isForceBubble() ? forceExtendPlotIds.contains(chart.getID()) : + extendPlotIds.contains(chart.getID()); + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotPane.java index 40269cc15c..8b37e952c1 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotPane.java @@ -5,12 +5,12 @@ import com.fr.chart.chartattr.Plot; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.column.ColumnIndependentVanChart; import com.fr.plugin.chart.column.VanChartColumnPlot; -import com.fr.van.chart.designer.type.AbstractVanChartTypePane; +import com.fr.van.chart.designer.type.AbstractRectanglePlotPane; /** * Created by Mitisky on 15/9/24. */ -public class VanChartColumnPlotPane extends AbstractVanChartTypePane { +public class VanChartColumnPlotPane extends AbstractRectanglePlotPane { @Override protected String[] getTypeIconPath() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java index 6bace5ef90..ff0147652a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java @@ -119,7 +119,7 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { } @Override - public void updateBean(Chart chart) { + public void updateBean(VanChart chart) { //保存上次选中的值,其会在super中更新 int lastState = chart.getPlot().getDetailType(); @@ -129,7 +129,7 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { //如果上次的状态和这次的装填不在同一个页面,说明同一个图表內切换了,需要情況数据配置 if (lastState != chart.getPlot().getDetailType()) { chart.setFilterDefinition(null); - ((VanChart) chart).setChartDataDefinition(null); + chart.setChartDataDefinition(null); } Chart[] customChart = CustomIndependentVanChart.CustomVanChartTypes; @@ -214,12 +214,12 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { * @param newPlot */ @Override - protected void resetChartAttr(Chart chart, Plot newPlot) { + protected void resetChartAttr(VanChart chart, VanChartPlot newPlot) { super.resetChartAttr(chart, newPlot); //切换图表清空数据配置 chart.setFilterDefinition(null); //设置默认不排序 - VanChartTools tools = ((VanChart) chart).getVanChartTools(); + VanChartTools tools = chart.getVanChartTools(); if (tools != null) { tools.setSort(false); } @@ -228,7 +228,7 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { /** * 更新界面内容 */ - public void populateBean(Chart chart) { + public void populateBean(VanChart chart) { for (ChartImagePane imagePane : typeDemo) { imagePane.isPressing = false; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractRectanglePlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractRectanglePlotPane.java new file mode 100644 index 0000000000..6712fba900 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractRectanglePlotPane.java @@ -0,0 +1,88 @@ +package com.fr.van.chart.designer.type; + +import com.fr.chart.chartglyph.ConditionCollection; +import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.PiePlot4VanChart; +import com.fr.plugin.chart.area.VanChartAreaPlot; +import com.fr.plugin.chart.attr.axis.VanChartAxis; +import com.fr.plugin.chart.attr.plot.VanChartPlot; +import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; +import com.fr.plugin.chart.bubble.VanChartBubblePlot; +import com.fr.plugin.chart.column.VanChartColumnPlot; +import com.fr.plugin.chart.line.VanChartLinePlot; +import com.fr.plugin.chart.scatter.VanChartScatterPlot; +import com.fr.plugin.chart.type.VanChartPlotType; +import com.fr.plugin.chart.vanchart.VanChart; +import com.fr.stable.StringUtils; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-08-24 + */ +public abstract class AbstractRectanglePlotPane extends AbstractVanChartTypePane { + + private static Set extendPlotIds = new HashSet<>(); + + static { + extendPlotIds.add(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID); + extendPlotIds.add(VanChartColumnPlot.VAN_CHART_BAR_PLOT_ID); + extendPlotIds.add(VanChartLinePlot.VAN_CHART_LINE_PLOT); + extendPlotIds.add(VanChartAreaPlot.VAN_CHART_AREA_PLOT_ID); + extendPlotIds.add(VanChartScatterPlot.VAN_CHART_SCATTER_PLOT_ID); + extendPlotIds.add(PiePlot4VanChart.VAN_CHART_PIE_PLOT); + } + + @Override + protected VanChartPlot cloneOldPlot2New(VanChartPlot oldPlot, VanChartPlot newPlot) { + try { + VanChartRectanglePlot vanChartRectanglePlot = (VanChartRectanglePlot) newPlot; + VanChartRectanglePlot clonePlot = (VanChartRectanglePlot) oldPlot.clone(); + clonePlot.setVanChartPlotType(vanChartRectanglePlot.getVanChartPlotType()); + //自定义类型的图形要增加一个y2轴,并且增加系列中的堆积条件,反之则要去掉y2轴和条件 + if (clonePlot.isCustomChart()) { + List valueAxisList = clonePlot.getValueAxisList(); + valueAxisList.add(vanChartRectanglePlot.getValueAxisList().get(1)); + clonePlot.setStackAndAxisCondition(vanChartRectanglePlot.getStackAndAxisCondition()); + } else { + List xAxisList = clonePlot.getXAxisList(); + List yAxisList = clonePlot.getYAxisList(); + List newXAxisList = new ArrayList<>(); + List newYAxisList = new ArrayList<>(); + newXAxisList.add(xAxisList.get(0)); + newYAxisList.add(yAxisList.get(0)); + clonePlot.setXAxisList(newXAxisList); + clonePlot.setYAxisList(newYAxisList); + clonePlot.setStackAndAxisCondition(new ConditionCollection()); + } + + //百分比堆积图值轴的格式不保留 + if (clonePlot.getVanChartPlotType() == VanChartPlotType.STACK_BY_PERCENT || + ((VanChartRectanglePlot) oldPlot).getVanChartPlotType() == VanChartPlotType.STACK_BY_PERCENT) { + VanChartAxis cloneAxis = clonePlot.getValueAxisList().get(0); + VanChartAxis vanChartAxis = vanChartRectanglePlot.getValueAxisList().get(0); + cloneAxis.setFormat(vanChartAxis.getFormat()); + cloneAxis.setPercentage(vanChartAxis.isPercentage()); + } + return clonePlot; + } catch (CloneNotSupportedException ex) { + FineLoggerFactory.getLogger().error("Error in change plot"); + return newPlot; + } + } + + //是否支持属性的继承 + @Override + protected boolean supportExtendAttr(VanChart chart) { + if (StringUtils.equals(VanChartBubblePlot.VAN_CHART_BUBBLE_PLOT_ID, chart.getID())) { + VanChartBubblePlot vanChartBubblePlot = chart.getPlot(); + return !vanChartBubblePlot.isForceBubble(); + } + return extendPlotIds.contains(chart.getID()); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java index 6189c347b4..a4b53796fd 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java @@ -37,7 +37,7 @@ import java.awt.Component; import java.awt.Dimension; import java.awt.event.ActionListener; -public abstract class AbstractVanChartTypePane extends AbstractChartTypePane { +public abstract class AbstractVanChartTypePane extends AbstractChartTypePane { private static final long serialVersionUID = 7743244512351499265L; private UICheckBox largeModelCheckBox; @@ -119,7 +119,7 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane extendPlotIds = new HashSet<>(); + + static { + extendPlotIds.add(VanChartMapPlot.VAN_CHART_MAP_ID); + extendPlotIds.add(VanChartDrillMapPlot.VAN_CHART_DRILL_MAP_ID); + extendPlotIds.add(VanChartHeatMapPlot.VAN_CHART_HEAT_MAP_ID); + } + @Override protected String[] getTypeIconPath() { return new String[]{"/com/fr/van/chart/map/images/area-map.png", @@ -54,7 +67,7 @@ public class VanChartMapPlotPane extends AbstractVanChartTypePane { /** * 更新界面内容 */ - public void populateBean(Chart chart) { + public void populateBean(VanChart chart) { for (ChartImagePane imagePane : typeDemo) { imagePane.isPressing = false; } @@ -80,7 +93,7 @@ public class VanChartMapPlotPane extends AbstractVanChartTypePane { } } - public void updateBean(Chart chart) { + public void updateBean(VanChart chart) { super.updateBean(chart); Plot plot = chart.getPlot(); if (plot instanceof VanChartMapPlot) { @@ -154,4 +167,10 @@ public class VanChartMapPlotPane extends AbstractVanChartTypePane { protected boolean acceptDefinition(ChartDataDefinitionProvider definition, VanChartPlot vanChartPlot) { return definition instanceof MapChartDataDefinition; } + + //是否支持属性的继承 + @Override + protected boolean supportExtendAttr(VanChart chart) { + return extendPlotIds.contains(chart.getID()); + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/VanChartMultiPiePlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/VanChartMultiPiePlotPane.java index 555cca468d..7854ecd170 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/VanChartMultiPiePlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/VanChartMultiPiePlotPane.java @@ -55,10 +55,10 @@ public class VanChartMultiPiePlotPane extends AbstractVanChartTypePane { return MultiPieIndependentVanChart.MultilayerVanChartTypes[0]; } - protected void resetChartAttr(Chart chart, Plot newPlot) { + protected void resetChartAttr(VanChart chart, VanChartPlot newPlot) { super.resetChartAttr(chart, newPlot); //重置工具栏选项 - VanChartTools tools = ((VanChart) chart).getVanChartTools(); + VanChartTools tools = chart.getVanChartTools(); if (tools != null) { tools.setSort(false); tools.setFullScreen(false); diff --git a/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPiePlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPiePlotPane.java index 9bbddbb039..9e6e08a0ad 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPiePlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPiePlotPane.java @@ -5,9 +5,17 @@ import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.PiePlot4VanChart; +import com.fr.plugin.chart.area.VanChartAreaPlot; +import com.fr.plugin.chart.attr.plot.VanChartPlot; +import com.fr.plugin.chart.column.VanChartColumnPlot; +import com.fr.plugin.chart.line.VanChartLinePlot; import com.fr.plugin.chart.pie.PieIndependentVanChart; +import com.fr.plugin.chart.vanchart.VanChart; import com.fr.van.chart.designer.type.AbstractVanChartTypePane; +import java.util.HashSet; +import java.util.Set; + /** * 饼图(新特性) 属性表 选择类型 布局界面. */ @@ -15,6 +23,15 @@ public class VanChartPiePlotPane extends AbstractVanChartTypePane { private static final long serialVersionUID = 6163246902689597259L; + private static Set extendPlotIds = new HashSet<>(); + + static { + extendPlotIds.add(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID); + extendPlotIds.add(VanChartColumnPlot.VAN_CHART_BAR_PLOT_ID); + extendPlotIds.add(VanChartLinePlot.VAN_CHART_LINE_PLOT); + extendPlotIds.add(VanChartAreaPlot.VAN_CHART_AREA_PLOT_ID); + } + @Override protected String[] getTypeIconPath() { return new String[]{"/com/fr/van/chart/pie/images/pie.png", @@ -44,6 +61,25 @@ public class VanChartPiePlotPane extends AbstractVanChartTypePane { return cloned; } + @Override + protected VanChartPlot cloneOldPlot2New(VanChartPlot oldPlot, VanChartPlot newPlot) { + try { + PiePlot4VanChart piePlot4VanChart = (PiePlot4VanChart) newPlot; + PiePlot4VanChart clonePlot = (PiePlot4VanChart) oldPlot.clone(); + clonePlot.setRoseType(piePlot4VanChart.getRoseType()); + return clonePlot; + } catch (CloneNotSupportedException e) { + FineLoggerFactory.getLogger().error("Error in change plot"); + return newPlot; + } + } + + //是否支持属性的继承 + @Override + protected boolean supportExtendAttr(VanChart chart) { + return extendPlotIds.contains(chart.getID()); + } + public Chart getDefaultChart() { return PieIndependentVanChart.newPieChartTypes[0]; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterPlotPane.java index f93051a747..9ef5155a77 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterPlotPane.java @@ -10,13 +10,21 @@ import com.fr.chartx.data.ChartDataDefinitionProvider; import com.fr.chartx.data.field.AbstractColumnFieldCollection; import com.fr.chartx.data.field.diff.BubbleColumnFieldCollection; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.area.VanChartAreaPlot; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.VanChartAttrLine; import com.fr.plugin.chart.base.VanChartTools; +import com.fr.plugin.chart.bubble.VanChartBubblePlot; +import com.fr.plugin.chart.column.VanChartColumnPlot; +import com.fr.plugin.chart.line.VanChartLinePlot; import com.fr.plugin.chart.scatter.ScatterIndependentVanChart; import com.fr.plugin.chart.scatter.VanChartScatterPlot; +import com.fr.plugin.chart.vanchart.VanChart; import com.fr.van.chart.designer.type.AbstractVanChartTypePane; +import java.util.HashSet; +import java.util.Set; + /** * Created by Mitisky on 16/2/16. */ @@ -29,6 +37,16 @@ public class VanChartScatterPlotPane extends AbstractVanChartTypePane { }; } + private static Set extendPlotIds = new HashSet<>(); + + static { + extendPlotIds.add(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID); + extendPlotIds.add(VanChartColumnPlot.VAN_CHART_BAR_PLOT_ID); + extendPlotIds.add(VanChartLinePlot.VAN_CHART_LINE_PLOT); + extendPlotIds.add(VanChartAreaPlot.VAN_CHART_AREA_PLOT_ID); + extendPlotIds.add(VanChartBubblePlot.VAN_CHART_BUBBLE_PLOT_ID); + } + protected Plot getSelectedClonedPlot(){ VanChartScatterPlot newPlot = null; Chart[] scatterChart = ScatterIndependentVanChart.ScatterVanChartTypes; @@ -95,4 +113,10 @@ public class VanChartScatterPlotPane extends AbstractVanChartTypePane { } return false; } + + //是否支持属性的继承 + @Override + protected boolean supportExtendAttr(VanChart chart) { + return extendPlotIds.contains(chart.getID()); + } } \ No newline at end of file