Browse Source

增加子类来代替参数

feature/big-screen
Qinghui.Liu 4 years ago
parent
commit
e04882b2af
  1. 3
      designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java
  2. 121
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPane.java
  3. 113
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPaneWithGradientBar.java

3
designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java

@ -19,6 +19,7 @@ import com.fr.plugin.chart.column.VanChartColumnPlot;
import com.fr.stable.Constants;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.VanChartBeautyPane;
import com.fr.van.chart.designer.component.VanChartBeautyPaneWithGradientBar;
import com.fr.van.chart.designer.component.border.VanChartBorderPane;
import com.fr.van.chart.designer.component.border.VanChartBorderWithRadiusPane;
import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane;
@ -134,7 +135,7 @@ public class VanChartColumnSeriesPane extends VanChartAbstractPlotSeriesPane {
}
protected VanChartBeautyPane createStylePane() {
return new VanChartBeautyPane(true);
return new VanChartBeautyPaneWithGradientBar();
}
private void checkImagePane() {

121
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPane.java

@ -6,7 +6,6 @@ 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.style.background.gradient.FixedGradientBar;
import com.fr.plugin.chart.type.GradientType;
import com.fr.stable.StringUtils;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
@ -14,8 +13,6 @@ import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Created by Mitisky on 15/9/8.
@ -24,33 +21,20 @@ import java.awt.event.ActionListener;
public class VanChartBeautyPane extends BasicBeanPane<GradientStyle> {
private UIButtonGroup gradientTypeBox;
private FixedGradientBar colorGradient;
private JPanel gradientBarPane;
private boolean hasGradientBar;
public VanChartBeautyPane() {
this(false);
public UIButtonGroup getGradientTypeBox() {
return gradientTypeBox;
}
public VanChartBeautyPane(boolean hasGradientBar) {
this.hasGradientBar = hasGradientBar;
String[] typeNames = getNameArray();
public VanChartBeautyPane() {
this.setLayout(new BorderLayout());
if (hasGradientBar) {
this.add(initGradientTypePane(typeNames), BorderLayout.NORTH);
this.add(initGradientBarPane(), BorderLayout.CENTER);
initListener();
} else {
this.add(initGradientTypePane(typeNames), BorderLayout.CENTER);
}
this.add(initGradientTypePane(), BorderLayout.CENTER);
}
private JPanel initGradientTypePane(String[] names) {
private JPanel initGradientTypePane() {
String[] names = getNameArray();
gradientTypeBox = new UIButtonGroup(names);
double p = TableLayout.PREFERRED;
@ -66,48 +50,7 @@ public class VanChartBeautyPane extends BasicBeanPane<GradientStyle> {
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize);
}
private JPanel initGradientBarPane() {
colorGradient = new FixedGradientBar(4, 140);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double[] columnSize = {f, e};
double[] rowSize = {p, p};
Component[][] components = new Component[][]{
new Component[]{null, null},
new Component[]{null, colorGradient},
};
gradientBarPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize);
return gradientBarPane;
}
private void initListener() {
gradientTypeBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
checkGradientBarVisible();
}
});
}
private void checkGradientBarVisible() {
if (colorGradient != null && gradientBarPane != null) {
gradientBarPane.setVisible(gradientTypeBox.getSelectedIndex() == 1);
}
}
protected String[] getNameArray() {
if (this.hasGradientBar) {
return new String[]{
Toolkit.i18nText("Fine-Design_Chart_Auto"),
Toolkit.i18nText("Fine-Design_Chart_Custom"),
Toolkit.i18nText("Fine-Design_Chart_Off")
};
}
return new String[]{
Toolkit.i18nText("Fine-Design_Chart_On"),
Toolkit.i18nText("Fine-Design_Chart_Off")
@ -116,12 +59,6 @@ public class VanChartBeautyPane extends BasicBeanPane<GradientStyle> {
public void populateBean(GradientStyle gradientStyle) {
gradientTypeBox.setSelectedIndex(this.convertGradientTypeToIndex(gradientStyle.getGradientType()));
if (this.hasGradientBar && colorGradient != null) {
colorGradient.updateColor(gradientStyle.getStartColor(), gradientStyle.getEndColor());
}
checkGradientBarVisible();
}
@Override
@ -130,53 +67,17 @@ public class VanChartBeautyPane extends BasicBeanPane<GradientStyle> {
gradientStyle.setGradientType(this.convertIndexToGradientType(this.gradientTypeBox.getSelectedIndex()));
if (this.hasGradientBar && this.colorGradient != null && this.gradientBarPane != null) {
gradientStyle.setStartColor(colorGradient.getSelectColorPointBtnP1().getColorInner());
gradientStyle.setEndColor(colorGradient.getSelectColorPointBtnP2().getColorInner());
}
return gradientStyle;
}
private int convertGradientTypeToIndex(GradientType gradientType) {
if (this.hasGradientBar) {
switch (gradientType) {
case CUSTOM:
return 1;
case NONE:
return 2;
default:
return 0;
}
}
if (gradientType == GradientType.NONE) {
return 1;
protected int convertGradientTypeToIndex(GradientType gradientType) {
return gradientType == GradientType.NONE ? 1 : 0;
}
return 0;
}
private GradientType convertIndexToGradientType(int index) {
if (this.hasGradientBar) {
switch (index) {
case 1:
return GradientType.CUSTOM;
case 2:
return GradientType.NONE;
default:
return GradientType.AUTO;
}
protected GradientType convertIndexToGradientType(int index) {
return index == 1 ? GradientType.NONE : GradientType.AUTO;
}
if (index == 1) {
return GradientType.NONE;
}
return GradientType.AUTO;
}
@Override
protected String title4PopupWindow() {
return StringUtils.EMPTY;
}

113
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPaneWithGradientBar.java

@ -0,0 +1,113 @@
package com.fr.van.chart.designer.component;
import com.fr.chart.base.GradientStyle;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.style.background.gradient.FixedGradientBar;
import com.fr.plugin.chart.type.GradientType;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class VanChartBeautyPaneWithGradientBar extends VanChartBeautyPane {
private FixedGradientBar colorGradient;
private JPanel gradientBarPane;
public VanChartBeautyPaneWithGradientBar() {
super();
this.add(initGradientBarPane(), BorderLayout.SOUTH);
initListener();
}
private JPanel initGradientBarPane() {
colorGradient = new FixedGradientBar(4, 140);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double[] columnSize = {f, e};
double[] rowSize = {p, p};
Component[][] components = new Component[][]{
new Component[]{null, null},
new Component[]{null, colorGradient},
};
gradientBarPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize);
return gradientBarPane;
}
private void initListener() {
getGradientTypeBox().addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
checkGradientBarVisible();
}
});
}
private void checkGradientBarVisible() {
if (colorGradient != null && gradientBarPane != null) {
gradientBarPane.setVisible(getGradientTypeBox().getSelectedIndex() == 1);
}
}
protected String[] getNameArray() {
return new String[]{
Toolkit.i18nText("Fine-Design_Chart_Auto"),
Toolkit.i18nText("Fine-Design_Chart_Custom"),
Toolkit.i18nText("Fine-Design_Chart_Off")
};
}
public void populateBean(GradientStyle gradientStyle) {
super.populateBean(gradientStyle);
if (colorGradient != null) {
colorGradient.updateColor(gradientStyle.getStartColor(), gradientStyle.getEndColor());
}
checkGradientBarVisible();
}
@Override
public GradientStyle updateBean() {
GradientStyle gradientStyle = super.updateBean();
if (this.colorGradient != null && this.gradientBarPane != null) {
gradientStyle.setStartColor(colorGradient.getSelectColorPointBtnP1().getColorInner());
gradientStyle.setEndColor(colorGradient.getSelectColorPointBtnP2().getColorInner());
}
return gradientStyle;
}
protected int convertGradientTypeToIndex(GradientType gradientType) {
switch (gradientType) {
case CUSTOM:
return 1;
case NONE:
return 2;
default:
return 0;
}
}
protected GradientType convertIndexToGradientType(int index) {
switch (index) {
case 1:
return GradientType.CUSTOM;
case 2:
return GradientType.NONE;
default:
return GradientType.AUTO;
}
}
}
Loading…
Cancel
Save