From 72a50125dbbf8d34c081e5f6de351e3fb3c8c667 Mon Sep 17 00:00:00 2001 From: shine Date: Fri, 29 Nov 2019 13:06:45 +0800 Subject: [PATCH] =?UTF-8?q?CHART-11634=20=E8=AF=95=E7=AE=A1=E4=BB=AA?= =?UTF-8?q?=E8=A1=A8=E7=9B=98=E4=BB=8E=E6=A8=AA=E5=90=91=E5=8F=98=E6=88=90?= =?UTF-8?q?=E7=BA=B5=E5=90=91=20=E6=A0=87=E7=AD=BE=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E5=BA=94=E8=AF=A5=E4=BB=8E=E4=B8=8A=E4=B8=8B=E5=8F=98=E6=88=90?= =?UTF-8?q?=E5=B7=A6=E5=8F=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/frpane/AbstractAttrNoScrollPane.java | 2 +- .../label/VanChartPlotLabelDetailPane.java | 95 ++++++++++++++----- 2 files changed, 72 insertions(+), 25 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java index 1366b46b3c..6af1194265 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java @@ -65,7 +65,7 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane { } - protected void initListener(Container parentComponent) { + public void initListener(Container parentComponent) { for (int i = 0; i < parentComponent.getComponentCount(); i++) { Component tmpComp = parentComponent.getComponent(i); 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 012c410a89..5168f443e7 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 @@ -1,6 +1,7 @@ package com.fr.van.chart.designer.style.label; import com.fr.chart.chartattr.Plot; +import com.fr.chartx.TwoTuple; import com.fr.design.beans.BasicBeanPane; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButtonGroup; @@ -11,6 +12,7 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.design.style.color.ColorSelectBox; +import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.attr.plot.VanChartLabelPositionPlot; import com.fr.plugin.chart.base.AttrLabelDetail; import com.fr.plugin.chart.base.AttrTooltipContent; @@ -47,11 +49,16 @@ public class VanChartPlotLabelDetailPane extends BasicPane { protected ColorSelectBox backgroundColor; private JPanel tractionLinePane; + private JPanel positionPane; + private Integer[] oldPositionValues; protected VanChartStylePane parent; + private Plot plot; public VanChartPlotLabelDetailPane(Plot plot, VanChartStylePane parent) { this.parent = parent; + this.plot = plot; + this.setLayout(new BorderLayout()); initToolTipContentPane(plot); JPanel contentPane = createLabelPane(plot); @@ -105,42 +112,80 @@ public class VanChartPlotLabelDetailPane extends BasicPane { return TableLayout4VanChartHelper.createExpandablePaneWithTitle(title, panel); } - protected JPanel createLabelPositionPane(double[] row, double[] col, Plot plot) { - if(plot instanceof VanChartLabelPositionPlot){ + private TwoTuple getPositionNamesAndValues() { + if (plot instanceof VanChartLabelPositionPlot) { + String[] names = ((VanChartLabelPositionPlot) plot).getLabelLocationNameArray(); - Integer[] values = ((VanChartLabelPositionPlot) plot).getLabelLocationValueArray(); + Integer[] values = ((VanChartLabelPositionPlot) plot).getLabelLocationValueArray(); - if(names == null || names.length == 0){ - return new JPanel(); + if (names == null || names.length == 0) { + return null; } - if(values == null || values.length == 0){ - return new JPanel(); + if (values == null || values.length == 0) { + return null; } - position = new UIButtonGroup(names, values); - autoAdjust = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_On"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Off")}, new Boolean[]{true, false}); + return new TwoTuple<>(names, values); + } + return null; + } + private JPanel createLabelPositionPane(double[] row, double[] col, Plot plot) { - Component[][] comps = new Component[2][2]; + if (getPositionNamesAndValues() == null) { + return new JPanel(); + } - comps[0] = new Component[]{null,null}; - comps[1] = new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), SwingConstants.LEFT), position}; + autoAdjust = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_On"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Off")}, new Boolean[]{true, false}); - JPanel panel =new JPanel(new BorderLayout()); - panel.add(getLabelPositionPane(comps,row,col),BorderLayout.CENTER); - if(plot.isSupportLeadLine()){ - tractionLine = new UIToggleButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Show_Guideline")); - tractionLinePane = TableLayout4VanChartHelper.createGapTableLayoutPane("",tractionLine); - panel.add(tractionLinePane, BorderLayout.SOUTH); - initPositionListener(); - } else if(PlotFactory.plotAutoAdjustLabelPosition(plot)){ - panel.add(TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Auto_Adjust"),autoAdjust), BorderLayout.SOUTH); - } - return panel; + JPanel panel = new JPanel(new BorderLayout()); + + positionPane = new JPanel(); + checkPositionPane(); + panel.add(positionPane, BorderLayout.CENTER); + + + if (plot.isSupportLeadLine()) { + tractionLine = new UIToggleButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Show_Guideline")); + tractionLinePane = TableLayout4VanChartHelper.createGapTableLayoutPane("", tractionLine); + panel.add(tractionLinePane, BorderLayout.SOUTH); + initPositionListener(); + } else if (PlotFactory.plotAutoAdjustLabelPosition(plot)) { + panel.add(TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Auto_Adjust"), autoAdjust), BorderLayout.SOUTH); } - return new JPanel(); + return panel; } + private void checkPositionPane() { + TwoTuple result = getPositionNamesAndValues(); + if (result == null) { + return; + } + + Integer[] values = result.getSecond(); + if (ComparatorUtils.equals(values, oldPositionValues)) { + return; + } + oldPositionValues = values; + + position = new UIButtonGroup(result.getFirst(), values); + + Component[][] comps = new Component[2][2]; + + comps[0] = new Component[]{null, null}; + comps[1] = new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), SwingConstants.LEFT), position}; + + double[] row = new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}; + double[] col = new double[]{TableLayout.FILL, TableLayout4VanChartHelper.EDIT_AREA_WIDTH}; + + positionPane.removeAll(); + positionPane.setLayout(new BorderLayout()); + positionPane.add(getLabelPositionPane(comps, row, col), BorderLayout.CENTER); + + parent.initListener(positionPane); + } + + protected JPanel getLabelPositionPane (Component[][] comps, double[] row, double[] col){ JPanel panel = TableLayoutHelper.createTableLayoutPane(comps,row,col); return createTableLayoutPaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout"), panel); @@ -228,6 +273,8 @@ public class VanChartPlotLabelDetailPane extends BasicPane { } public void populate(AttrLabelDetail detail) { + checkPositionPane(); + dataLabelContentPane.populateBean(detail.getContent()); if(position != null){ position.setSelectedItem(detail.getPosition());