From d683e6aa5c297746d6b08a26466eda2bad90043d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Thu, 1 Apr 2021 17:01:55 +0800 Subject: [PATCH] =?UTF-8?q?CHART-18720=20=20=E8=AF=95=E7=AE=A1=E5=9E=8B?= =?UTF-8?q?=E4=BB=AA=E8=A1=A8=E7=9B=98=E7=94=A8=E6=A8=AA=E5=90=91=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=88=9D=E5=A7=8B=E6=A0=87=E7=AD=BE=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E6=9C=89=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../label/VanChartGaugeLabelDetailPane.java | 64 ++++++++----------- 1 file changed, 26 insertions(+), 38 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java index 86d140f1d..8c672bab6 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java @@ -10,7 +10,6 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithAuto; -import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.base.AttrLabelDetail; import com.fr.plugin.chart.gauge.VanChartGaugePlot; import com.fr.plugin.chart.type.FontAutoType; @@ -50,7 +49,7 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { } public GaugeStyle getGaugeStyle() { - return ((VanChartGaugePlot)this.getPlot()).getGaugeStyle(); + return ((VanChartGaugePlot) this.getPlot()).getGaugeStyle(); } public void setGaugeStyle(GaugeStyle gaugeStyle) { @@ -127,15 +126,13 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { protected Component[][] getLabelPaneComponents(Plot plot, double p, double[] columnSize) { if (hasLabelAlignPane()) { - return new Component[][]{ new Component[]{getDataLabelContentPane(), null}, - new Component[]{createLabelPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Vertical"), plot), null}, - new Component[]{createLabelAlignPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Horizontal")), null}, + new Component[]{createLabelPositionPane(getVerticalTitle(), plot), null}, + new Component[]{createLabelAlignPane(), null}, new Component[]{createLabelStylePane(getLabelStyleRowSize(p), columnSize, plot), null}, }; } else { - return new Component[][]{ new Component[]{getDataLabelContentPane(), null}, new Component[]{createLabelStylePane(getLabelStyleRowSize(p), columnSize, plot), null}, @@ -143,50 +140,37 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { } } - private JPanel createLabelAlignPane(String title) { - JPanel panel = new JPanel(new BorderLayout()); - - alignPane = new JPanel(); - checkAlignPane(title); - panel.add(alignPane, BorderLayout.CENTER); - - return panel; + private JPanel createLabelAlignPane() { + alignPane = new JPanel(new BorderLayout()); + checkAlignPane(); + return alignPane; } - protected void checkAlignPane(String title) { - if (alignPane == null && !hasLabelAlign(getPlot())) { + protected void checkAlignPane() { + if (!hasLabelAlignPane()) { return; } - if (alignPane != null && !hasLabelAlign(getPlot())) { - oldAlignValues = null; + if (!hasLabelAlign()) { alignPane.removeAll(); return; } - if (alignPane == null && hasLabelAlign(getPlot())) { - alignPane = new JPanel(); + + if (alignPane.getComponents().length > 0) { + return; } TwoTuple result = getAlignNamesAndValues(); - String[] names = result.getFirst(); Integer[] values = result.getSecond(); - if (ComparatorUtils.equals(values, oldAlignValues)) { - return; - } - - oldAlignValues = values; - - align = new UIButtonGroup(names, values); + align = new UIButtonGroup<>(names, values); Component[][] comps = new Component[2][2]; comps[0] = new Component[]{null, null}; - comps[1] = new Component[]{new UILabel(title, SwingConstants.LEFT), align}; + comps[1] = new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Layout_Horizontal"), SwingConstants.LEFT), align}; double[] row = new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}; double[] col = new double[]{TableLayout.FILL, TableLayout4VanChartHelper.EDIT_AREA_WIDTH}; - alignPane.removeAll(); - alignPane.setLayout(new BorderLayout()); alignPane.add(getLabelPositionPane(comps, row, col), BorderLayout.CENTER); if (getParentPane() != null) { @@ -214,12 +198,16 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { } protected void checkPane() { - String verticalTitle = hasLabelAlign(getPlot()) - ? Toolkit.i18nText("Fine-Design_Chart_Layout_Vertical") - : Toolkit.i18nText("Fine-Design_Chart_Layout_Position"); + String verticalTitle = getVerticalTitle(); checkPositionPane(verticalTitle); - checkAlignPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Horizontal")); + checkAlignPane(); + } + + private String getVerticalTitle() { + return hasLabelAlign() + ? Toolkit.i18nText("Fine-Design_Chart_Layout_Vertical") + : Toolkit.i18nText("Fine-Design_Chart_Layout_Position"); } protected void checkStyleUse() { @@ -227,8 +215,8 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { textFontPane.setPreferredSize(new Dimension(0, TEXT_FONT_PANE_HEIGHT)); } - protected boolean hasLabelAlign(Plot plot) { - return getGaugeStyle() == GaugeStyle.THERMOMETER && !((VanChartGaugePlot) plot).getGaugeDetailStyle().isHorizontalLayout(); + protected boolean hasLabelAlign() { + return getGaugeStyle() == GaugeStyle.THERMOMETER && !((VanChartGaugePlot) getPlot()).getGaugeDetailStyle().isHorizontalLayout(); } protected boolean hasLabelAlignPane() { @@ -240,7 +228,7 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { style.setSelectedIndex(1); textFontPane.populate(detail.getTextAttr()); - if (hasLabelAlign(this.getPlot()) && align != null) { + if (hasLabelAlign() && align != null) { align.setSelectedItem(detail.getAlign()); }