Browse Source

Pull request #1741: CHART-14182 修改渐变风格面板和条件属性面板

Merge in DESIGN/design from ~QINGHUI.LIU/design:release/10.0 to release/10.0

* commit 'e04882b2afd82eebc7aea1b82f6ffdad3d4e777e':
  增加子类来代替参数
  更换空字符、跟新行尺寸
  CHART-14182 修改渐变风格面板和条件属性面板
feature/big-screen
Qinghui.Liu 5 years ago
parent
commit
f91373eda7
  1. 4
      designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnConditionPane.java
  2. 21
      designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java
  3. 27
      designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomSeriesPane.java
  4. 71
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPane.java
  5. 113
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPaneWithGradientBar.java
  6. 150
      designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartColumnSeriesColorConditionPane.java
  7. 6
      designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java

4
designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnConditionPane.java

@ -17,11 +17,11 @@ import com.fr.plugin.chart.base.AttrTooltip;
import com.fr.plugin.chart.base.VanChartAttrTrendLine; import com.fr.plugin.chart.base.VanChartAttrTrendLine;
import com.fr.plugin.chart.column.VanChartColumnPlot; import com.fr.plugin.chart.column.VanChartColumnPlot;
import com.fr.plugin.chart.type.ConditionKeyType; import com.fr.plugin.chart.type.ConditionKeyType;
import com.fr.van.chart.designer.other.condition.item.VanChartColumnSeriesColorConditionPane;
import com.fr.van.chart.designer.other.condition.item.VanChartDataSheetContentPane; import com.fr.van.chart.designer.other.condition.item.VanChartDataSheetContentPane;
import com.fr.van.chart.designer.other.condition.item.VanChartEffectConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartEffectConditionPane;
import com.fr.van.chart.designer.other.condition.item.VanChartFloatColorConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartFloatColorConditionPane;
import com.fr.van.chart.designer.other.condition.item.VanChartLabelConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartLabelConditionPane;
import com.fr.van.chart.designer.other.condition.item.VanChartSeriesColorConditionPane;
import com.fr.van.chart.designer.other.condition.item.VanChartSeriesImageBackgroundConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartSeriesImageBackgroundConditionPane;
import com.fr.van.chart.designer.other.condition.item.VanChartTooltipConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartTooltipConditionPane;
import com.fr.van.chart.designer.other.condition.item.VanChartTrendLineConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartTrendLineConditionPane;
@ -46,7 +46,7 @@ public class VanChartColumnConditionPane extends DataSeriesConditionPane{
@Override @Override
protected void addBasicAction() { protected void addBasicAction() {
classPaneMap.put(AttrBackground.class, new VanChartSeriesColorConditionPane(this)); classPaneMap.put(AttrBackground.class, new VanChartColumnSeriesColorConditionPane(this));
classPaneMap.put(AttrAlpha.class, new LabelAlphaPane(this)); classPaneMap.put(AttrAlpha.class, new LabelAlphaPane(this));
classPaneMap.put(AttrBorder.class, new VanChartColumnLabelBorderPane(this)); classPaneMap.put(AttrBorder.class, new VanChartColumnLabelBorderPane(this));
classPaneMap.put(AttrLabel.class, new VanChartLabelConditionPane(this, plot)); classPaneMap.put(AttrLabel.class, new VanChartLabelConditionPane(this, plot));

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

@ -3,6 +3,7 @@ package com.fr.van.chart.column;
import com.fr.base.background.ImageBackground; import com.fr.base.background.ImageBackground;
import com.fr.chart.chartattr.Plot; import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionAttr;
import com.fr.design.i18n.Toolkit;
import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.frpane.UINumberDragPane;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
@ -17,6 +18,8 @@ import com.fr.plugin.chart.base.AttrSeriesImageBackground;
import com.fr.plugin.chart.column.VanChartColumnPlot; import com.fr.plugin.chart.column.VanChartColumnPlot;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; 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.VanChartBorderPane;
import com.fr.van.chart.designer.component.border.VanChartBorderWithRadiusPane; import com.fr.van.chart.designer.component.border.VanChartBorderWithRadiusPane;
import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane;
@ -70,28 +73,28 @@ public class VanChartColumnSeriesPane extends VanChartAbstractPlotSeriesPane {
} }
private JPanel createSeriesStylePane(double[] row, double[] col) { private JPanel createSeriesStylePane(double[] row, double[] col) {
isFixedWidth = new UIButtonGroup<Integer>(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_YES"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_NO")}); isFixedWidth = new UIButtonGroup<Integer>(new String[]{Toolkit.i18nText("Fine-Design_Chart_YES"), Toolkit.i18nText("Fine-Design_Chart_NO")});
columnWidth = new UISpinner(0,1000,1,0); columnWidth = new UISpinner(0,1000,1,0);
columnWidth.setBorder(BorderFactory.createEmptyBorder(0, (int)TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH + TableLayout4VanChartHelper.COMPONENT_INTERVAL,0,0)); columnWidth.setBorder(BorderFactory.createEmptyBorder(0, (int)TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH + TableLayout4VanChartHelper.COMPONENT_INTERVAL,0,0));
seriesGap = new UINumberDragPane(-100, 100); seriesGap = new UINumberDragPane(-100, 100);
categoryGap = new UINumberDragPane(0, 100); categoryGap = new UINumberDragPane(0, 100);
isFillWithImage = new UIButtonGroup<Integer>(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_YES"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_NO")}); isFillWithImage = new UIButtonGroup<Integer>(new String[]{Toolkit.i18nText("Fine-Design_Chart_YES"), Toolkit.i18nText("Fine-Design_Chart_NO")});
imagePane = new ImageBackgroundQuickPane(false); imagePane = new ImageBackgroundQuickPane(false);
imagePane.setBorder(BorderFactory.createEmptyBorder(0,(int)TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH + TableLayout4VanChartHelper.COMPONENT_INTERVAL,0,0)); imagePane.setBorder(BorderFactory.createEmptyBorder(0,(int)TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH + TableLayout4VanChartHelper.COMPONENT_INTERVAL,0,0));
JPanel panel1 = new JPanel(new BorderLayout()); JPanel panel1 = new JPanel(new BorderLayout());
JPanel isFixedWidthPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Fixed_Column_Width"),isFixedWidth); JPanel isFixedWidthPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Fixed_Column_Width"),isFixedWidth);
isFixedWidthPane.setBorder(BorderFactory.createEmptyBorder(0,0,6,0)); isFixedWidthPane.setBorder(BorderFactory.createEmptyBorder(0,0,6,0));
panel1.add(isFixedWidthPane, BorderLayout.NORTH); panel1.add(isFixedWidthPane, BorderLayout.NORTH);
panel1.add(columnWidth, BorderLayout.CENTER); panel1.add(columnWidth, BorderLayout.CENTER);
Component[][] components2 = new Component[][]{ Component[][] components2 = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Gap_Series")),seriesGap}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Gap_Series")),seriesGap},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Gap_Category")),categoryGap}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Gap_Category")),categoryGap},
}; };
JPanel panel2 = TableLayout4VanChartHelper.createGapTableLayoutPane(components2, row, col); JPanel panel2 = TableLayout4VanChartHelper.createGapTableLayoutPane(components2, row, col);
UILabel fillImageLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Filled_With_Image")); UILabel fillImageLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Filled_With_Image"));
Component[][] components3 = new Component[][]{ Component[][] components3 = new Component[][]{
new Component[]{fillImageLabel, UIComponentUtils.wrapWithBorderLayoutPane(isFillWithImage)}, new Component[]{fillImageLabel, UIComponentUtils.wrapWithBorderLayoutPane(isFillWithImage)},
}; };
@ -117,7 +120,7 @@ public class VanChartColumnSeriesPane extends VanChartAbstractPlotSeriesPane {
checkImagePane(); checkImagePane();
} }
}); });
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), borderPane); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), borderPane);
} }
private void checkAll() { private void checkAll() {
@ -131,6 +134,10 @@ public class VanChartColumnSeriesPane extends VanChartAbstractPlotSeriesPane {
seriesGap.setEnabled(!b); seriesGap.setEnabled(!b);
} }
protected VanChartBeautyPane createStylePane() {
return new VanChartBeautyPaneWithGradientBar();
}
private void checkImagePane() { private void checkImagePane() {
imagePane.setVisible(isFillWithImage.getSelectedIndex() == 0); imagePane.setVisible(isFillWithImage.getSelectedIndex() == 0);
} }

27
designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomSeriesPane.java

@ -7,9 +7,7 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.style.series.ChartSeriesPane; import com.fr.design.mainframe.chart.gui.style.series.ChartSeriesPane;
import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.custom.VanChartCustomPlot; import com.fr.plugin.chart.custom.VanChartCustomPlot;
import com.fr.van.chart.designer.component.VanChartBeautyPane;
import com.fr.van.chart.designer.component.VanChartFillStylePane; import com.fr.van.chart.designer.component.VanChartFillStylePane;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -26,9 +24,6 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane {
private JPanel seriesPane; private JPanel seriesPane;
protected VanChartCustomPlotSeriesTabPane plotSeriesPane; protected VanChartCustomPlotSeriesTabPane plotSeriesPane;
private VanChartFillStylePane fillStylePane;//配色 private VanChartFillStylePane fillStylePane;//配色
private VanChartBeautyPane stylePane;//风格
public VanChartCustomSeriesPane(ChartStylePane parent) { public VanChartCustomSeriesPane(ChartStylePane parent) {
super(parent); super(parent);
@ -69,16 +64,13 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane {
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] row = {p,p}; double[] row = {p};
double[] col = {f}; double[] col = {f};
fillStylePane = new VanChartFillStylePane(); fillStylePane = new VanChartFillStylePane();
stylePane = new VanChartBeautyPane();
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{fillStylePane}, //配色 new Component[]{fillStylePane} //配色
new Component[]{stylePane},//风格
}; };
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, row, col); JPanel panel = TableLayoutHelper.createTableLayoutPane(components, row, col);
@ -101,16 +93,6 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane {
if (fillStylePane != null){ if (fillStylePane != null){
plot.setPlotFillStyle(fillStylePane.updateBean()); plot.setPlotFillStyle(fillStylePane.updateBean());
} }
if(stylePane != null) {
plot.setPlotStyle(stylePane.updateBean());
//风格属性传递
for (int i = 0; i < plot.getCustomPlotList().size(); i++){
VanChartPlot vanChartPlot = plot.getCustomPlotList().get(i);
vanChartPlot.setPlotStyle(plot.getPlotStyle());
}
}
if (seriesPane != null){ if (seriesPane != null){
plotSeriesPane.updateBean(plot); plotSeriesPane.updateBean(plot);
} }
@ -135,14 +117,9 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane {
if(plot == null) { if(plot == null) {
return; return;
} }
if(fillStylePane != null) {//配色 if(fillStylePane != null) {//配色
fillStylePane.populateBean(plot.getPlotFillStyle()); fillStylePane.populateBean(plot.getPlotFillStyle());
} }
if(stylePane != null){//风格
stylePane.populateBean(plot.getPlotStyle());
}
//更新不同点的系列界面 //更新不同点的系列界面
plotSeriesPane.populateBean(plot); plotSeriesPane.populateBean(plot);

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

@ -1,12 +1,13 @@
package com.fr.van.chart.designer.component; package com.fr.van.chart.designer.component;
import com.fr.chart.base.ChartConstants; import com.fr.chart.base.GradientStyle;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
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.design.layout.TableLayout;
import com.fr.plugin.chart.type.GradientType;
import com.fr.stable.StringUtils;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -17,56 +18,68 @@ import java.awt.Component;
* Created by Mitisky on 15/9/8. * Created by Mitisky on 15/9/8.
*/ */
//系列-风格 //系列-风格
public class VanChartBeautyPane extends BasicBeanPane<Integer> { public class VanChartBeautyPane extends BasicBeanPane<GradientStyle> {
private UIButtonGroup styleBox;
private UIButtonGroup gradientTypeBox;
public UIButtonGroup getGradientTypeBox() {
return gradientTypeBox;
}
public VanChartBeautyPane() { public VanChartBeautyPane() {
styleBox = new UIButtonGroup(getNameArray()); this.setLayout(new BorderLayout());
this.add(initGradientTypePane(), BorderLayout.CENTER);
}
private JPanel initGradientTypePane() {
String[] names = getNameArray();
gradientTypeBox = new UIButtonGroup(names);
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double[] columnSize = {f, e}; double[] columnSize = {f, e};
double[] rowSize = {p}; double[] rowSize = {p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Gradient_Style")), styleBox}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Gradient_Style")), gradientTypeBox},
}; };
JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize);
this.setLayout(new BorderLayout()); return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize);
this.add(panel,BorderLayout.CENTER);
} }
protected String[] getNameArray() { protected String[] getNameArray() {
return new String[]{Toolkit.i18nText("Fine-Design_Chart_On"), return new String[]{
Toolkit.i18nText("Fine-Design_Chart_On"),
Toolkit.i18nText("Fine-Design_Chart_Off") Toolkit.i18nText("Fine-Design_Chart_Off")
}; };
} }
@Override
public void populateBean(Integer ob) { public void populateBean(GradientStyle gradientStyle) {
int finalIndex; gradientTypeBox.setSelectedIndex(this.convertGradientTypeToIndex(gradientStyle.getGradientType()));
switch (ob){
case ChartConstants.STYLE_NONE: finalIndex = 1; break;
case ChartConstants.STYLE_SHADE: finalIndex = 0; break;
default: finalIndex = 1;
}
styleBox.setSelectedIndex(finalIndex);
} }
@Override @Override
public Integer updateBean() { public GradientStyle updateBean() {
int index = styleBox.getSelectedIndex(); GradientStyle gradientStyle = new GradientStyle();
int style;
switch (index){ gradientStyle.setGradientType(this.convertIndexToGradientType(this.gradientTypeBox.getSelectedIndex()));
case 0: style = ChartConstants.STYLE_SHADE; break;
case 1: style = ChartConstants.STYLE_NONE; break; return gradientStyle;
default: style = ChartConstants.STYLE_NONE;
} }
return style;
protected int convertGradientTypeToIndex(GradientType gradientType) {
return gradientType == GradientType.NONE ? 1 : 0;
}
protected GradientType convertIndexToGradientType(int index) {
return index == 1 ? GradientType.NONE : GradientType.AUTO;
} }
@Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return ""; 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;
}
}
}

