From 4b95b5c5b98845ecf9eaa4ca3721ecfa3a872c96 Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Mon, 15 Jun 2020 15:59:41 +0800 Subject: [PATCH] =?UTF-8?q?CHART-14228=20=E5=90=91=E4=B8=8B=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E7=BD=91=E6=A0=BC=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../background/VanChartAxisAreaPane.java | 58 +++++++++++++++++-- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAxisAreaPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAxisAreaPane.java index b781d0bb6..b7488cf3d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAxisAreaPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAxisAreaPane.java @@ -20,6 +20,7 @@ import javax.swing.BorderFactory; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.CardLayout; +import java.awt.Color; import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -48,10 +49,29 @@ public class VanChartAxisAreaPane extends BasicBeanPane { private JPanel horizontalColorPane; private JPanel verticalColorPane; + private Color horizontalColor; + private Color verticalColor; + public VanChartAxisAreaPane() { initComponents(); } + public Color getHorizontalColor() { + return horizontalColor; + } + + public void setHorizontalColor(Color horizontalColor) { + this.horizontalColor = horizontalColor; + } + + public Color getVerticalColor() { + return verticalColor; + } + + public void setVerticalColor(Color verticalColor) { + this.verticalColor = verticalColor; + } + private void initComponents() { horizontalColorBox = new ColorSelectBox(PREFERRED_WIDTH); verticalColorBox = new ColorSelectBox(PREFERRED_WIDTH); @@ -252,14 +272,44 @@ public class VanChartAxisAreaPane extends BasicBeanPane { VanChartAxis defaultXAxis = rectanglePlot.getDefaultXAxis(); VanChartAxis defaultYAxis = rectanglePlot.getDefaultYAxis(); + // CHART-14241 10.0.6向下兼容10.0.5的设计器,分三种情况: + // 1、选中线型为无时,设置颜色为null + // 2、选中线型不为空,但是上次选中的线型为空时,使用上次保存下的color + // 3、选中前后均不为空时,正常set即可 if (defaultXAxis != null) { - defaultXAxis.setMainGridColor(verticalColorBox.getSelectObject()); - defaultXAxis.setGridLineType((LineType) verticalLineType.getSelectedItem()); + LineType selectVerticalType = (LineType) this.verticalLineType.getSelectedItem(); + Color selectVerticalColor = verticalColorBox.getSelectObject(); + + setVerticalColor(selectVerticalColor); + + if (selectVerticalType == LineType.NONE) { + defaultXAxis.setMainGridColor(null); + defaultXAxis.setGridLineType(LineType.NONE); + } else if (defaultXAxis.getGridLineType() == LineType.NONE) { + defaultXAxis.setMainGridColor(getVerticalColor()); + defaultXAxis.setGridLineType(selectVerticalType); + } else { + defaultXAxis.setMainGridColor(selectVerticalColor); + defaultXAxis.setGridLineType(selectVerticalType); + } } if (defaultYAxis != null) { - defaultYAxis.setMainGridColor(horizontalColorBox.getSelectObject()); - defaultYAxis.setGridLineType((LineType) horizonLineType.getSelectedItem()); + LineType selectHorizontalType = (LineType) this.horizonLineType.getSelectedItem(); + Color selectHorizontalColor = horizontalColorBox.getSelectObject(); + + setHorizontalColor(selectHorizontalColor); + + if (selectHorizontalType == LineType.NONE) { + defaultYAxis.setMainGridColor(null); + defaultYAxis.setGridLineType(LineType.NONE); + } else if (defaultYAxis.getGridLineType() == LineType.NONE) { + defaultYAxis.setMainGridColor(getHorizontalColor()); + defaultYAxis.setGridLineType(selectHorizontalType); + } else { + defaultYAxis.setMainGridColor(selectHorizontalColor); + defaultYAxis.setGridLineType(selectHorizontalType); + } } }