From 2da7596a921cacb43880c1495ed8a8b8836de90a Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Thu, 5 Mar 2020 00:25:00 +0800 Subject: [PATCH] =?UTF-8?q?CHART-9435=20=E8=AF=95=E7=AE=A1=E5=9E=8B?= =?UTF-8?q?=E4=BB=AA=E8=A1=A8=E7=9B=98=E7=BA=B5=E5=90=91=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...hartGaugeCateOrPercentLabelDetailPane.java | 10 -- .../label/VanChartGaugeLabelDetailPane.java | 134 +++++++++++++++++- .../VanChartGaugeValueLabelDetailPane.java | 10 -- .../label/VanChartPlotLabelDetailPane.java | 26 ++-- 4 files changed, 146 insertions(+), 34 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java index 4199e8f7c..3b88a031a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java @@ -4,8 +4,6 @@ import com.fr.chart.chartattr.Plot; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.TableLayout; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; - -import com.fr.plugin.chart.gauge.VanChartGaugePlot; import com.fr.plugin.chart.type.GaugeStyle; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.label.LabelContentPaneWithCate; @@ -24,8 +22,6 @@ public class VanChartGaugeCateOrPercentLabelDetailPane extends VanChartGaugeLabe private static final long serialVersionUID = 5176535960949074945L; - private GaugeStyle gaugeStyle; - public VanChartGaugeCateOrPercentLabelDetailPane(Plot plot, VanChartStylePane parent) { super(plot, parent); } @@ -34,12 +30,6 @@ public class VanChartGaugeCateOrPercentLabelDetailPane extends VanChartGaugeLabe return hasLabelPosition(plot) ? new double[]{p,p,p} : new double[]{p,p}; } - private void initGaugeStyle(Plot plot) { - if(gaugeStyle == null){ - gaugeStyle = ((VanChartGaugePlot)plot).getGaugeStyle(); - } - } - protected void initToolTipContentPane(Plot plot) { initGaugeStyle(plot); switch (gaugeStyle){ 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 3cf057df5..e26b771be 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 @@ -1,14 +1,25 @@ package com.fr.van.chart.designer.style.label; +import com.fr.chart.base.ChartConstants; import com.fr.chart.chartattr.Plot; +import com.fr.chartx.TwoTuple; import com.fr.design.gui.ibutton.UIButtonGroup; +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.style.ChartTextAttrPane; - +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.GaugeStyle; +import com.fr.stable.Constants; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; import java.awt.Component; /** @@ -16,10 +27,21 @@ import java.awt.Component; */ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { + protected GaugeStyle gaugeStyle; + protected UIButtonGroup align; + private JPanel alignPane; + protected Integer[] oldAlignValues; + public VanChartGaugeLabelDetailPane(Plot plot, VanChartStylePane parent) { super(plot, parent); } + protected void initGaugeStyle(Plot plot) { + if (gaugeStyle == null) { + gaugeStyle = ((VanChartGaugePlot) plot).getGaugeStyle(); + } + } + protected JPanel createLabelStylePane(double[] row, double[] col, Plot plot) { style = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Automatic"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")}); @@ -30,16 +52,118 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { return TableLayoutHelper.createTableLayoutPane(getLabelStyleComponents(plot), row, col); } - - protected ChartTextAttrPane initTextFontPane () { + protected ChartTextAttrPane initTextFontPane() { return new ChartTextAttrPane(); } - protected JPanel getLabelPositionPane (Component[][] comps, double[] row, double[] col){ - return TableLayoutHelper.createTableLayoutPane(comps,row,col); + protected JPanel getLabelPositionPane(Component[][] comps, double[] row, double[] col) { + return TableLayoutHelper.createTableLayoutPane(comps, row, col); } protected JPanel createTableLayoutPaneWithTitle(String title, JPanel panel) { return TableLayout4VanChartHelper.createGapTableLayoutPane(title, panel); } + + protected Component[][] getLabelPaneComponents(Plot plot, double p, double[] columnSize) { + if (hasLabelAlign(plot)) { + + return new Component[][]{ + new Component[]{dataLabelContentPane, 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[]{createLabelStylePane(getLabelStyleRowSize(p), columnSize, plot), null}, + }; + } else { + return super.getLabelPaneComponents(plot, p, columnSize); + } + } + + private JPanel createLabelAlignPane(String title) { + JPanel panel = new JPanel(new BorderLayout()); + + alignPane = new JPanel(); + checkAlignPane(title); + panel.add(alignPane, BorderLayout.CENTER); + + return panel; + } + + protected void checkAlignPane(String title) { + if (alignPane == null && !hasLabelAlign(getPlot())) { + return; + } + if (alignPane != null && !hasLabelAlign(getPlot())) { + oldAlignValues = null; + alignPane.removeAll(); + return; + } + if (alignPane == null && hasLabelAlign(getPlot())) { + alignPane = new JPanel(); + } + TwoTuple result = getAlignNamesAndValues(); + + String[] names = result.getFirst(); + Integer[] values = result.getSecond(); + if (ComparatorUtils.equals(values, oldAlignValues)) { + return; + } + + oldAlignValues = 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}; + + 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 (parent != null) { + parent.initListener(alignPane); + } + } + + private TwoTuple getAlignNamesAndValues() { + String[] names = new String[]{Toolkit.i18nText("Fine-Design_Chart_Follow"), Toolkit.i18nText("Fine-Design_Chart_Align_Left"), Toolkit.i18nText("Fine-Design_Chart_Align_Right")}; + Integer[] values = new Integer[]{ChartConstants.AUTO_LABEL_POSITION, Constants.LEFT, Constants.RIGHT}; + + return new TwoTuple<>(names, values); + } + + protected void checkPane() { + String verticalTitle = hasLabelAlign(getPlot()) + ? Toolkit.i18nText("Fine-Design_Chart_Layout_Vertical") + : Toolkit.i18nText("Fine-Design_Chart_Layout_Position"); + + checkPositionPane(verticalTitle); + checkAlignPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Horizontal")); + } + + private boolean hasLabelAlign(Plot plot) { + return ComparatorUtils.equals(gaugeStyle, GaugeStyle.THERMOMETER) && !((VanChartGaugePlot) plot).getGaugeDetailStyle().isHorizontalLayout(); + } + + public void populate(AttrLabelDetail detail) { + super.populate(detail); + + if (hasLabelAlign(this.getPlot()) && align != null) { + align.setSelectedItem(detail.getAlign()); + } + } + + public void update(AttrLabelDetail detail) { + super.update(detail); + + if (align != null && align.getSelectedItem() != null) { + detail.setAlign(align.getSelectedItem()); + } else if (align != null) { + align.setSelectedItem(detail.getAlign()); + } + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeValueLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeValueLabelDetailPane.java index 1d6692555..3bb3a8a08 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeValueLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeValueLabelDetailPane.java @@ -1,8 +1,6 @@ package com.fr.van.chart.designer.style.label; import com.fr.chart.chartattr.Plot; -import com.fr.plugin.chart.gauge.VanChartGaugePlot; -import com.fr.plugin.chart.type.GaugeStyle; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.label.LabelContentPaneWithCateValue; import com.fr.van.chart.designer.component.label.LabelContentPaneWithOutCate; @@ -17,18 +15,10 @@ import java.awt.Component; public class VanChartGaugeValueLabelDetailPane extends VanChartGaugeLabelDetailPane { private static final long serialVersionUID = 2601073419430634281L; - private GaugeStyle gaugeStyle; - public VanChartGaugeValueLabelDetailPane(Plot plot, VanChartStylePane parent) { super(plot, parent); } - private void initGaugeStyle(Plot plot) { - if(gaugeStyle == null){ - gaugeStyle = ((VanChartGaugePlot)plot).getGaugeStyle(); - } - } - protected void initToolTipContentPane(Plot plot) { initGaugeStyle(plot); switch (gaugeStyle){ 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 b774de89e..fde315094 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 @@ -11,6 +11,7 @@ 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.style.color.ColorSelectBox; +import com.fr.design.i18n.Toolkit; import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.attr.plot.VanChartLabelPositionPlot; @@ -65,6 +66,10 @@ public class VanChartPlotLabelDetailPane extends BasicPane { this.add(contentPane,BorderLayout.CENTER); } + public Plot getPlot() { + return plot; + } + //默认从factory中取 protected void initToolTipContentPane(Plot plot) { dataLabelContentPane = PlotFactory.createPlotLabelContentPane(plot, parent, VanChartPlotLabelDetailPane.this); @@ -85,7 +90,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { if(hasLabelPosition(plot)){ return new Component[][]{ new Component[]{dataLabelContentPane,null}, - new Component[]{createLabelPositionPane(new double[]{p,p,p}, columnSize, plot),null}, + new Component[]{createLabelPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), plot), null}, new Component[]{createLabelStylePane(getLabelStyleRowSize(p), columnSize, plot),null}, }; } else { @@ -112,7 +117,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { return TableLayout4VanChartHelper.createExpandablePaneWithTitle(title, panel); } - private TwoTuple getPositionNamesAndValues() { + protected TwoTuple getPositionNamesAndValues() { if (plot instanceof VanChartLabelPositionPlot) { String[] names = ((VanChartLabelPositionPlot) plot).getLabelLocationNameArray(); @@ -130,7 +135,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { return null; } - private JPanel createLabelPositionPane(double[] row, double[] col, Plot plot) { + protected JPanel createLabelPositionPane(String title, Plot plot) { if (getPositionNamesAndValues() == null) { return new JPanel(); @@ -141,7 +146,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { JPanel panel = new JPanel(new BorderLayout()); positionPane = new JPanel(); - checkPositionPane(); + checkPositionPane(title); panel.add(positionPane, BorderLayout.CENTER); @@ -156,7 +161,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { return panel; } - private void checkPositionPane() { + protected void checkPositionPane(String title) { if (positionPane == null) { return; } @@ -176,7 +181,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { 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}; + comps[1] = new Component[]{new UILabel(title, SwingConstants.LEFT), position}; double[] row = new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}; double[] col = new double[]{TableLayout.FILL, TableLayout4VanChartHelper.EDIT_AREA_WIDTH}; @@ -277,9 +282,12 @@ public class VanChartPlotLabelDetailPane extends BasicPane { tractionLinePane.setVisible(position.getSelectedItem() == Constants.OUTSIDE); } - public void populate(AttrLabelDetail detail) { - checkPositionPane(); + protected void checkPane(){ + checkPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Position")); + } + public void populate(AttrLabelDetail detail) { + checkPane(); dataLabelContentPane.populateBean(detail.getContent()); if(position != null){ position.setSelectedItem(detail.getPosition()); @@ -306,7 +314,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { if(position != null && position.getSelectedItem() != null){ detail.setPosition(position.getSelectedItem()); - + } else if(position != null){ position.setSelectedItem(detail.getPosition()); }