150
designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartColumnSeriesColorConditionPane.java

@ -0,0 +1,150 @@
package com.fr.van.chart.designer.other.condition.item;
import com.fr.base.background.ColorBackground;
import com.fr.chart.base.AttrBackground;
import com.fr.chart.base.DataSeriesCondition;
import com.fr.design.condition.ConditionAttrSingleConditionPane;
import com.fr.design.condition.ConditionAttributesPane;
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.design.style.color.ColorSelectBox;
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 VanChartColumnSeriesColorConditionPane extends ConditionAttrSingleConditionPane<DataSeriesCondition> {
private UIButtonGroup matchColorTypeBox;
private ColorSelectBox colorSelectionBox;
private FixedGradientBar colorGradient;
private JPanel colorSelectPane;
private JPanel colorGradientPane;
public VanChartColumnSeriesColorConditionPane(ConditionAttributesPane conditionAttributesPane) {
this(conditionAttributesPane, true);
}
public VanChartColumnSeriesColorConditionPane(ConditionAttributesPane conditionAttributesPane, boolean isRemove) {
super(conditionAttributesPane, isRemove);
if (isRemove) {
this.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Match_Color")));
}
this.add(createComponents());
initListener();
}
private JPanel createComponents() {
String[] names = new String[]{
Toolkit.i18nText("Fine-Design_Chart_Solid_Color"),
Toolkit.i18nText("Fine-Design_Chart_Style_TopDownShade")
};
matchColorTypeBox = new UIButtonGroup(names);
colorSelectionBox = new ColorSelectBox(80);
colorGradient = new FixedGradientBar(4, 150);
colorSelectPane = createJPanelWithComponent(colorSelectionBox);
colorGradientPane = createJPanelWithComponent(colorGradient);
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(createJPanelWithComponent(matchColorTypeBox), BorderLayout.NORTH);
panel.add(colorSelectPane, BorderLayout.CENTER);
panel.add(colorGradientPane, BorderLayout.SOUTH);
return panel;
}
private void initListener() {
matchColorTypeBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
checkColorPaneVisible();
}
});
}
private void checkColorPaneVisible() {
if (colorSelectPane != null) {
colorSelectPane.setVisible(matchColorTypeBox.getSelectedIndex() == 0);
}
if (colorGradientPane != null) {
colorGradientPane.setVisible(matchColorTypeBox.getSelectedIndex() == 1);
}
}
public String nameForPopupMenuItem() {
return Toolkit.i18nText("Fine-Design_Chart_Match_Color");
}
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Chart_Match_Color");
}
public void populate(DataSeriesCondition condition) {
if (condition instanceof AttrBackground) {
AttrBackground matchColor = (AttrBackground) condition;
if (matchColor.getGradient() == GradientType.NONE) {
this.matchColorTypeBox.setSelectedIndex(0);
} else {
this.matchColorTypeBox.setSelectedIndex(1);
}
ColorBackground seriesColor = (ColorBackground) matchColor.getSeriesBackground();
if (seriesColor != null) {
this.colorSelectionBox.setSelectObject(seriesColor.getColor());
}
this.colorGradient.updateColor(matchColor.getGradientStartColor(), matchColor.getGradientEndColor());
}
checkColorPaneVisible();
}
public DataSeriesCondition update() {
AttrBackground matchColor = new AttrBackground();
if (this.matchColorTypeBox.getSelectedIndex() == 0) {
matchColor.setGradient(GradientType.NONE);
} else {
matchColor.setGradient(GradientType.CUSTOM);
}
matchColor.setSeriesBackground(ColorBackground.getInstance(this.colorSelectionBox.getSelectObject()));
matchColor.setGradientStartColor(this.colorGradient.getSelectColorPointBtnP1().getColorInner());
matchColor.setGradientEndColor(this.colorGradient.getSelectColorPointBtnP2().getColorInner());
return matchColor;
}
public void setDefault() {
this.populate(new AttrBackground());
}
private JPanel createJPanelWithComponent(Component component) {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
Component[][] components = new Component[][]{
new Component[]{null, null},
new Component[]{null, component},
};
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p, p}, new double[]{f, e});
}
}

6
designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java

@ -105,7 +105,7 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP
//风格 //风格
protected VanChartBeautyPane createStylePane() { protected VanChartBeautyPane createStylePane() {
return parentPane instanceof VanChartCustomStylePane ? null : new VanChartBeautyPane(); return new VanChartBeautyPane();
} }
//获取颜色面板 //获取颜色面板
@ -276,7 +276,7 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP
} }
if (stylePane != null) {//风格 if (stylePane != null) {//风格
stylePane.populateBean(plot.getPlotStyle()); stylePane.populateBean(((VanChartPlot)plot).getGradientStyle());
} }
//大数据模式 恢复用注释。下面3行删除。 //大数据模式 恢复用注释。下面3行删除。
@ -335,7 +335,7 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP
} }
if (stylePane != null) {//风格 if (stylePane != null) {//风格
plot.setPlotStyle(stylePane.updateBean()); ((VanChartPlot)plot).setGradientStyle(stylePane.updateBean());
} }
//大数据模式 恢复用注释。下面3行删除。 //大数据模式 恢复用注释。下面3行删除。

Loading…
Cancel
Save