From 5b952eb12466b5ce65a4be0118a9c3a5d713fce4 Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Tue, 22 Sep 2020 15:22:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=87=E7=AD=BE=E5=A2=9E=E5=8A=A0=E8=BE=B9?= =?UTF-8?q?=E6=A1=86=E5=92=8C=E8=83=8C=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/van/chart/designer/PlotFactory.java | 18 +++++- .../label/VanChartPlotLabelDetailPane.java | 61 +++++++++++++++++-- 2 files changed, 73 insertions(+), 6 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java b/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java index b518b1ec86..9ea26a5c5b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java @@ -7,6 +7,7 @@ import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.gui.style.FormatPane; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.PiePlot4VanChart; import com.fr.plugin.chart.area.VanChartAreaPlot; import com.fr.plugin.chart.bubble.VanChartBubblePlot; import com.fr.plugin.chart.column.VanChartColumnPlot; @@ -77,7 +78,7 @@ import java.util.Set; */ public class PlotFactory { - private static Set> autoAdjustLabelPlots = new HashSet>(); + private static Set> autoAdjustLabelPlots = new HashSet<>(); static { autoAdjustLabelPlots.add(VanChartColumnPlot.class); @@ -90,10 +91,23 @@ public class PlotFactory { return autoAdjustLabelPlots.contains(plot.getClass()); } + private static Set> borderAndBackgroundLabelPlots = new HashSet<>(); + + static { + borderAndBackgroundLabelPlots.add(PiePlot4VanChart.class); + borderAndBackgroundLabelPlots.add(VanChartColumnPlot.class); + borderAndBackgroundLabelPlots.add(VanChartLinePlot.class); + borderAndBackgroundLabelPlots.add(VanChartAreaPlot.class); + } + + public static boolean hasBorderAndBackgroundPlotLabel(Plot plot) { + return borderAndBackgroundLabelPlots.contains(plot.getClass()); + } + /** * 标签Map */ - private static Map, Class> labelMap = new HashMap, Class>(); + private static Map, Class> labelMap = new HashMap<>(); static { labelMap.put(VanChartColumnPlot.class, VanChartColumnPlotLabelPane.class); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java index 253a6f8322..b159af7558 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java @@ -20,6 +20,8 @@ import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.stable.Constants; import com.fr.van.chart.designer.PlotFactory; import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.designer.component.background.VanChartBackgroundWithOutImagePane; +import com.fr.van.chart.designer.component.border.VanChartBorderWithRadiusPane; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -43,6 +45,8 @@ public class VanChartPlotLabelDetailPane extends BasicPane { private UIToggleButton tractionLine; private ColorSelectBox backgroundColor; + private VanChartBorderWithRadiusPane borderPane; + private VanChartBackgroundWithOutImagePane backgroundPane; private JPanel tractionLinePane; private JPanel positionPane; @@ -98,15 +102,48 @@ public class VanChartPlotLabelDetailPane extends BasicPane { protected Component[][] getLabelPaneComponents(Plot plot, double p, double[] columnSize) { if(hasLabelPosition(plot)){ + + // 仅饼图、柱形图、条形图、折线图、面积图含有边框和背景 + if (hasBorderAndBackground(plot)) { + return new Component[][]{ + new Component[]{dataLabelContentPane,null}, + new Component[]{createLabelPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), plot), null}, + new Component[]{createLabelBorderPane(), null}, + new Component[]{createLabelBackgroundPane(), null} + }; + } + return new Component[][]{ new Component[]{dataLabelContentPane,null}, new Component[]{createLabelPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), plot), null} }; - } else { - return new Component[][]{ - new Component[]{dataLabelContentPane,null} - }; } + + return new Component[][]{ + new Component[]{dataLabelContentPane,null} + }; + } + + private JPanel createLabelBorderPane() { + borderPane = new VanChartBorderWithRadiusPane(); + + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane); + } + + private JPanel createLabelBackgroundPane() { + backgroundPane = new VanChartBackgroundWithOutImagePane(){ + + protected Component[][] getPaneComponents() { + return new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Fill")), typeComboBox}, + new Component[]{null, centerPane}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Alpha")), transparent}, + }; + } + }; + + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane); } protected double[] getLabelStyleRowSize(double p) { @@ -121,6 +158,10 @@ public class VanChartPlotLabelDetailPane extends BasicPane { return plot instanceof VanChartLabelPositionPlot; } + private boolean hasBorderAndBackground(Plot plot) { + return PlotFactory.hasBorderAndBackgroundPlotLabel(plot); + } + protected JPanel createTableLayoutPaneWithTitle(String title, JPanel panel) { return TableLayout4VanChartHelper.createExpandablePaneWithTitle(title, panel); } @@ -296,6 +337,12 @@ public class VanChartPlotLabelDetailPane extends BasicPane { if(backgroundColor != null){ backgroundColor.setSelectObject(detail.getBackgroundColor()); } + if(borderPane != null){ + borderPane.populate(detail.getGeneralInfo()); + } + if(backgroundPane != null){ + backgroundPane.populate(detail.getGeneralInfo()); + } checkAllUse(); } @@ -322,6 +369,12 @@ public class VanChartPlotLabelDetailPane extends BasicPane { if(backgroundColor != null){ detail.setBackgroundColor(backgroundColor.getSelectObject()); } + if(borderPane != null){ + borderPane.update(detail.getGeneralInfo()); + } + if(backgroundPane != null){ + backgroundPane.update(detail.getGeneralInfo()); + } } }