Browse Source

CHART-13740 雷达图网格线支持线型选择

feature/big-screen
Qinghui.Liu 5 years ago
parent
commit
1617aadc14
  1. 63
      designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAxisAreaPane.java
  2. 21
      designer-chart/src/main/java/com/fr/van/chart/designer/style/background/radar/VanChartRadarAxisAreaPane.java

63
designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAxisAreaPane.java

@ -32,9 +32,6 @@ public class VanChartAxisAreaPane extends BasicBeanPane<Plot> {
private static final int PREFERRED_WIDTH = 100; private static final int PREFERRED_WIDTH = 100;
protected ColorSelectBox horizontalGridLine;
protected ColorSelectBox verticalGridLine;
protected AlertLineListControlPane alertLine; protected AlertLineListControlPane alertLine;
private UIButtonGroup isDefaultIntervalBackground; private UIButtonGroup isDefaultIntervalBackground;
@ -44,8 +41,10 @@ public class VanChartAxisAreaPane extends BasicBeanPane<Plot> {
private ColorSelectBox verticalColorBackground; private ColorSelectBox verticalColorBackground;
protected BackgroundListControlPane customIntervalBackground; protected BackgroundListControlPane customIntervalBackground;
private LineTypeComboBox horizonLineType;//横向线型 private LineTypeComboBox horizonLineType;
private LineTypeComboBox verticalLineType;//纵向线型 private LineTypeComboBox verticalLineType;
private ColorSelectBox horizontalColorBox;
private ColorSelectBox verticalColorBox;
private JPanel horizontalColorPane; private JPanel horizontalColorPane;
private JPanel verticalColorPane; private JPanel verticalColorPane;
@ -53,9 +52,9 @@ public class VanChartAxisAreaPane extends BasicBeanPane<Plot> {
initComponents(); initComponents();
} }
protected void initComponents() { private void initComponents() {
horizontalGridLine = new ColorSelectBox(PREFERRED_WIDTH); horizontalColorBox = new ColorSelectBox(PREFERRED_WIDTH);
verticalGridLine = new ColorSelectBox(PREFERRED_WIDTH); verticalColorBox = new ColorSelectBox(PREFERRED_WIDTH);
horizonLineType = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.SOLID, LineType.DASHED}); horizonLineType = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.SOLID, LineType.DASHED});
verticalLineType = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.SOLID, LineType.DASHED}); verticalLineType = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.SOLID, LineType.DASHED});
@ -77,23 +76,33 @@ public class VanChartAxisAreaPane extends BasicBeanPane<Plot> {
} }
protected JPanel createGridLinePane() { protected JPanel createGridLinePane() {
initGridLineComponents();
JPanel panel = new JPanel(new BorderLayout(0, 4));
panel.add(createSingleGridLinePane(Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal"), true), BorderLayout.NORTH);
panel.add(createSingleGridLinePane(Toolkit.i18nText("Fine-Design_Chart_Direction_Vertical"), false), BorderLayout.CENTER);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Grid_Line"), panel);
}
protected void initGridLineComponents() {
Component[][] upComponent = new Component[][]{ Component[][] upComponent = new Component[][]{
new Component[]{null, null}, new Component[]{null, null},
new Component[]{null, horizontalGridLine} new Component[]{null, horizontalColorBox}
}; };
horizontalColorPane = TableLayout4VanChartHelper.createGapTableLayoutPane(upComponent); horizontalColorPane = TableLayout4VanChartHelper.createGapTableLayoutPane(upComponent);
Component[][] downComponent = new Component[][]{ Component[][] downComponent = new Component[][]{
new Component[]{null, null}, new Component[]{null, null},
new Component[]{null, verticalGridLine} new Component[]{null, verticalColorBox}
}; };
verticalColorPane = TableLayout4VanChartHelper.createGapTableLayoutPane(downComponent); verticalColorPane = TableLayout4VanChartHelper.createGapTableLayoutPane(downComponent);
horizonLineType.addActionListener(new ActionListener() { horizonLineType.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (horizontalGridLine == null || horizonLineType == null) { if (horizontalColorBox == null || horizonLineType == null) {
return; return;
} }
horizontalColorPane.setVisible(horizonLineType.getSelectedItem() != LineType.NONE); horizontalColorPane.setVisible(horizonLineType.getSelectedItem() != LineType.NONE);
@ -103,7 +112,7 @@ public class VanChartAxisAreaPane extends BasicBeanPane<Plot> {
verticalLineType.addActionListener(new ActionListener() { verticalLineType.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (verticalGridLine == null || verticalLineType == null) { if (verticalColorBox == null || verticalLineType == null) {
return; return;
} }
verticalColorPane.setVisible(verticalLineType.getSelectedItem() != LineType.NONE); verticalColorPane.setVisible(verticalLineType.getSelectedItem() != LineType.NONE);
@ -111,22 +120,20 @@ public class VanChartAxisAreaPane extends BasicBeanPane<Plot> {
}); });
checkColorBoxVisible(); checkColorBoxVisible();
}
JPanel horizonLineTypePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal"), horizonLineType); protected JPanel createSingleGridLinePane(String title, boolean isHorizontal) {
JPanel horizontal = new JPanel(new BorderLayout()); LineTypeComboBox lineTypeComboBox = isHorizontal ? horizonLineType : verticalLineType;
horizontal.add(horizonLineTypePane, BorderLayout.NORTH); JPanel colorSelectPane = isHorizontal ? horizontalColorPane : verticalColorPane;
horizontal.add(horizontalColorPane, BorderLayout.CENTER);
JPanel verticalLineTypePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Direction_Vertical"), verticalLineType); JPanel lineTypePane = TableLayout4VanChartHelper.createGapTableLayoutPane(title, lineTypeComboBox);
JPanel vertical = new JPanel(new BorderLayout());
vertical.add(verticalLineTypePane, BorderLayout.NORTH);
vertical.add(verticalColorPane, BorderLayout.CENTER);
JPanel panel = new JPanel(new BorderLayout(0, 4)); JPanel horizontalGridLinePane = new JPanel(new BorderLayout());
panel.add(horizontal, BorderLayout.NORTH);
panel.add(vertical, BorderLayout.CENTER);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Grid_Line"), panel); horizontalGridLinePane.add(lineTypePane, BorderLayout.NORTH);
horizontalGridLinePane.add(colorSelectPane, BorderLayout.CENTER);
return horizontalGridLinePane;
} }
protected JPanel createAlertLinePane() { protected JPanel createAlertLinePane() {
@ -213,12 +220,12 @@ public class VanChartAxisAreaPane extends BasicBeanPane<Plot> {
VanChartAxis defaultYAxis = rectanglePlot.getDefaultYAxis(); VanChartAxis defaultYAxis = rectanglePlot.getDefaultYAxis();
if (defaultXAxis != null) { if (defaultXAxis != null) {
verticalGridLine.setSelectObject(defaultXAxis.getMainGridColor()); verticalColorBox.setSelectObject(defaultXAxis.getMainGridColor());
verticalLineType.setSelectedItem(defaultXAxis.getGridLineType()); verticalLineType.setSelectedItem(defaultXAxis.getGridLineType());
} }
if (defaultYAxis != null) { if (defaultYAxis != null) {
horizontalGridLine.setSelectObject(defaultYAxis.getMainGridColor()); horizontalColorBox.setSelectObject(defaultYAxis.getMainGridColor());
horizonLineType.setSelectedItem(defaultYAxis.getGridLineType()); horizonLineType.setSelectedItem(defaultYAxis.getGridLineType());
} }
} }
@ -246,12 +253,12 @@ public class VanChartAxisAreaPane extends BasicBeanPane<Plot> {
VanChartAxis defaultYAxis = rectanglePlot.getDefaultYAxis(); VanChartAxis defaultYAxis = rectanglePlot.getDefaultYAxis();
if (defaultXAxis != null) { if (defaultXAxis != null) {
defaultXAxis.setMainGridColor(verticalGridLine.getSelectObject()); defaultXAxis.setMainGridColor(verticalColorBox.getSelectObject());
defaultXAxis.setGridLineType((LineType) verticalLineType.getSelectedItem()); defaultXAxis.setGridLineType((LineType) verticalLineType.getSelectedItem());
} }
if (defaultYAxis != null) { if (defaultYAxis != null) {
defaultYAxis.setMainGridColor(horizontalGridLine.getSelectObject()); defaultYAxis.setMainGridColor(horizontalColorBox.getSelectObject());
defaultYAxis.setGridLineType((LineType) horizonLineType.getSelectedItem()); defaultYAxis.setGridLineType((LineType) horizonLineType.getSelectedItem());
} }
} }

21
designer-chart/src/main/java/com/fr/van/chart/designer/style/background/radar/VanChartRadarAxisAreaPane.java

@ -3,15 +3,14 @@ package com.fr.van.chart.designer.style.background.radar;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.style.background.AlertLineListControlPane; import com.fr.van.chart.designer.style.background.AlertLineListControlPane;
import com.fr.van.chart.designer.style.background.BackgroundListControlPane; import com.fr.van.chart.designer.style.background.BackgroundListControlPane;
import com.fr.van.chart.designer.style.background.VanChartAxisAreaPane; import com.fr.van.chart.designer.style.background.VanChartAxisAreaPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.util.Arrays;
/** /**
* 样式-背景-绘图区背景-雷达图只有Y轴的配置间隔背景网格线警戒线 * 样式-背景-绘图区背景-雷达图只有Y轴的配置间隔背景网格线警戒线
@ -23,24 +22,18 @@ public class VanChartRadarAxisAreaPane extends VanChartAxisAreaPane {
//雷达图只有横向的y轴的网格线配置 //雷达图只有横向的y轴的网格线配置
@Override @Override
protected JPanel createGridLinePane() { protected JPanel createGridLinePane() {
initGridLineComponents();
JPanel panel = new JPanel(new BorderLayout(0, 4));
panel.add(createSingleGridLinePane(Toolkit.i18nText("Fine-Design_Chart_Grid_Line"), true), BorderLayout.CENTER);
Component[][] components = new Component[][]{
new Component[]{null,null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")),horizontalGridLine},
};
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double[] row = new double[components.length];
Arrays.fill(row, p);
double[] col = {f, e};
JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Grid_Line"), panel); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Grid_Line"), panel);
} }
protected Component[][] getIntervalPaneComponents() { protected Component[][] getIntervalPaneComponents() {
return new Component[][]{ return new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")),horizontalColorBackground}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), horizontalColorBackground},
}; };
} }

Loading…
Cancel
Save