Browse Source

CHART-14182 修改渐变风格面板和条件属性面板

feature/big-screen
Qinghui.Liu 5 years ago
parent
commit
1df8696a92
  1. 4
      designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnConditionPane.java
  2. 20
      designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java
  3. 25
      designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomSeriesPane.java
  4. 167
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPane.java
  5. 150
      designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartColumnSeriesColorConditionPane.java
  6. 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.column.VanChartColumnPlot;
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.VanChartEffectConditionPane;
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.VanChartSeriesColorConditionPane;
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.VanChartTrendLineConditionPane;
@ -46,7 +46,7 @@ public class VanChartColumnConditionPane extends DataSeriesConditionPane{
@Override
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(AttrBorder.class, new VanChartColumnLabelBorderPane(this));
classPaneMap.put(AttrLabel.class, new VanChartLabelConditionPane(this, plot));

20
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.chart.chartattr.Plot;
import com.fr.chart.chartglyph.ConditionAttr;
import com.fr.design.i18n.Toolkit;
import com.fr.design.gui.frpane.UINumberDragPane;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel;
@ -17,6 +18,7 @@ import com.fr.plugin.chart.base.AttrSeriesImageBackground;
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.border.VanChartBorderPane;
import com.fr.van.chart.designer.component.border.VanChartBorderWithRadiusPane;
import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane;
@ -70,28 +72,28 @@ public class VanChartColumnSeriesPane extends VanChartAbstractPlotSeriesPane {
}
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.setBorder(BorderFactory.createEmptyBorder(0, (int)TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH + TableLayout4VanChartHelper.COMPONENT_INTERVAL,0,0));
seriesGap = new UINumberDragPane(-100, 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.setBorder(BorderFactory.createEmptyBorder(0,(int)TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH + TableLayout4VanChartHelper.COMPONENT_INTERVAL,0,0));
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));
panel1.add(isFixedWidthPane, BorderLayout.NORTH);
panel1.add(columnWidth, BorderLayout.CENTER);
Component[][] components2 = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.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_Series")),seriesGap},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Gap_Category")),categoryGap},
};
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[][]{
new Component[]{fillImageLabel, UIComponentUtils.wrapWithBorderLayoutPane(isFillWithImage)},
};
@ -117,7 +119,7 @@ public class VanChartColumnSeriesPane extends VanChartAbstractPlotSeriesPane {
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() {
@ -131,6 +133,10 @@ public class VanChartColumnSeriesPane extends VanChartAbstractPlotSeriesPane {
seriesGap.setEnabled(!b);
}
protected VanChartBeautyPane createStylePane() {
return new VanChartBeautyPane(true);
}
private void checkImagePane() {
imagePane.setVisible(isFillWithImage.getSelectedIndex() == 0);
}

25
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.style.series.ChartSeriesPane;
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.van.chart.designer.component.VanChartBeautyPane;
import com.fr.van.chart.designer.component.VanChartFillStylePane;
import javax.swing.BorderFactory;
@ -26,9 +24,6 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane {
private JPanel seriesPane;
protected VanChartCustomPlotSeriesTabPane plotSeriesPane;
private VanChartFillStylePane fillStylePane;//配色
private VanChartBeautyPane stylePane;//风格
public VanChartCustomSeriesPane(ChartStylePane parent) {
super(parent);
@ -74,11 +69,8 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane {
fillStylePane = new VanChartFillStylePane();
stylePane = new VanChartBeautyPane();
Component[][] components = new Component[][]{
new Component[]{fillStylePane}, //配色
new Component[]{stylePane},//风格
new Component[]{fillStylePane} //配色
};
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, row, col);
@ -101,16 +93,6 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane {
if (fillStylePane != null){
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){
plotSeriesPane.updateBean(plot);
}
@ -135,14 +117,9 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane {
if(plot == null) {
return;
}
if(fillStylePane != null) {//配色
fillStylePane.populateBean(plot.getPlotFillStyle());
}
if(stylePane != null){//风格
stylePane.populateBean(plot.getPlotStyle());
}
//更新不同点的系列界面
plotSeriesPane.populateBean(plot);

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

@ -1,67 +1,178 @@
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.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.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.
*/
//系列-风格
public class VanChartBeautyPane extends BasicBeanPane<Integer> {
private UIButtonGroup styleBox;
public class VanChartBeautyPane extends BasicBeanPane<GradientStyle> {
private UIButtonGroup gradientTypeBox;
private FixedGradientBar colorGradient;
private JPanel gradientBarPane;
private boolean hasGradientBar;
public VanChartBeautyPane() {
styleBox = new UIButtonGroup(getNameArray());
this(false);
}
public VanChartBeautyPane(boolean hasGradientBar) {
this.hasGradientBar = hasGradientBar;
String[] typeNames = getNameArray();
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);
}
}
private JPanel initGradientTypePane(String[] names) {
gradientTypeBox = new UIButtonGroup(names);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double[] columnSize = {f, e};
double[] rowSize = {p};
Component[][] components = new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Gradient_Style")), styleBox},
} ;
JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize);
this.setLayout(new BorderLayout());
this.add(panel,BorderLayout.CENTER);
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Gradient_Style")), gradientTypeBox},
};
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;
}
protected String[] getNameArray(){
return new String[]{Toolkit.i18nText("Fine-Design_Chart_On"),
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")
};
}
@Override
public void populateBean(Integer ob) {
int finalIndex;
switch (ob){
case ChartConstants.STYLE_NONE: finalIndex = 1; break;
case ChartConstants.STYLE_SHADE: finalIndex = 0; break;
default: finalIndex = 1;
public void populateBean(GradientStyle gradientStyle) {
gradientTypeBox.setSelectedIndex(this.convertGradientTypeToIndex(gradientStyle.getGradientType()));
if (this.hasGradientBar && colorGradient != null) {
colorGradient.updateColor(gradientStyle.getStartColor(), gradientStyle.getEndColor());
}
styleBox.setSelectedIndex(finalIndex);
checkGradientBarVisible();
}
@Override
public Integer updateBean() {
int index = styleBox.getSelectedIndex();
int style;
switch (index){
case 0: style = ChartConstants.STYLE_SHADE; break;
case 1: style = ChartConstants.STYLE_NONE; break;
default: style = ChartConstants.STYLE_NONE;
public GradientStyle updateBean() {
GradientStyle gradientStyle = new 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 style;
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;
}
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;
}
}
if (index == 1) {
return GradientType.NONE;
}
return GradientType.AUTO;
}
@Override

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

Loading…
Cancel
Save